mirror of https://github.com/python/cpython
gh-100227: Move func_state.next_version to PyInterpreterState (gh-102334)
https://github.com/python/cpython/issues/100227
This commit is contained in:
parent
cbb0aa71d0
commit
66ff374d4f
|
@ -10,7 +10,7 @@ extern "C" {
|
|||
|
||||
#define FUNC_MAX_WATCHERS 8
|
||||
|
||||
struct _py_func_runtime_state {
|
||||
struct _py_func_state {
|
||||
uint32_t next_version;
|
||||
};
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ struct _is {
|
|||
struct _Py_float_state float_state;
|
||||
struct _Py_long_state long_state;
|
||||
struct _dtoa_state dtoa;
|
||||
struct _py_func_state func_state;
|
||||
/* Using a cache is very effective since typically only a single slice is
|
||||
created and then deleted again. */
|
||||
PySliceObject *slice_cache;
|
||||
|
|
|
@ -13,7 +13,6 @@ extern "C" {
|
|||
#include "pycore_dict_state.h" // struct _Py_dict_runtime_state
|
||||
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
|
||||
#include "pycore_faulthandler.h" // struct _faulthandler_runtime_state
|
||||
#include "pycore_function.h" // struct _func_runtime_state
|
||||
#include "pycore_global_objects.h" // struct _Py_global_objects
|
||||
#include "pycore_import.h" // struct _import_runtime_state
|
||||
#include "pycore_interp.h" // PyInterpreterState
|
||||
|
@ -155,7 +154,6 @@ typedef struct pyruntimestate {
|
|||
struct _Py_float_runtime_state float_state;
|
||||
struct _Py_unicode_runtime_state unicode_state;
|
||||
struct _Py_dict_runtime_state dict_state;
|
||||
struct _py_func_runtime_state func_state;
|
||||
|
||||
struct {
|
||||
/* Used to set PyTypeObject.tp_version_tag */
|
||||
|
|
|
@ -68,9 +68,6 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
.dict_state = { \
|
||||
.next_keys_version = 2, \
|
||||
}, \
|
||||
.func_state = { \
|
||||
.next_version = 1, \
|
||||
}, \
|
||||
.types = { \
|
||||
.next_version_tag = 1, \
|
||||
}, \
|
||||
|
@ -116,6 +113,9 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
}, \
|
||||
}, \
|
||||
.dtoa = _dtoa_state_INIT(&(INTERP)), \
|
||||
.func_state = { \
|
||||
.next_version = 1, \
|
||||
}, \
|
||||
.static_objects = { \
|
||||
.singletons = { \
|
||||
._not_used = 1, \
|
||||
|
|
|
@ -227,10 +227,11 @@ uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func)
|
|||
if (func->vectorcall != _PyFunction_Vectorcall) {
|
||||
return 0;
|
||||
}
|
||||
if (_PyRuntime.func_state.next_version == 0) {
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
if (interp->func_state.next_version == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t v = _PyRuntime.func_state.next_version++;
|
||||
uint32_t v = interp->func_state.next_version++;
|
||||
func->func_version = v;
|
||||
return v;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue