summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_analysis.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-116422: Tier2 hot/cold splitting (GH-116813)Mark Shannon2024-03-261-28/+22
| | | | | Splits the "cold" path, deopts and exits, from the "hot" path, reducing the size of most jitted instructions, at the cost of slower exits.
* gh-117045: Add code object to function version cache (#117028)Guido van Rossum2024-03-211-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-211-2/+9
|
* GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't ↵Mark Shannon2024-03-201-6/+10
| | | | optimize them perfectly. (GH-117067)
* Cleanup tier2 debug output (#116920)Guido van Rossum2024-03-181-4/+14
| | | Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.
* GH-116596: Better determination of escaping uops. (GH-116597)Mark Shannon2024-03-111-4/+4
|
* GH-113710: Fix optimization of globals using `_CHECK_FUNCTION` (GH-116460)Mark Shannon2024-03-081-6/+10
|
* GH-113710: Tier 2 optimizer: check the function instead of checking globals. ↵Mark Shannon2024-03-061-16/+21
| | | | (GH-116410)
* GH-115685: Split `_TO_BOOL_ALWAYS_TRUE` into micro-ops (GH-116352)Mark Shannon2024-03-051-0/+3
|
* GH-115819: Eliminate Boolean guards when value is known (GH-116355)Mark Shannon2024-03-051-0/+11
|
* GH-115685: Optimize `TO_BOOL` and variants based on truthiness of input. ↵Mark Shannon2024-03-051-0/+22
| | | | (GH-116311)
* gh-116088: Insert bottom checks after all sym_set_...() calls (#116089)Guido van Rossum2024-02-291-0/+9
| | | | | | | | | 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-281-6/+4
| | | | | | | | | | | | | 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
* gh-115816: Improve internal symbols API in optimizer (#116028)Guido van Rossum2024-02-281-0/+2
| | | | | | | - Any `sym_set_...` call that attempts to set conflicting information cause the symbol to become `bottom` (contradiction). - All `sym_is...` and similar calls return false or NULL for `bottom`. - Everything's tested. - The tests still pass with `PYTHONUOPSOPTIMIZE=1`.
* GH-115816: Assorted naming and formatting changes to improve ↵Mark Shannon2024-02-271-4/+21
| | | | | | | maintainability. (GH-115987) * Rename _Py_UOpsAbstractInterpContext to _Py_UOpsContext and _Py_UOpsSymType to _Py_UopsSymbol. * #define shortened form of _Py_uop_... names for improved readability.
* GH-115816: Make tier2 optimizer symbols testable, and add a few tests. ↵Mark Shannon2024-02-271-331/+12
| | | | (GH-115953)
* gh-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-261-1/+1
|
* Rename tier 2 redundancy eliminator to optimizer (#115888)Guido van Rossum2024-02-261-4/+4
| | | | The original name is just too much of a mouthful.
* gh-115859: Disable the tier 2 redundancy eliminator by default (GH-115860)Ken Jin2024-02-231-3/+6
|
* gh-114058: More robust method handling in redundancy eliminator (GH-115779)Ken Jin2024-02-231-0/+1
|
* GH-115651: Convert `LOAD_MODULE_ATTR` into `LOAD_INLINE_CONST` when the ↵Mark Shannon2024-02-221-24/+44
| | | | module is itself a constant. (GH-115711)
* Delete unused sym_clear_flag function. (#115744)Benjamin Peterson2024-02-211-6/+0
|
* Tier 2 cleanups and tweaks (#115534)Guido van Rossum2024-02-201-1/+2
| | | | | | | | | * Rename `_testinternalcapi.get_{uop,counter}_optimizer` to `new_*_optimizer` * Use `_PyUOpName()` instead of` _PyOpcode_uop_name[]` * Add `target` to executor iterator items -- `list(ex)` now returns `(opcode, oparg, target, operand)` quadruples * Add executor methods `get_opcode()` and `get_oparg()` to get `vmdata.opcode`, `vmdata.oparg` * Define a helper for printing uops, and unify various places where they are printed * Add a hack to summarize_stats.py to fix legacy uop names (e.g. `POP_TOP` -> `_POP_TOP`) * Define helpers in `test_opt.py` for accessing the set or list of opnames of an executor
* gh-115480: Minor fixups in int constant propagation (GH-115507)Ken Jin2024-02-161-8/+9
|
* gh-115480: Type and constant propagation for int BINARY_OPs (GH-115478)Ken Jin2024-02-151-0/+12
|
* GH-113710: Improve `_SET_IP` and `_CHECK_VALIDITY` (GH-115248)Mark Shannon2024-02-131-24/+51
|
* gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)Ken Jin2024-02-131-44/+511
| | | | | | | --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com> Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
* GH-113710: Fix updating of dict version tag and add watched dict stats ↵Mark Shannon2024-02-121-19/+12
| | | | (GH-115221)
* GH-113710: Add a "globals to constants" pass (GH-114592)Mark Shannon2024-02-021-7/+223
| | | Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
* GH-113710: Add a tier 2 peephole optimization pass. (GH-114487)Mark Shannon2024-01-241-0/+34
| | | | | * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
* GH-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)Brandt Bucher2024-01-121-1/+0
|
* GH-113657: Add back missing _SET_IP uops in tier two (GH-113662)Brandt Bucher2024-01-021-2/+3
|
* A smattering of cleanups in uop debug output and lltrace (#112980)Guido van Rossum2023-12-121-1/+0
| | | | | | * Include destination T1 opcode in Error debug message * Include destination T1 opcode in DEOPT debug message * Remove obsolete comment from remove_unneeded_uops * Change lltrace_instruction() to print caller's opcode/oparg
* GH-111848: Set the IP when de-optimizing (GH-112065)Mark Shannon2023-11-151-12/+10
| | | | | | | | | | | | * Replace jumps with deopts in tier 2 * Fewer special cases of uop names * Add target field to uop IR * Remove more redundant SET_IP and _CHECK_VALIDITY micro-ops * Extend whitelist of non-escaping API functions.
* GH-109369: Exit tier 2 if executor is invalid (GH-111657)Mark Shannon2023-11-091-1/+14
|
* GH-111646: Simplify optimizer, by compacting uops when making executor. ↵Mark Shannon2023-11-061-3/+32
| | | | (GH-111647)
* gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. ↵Irit Katriel2023-08-231-1/+0
| | | | (#108367)
* gh-107557: Setup abstract interpretation (#107847)Ken Jin2023-08-151-0/+26
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com> Co-authored-by: Jules <57632293+juliapoo@users.noreply.github.com>