summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-134584: Remove redundant refcount from `_STORE_ATTR_SLOT` (#142729)Savannah Ostrowski11 days1-3/+5
|
* gh-134584: JIT: Eliminate redundant refcount ops for X_INT (GH-142765)Ken Jin11 days1-16/+16
|
* gh-134584: Eliminate redundant refcounting from `_STORE_ATTR_INSTANCE_VALUE` ↵Nadeshiko Manju11 days1-3/+5
| | | | | (GH-142759) Signed-off-by: Manjusaka <me@manjusaka.me>
* gh-134584: Remove custom float decref ops (GH-142576)Ken Jin11 days1-55/+21
|
* gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT (GH-142712)Donghee Na11 days1-4/+8
| | | Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-134584: Eliminate redundant refcounting from _CALL_LIST_APPEND (GH-142711)Nadeshiko Manju11 days1-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 Na12 days1-5/+5
| | | | (gh-142703)
* gh-134584: Eliminate redundant refcounting from `_CALL_BUILTION_O` (GH-142695)PuQing12 days1-7/+9
| | | Co-authored-by: Ken Jin <kenjin4096@gmail.com>
* gh-134584: Eliminate redundant refcounting from `_CALL_STR_1` (GH-136070)Nadeshiko Manju12 days1-7/+7
| | | Signed-off-by: Manjusaka <me@manjusaka.me>
* gh-134584: Cleanups for GH-135860 (GH-142604)Ken Jin13 days1-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
|
* GH-135379: Specialize int operations for compact ints only (GH-135668)Mark Shannon2025-06-191-16/+27
|
* gh-134584: Decref elimination for float ops in the JIT (GH-134588)Ken Jin2025-06-171-0/+46
| | | This PR adds a PyJitRef API to the JIT's optimizer that mimics the _PyStackRef API. This allows it to track references and their stack lifetimes properly. Thus opening up the doorway to refcount elimination in the JIT.
* GH-135379: Support limited scalar replacement for replicated uops in the JIT ↵Mark Shannon2025-06-171-4/+2
| | | | | | code generator. (GH-135563) * Use it to support efficient specializations of COPY and SWAP in the JIT.
* gh-135474: Specialize arithmetic only on compact ints (GH-135479)Ken Jin2025-06-141-3/+6
| | | | Specialize arithmetic only on compact ints. This also makes int operations non-escaping in the JIT and in tier 1.
* GH-135379: Remove types from stack items in code generator. (GH-135384)Mark Shannon2025-06-111-30/+33
| | | | * Make casts explicit in the instruction definitions
* GH-132554: Fix tier2 `FOR_ITER` implementation and optimizations (GH-135137)Mark Shannon2025-06-051-74/+23
|
* GH-134879: Fix `INSTRUMENT_FOR_ITER` for list/tuple (#134897)Mark Shannon2025-05-301-1/+1
| | | Fix INSTRUMENT_FOR_ITER for list/tuple
* GH-132554: "Virtual" iterators (GH-132555)Mark Shannon2025-05-271-157/+143
| | | | | | * FOR_ITER now pushes either the iterator and NULL or leaves the iterable and pushes tagged zero * NEXT_ITER uses the tagged int as the index into the sequence or, if TOS is NULL, iterates as before.
* GH-131798: Optimize away isinstance calls in the JIT (GH-134369)Tomas R.2025-05-221-3/+39
|
* GH-131798: Optimize cached class attributes and methods in the JIT (GH-134403)Brandt Bucher2025-05-221-0/+12
|
* GH-131798: Narrow types more aggressively in the JIT (GH-134373)Brandt Bucher2025-05-201-0/+5
|
* GH-134282: Always borrow references LOAD_CONST (GH-134284)Mark Shannon2025-05-201-56/+7
|