summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_stackref.h
Commit message (Collapse)AuthorAgeFilesLines
* gh-142472: Clean-up _PyStackRef functions (gh-142479)Sam Gross2025-12-151-195/+48
| | | | | | | | This combines most _PyStackRef functions and macros between the free threaded and default builds. - Remove Py_TAG_DEFERRED (same as Py_TAG_REFCNT) - Remove PyStackRef_IsDeferred (same as !PyStackRef_RefcountOnObject)
* GH-135379: Top of stack caching for the JIT. (GH-135465)Mark Shannon2025-12-111-0/+17
| | | | Uses three registers to cache values at the top of the evaluation stack This significantly reduces memory traffic for smaller, more common uops.
* gh-124379: Document _PyStackRef (gh-142321)Sam Gross2025-12-081-7/+0
|
* gh-131527: Stackref debug borrow checker (#140599)Mikhail Efimov2025-11-051-5/+26
| | | | | | | Add borrow checking to the stackref debug mode --------- Co-authored-by: mpage <mpage@meta.com>
* gh-140868: Don't rely on undefined left shift behavior in assert (#140869)Dino Viehland2025-11-011-1/+2
| | | Don't rely on undefined left shift behavior in assert
* gh-135125: Fix Py_STACKREF_DEBUG build (GH-139475)Mikhail Efimov2025-10-231-46/+131
| | | | * Use the same pattern of refcounting for stackrefs as in production build
* GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384)Sergey Miryanov2025-10-221-0/+6
|
* gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800)Donghee Na2025-09-241-0/+6
|
* gh-134043: use stackrefs for dict lookup in `_PyObject_GetMethodStackRef` ↵Kumar Aditya2025-07-281-0/+7
| | | | | (#136412) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)Charlie Lin2025-07-071-1/+1
| | | | | | | | Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build. --------- Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-127705: Move Py_INCREF_MORTAL() to the internal C API (GH-136178)Victor Stinner2025-07-021-4/+4
| | | | Rename Py_INCREF_MORTAL() to _Py_INCREF_MORTAL() and move it to pycore_object.h internal header.
* GH-135379: Remove types from stack items in code generator. (GH-135384)Mark Shannon2025-06-111-0/+26
| | | | * Make casts explicit in the instruction definitions
* GH-132554: Fix tier2 `FOR_ITER` implementation and optimizations (GH-135137)Mark Shannon2025-06-051-4/+38
|
* GH-132554: "Virtual" iterators (GH-132555)Mark Shannon2025-05-271-34/+40
| | | | | | * 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-133932: Tagged ints are heap safe (GH-134244)Mark Shannon2025-05-221-13/+7
|
* GH-134282: Always borrow references LOAD_CONST (GH-134284)Mark Shannon2025-05-201-8/+5
|
* gh-133476: Assert with the `PyStackRef_IsTaggedInt` function (GH-133477)Nybblista2025-05-091-8/+9
|
* GH-132508: Use tagged integers on the evaluation stack for the last ↵Mark Shannon2025-04-291-10/+68
| | | | instruction offset (GH-132545)
* GH-131498: Cases generator: manage stacks automatically (GH-132074)Mark Shannon2025-04-041-5/+0
|
* GH-131904: Fix Py_STACKREF_DEBUG build (GH-132022)Mark Shannon2025-04-031-4/+19
|
* gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)mpage2025-04-011-14/+36
| | | Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
* Revise `pycore_stackref.h` comments. (#130601)Neil Schemenauer2025-03-271-3/+3
|
* gh-131782: Fix cast to match type of `bits` in ↵Neil Schemenauer2025-03-271-1/+1
| | | | `_Py_TryIncrefCompareStackRef` (#131783)
* gh-131586: Avoid refcount contention in some "special" calls (#131588)Sam Gross2025-03-261-1/+34
| | | | | | | | | | In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to reference count contention on the returned function object becuase it doesn't use stackrefs. Refactor some of the callers to use `_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally. This fixes the scaling bottleneck in the "lookup_special" microbenchmark in `ftscalingbench.py`. However, the are still some uses of `_PyObject_LookupSpecial()` that need to be addressed in future PRs.
* gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h (#131560)Victor Stinner2025-03-211-0/+10
| | | | | | | * Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h. * Remove pycore_interpframe.h include from pycore_genobject.h. * Remove now useless includes from C files. * Add pycore_interpframe_structs.h to Makefile.pre.in and pythoncore.vcxproj.
* gh-131238: Remove pycore_object_deferred.h from pycore_object.h (#131549)Victor Stinner2025-03-211-4/+4
| | | Remove also pycore_function.h from pycore_typeobject.h.
* GH-131238: More refactoring of core header files (GH-131351)Mark Shannon2025-03-171-0/+19
| | | | Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
* GH-131238: Core header refactor (GH-131250)Mark Shannon2025-03-171-11/+0
| | | | | * Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h * Removes many cross-header dependencies
* GH-127705: Use `_PyStackRef`s in the default build. (GH-127875)Mark Shannon2025-03-101-40/+306
|
* GH-127705: better double free message. (GH-130785)Mark Shannon2025-03-051-5/+12
| | | | | * Add location information when accessing already closed stackref * Add #def option to track closed stackrefs to provide precise information for use after free and double frees.
* gh-129984: Mark immortal objects as deferred (#129985)Dino Viehland2025-02-131-1/+1
| | | Mark immortal objects as deferred
* GH-127705: Add debug mode for `_PyStackRef`s inspired by HPy debug mode ↵Mark Shannon2024-12-201-0/+113
| | | | (GH-128121)
* gh-127022: Simplify `PyStackRef_FromPyObjectSteal` (#127024)Sam Gross2024-11-221-4/+10
| | | | | | | | | This gets rid of the immortal check in `PyStackRef_FromPyObjectSteal()`. Overall, this improves performance about 2% in the free threading build. This also renames `PyStackRef_Is()` to `PyStackRef_IsExactly()` because the macro requires that the tag bits of the arguments match, which is only true in certain special cases.
* GH-125323: Convert DECREF_INPUTS_AND_REUSE_FLOAT into a function that takes ↵Mark Shannon2024-10-141-0/+7
| | | | PyStackRefs. (GH-125439)
* gh-125323: Remove some unsafe Py_DECREFs in bytecodes.c, replacing them with ↵Ken Jin2024-10-141-0/+3
| | | | PyStackRef_CLOSEs (GH-125324)
* GH-120024: Tidy up pycore_stackref.h, splitting into GIL and free-threading ↵Mark Shannon2024-10-091-101/+65
| | | | sections (GH-125095)
* GH-121459: Streamline PyObject* to PyStackRef conversions by disallowing ↵Mark Shannon2024-10-071-5/+9
| | | | NULL pointers. (GH-124894)
* gh-124064: Fix -Wconversion warnings in pycore_{long,object}.h (#124177)Victor Stinner2024-09-171-3/+3
| | | | Change also the fix for pycore_gc.h and pycore_stackref.h: declare constants as uintptr_t, rather than casting constants.
* gh-124064: Fix -Wconversion warnings in pycore_{gc,list,stackref}.h (#124174)Victor Stinner2024-09-171-2/+2
|
* gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` ↵Sam Gross2024-09-121-0/+12
| | | | | | | | (#123924) Use a `_PyStackRef` and defer the reference to `f_executable` when possible. This avoids some reference count contention in the common case of executing the same code object from multiple threads concurrently in the free-threaded build.
* gh-117376: Make `Py_DECREF` a macro in ceval.c in free-threaded build (#122975)Sam Gross2024-08-231-12/+9
| | | | | | | | | | | `Py_DECREF` and `PyStackRef_CLOSE` are now implemented as macros in the free-threaded build in ceval.c. There are two motivations; * MSVC has problems inlining functions in ceval.c in the PGO build. * We will want to mark escaping calls in order to spill the stack pointer in ceval.c and we will want to do this around `_Py_Dealloc` (or `_Py_MergeZeroLocalRefcount` or `_Py_DecRefShared`), not around the entire `Py_DECREF` or `PyStackRef_CLOSE` call.
* gh-117139: Garbage collector support for deferred refcounting (#122956)Sam Gross2024-08-151-3/+3
| | | | | | | | | | The free-threaded GC now visits interpreter stacks to keep objects that use deferred reference counting alive. Interpreter frames are zero initialized in the free-threaded GC so that the GC doesn't see garbage data. This is a temporary measure until stack spilling around escaping calls is implemented. Co-authored-by: Ken Jin <kenjin@python.org>
* GH-122034: Add StackRef variants of type checks to reduce the number of ↵Mark Shannon2024-07-251-0/+33
| | | | PyStackRef_AsPyObjectBorrow calls (GH-122037)
* gh-121263: Macro-ify most stackref functions for MSVC (GH-121270)Ken Jin2024-07-031-58/+30
| | | Macro-ify most stackref functions for MSVC
* gh-117139: Add _PyTuple_FromStackRefSteal and use it (#121244)Sam Gross2024-07-021-1/+1
| | | Avoids the extra conversion from stack refs to PyObjects.
* gh-117139: Convert the evaluation stack to stack refs (#118450)Ken Jin2024-06-261-109/+186
| | | | | | | | | | | | | | | | | This PR sets up tagged pointers for CPython. The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly. Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out. This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it. The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs. Please read Include/internal/pycore_stackref.h for more information! --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
* gh-117139: Fix missing semicolon (GH-118573)Ken Jin2024-05-041-1/+1
|
* gh-117139: Add header for tagged pointers (GH-118330)Ken Jin2024-04-301-0/+195
--------- Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>