summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-142448: Disable JIT tracing when monitoring is enabled (GH-142842)Ken Jin2025-12-231-3/+8
|
* gh-134584: Eliminate redundant refcounting from `_LOAD_ATTR_WITH_HINT` ↵Hai Zhu2025-12-231-2/+4
| | | | | (GH-143062) Eliminate redundant refcounting from _LOAD_ATTR_WITH_HINT
* GH-139922: Tail calling for MSVC (VS 2026) (GH-143068)Chris Eibl2025-12-221-77/+57
| | | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Brandt Bucher <brandt@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-120321: Make gi_frame_state transitions atomic in FT build (gh-142599)Sam Gross2025-12-191-14/+5
| | | | | | | | | | | | | This makes generator frame state transitions atomic in the free threading build, which avoids segfaults when trying to execute a generator from multiple threads concurrently. There are still a few operations that aren't thread-safe and may crash if performed concurrently on the same generator/coroutine: * Accessing gi_yieldfrom/cr_await/ag_await * Accessing gi_frame/cr_frame/ag_frame * Async generator operations
* gh-142961: Fix constant folding len(tuple) in JIT (GH-142963)Ken Jin2025-12-191-0/+7
|
* GH-134584: Remove redundant refcount for `BINARY_OP_SUBSCR_STR_INT` (#142844)Savannah Ostrowski2025-12-181-5/+5
|
* gh-134584: Eliminate redundant refcounting from _BINARY_OP_SUBSCR_LIST_INT ↵LloydZ2025-12-181-3/+5
| | | | (GH-142926)
* gh-142890: remove unnecessary interp parameter from dict functions and ↵Kumar Aditya2025-12-181-1/+1
| | | | `_PyDict_NotifyEvent` (#142923)
* gh-134584: Remove redundant refcount from _BINARY_OP_ADD_UNICODE (gh-142825)Donghee Na2025-12-181-6/+8
|
* gh-134584: Eliminate redundant refcounting from `_STORE_ATTR_WITH_HINT` ↵Nadeshiko Manju2025-12-161-3/+5
| | | | | (GH-142767) Signed-off-by: Manjusaka <me@manjusaka.me>
* gh-134584: Eliminate redundant refcounting from `_LOAD_ATTR_INSTANCE_VALUE` ↵Nadeshiko Manju2025-12-161-2/+4
| | | | | (GH-142769) Signed-off-by: Manjusaka <me@manjusaka.me>
* Make RESUME monitoring more readable and robust (GH-142136)Gabriele N. Tornetta2025-12-161-1/+1
|
* GH-134584: Remove redundant refcount from `_STORE_ATTR_SLOT` (#142729)Savannah Ostrowski2025-12-151-3/+5
|
* gh-134584: JIT: Eliminate redundant refcount ops for X_INT (GH-142765)Ken Jin2025-12-151-16/+16
|
* gh-134584: Eliminate redundant refcounting from `_STORE_ATTR_INSTANCE_VALUE` ↵Nadeshiko Manju2025-12-151-3/+5
| | | | | (GH-142759) Signed-off-by: Manjusaka <me@manjusaka.me>
* gh-134584: Remove custom float decref ops (GH-142576)Ken Jin2025-12-151-55/+21
|
* gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT (GH-142712)Donghee Na2025-12-151-4/+8
| | | Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-134584: Eliminate redundant refcounting from _CALL_LIST_APPEND (GH-142711)Nadeshiko Manju2025-12-151-5/+10
| | | | Signed-off-by: Manjusaka <me@manjusaka.me> Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_LIST_INT ↵Donghee Na2025-12-141-5/+5
| | | | (gh-142703)
* gh-134584: Eliminate redundant refcounting from `_CALL_BUILTION_O` (GH-142695)PuQing2025-12-141-7/+9
| | | Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-134584: Eliminate redundant refcounting from `_CALL_STR_1` (GH-136070)Nadeshiko Manju2025-12-141-7/+7
| | | Signed-off-by: Manjusaka <me@manjusaka.me>
* gh-134584: Cleanups for GH-135860 (GH-142604)Ken Jin2025-12-131-3/+6
|
* gh-134584: Revert partially GH-135860 (GH-142620)Ken Jin2025-12-121-9/+2
|
* gh-134584: Eliminate redundant refcounting from ``_CALL_LEN`` (gh-136104)Donghee Na2025-12-111-6/+7
|
* gh-134584: Eliminate redundant refcounting from `_CALL_TUPLE_1` (GH-135860)Noam Cohen2025-12-111-6/+10
|
* GH-140683: JIT: Improve machine code for loading smaller constants on ↵Mark Shannon2025-12-111-1/+1
| | | | | | AArch64. (GH-142511) * Use movz and movk instructions for loading 16 and 32 bit operands and oparg. * Loading of 64 bit operands is unchanged.
* GH-135379: Top of stack caching for the JIT. (GH-135465)Mark Shannon2025-12-111-6/+21
| | | | Uses three registers to cache values at the top of the evaluation stack This significantly reduces memory traffic for smaller, more common uops.
* GH-139757: JIT: Remove redundant branches to jumps in the assembly optimizer ↵Mark Shannon2025-12-081-3/+4
| | | | | | | | | (GH-140800) JIT: Remove redundant branches to jump in the assembly optimizer * Refactor JIT assembly optimizer making instructions instances not just strings * Remove redundant jumps and branches where legal to do so * Modifies _BINARY_OP_SUBSCR_STR_INT to avoid excessive inlining depth
* GH-141794: Limit size of generated machine code. (GH-142228)Mark Shannon2025-12-031-116/+63
| | | | | | * Factor out bodies of the largest uops, to reduce jit code size. * Factor out common assert, also reducing jit code size. * Limit size of jitted code for a single executor to 1MB.
* GH-141861: Fix TRACE_RECORD if full (GH-141959)Sergey Miryanov2025-11-261-2/+2
|
* GH-141861: Fix invalid memory read in the ENTER_EXECUTOR (GH-141921)Sergey Miryanov2025-11-241-1/+1
|
* GH-139109: Support switch/case dispatch with the tracing interpreter. ↵Mark Shannon2025-11-181-3/+6
| | | | (GH-141703)
* gh-139109: JIT _EXIT_TRACE to ENTER_EXECUTOR rather than _DEOPT (GH-141573)Ken Jin2025-11-151-2/+2
|
* gh-141367: Use CALL_LIST_APPEND instruction only for lists, not for list ↵Mikhail Efimov2025-11-141-2/+1
| | | | | subclasses (GH-141398) Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-139109: A new tracing JIT compiler frontend for CPython (GH-140310)Ken Jin2025-11-131-35/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR changes the current JIT model from trace projection to trace recording. Benchmarking: better pyperformance (about 1.7% overall) geomean versus current https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251108-3.15.0a1%2B-7e2bc1d-JIT/bm-20251108-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-7e2bc1d-vs-base.svg, 100% faster Richards on the most improved benchmark versus the current JIT. Slowdown of about 10-15% on the worst benchmark versus the current JIT. **Note: the fastest version isn't the one merged, as it relies on fixing bugs in the specializing interpreter, which is left to another PR**. The speedup in the merged version is about 1.1%. https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251112-3.15.0a1%2B-f8a764a-JIT/bm-20251112-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-f8a764a-vs-base.svg Stats: 50% more uops executed, 30% more traces entered the last time we ran them. It also suggests our trace lengths for a real trace recording JIT are too short, as a lot of trace too long aborts https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251023-3.15.0a1%2B-eb73378-CLANG%2CJIT/bm-20251023-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-eb73378-pystats-vs-base.md . This new JIT frontend is already able to record/execute significantly more instructions than the previous JIT frontend. In this PR, we are now able to record through custom dunders, simple object creation, generators, etc. None of these were done by the old JIT frontend. Some custom dunders uops were discovered to be broken as part of this work gh-140277 The optimizer stack space check is disabled, as it's no longer valid to deal with underflow. Pros: * Ignoring the generated tracer code as it's automatically created, this is only additional 1k lines of code. The maintenance burden is handled by the DSL and code generator. * `optimizer.c` is now significantly simpler, as we don't have to do strange things to recover the bytecode from a trace. * The new JIT frontend is able to handle a lot more control-flow than the old one. * Tracing is very low overhead. We use the tail calling interpreter/computed goto interpreter to switch between tracing mode and non-tracing mode. I call this mechanism dual dispatch, as we have two dispatch tables dispatching to each other. Specialization is still enabled while tracing. * Better handling of polymorphism. We leverage the specializing interpreter for this. Cons: * (For now) requires tail calling interpreter or computed gotos. This means no Windows JIT for now :(. Not to fret, tail calling is coming soon to Windows though https://github.com/python/cpython/pull/139962 Design: * After each instruction, the `record_previous_inst` function/label is executed. This does as the name suggests. * The tracing interpreter lowers bytecode to uops directly so that it can obtain "fresh" values at the point of lowering. * The tracing version behaves nearly identical to the normal interpreter, in fact it even has specialization! This allows it to run without much of a slowdown when tracing. The actual cost of tracing is only a function call and writes to memory. * The tracing interpreter uses the specializing interpreter's deopt to naturally form the side exit chains. This allows it to side exit chain effectively, without repeating much code. We force a re-specializing when tracing a deopt. * The tracing interpreter can even handle goto errors/exceptions, but I chose to disable them for now as it's not tested. * Because we do not share interpreter dispatch, there is should be no significant slowdown to the original specializing interpreter on tailcall and computed got with JIT disabled. With JIT enabled, there might be a slowdown in the form of the JIT trying to trace. * Things that could have dynamic instruction pointer effects are guarded on. The guard deopts to a new instruction --- `_DYNAMIC_EXIT`.
* gh-138050: [WIP] JIT - Streamline MAKE_WARM - move coldness check to ↵alm2025-10-271-5/+0
| | | | executor creation (GH-138240)
* gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800)Donghee Na2025-09-241-2/+3
|
* gh-135755: Make Py_TAIL_CALL_INTERP macro private (#138981)Victor Stinner2025-09-181-5/+5
| | | Rename Py_TAIL_CALL_INTERP to _Py_TAIL_CALL_INTERP.
* GH-138378: Move globals-to-consts pass into main optimizer pass (GH-138379)Mark Shannon2025-09-181-6/+0
|
* gh-137136: Suppress build warnings when build on Windows with ↵AN Long2025-09-031-2/+2
| | | | --experimental-jit-interpreter (GH-137137)
* GH-137959: Replace shim code in jitted code with a single trampoline ↵Mark Shannon2025-08-211-5/+5
| | | | function. (GH-137961)
* gh-137883: Check the recursion limit for specialized keyword argument calls ↵Peter Bierma2025-08-191-0/+1
| | | | (GH-137887)
* gh-137400: Fix thread-safety issues when profiling all threads (gh-137518)Sam Gross2025-08-131-1/+9
| | | | | | | | | | There were a few thread-safety issues when profiling or tracing all threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads: * The loop over thread states could crash if a thread exits concurrently (in both the free threading and default build) * The modification of `c_profilefunc` and `c_tracefunc` wasn't thread-safe on the free threading build.
* GH-132532: Add new DSL macros to better declare semantics of exits at ends ↵Mark Shannon2025-08-091-38/+36
| | | | of instructions/uops. (GH-137098)
* GH-136410: Faster side exits by using a cold exit stub (GH-136411)Mark Shannon2025-08-011-29/+45
|
* gh-115999: remove redundant check in free-threading from ↵Kumar Aditya2025-07-041-6/+0
| | | | `_STORE_ATTR_WITH_HINT` (#136249)
* gh-136125: Use `_PyObject_GetMethodStackRef` for `LOAD_ATTR` (GH-136127)Ken Jin2025-07-011-8/+7
|
* gh-132732: Automatically constant evaluate pure operations (GH-132733)Ken Jin2025-06-271-1/+1
| | | | | | This adds a "macro" to the optimizer DSL called "REPLACE_OPCODE_IF_EVALUATES_PURE", which allows automatically constant evaluating a bytecode body if certain inputs have no side effects upon evaluations (such as ints, strings, and floats). Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
* gh-134584: Specialize POP_TOP by reference and type in JIT (GH-135761)Ken Jin2025-06-231-0/+21
|
* gh-135379: Move PyLong_CheckCompact to private header and rename it (GH-135707)Ken Jin2025-06-191-2/+2
|