mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
gh-112075: Make instance attributes stored in inline "dict" thread safe (#114742)
Make instance attributes stored in inline "dict" thread safe on free-threaded builds
This commit is contained in:
parent
1446024124
commit
8b541c017e
13 changed files with 419 additions and 142 deletions
10
Python/executor_cases.c.h
generated
10
Python/executor_cases.c.h
generated
|
@ -1998,8 +1998,7 @@
|
|||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyManagedDictPointer *managed_dict = _PyObject_ManagedDictPointer(owner);
|
||||
PyDictObject *dict = managed_dict->dict;
|
||||
PyDictObject *dict = _PyObject_GetManagedDict(owner);
|
||||
if (dict == NULL) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
@ -2015,8 +2014,7 @@
|
|||
oparg = CURRENT_OPARG();
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t hint = (uint16_t)CURRENT_OPERAND();
|
||||
PyManagedDictPointer *managed_dict = _PyObject_ManagedDictPointer(owner);
|
||||
PyDictObject *dict = managed_dict->dict;
|
||||
PyDictObject *dict = _PyObject_GetManagedDict(owner);
|
||||
if (hint >= (size_t)dict->ma_keys->dk_nentries) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
@ -2159,7 +2157,7 @@
|
|||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_dictoffset < 0);
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
|
||||
if (_PyObject_ManagedDictPointer(owner)->dict) {
|
||||
if (_PyObject_GetManagedDict(owner)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
|
@ -2177,7 +2175,7 @@
|
|||
value = stack_pointer[-2];
|
||||
uint16_t index = (uint16_t)CURRENT_OPERAND();
|
||||
STAT_INC(STORE_ATTR, hit);
|
||||
assert(_PyObject_ManagedDictPointer(owner)->dict == NULL);
|
||||
assert(_PyObject_GetManagedDict(owner) == NULL);
|
||||
PyDictValues *values = _PyObject_InlineValues(owner);
|
||||
PyObject *old_value = values->values[index];
|
||||
values->values[index] = value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue