| Commit message (Collapse) | Author | Age |
|
|
|
|
|
| |
Save and restore exceptions during take_ownership processing to preserve
exceptions currently being raised.
Co-authored-by: alperyoney <alperyoney@fb.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This tells TSAN not to sanitize `PyUnstable_InterpreterFrame_GetLine()`.
There's a possible data race on the access to the frame's `instr_ptr`
if the frame is currently executing. We don't really care about the
race. In theory, we could use relaxed atomics for every access to
`instr_ptr`, but that would create more code churn and current compilers
are overly conservative with optimizations around relaxed atomic
accesses.
We also don't sanitize `_PyFrame_IsIncomplete()` because it accesses
`instr_ptr` and is called from assertions within PyFrame_GetCode().
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
| |
This makes more operations on frame objects thread-safe in the free
threaded build, which fixes some data races that occurred when passing
exceptions between threads.
However, accessing local variables from another thread while its running
is still not thread-safe and may crash the interpreter.
|
|
|
|
| |
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
|
| |
|
|
|
| |
Add new frame owner type for interpreter entry frames
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-124148)
The `owner` field of `_PyInterpreterFrame` is supposed to be a member of
`enum _frameowner`, but `FRAME_CLEARED` is a member of `enum _framestate`.
At present, it happens that `FRAME_CLEARED` is not numerically equal to any
member of `enum _frameowner`, but that could change in the future. The code
that incorrectly assigned `owner = FRAME_CLEARED` was deleted in commit
a53cc3f49463e50cb3e2b839b3a82e6bf7f73fee (GH-116687). Remove the incorrect
checks for `owner != FRAME_CLEARED` as well.
|
|
|
|
|
|
|
|
|
| |
`BINARY_OP` (#123926)
Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads.
Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization.
Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
|
|
|
|
|
|
| |
Use a `_PyStackRef` and defer the reference to `f_funcobj` 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.
|
|
|
|
|
|
|
|
| |
(#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.
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
| |
invalid objects during GC (#118478)
|
|
|
| |
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
|
| |
|
| |
|
|
|
|
|
|
| |
frame->frame_obj was set to NULL a few lines earlier.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
|
| |
|
|
|
|
|
|
| |
Move PyUnstable_ExecutableKinds and associated macros from the
internal C API to the public C API.
Rename constants: replace "PY_" prefix with "PyUnstable_" prefix.
|
|
|
|
| |
performance. (GH-108036)
|
|
|
|
|
|
|
|
|
|
| |
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-104211)
Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
|
|
|
|
| |
for users of PEP 523. (GH-96849)
|
|
|
|
| |
(in Python/) (#102193)
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
`PyFrameObject` (GH-97996)
|
|
|
|
| |
(GH-97845)
|
|
|
|
| |
frames (GH-97795)
|
| |
|
|
|
|
| |
(GH-94371)
|
|
|
|
| |
on thread frame stack. (GH-93908)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
| |
* Remove the f_state field from _PyInterpreterFrame
* Make ownership of the frame explicit, replacing the is_generator field with an owner field.
|
|
|
|
|
| |
Rename also struct _interpreter_frame to struct _PyInterpreterFrame.
Reduce risk of name conflicts if a project includes pycore_frame.h.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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).
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
deallocated. (GH-29700)
|