aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_bytecodes.c
Commit message (Collapse)AuthorAge
* gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR ↵Irit Katriel2025-02-07
| | | | (#129700)
* GH-129709: Clean up tier two (GH-129710)Brandt Bucher2025-02-07
|
* GH-128682: Make `PyStackRef_CLOSE` escaping. (GH-129404)Mark Shannon2025-02-03
|
* GH-128914: Remove all but one conditional stack effects (GH-129226)Mark Shannon2025-01-27
| | | | | | | | | | | | | * Remove all 'if (0)' and 'if (1)' conditional stack effects * Use array instead of conditional for BUILD_SLICE args * Refactor LOAD_GLOBAL to use a common conditional uop * Remove conditional stack effects from LOAD_ATTR specializations * Replace conditional stack effects in LOAD_ATTR with a 0 or 1 sized array. * Remove conditional stack effects from CALL_FUNCTION_EX
* Revert "GH-128914: Remove conditional stack effects from `bytecodes.c` and ↵Sam Gross2025-01-23
| | | | | | | the code generators (GH-128918)" (GH-129202) The commit introduced a ~2.5-3% regression in the free threading build. This reverts commit ab61d3f4303d14a413bc9ae6557c730ffdf7579e.
* GH-128914: Remove conditional stack effects from `bytecodes.c` and the code ↵Mark Shannon2025-01-20
| | | | generators (GH-128918)
* GH-128939: Refactor JIT optimize structs (GH-128940)Mark Shannon2025-01-20
|
* gh-115999: Specialize `LOAD_ATTR` for instance and class receivers in ↵mpage2025-01-14
| | | | | | | free-threaded builds (#128164) Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
* GH-128685: Specialize (rather than quicken) LOAD_CONST into ↵Mark Shannon2025-01-13
| | | | LOAD_CONST_[IM]MORTAL (GH-128708)
* GH-127809: Fix the JIT's understanding of ** (GH-127844)Brandt Bucher2025-01-07
|
* gh-128195: Add `_REPLACE_WITH_TRUE` to the tier2 optimizer (GH-128203)Yan Yanchii2024-12-24
| | | Add `_REPLACE_WITH_TRUE` to the tier2 optimizer
* gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737)Donghee Na2024-12-19
|
* gh-115999: Specialize loading attributes from modules in free-threaded ↵mpage2024-12-13
| | | | | | | | | builds (#127711) We use the same approach that was used for specialization of LOAD_GLOBAL in free-threaded builds: _CHECK_ATTR_MODULE is renamed to _CHECK_ATTR_MODULE_PUSH_KEYS; it pushes the keys object for the following _LOAD_ATTR_MODULE_FROM_KEYS (nee _LOAD_ATTR_MODULE). This arrangement avoids having to recheck the keys version. _LOAD_ATTR_MODULE is renamed to _LOAD_ATTR_MODULE_FROM_KEYS; it loads the value from the keys object pushed by the preceding _CHECK_ATTR_MODULE_PUSH_KEYS at the cached index.
* gh-120619: Strength reduce function guards, support 2-operand uop forms ↵Ken Jin2024-11-09
| | | | | (GH-124846) Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* GH-125837: Split `LOAD_CONST` into three. (GH-125972)Mark Shannon2024-10-29
| | | | | | | | * Add LOAD_CONST_IMMORTAL opcode * Add LOAD_SMALL_INT opcode * Remove RETURN_CONST opcode
* GH-125912: Teach the JIT's optimizer about _BINARY_OP_INPLACE_ADD_UNICODE ↵Brandt Bucher2024-10-28
| | | | (GH-125935)
* gh-115999: Refactor `LOAD_GLOBAL` specializations to avoid reloading ↵mpage2024-10-09
| | | | | | | | | | | | | | | | | | {globals, builtins} keys (gh-124953) Each of the `LOAD_GLOBAL` specializations is implemented roughly as: 1. Load keys version. 2. Load cached keys version. 3. Deopt if (1) and (2) don't match. 4. Load keys. 5. Load cached index into keys. 6. Load object from (4) at offset from (5). This is not thread-safe in free-threaded builds; the keys object may be replaced in between steps (3) and (4). This change refactors the specializations to avoid reloading the keys object and instead pass the keys object from guards to be consumed by downstream uops.
* GH-119866: Spill the stack around escaping calls. (GH-124392)Mark Shannon2024-10-07
| | | | | | | * Spill the evaluation around escaping calls in the generated interpreter and JIT. * The code generator tracks live, cached values so they can be saved to memory when needed. * Spills the stack pointer around escaping calls, so that the exact stack is visible to the cycle GC.
* gh-120619: Optimize through `_Py_FRAME_GENERAL` (GH-124518)Ken Jin2024-10-03
| | | | | * Optimize through _Py_FRAME_GENERAL * refactor
* GH-115776: Allow any fixed sized object to have inline values (GH-123192)Mark Shannon2024-08-21
|
* GH-118093: Make `CALL_ALLOC_AND_ENTER_INIT` suitable for tier 2. (GH-123140)Mark Shannon2024-08-20
| | | | | * Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it * Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
* GH-118093: Specialize `CALL_KW` (GH-123006)Mark Shannon2024-08-16
|
* GH-122869: Add missing tier two optimizer cases (GH-122936)Mark Shannon2024-08-12
|
* Manually override bytecode definition in optimizer, to avoid build error ↵Mark Shannon2024-07-26
| | | | (GH-122316)
* GH-122294: Burn in the addresses of side exits (GH-122295)Brandt Bucher2024-07-26
|
* GH-118093: Add tier two support to several instructions (GH-121884)Brandt Bucher2024-07-18
|
* gh-120437: Fix `_CHECK_STACK_SPACE` optimization problems introduced in ↵Nadeshiko Manju2024-06-19
| | | | | | gh-118322 (GH-120712) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. ↵Mark Shannon2024-06-18
| | | | | | | | | (#120640) * Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions. * Add LOAD_SPECIAL instruction * Reimplement `with` and `async with` statements using LOAD_SPECIAL
* GH-120619: Clean up `RETURN_VALUE` instruction (GH-120624)Mark Shannon2024-06-17
| | | | | * Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame. * Remove remaining _POP_FRAMEs
* gh-119258: Eliminate Type Guards in Tier 2 Optimizer with Watcher (GH-119365)Saul Shanabrook2024-06-08
| | | | | | | Co-authored-by: parmeggiani <parmeggiani@spaziodati.eu> Co-authored-by: dpdani <git@danieleparmeggiani.me> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com> Co-authored-by: Ken Jin <kenjin@python.org>
* GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS ↵Brandt Bucher2024-05-28
| | | | (GH-119510)
* GH-118910: Less boilerplate in the tier 2 optimizer (#118913)Mark Shannon2024-05-10
|
* GH-118095: Use broader specializations of CALL in tier 1, for better tier 2 ↵Mark Shannon2024-05-04
| | | | | | | | | | support of calls. (GH-118322) * Add CALL_PY_GENERAL, CALL_BOUND_METHOD_GENERAL and call CALL_NON_PY_GENERAL specializations. * Remove CALL_PY_WITH_DEFAULTS specialization * Use CALL_NON_PY_GENERAL in more cases when otherwise failing to specialize
* GH-118095: Add tier 2 support for YIELD_VALUE (GH-118380)Mark Shannon2024-04-30
|
* GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)Mark Shannon2024-04-25
|
* GH-115480: Reduce guard strength for binary ops when type of one operand is ↵Mark Shannon2024-04-22
| | | | known already (GH-118050)
* GH-115419: Tidy up tier 2 optimizer. Merge peephole pass into main pass ↵Mark Shannon2024-04-18
| | | | (GH-117997)
* gh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)Kirill Podoprigora2024-03-24
|
* gh-117045: Add code object to function version cache (#117028)Guido van Rossum2024-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | Changes to the function version cache: - In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. - Stop assigning new function versions after a critical attribute (e.g. `__code__`) has been modified; the version is permanently reset to zero in this case. - Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.) Changes to the Tier 2 optimization machinery: - If we cannot map a function version to a function, but it is still mapped to a code object, we continue projecting the trace. The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL, a function object, or a code object with the lowest bit set. This allows us to trace through code that calls an ephemeral function, i.e., a function that may not be alive when we are constructing the executor, e.g. a generator expression or certain nested functions. We will lose globals removal inside such functions, but we can still do other peephole operations (and even possibly [call inlining](https://github.com/python/cpython/pull/116290), if we decide to do it), which only need the code object. As before, if we cannot retrieve the code object from the cache, we stop projecting.
* GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't ↵Mark Shannon2024-03-20
| | | | optimize them perfectly. (GH-117067)
* Cleanup tier2 debug output (#116920)Guido van Rossum2024-03-18
| | | Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.
* gh-115419: Change default sym to not_null (GH-116562)Ken Jin2024-03-13
|
* gh-116420: Fix unused var compilation warnings (GH-116466)Ken Jin2024-03-08
| | | Fix unused var compilation warnings
* GH-115687: Most comparisons create Booleans, so propagate that information ↵Mark Shannon2024-03-06
| | | | | (GH-116360) Most comparisons create booleans
* GH-115819: Eliminate Boolean guards when value is known (GH-116355)Mark Shannon2024-03-05
|
* GH-115685: Optimize `TO_BOOL` and variants based on truthiness of input. ↵Mark Shannon2024-03-05
| | | | (GH-116311)
* gh-115480: Type propagate _BINARY_OP_ADD_UNICODE (GH-115710)Ken Jin2024-03-02
|
* gh-115685: Type/values propagate for TO_BOOL in tier 2 (GH-115686)Ken Jin2024-03-01
|
* gh-116088: Insert bottom checks after all sym_set_...() calls (#116089)Guido van Rossum2024-02-29
| | | | | | | | | This changes the `sym_set_...()` functions to return a `bool` which is `false` when the symbol is `bottom` after the operation. All calls to such functions now check this result and go to `hit_bottom`, a special error label that prints a different message and then reports that it wasn't able to optimize the trace. No executor will be produced in this case.
* gh-115859: Re-enable T2 optimizer pass by default (#116062)Guido van Rossum2024-02-28
| | | | | | | | | | | | | This undoes the *temporary* default disabling of the T2 optimizer pass in gh-115860. - Add a new test that reproduces Brandt's example from gh-115859; it indeed crashes before gh-116028 with PYTHONUOPSOPTIMIZE=1 - Re-enable the optimizer pass in T2, stop checking PYTHONUOPSOPTIMIZE - Rename the env var to disable T2 entirely to PYTHON_UOPS_OPTIMIZE (must be explicitly set to 0 to disable) - Fix skipIf conditions on tests in test_opt.py accordingly - Export sym_is_bottom() (for debugging) - Fix various things in the `_BINARY_OP_` specializations in the abstract interpreter: - DECREF(temp) - out-of-space check after sym_new_const() - add sym_matches_type() checks, so even if we somehow reach a binary op with symbolic constants of the wrong type on the stack we won't trigger the type assert