File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ struct _gc_thread_state {
2121};
2222#endif
2323
24+ /* How much scratch space to give stackref to PyObject* conversion. */
25+ #define MAX_STACKREF_SCRATCH 10
26+
27+
2428// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The
2529// PyThreadState fields are exposed as part of the C API, although most fields
2630// are intended to be private. The _PyThreadStateImpl fields not exposed.
@@ -47,6 +51,9 @@ typedef struct _PyThreadStateImpl {
4751 struct _qsbr_thread_state * qsbr ; // only used by free-threaded build
4852 struct llist_node mem_free_queue ; // delayed free queue
4953
54+ // Scratch space to convert _PyStackRef to PyObject *
55+ // +1 to account for possible vectorcalls.
56+ PyObject * stackref_scratch [MAX_STACKREF_SCRATCH + 1 ];
5057#ifdef Py_GIL_DISABLED
5158 // Stack references for the current thread that exist on the C stack
5259 struct _PyCStackRef * c_stack_refs ;
Original file line number Diff line number Diff line change @@ -390,13 +390,11 @@ do { \
390390
391391/* Stackref macros */
392392
393- /* How much scratch space to give stackref to PyObject* conversion. */
394- #define MAX_STACKREF_SCRATCH 10
395-
396393#define STACKREFS_TO_PYOBJECTS (ARGS , ARG_COUNT , NAME ) \
397394 /* +1 because vectorcall might use -1 to write self */ \
398- PyObject *NAME##_temp[MAX_STACKREF_SCRATCH+1]; \
399- PyObject **NAME = _PyObjectArray_FromStackRefArray(ARGS, ARG_COUNT, NAME##_temp + 1);
395+ _PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate; \
396+ PyObject **NAME##_temp = _tstate->stackref_scratch; \
397+ PyObject **NAME = _PyObjectArray_FromStackRefArray(ARGS, ARG_COUNT,
400398
401399#define STACKREFS_TO_PYOBJECTS_CLEANUP (NAME ) \
402400 /* +1 because we +1 previously */ \
You can’t perform that action at this time.
0 commit comments