mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
GH-95245: Store object values and dict pointers in single tagged pointer. (GH-95278)
This commit is contained in:
parent
fb75d015f4
commit
de388c0a7b
10 changed files with 271 additions and 203 deletions
|
@ -3564,9 +3564,9 @@ handle_eval_breaker:
|
|||
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
|
||||
assert(tp->tp_dictoffset < 0);
|
||||
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictValues *values = *_PyObject_ValuesPointer(owner);
|
||||
DEOPT_IF(values == NULL, LOAD_ATTR);
|
||||
res = values->values[cache->index];
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
|
||||
res = _PyDictOrValues_GetValues(dorv)->values[cache->index];
|
||||
DEOPT_IF(res == NULL, LOAD_ATTR);
|
||||
STAT_INC(LOAD_ATTR, hit);
|
||||
Py_INCREF(res);
|
||||
|
@ -3613,7 +3613,9 @@ handle_eval_breaker:
|
|||
assert(type_version != 0);
|
||||
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
|
||||
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictObject *dict = *(PyDictObject **)_PyObject_ManagedDictPointer(owner);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
|
||||
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
|
||||
DEOPT_IF(dict == NULL, LOAD_ATTR);
|
||||
assert(PyDict_CheckExact((PyObject *)dict));
|
||||
PyObject *name = GETITEM(names, oparg>>1);
|
||||
|
@ -3750,12 +3752,13 @@ handle_eval_breaker:
|
|||
assert(type_version != 0);
|
||||
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
|
||||
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictValues *values = *_PyObject_ValuesPointer(owner);
|
||||
DEOPT_IF(values == NULL, STORE_ATTR);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), STORE_ATTR);
|
||||
STAT_INC(STORE_ATTR, hit);
|
||||
Py_ssize_t index = cache->index;
|
||||
STACK_SHRINK(1);
|
||||
PyObject *value = POP();
|
||||
PyDictValues *values = _PyDictOrValues_GetValues(dorv);
|
||||
PyObject *old_value = values->values[index];
|
||||
values->values[index] = value;
|
||||
if (old_value == NULL) {
|
||||
|
@ -3778,7 +3781,9 @@ handle_eval_breaker:
|
|||
assert(type_version != 0);
|
||||
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
|
||||
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictObject *dict = *(PyDictObject **)_PyObject_ManagedDictPointer(owner);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
|
||||
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
|
||||
DEOPT_IF(dict == NULL, STORE_ATTR);
|
||||
assert(PyDict_CheckExact((PyObject *)dict));
|
||||
PyObject *name = GETITEM(names, oparg);
|
||||
|
@ -4680,8 +4685,8 @@ handle_eval_breaker:
|
|||
assert(type_version != 0);
|
||||
DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR);
|
||||
assert(self_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictObject *dict = *(PyDictObject**)_PyObject_ManagedDictPointer(self);
|
||||
DEOPT_IF(dict != NULL, LOAD_ATTR);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(self);
|
||||
DEOPT_IF(!_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
|
||||
PyHeapTypeObject *self_heap_type = (PyHeapTypeObject *)self_cls;
|
||||
DEOPT_IF(self_heap_type->ht_cached_keys->dk_version !=
|
||||
read_u32(cache->keys_version), LOAD_ATTR);
|
||||
|
|
|
@ -635,9 +635,8 @@ specialize_dict_access(
|
|||
return 0;
|
||||
}
|
||||
_PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
|
||||
PyObject **dictptr = _PyObject_ManagedDictPointer(owner);
|
||||
PyDictObject *dict = (PyDictObject *)*dictptr;
|
||||
if (dict == NULL) {
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
if (_PyDictOrValues_IsValues(dorv)) {
|
||||
// Virtual dictionary
|
||||
PyDictKeysObject *keys = ((PyHeapTypeObject *)type)->ht_cached_keys;
|
||||
assert(PyUnicode_CheckExact(name));
|
||||
|
@ -652,7 +651,8 @@ specialize_dict_access(
|
|||
_Py_SET_OPCODE(*instr, values_op);
|
||||
}
|
||||
else {
|
||||
if (!PyDict_CheckExact(dict)) {
|
||||
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
|
||||
if (dict == NULL || !PyDict_CheckExact(dict)) {
|
||||
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_NO_DICT);
|
||||
return 0;
|
||||
}
|
||||
|
@ -995,9 +995,9 @@ PyObject *descr, DescriptorClassification kind)
|
|||
ObjectDictKind dictkind;
|
||||
PyDictKeysObject *keys;
|
||||
if (owner_cls->tp_flags & Py_TPFLAGS_MANAGED_DICT) {
|
||||
PyObject *dict = *_PyObject_ManagedDictPointer(owner);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
keys = ((PyHeapTypeObject *)owner_cls)->ht_cached_keys;
|
||||
if (dict == NULL) {
|
||||
if (_PyDictOrValues_IsValues(dorv)) {
|
||||
dictkind = MANAGED_VALUES;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue