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" {
8
8
# error "this header requires Py_BUILD_CORE define"
9
9
#endif
10
10
11
+ struct _py_func_runtime_state {
12
+ uint32_t next_version ;
13
+ };
14
+
11
15
extern PyFunctionObject * _PyFunction_FromConstructor (PyFrameConstructor * constr );
12
16
13
17
extern uint32_t _PyFunction_GetVersionForCurrentState (PyFunctionObject * func );
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ extern "C" {
12
12
#include "pycore_dict_state.h" // struct _Py_dict_runtime_state
13
13
#include "pycore_dtoa.h" // struct _dtoa_runtime_state
14
14
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
15
+ #include "pycore_function.h" // struct _func_runtime_state
15
16
#include "pycore_gil.h" // struct _gil_runtime_state
16
17
#include "pycore_global_objects.h" // struct _Py_global_objects
17
18
#include "pycore_import.h" // struct _import_runtime_state
@@ -153,6 +154,7 @@ typedef struct pyruntimestate {
153
154
struct _Py_float_runtime_state float_state ;
154
155
struct _Py_unicode_runtime_state unicode_state ;
155
156
struct _Py_dict_runtime_state dict_state ;
157
+ struct _py_func_runtime_state func_state ;
156
158
157
159
struct {
158
160
/* Used to set PyTypeObject.tp_version_tag */
Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ extern "C" {
61
61
.dict_state = { \
62
62
.next_keys_version = 2, \
63
63
}, \
64
+ .func_state = { \
65
+ .next_version = 1, \
66
+ }, \
64
67
.types = { \
65
68
.next_version_tag = 1, \
66
69
}, \
Original file line number Diff line number Diff line change 7
7
#include "pycore_pyerrors.h" // _PyErr_Occurred()
8
8
#include "structmember.h" // PyMemberDef
9
9
10
- static uint32_t next_func_version = 1 ;
11
-
12
10
PyFunctionObject *
13
11
_PyFunction_FromConstructor (PyFrameConstructor * constr )
14
12
{
@@ -129,10 +127,10 @@ uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func)
129
127
if (func -> vectorcall != _PyFunction_Vectorcall ) {
130
128
return 0 ;
131
129
}
132
- if (next_func_version == 0 ) {
130
+ if (_PyRuntime . func_state . next_version == 0 ) {
133
131
return 0 ;
134
132
}
135
- uint32_t v = next_func_version ++ ;
133
+ uint32_t v = _PyRuntime . func_state . next_version ++ ;
136
134
func -> func_version = v ;
137
135
return v ;
138
136
}
Original file line number Diff line number Diff line change @@ -328,7 +328,6 @@ Objects/unicodeobject.c - ucnhash_capi -
328
328
Python/suggestions.c levenshtein_distance buffer -
329
329
330
330
# other
331
- Objects/funcobject.c - next_func_version -
332
331
Objects/object.c - _Py_RefTotal -
333
332
Python/perf_trampoline.c - perf_status -
334
333
Python/perf_trampoline.c - extra_code_index -
You can’t perform that action at this time.
0 commit comments