Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-127705: Use _PyStackRefs in the default build. #127875

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2ec65dc
Initial implementation of tagged stackrefs for GIL build. Requires fi…
markshannon Oct 9, 2024
9a5c3a6
Merge branch 'main' into use-stackrefs
markshannon Oct 11, 2024
ee7f3a6
Streamline PyStackRef_XCLOSE and PyStackRef_CLEAR.
markshannon Oct 11, 2024
21d7e87
Fix error handling with not stackref outputs in code generator
markshannon Oct 11, 2024
370e77b
Merge branch 'main' into use-stackrefs
markshannon Oct 14, 2024
2636c04
Attempt to fix _BINARY_OP_INPLACE_ADD_UNICODE and use tag references …
markshannon Oct 14, 2024
5a38e03
Merge branch 'main' into use-stackrefs
markshannon Oct 14, 2024
a79aa47
Show frame locals in lltrace
markshannon Oct 14, 2024
a90e644
Fix _PyFrame_Copy and add some asserts to make reference heap safe
markshannon Oct 15, 2024
83e0323
Improve efficiency of _PyStackRef_FromPyObjectNew a bit
markshannon Oct 16, 2024
7fb6a48
Merge branch 'main' into use-stackrefs
markshannon Oct 22, 2024
7e6deef
Merge branch 'main' into use-stackrefs
markshannon Oct 29, 2024
f03f745
Make making heap safe more efficient
markshannon Oct 29, 2024
67670f0
Merge branch 'main' into use-stackrefs
markshannon Dec 2, 2024
ff9d044
Fix up after merge
markshannon Dec 2, 2024
3334c14
Merge branch 'main' into use-stackrefs
markshannon Dec 4, 2024
b7a8b5d
Restore immortality bit
markshannon Dec 4, 2024
49d0d42
Fix validity check
markshannon Dec 4, 2024
3a12d18
Add PyStackRef_IsMortal
markshannon Dec 5, 2024
497fb9f
Reduce overhead of stackrefs a tiny bit for mortal objects
markshannon Dec 5, 2024
4768a38
Merge branch 'main' into use-stackrefs
markshannon Dec 5, 2024
806c28a
Attempt to use tagged RC for a bit of extra speed
markshannon Dec 5, 2024
c540f28
Merge branch 'main' into use-stackrefs
markshannon Dec 6, 2024
0c20416
Revert addition of LOAD_FAST_WITH_COUNT
markshannon Dec 6, 2024
c88bcbc
Avoid INCREF + Steal pairs by using New or return stack ref directly
markshannon Dec 6, 2024
f5dec96
Avoid masking when comparing to True and False
markshannon Dec 6, 2024
bf2dca5
Merge branch 'main' into use-stackrefs
markshannon Dec 10, 2024
1069d98
Revert not-quite-true assert
markshannon Dec 10, 2024
2e752fc
Merge branch 'main' into use-stackrefs
markshannon Dec 12, 2024
d23ae47
Fix up after merge
markshannon Dec 12, 2024
382d101
Merge branch 'main' into use-stackrefs
markshannon Dec 13, 2024
d230f68
Fix compiler errors and warnings
markshannon Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ _Py_eval_breaker_bit_is_set(PyThreadState *tstate, uintptr_t bit)
void _Py_set_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit);
void _Py_unset_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit);

PyAPI_FUNC(PyObject *) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef right, double value);
PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef right, double value);


#ifdef __cplusplus
Expand Down
22 changes: 14 additions & 8 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,23 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)

static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
{
*dest = *src;
dest->f_executable = PyStackRef_MakeHeapSafe(src->f_executable);
// Don't leave a dangling pointer to the old frame when creating generators
// and coroutines:
dest->previous = NULL;
dest->f_funcobj = PyStackRef_MakeHeapSafe(src->f_funcobj);
dest->f_globals = src->f_globals;
dest->f_builtins = src->f_builtins;
dest->f_locals = src->f_locals;
dest->frame_obj = src->frame_obj;
dest->instr_ptr = src->instr_ptr;
assert(src->stackpointer != NULL);
int stacktop = (int)(src->stackpointer - src->localsplus);
assert(stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus);
assert(stacktop >= 0);
dest->stackpointer = dest->localsplus + stacktop;
for (int i = 1; i < stacktop; i++) {
dest->localsplus[i] = src->localsplus[i];
for (int i = 0; i < stacktop; i++) {
dest->localsplus[i] = PyStackRef_MakeHeapSafe(src->localsplus[i]);
}
// Don't leave a dangling pointer to the old frame when creating generators
// and coroutines:
dest->previous = NULL;

#ifdef Py_GIL_DISABLED
PyCodeObject *co = _PyFrame_GetCode(dest);
Expand Down Expand Up @@ -405,7 +411,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int

PyAPI_FUNC(_PyInterpreterFrame *)
_PyEvalFramePushAndInit(PyThreadState *tstate, _PyStackRef func,
PyObject *locals, _PyStackRef const* args,
PyObject *locals, _PyStackRef const *args,
size_t argcount, PyObject *kwnames,
_PyInterpreterFrame *previous);

Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ PyAPI_DATA(PyObject*) _PyLong_Rshift(PyObject *, int64_t);
// Export for 'math' shared extension
PyAPI_DATA(PyObject*) _PyLong_Lshift(PyObject *, int64_t);

PyAPI_FUNC(PyObject*) _PyLong_Add(PyLongObject *left, PyLongObject *right);
PyAPI_FUNC(_PyStackRef) _PyLong_Add(PyLongObject *left, PyLongObject *right);
PyAPI_FUNC(PyObject*) _PyLong_Multiply(PyLongObject *left, PyLongObject *right);
PyAPI_FUNC(PyObject*) _PyLong_Subtract(PyLongObject *left, PyLongObject *right);

Expand Down
10 changes: 5 additions & 5 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading