File tree Expand file tree Collapse file tree 5 files changed +11
-5
lines changed Expand file tree Collapse file tree 5 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ extern "C" {
88# error "this header requires Py_BUILD_CORE define"
99#endif
1010
11+ struct _py_func_runtime_state {
12+ uint32_t next_version ;
13+ };
14+
1115extern PyFunctionObject * _PyFunction_FromConstructor (PyFrameConstructor * constr );
1216
1317extern uint32_t _PyFunction_GetVersionForCurrentState (PyFunctionObject * func );
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ extern "C" {
1010
1111#include "pycore_atomic.h" /* _Py_atomic_address */
1212#include "pycore_dict_state.h" // struct _Py_dict_runtime_state
13+ #include "pycore_function.h" // struct _func_runtime_state
1314#include "pycore_gil.h" // struct _gil_runtime_state
1415#include "pycore_global_objects.h" // struct _Py_global_objects
1516#include "pycore_import.h" // struct _import_runtime_state
@@ -137,6 +138,7 @@ typedef struct pyruntimestate {
137138
138139 struct _Py_unicode_runtime_ids unicode_ids ;
139140 struct _Py_dict_runtime_state dict_state ;
141+ struct _py_func_runtime_state func_state ;
140142
141143 struct {
142144 /* Used to set PyTypeObject.tp_version_tag */
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ extern "C" {
3939 .dict_state = { \
4040 .next_keys_version = 2, \
4141 }, \
42+ .func_state = { \
43+ .next_version = 1, \
44+ }, \
4245 .types = { \
4346 .next_version_tag = 1, \
4447 }, \
Original file line number Diff line number Diff line change 77#include "pycore_pyerrors.h" // _PyErr_Occurred()
88#include "structmember.h" // PyMemberDef
99
10- static uint32_t next_func_version = 1 ;
11-
1210PyFunctionObject *
1311_PyFunction_FromConstructor (PyFrameConstructor * constr )
1412{
@@ -130,10 +128,10 @@ uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func)
130128 if (func -> vectorcall != _PyFunction_Vectorcall ) {
131129 return 0 ;
132130 }
133- if (next_func_version == 0 ) {
131+ if (_PyRuntime . func_state . next_version == 0 ) {
134132 return 0 ;
135133 }
136- uint32_t v = next_func_version ++ ;
134+ uint32_t v = _PyRuntime . func_state . next_version ++ ;
137135 func -> func_version = v ;
138136 return v ;
139137}
Original file line number Diff line number Diff line change @@ -416,7 +416,6 @@ Python/dtoa.c - pmem_next -
416416Python/getargs.c - static_arg_parsers -
417417
418418# other
419- Objects/funcobject.c - next_func_version -
420419Objects/object.c - _Py_RefTotal -
421420Python/perf_trampoline.c - perf_status -
422421Python/perf_trampoline.c - extra_code_index -
You can’t perform that action at this time.
0 commit comments