summaryrefslogtreecommitdiffstats
path: root/Python/frame.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-117139: Garbage collector support for deferred refcounting (#122956)Sam Gross2024-08-151-9/+1
| | | | | | | | | | 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-120024: Use pointer for stack pointer (GH-121923)Mark Shannon2024-07-181-9/+13
|
* gh-117139: Convert the evaluation stack to stack refs (#118450)Ken Jin2024-06-261-3/+3
| | | | | | | | | | | | | | | | | 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-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration (#120835)Irit Katriel2024-06-241-1/+1
|
* gh-118272: set stacktop to 0 before freeing contents, to avoid access to ↵Irit Katriel2024-05-011-2/+3
| | | | invalid objects during GC (#118478)
* gh-118272: Clear generator frame's locals when the generator is closed (#118277)Irit Katriel2024-04-301-5/+12
| | | Co-authored-by: Thomas Grainger <tagrain@gmail.com>
* GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)Mark Shannon2024-04-251-12/+0
|
* GH-116098: Remove dead frame object creation code (GH-116687)Tian Gao2024-03-121-18/+9
|
* Remove unused Py_XDECREF from _PyFrame_ClearExceptCode (GH-106158)Anders Kaseorg2024-02-011-1/+0
| | | | | | frame->frame_obj was set to NULL a few lines earlier. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)Irit Katriel2023-10-261-1/+1
|
* gh-107149: Make PyUnstable_ExecutableKinds public (#108440)Victor Stinner2023-08-311-6/+6
| | | | | | Move PyUnstable_ExecutableKinds and associated macros from the internal C API to the public C API. Rename constants: replace "PY_" prefix with "PyUnstable_" prefix.
* GH-108035: Remove the `_PyCFrame` struct as it is no longer needed for ↵Mark Shannon2023-08-171-1/+1
| | | | performance. (GH-108036)
* GH-100987: Allow objects other than code objects as the "executable" of an ↵Mark Shannon2023-06-141-7/+15
| | | | | | | | | | internal frame. (GH-105727) * Add table describing possible executable classes for out-of-process debuggers. * Remove shim code object creation code as it is no longer needed. * Make lltrace a bit more robust w.r.t. non-standard frames.
* GH-96803: Document and test new unstable internal frame API functions ↵Mark Shannon2023-05-181-2/+2
| | | | | | (GH-104211) Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
* GH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque ↵Mark Shannon2023-05-051-1/+17
| | | | for users of PEP 523. (GH-96849)
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-281-6/+3
| | | | (in Python/) (#102193)
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-2/+2
|
* GH-100126: Skip incomplete frames in more places (GH-100613)Brandt Bucher2023-01-091-4/+1
|
* GH-99729: Unlink frames before clearing them (GH-100030)Brandt Bucher2022-12-061-0/+3
|
* GH-96421: Insert shim frame on entry to interpreter (GH-96319)Mark Shannon2022-11-101-1/+3
| | | | | | * Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault() * Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
* GH-97002: Prevent `_PyInterpreterFrame`s from backing more than one ↵Brandt Bucher2022-10-061-6/+23
| | | | `PyFrameObject` (GH-97996)
* GH-97779: Ensure that *all* frame objects are backed by "complete" frames ↵Brandt Bucher2022-10-051-0/+7
| | | | (GH-97845)
* GH-97752: Clear the `previous` member of newly-created generator/coroutine ↵Brandt Bucher2022-10-031-0/+3
| | | | frames (GH-97795)
* GH-96237: Allow non-functions as reference-holder in frames. (GH-96238)Mark Shannon2022-08-251-2/+2
|
* GH-94262: Don't create frame objects for frames that aren't yet complete. ↵Mark Shannon2022-07-011-2/+6
| | | | (GH-94371)
* GH-93897: Store frame size in code object and de-opt if insufficient space ↵Mark Shannon2022-06-201-16/+0
| | | | on thread frame stack. (GH-93908)
* gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938)Victor Stinner2022-06-191-1/+1
| | | | | | | | | | | | | | | | Move the follow functions and type from frameobject.h to pyframe.h, so the standard <Python.h> provide frame getter functions: * PyFrame_Check() * PyFrame_GetBack() * PyFrame_GetBuiltins() * PyFrame_GetGenerator() * PyFrame_GetGlobals() * PyFrame_GetLasti() * PyFrame_GetLocals() * PyFrame_Type Remove #include "frameobject.h" from many C files. It's no longer needed.
* Split refcount stats into 'interpreter' and 'non-interpreter' (GH-92919)Mark Shannon2022-05-181-0/+2
|
* bpo-47177: Replace `f_lasti` with `prev_instr` (GH-32208)Brandt Bucher2022-04-071-0/+7
|
* bpo-47045: Remove `f_state` field (GH-31963)Mark Shannon2022-03-221-4/+7
| | | | | * Remove the f_state field from _PyInterpreterFrame * Make ownership of the frame explicit, replacing the is_generator field with an owner field.
* bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)Victor Stinner2022-02-251-10/+10
| | | | | Rename also struct _interpreter_frame to struct _PyInterpreterFrame. Reduce risk of name conflicts if a project includes pycore_frame.h.
* Pass reference to func, as well as args, when pushing frame. (GH-31100)Mark Shannon2022-02-031-0/+2
|
* bpo-46072: Add some frame stats. (GH-31060)Mark Shannon2022-02-021-0/+2
|
* bpo-46329: Split calls into precall and call instructions. (GH-30855)Mark Shannon2022-01-281-1/+14
| | | | | | | | | | | | | | * Add PRECALL_FUNCTION opcode. * Move 'call shape' varaibles into struct. * Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions. * Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol. * Allow kwnames for specialized calls to builtin types. * Specialize calls to tuple(arg) and str(arg).
* bpo-46409: Make generators in bytecode (GH-30633)Mark Shannon2022-01-201-12/+7
| | | | | | | | | | | | * Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes. * Trim frame and generator by word each. * Minor refactor of frame.c * Update test.test_sys to account for smaller frames. * Treat generator functions as normal functions when evaluating and specializing.
* bpo-45963: Make space for the InterpreterFrame of a generator in that ↵Mark Shannon2021-12-061-12/+6
| | | | | | | generator. (GH-29891) * Make generator, coroutine and async gen structs all the same size. * Store interpreter frame in generator (and coroutine). Reduces the number of allocations neeeded for a generator from two to one.
* bpo-45786: Allocate space for frame in frame object. (GH-29729)Mark Shannon2021-11-291-23/+15
|
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-231-4/+2
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* bpo-45813: Make sure that frame->generator is NULLed when generator is ↵Mark Shannon2021-11-221-0/+3
| | | | deallocated. (GH-29700)
* bpo-44990: Change layout of evaluation frames. "Layout B" (GH-27933)Mark Shannon2021-08-251-20/+12
| | | Places the locals between the specials and stack. This is the more "natural" layout for a C struct, makes the code simpler and gives a slight speedup (~1%)
* bpo-44590: Lazily allocate frame objects (GH-27077)Mark Shannon2021-07-261-0/+135
* Convert "specials" array to InterpreterFrame struct, adding f_lasti, f_state and other non-debug FrameObject fields to it. * Refactor, calls pushing the call to the interpreter upward toward _PyEval_Vector. * Compute f_back when on thread stack, only filling in value when frame object outlives stack invocation. * Move ownership of InterpreterFrame in generator from frame object to generator object. * Do not create frame objects for Python calls. * Do not create frame objects for generators.