8000 Move next_func_version to _PyRuntimeState. · python/cpython@5182895 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5182895

Move next_func_version to _PyRuntimeState.
1 parent bd3cfde commit 5182895

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

Include/internal/pycore_function.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
1115
extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr);
1216

1317
extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);

Include/internal/pycore_runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 */

Include/internal/pycore_runtime_init.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}, \

Objects/funcobject.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include "pycore_pyerrors.h" // _PyErr_Occurred()
88
#include "structmember.h" // PyMemberDef
99

10-
static uint32_t next_func_version = 1;
11-
1210
PyFunctionObject *
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
}

Tools/c-analyzer/cpython/globals-to-fix.tsv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ Python/dtoa.c - pmem_next -
416416
Python/getargs.c - static_arg_parsers -
417417

418418
# other
419-
Objects/funcobject.c - next_func_version -
420419
Objects/object.c - _Py_RefTotal -
421420
Python/perf_trampoline.c - perf_status -
422421
Python/perf_trampoline.c - extra_code_index -

0 commit comments

Comments
 (0)
0