summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-46039: Split yield from in two (GH-30035)Mark Shannon2021-12-151-16/+39
| | | | | | * Split YIELD_FROM opcode into SEND and JUMP_ABSOLUTE. * Remove YIELD_FROM opcode.
* bpo-44525: Split calls into PRECALL and CALL (GH-30011)Mark Shannon2021-12-141-15/+16
| | | | | | | | | | * Add 3 new opcodes for calls: PRECALL_METHOD, CALL_NO_KW, CALL_KW. * Update specialization to handle new CALL opcodes. * Specialize call to method descriptors. * Remove old CALL opcodes: CALL_FUNCTION, CALL_METHOD, CALL_METHOD_KW, CALL_FUNCTION_KW.
* bpo-45292: [PEP-654] add except* (GH-29581)Irit Katriel2021-12-141-1/+338
|
* bpo-37971: fix the position of decorator application (GH-30027)Carl Friedrich Bolz-Tereick2021-12-101-8/+25
| | | | | | | The line numbers of actually calling the decorator functions of functions and classes was wrong (as opposed to loading them, were they have been correct previously too). Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Delete orphaned comment (#29917)Guido van Rossum2021-12-051-5/+0
| | | (The function this described was deleted by PR #23743, the comment was accidentally retained.)
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-2/+19
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* Fix link to exception handling notes (GH-29617)Irit Katriel2021-11-191-1/+1
|
* bpo-45773: Stop "optimizing" certain jump patterns (GH-29505)Brandt Bucher2021-11-111-76/+41
|
* bpo-45636: Merge all numeric operators (GH-29482)Brandt Bucher2021-11-111-106/+59
|
* bpo-45711: remove unnecessary DUP_TOP and POP in exception handling (GH-29495)Irit Katriel2021-11-101-6/+4
|
* bpo-44511: Improve the bytecode for class and mapping patterns (GH-26922)Brandt Bucher2021-10-271-29/+44
| | | | | | | * Refactor mapping patterns and speed up class patterns. * Simplify MATCH_KEYS and MATCH_CLASS. * Add COPY opcode.
* Fix typos in the Python directory (GH-28767)Christian Clauss2021-10-061-2/+2
|
* Normalize jumps in compiler. All forward jumps to use JUMP_FORWARD. (GH-28755)Mark Shannon2021-10-061-0/+23
|
* bpo-45355: More use of sizeof(_Py_CODEUNIT) (GH-28720)Serhiy Storchaka2021-10-041-1/+1
|
* bpo-45152: Add HAS_CONST macro and get_const_value() function and use… ↵Irit Katriel2021-09-141-7/+39
| | | | (#28262)
* bpo-45056: Remove trailing unused constants from co_consts (GH-28109)Inada Naoki2021-09-021-0/+33
|
* bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than ↵Irit Katriel2021-08-311-2/+4
| | | | ADDOP_O(c, LOAD_CONST,...) (GH-28015)
* bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947)Dong-hee Na2021-08-251-0/+4
| | | Automerge-Triggered-By: GH:pablogsal
* Remove unused variable. (GH-27677)Mark Shannon2021-08-091-3/+0
|
* bpo-44840: Compiler: Move duplication of exit blocks with no line numbers to ↵Mark Shannon2021-08-091-16/+25
| | | | after CFG optimization. (GH-27656)
* bpo-44600: Fix line numbers for pattern matching cleanup code (GH-27346)Charles Burkland2021-07-251-4/+12
|
* bpo-44626: Merge basic blocks earlier to enable better handling of exit ↵Mark Shannon2021-07-151-16/+48
| | | | blocks without line numbers (GH-27138)
* bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. ↵Mark Shannon2021-07-151-1/+3
| | | | (GH-27160)
* bpo-44589: raise a SyntaxError when mapping patterns have duplicate literal ↵Jack DeVries2021-07-151-4/+41
| | | | keys (GH-27131)
* bpo-44616: Mark all clean up instructions at end of named exception block as ↵Mark Shannon2021-07-141-3/+2
| | | | artificial (GH-27109)
* bpo-33346: Allow async comprehensions inside implicit async comprehensions ↵Serhiy Storchaka2021-07-131-6/+8
| | | | | (GH-6766) Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)Gabriele N. Tornetta2021-07-071-4/+2
|
* bpo-43950: optimize column table assembling with pre-sizing object (GH-26997)Batuhan Taskaya2021-07-021-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The new resizing system works like this; ``` $ cat t.py a + a + a + b + c + a + a + a + b + c + a + a + a + b + c + a + a + a + b + c [repeated 99 more times] $ ./python t.py RESIZE: prev len = 32, new len = 66 FINAL SIZE: 56 ----------------------------------------------------- RESIZE: prev len = 32, new len = 66 RESIZE: prev len = 66, new len = 134 RESIZE: prev len = 134, new len = 270 RESIZE: prev len = 270, new len = 542 RESIZE: prev len = 542, new len = 1086 RESIZE: prev len = 1086, new len = 2174 RESIZE: prev len = 2174, new len = 4350 RESIZE: prev len = 4350, new len = 8702 FINAL SIZE: 8004 ``` So now we do considerably lower number of `_PyBytes_Resize` calls. Automerge-Triggered-By: GH:isidentical
* bpo-43950: Add code.co_positions (PEP 657) (GH-26955)Pablo Galindo2021-07-021-63/+208
| | | | | | | | | | | | | | | This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-44313: generate LOAD_ATTR/CALL_FUNCTION for top-level imported objects ↵Batuhan Taskaya2021-06-301-0/+23
| | | | (GH-26677)
* Make sure that line number is set correctly for call to __exit__ when ↵Mark Shannon2021-06-241-2/+1
| | | | handling exception in body of a with statement. (GH-26890)
* bpo-43693: Turn localspluskinds into an object (GH-26749)Guido van Rossum2021-06-211-12/+8
| | | Managing it as a bare pointer to malloc'ed bytes is just too awkward in a few places.
* bpo-44297: Fix missing line number in generator expressions (GH-26801)Mark Shannon2021-06-211-0/+1
| | | * Make sure that line number is set when entering comprehension scope in compiler.
* bpo-43693: Eliminate unused "fast locals". (gh-26587)Eric Snow2021-06-151-41/+144
| | | | | Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function). https://bugs.python.org/issue43693
* bpo-43693: Un-revert commit f3fa63e. (#26609)Eric Snow2021-06-081-19/+53
| | | | | | | | | This was reverted in GH-26596 (commit 6d518bb) due to some bad memory accesses. * Add the MAKE_CELL opcode. (gh-26396) The memory accesses have been fixed. https://bugs.python.org/issue43693
* Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals ↵Pablo Galindo2021-06-081-53/+19
| | | | | offsets. (gh-26396)" (GH-26597) This reverts commit 631f9938b1604d4f893417ec339b9e0fa9196fb1.
* Fix compiler errors for unused variables (GH-26601)Pablo Galindo2021-06-081-0/+1
|
* bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. ↵Eric Snow2021-06-071-19/+53
| | | | | | | (gh-26396) This moves logic out of the frame initialization code and into the compiler and eval loop. Doing so simplifies the runtime code and allows us to optimize it better. https://bugs.python.org/issue43693
* bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. (gh-26577)Eric Snow2021-06-071-37/+123
| | | | | | | | | | These were reverted in gh-26530 (commit 17c4edc) due to refleaks. * 2c1e258 - Compute deref offsets in compiler (gh-25152) * b2bf2bc - Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388) This change fixes the refleaks. https://bugs.python.org/issue43693
* bpo-43693: Revert commits 2c1e2583fdc4db6b43d163239ea42b0e8394171f and ↵Pablo Galindo2021-06-041-122/+37
| | | | | | | | | | | | | b2bf2bc1ece673d387341e06c8d3c2bc6e259747 (GH-26530) * Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)" This reverts commit b2bf2bc1ece673d387341e06c8d3c2bc6e259747. * Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)" This reverts commit 2c1e2583fdc4db6b43d163239ea42b0e8394171f. These two commits are breaking the refleak buildbots.
* bpo-43693: Compute deref offsets in compiler (gh-25152)Mark Shannon2021-06-041-0/+21
| | | | | | Merges locals and cells into a single array. Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more https://bugs.python.org/issue43693
* bpo-43693: Add new internal code objects fields: co_fastlocalnames and ↵Eric Snow2021-06-031-37/+101
| | | | | | | | | | | | | | | | | co_fastlocalkinds. (gh-26388) A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead. This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily). Aside from the (mild) performance impact, there are a number of other benefits: * there's now a clear, direct relationship between locals-plus and variables * code that relies on the locals-plus-to-name mapping is simpler * marshaled code objects are smaller and serialize/de-serialize faster Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further. https://bugs.python.org/issue43693
* bpo-44298: Fix line numbers for early exits in with statements. (GH-26513)Mark Shannon2021-06-031-7/+17
|
* bpo-43693: Add _PyCode_New(). (gh-26375)Eric Snow2021-05-271-15/+35
| | | | | This is an internal-only API that helps us manage the many values used to create a code object. https://bugs.python.org/issue43693
* bpo-44156: Make cached string constants in compile.c subinterpreter ↵Ken Jin2021-05-251-52/+44
| | | | compatible (GH-26161)
* bpo-26110: Add ``CALL_METHOD_KW`` opcode to speedup method calls with ↵Ken Jin2021-05-151-18/+63
| | | | | | | | | keywords (GH-26014) * Add CALL_METHOD_KW * Make CALL_METHOD branchless too since it shares the same code * Place parentheses in STACK_SHRINK
* bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26054)Mark Shannon2021-05-121-0/+29
|
* bpo-44063: set the missing end locations on the compiler (GH-25956)Batuhan Taskaya2021-05-071-5/+13
|
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-72/+410
| | | | | | | | "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
* bpo-43754: Fix compiler warning in Python/compile.c (GH-25855)Pablo Galindo2021-05-031-1/+1
| | | | | This fixes the following warning: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]