/* Gets a version number unique to the current state of the keys of dict, if possible.
* Returns the version number, or zero if it was not possible to get a version number. */
-extern uint32_t _PyDictKeys_GetVersionForCurrentState(PyDictKeysObject *dictkeys);
+extern uint32_t _PyDictKeys_GetVersionForCurrentState(
+ PyInterpreterState *interp, PyDictKeysObject *dictkeys);
extern size_t _PyDict_KeysSize(PyDictKeysObject *keys);
* It is incremented each time that a dictionary is created and each
* time that a dictionary is modified. */
uint64_t global_version;
- uint32_t next_keys_version;
};
#define DICT_MAX_WATCHERS 8
struct _Py_dict_state {
+ uint32_t next_keys_version;
+
#if PyDict_MAXFREELIST > 0
/* Dictionary reuse scheme to save calls to malloc and free */
PyDictObject *free_list[PyDict_MAXFREELIST];
int numfree;
int keys_numfree;
#endif
+
PyDict_WatchCallback watchers[DICT_MAX_WATCHERS];
};
.float_format = _py_float_format_unknown, \
.double_format = _py_float_format_unknown, \
}, \
- .dict_state = { \
- .next_keys_version = 2, \
- }, \
.types = { \
.next_version_tag = 1, \
}, \
}, \
}, \
.dtoa = _dtoa_state_INIT(&(INTERP)), \
+ .dict_state = { \
+ .next_keys_version = 2, \
+ }, \
.func_state = { \
.next_version = 1, \
}, \
dictkeys_decref(keys);
}
-uint32_t _PyDictKeys_GetVersionForCurrentState(PyDictKeysObject *dictkeys)
+uint32_t _PyDictKeys_GetVersionForCurrentState(PyInterpreterState *interp,
+ PyDictKeysObject *dictkeys)
{
if (dictkeys->dk_version != 0) {
return dictkeys->dk_version;
}
- if (_PyRuntime.dict_state.next_keys_version == 0) {
+ if (interp->dict_state.next_keys_version == 0) {
return 0;
}
- uint32_t v = _PyRuntime.dict_state.next_keys_version++;
+ uint32_t v = interp->dict_state.next_keys_version++;
dictkeys->dk_version = v;
return v;
}
SPEC_FAIL_OUT_OF_RANGE);
return -1;
}
- uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(dict->ma_keys);
+ uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(
+ _PyInterpreterState_GET(), dict->ma_keys);
if (keys_version == 0) {
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OUT_OF_VERSIONS);
return -1;
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_SHADOWED);
return 0;
}
- uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(keys);
+ uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(
+ _PyInterpreterState_GET(), keys);
if (keys_version == 0) {
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OUT_OF_VERSIONS);
return 0;
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_EXPECTED_ERROR);
goto fail;
}
+ PyInterpreterState *interp = _PyInterpreterState_GET();
if (index != DKIX_EMPTY) {
if (index != (uint16_t)index) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
- uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(globals_keys);
+ uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState(
+ interp, globals_keys);
if (keys_version == 0) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
goto fail;
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
- uint32_t globals_version = _PyDictKeys_GetVersionForCurrentState(globals_keys);
+ uint32_t globals_version = _PyDictKeys_GetVersionForCurrentState(
+ interp, globals_keys);
if (globals_version == 0) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
goto fail;
}
- uint32_t builtins_version = _PyDictKeys_GetVersionForCurrentState(builtin_keys);
+ uint32_t builtins_version = _PyDictKeys_GetVersionForCurrentState(
+ interp, builtin_keys);
if (builtins_version == 0) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
goto fail;