mirror of
https://github.com/python/cpython.git
synced 2025-08-26 03:34:43 +00:00
GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115)
This commit is contained in:
parent
c97d3af239
commit
c32dc47aca
35 changed files with 787 additions and 537 deletions
44
Python/executor_cases.c.h
generated
44
Python/executor_cases.c.h
generated
|
@ -1753,9 +1753,8 @@
|
|||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_dictoffset < 0);
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictOrValues *dorv = _PyObject_DictOrValuesPointer(owner);
|
||||
if (!_PyDictOrValues_IsValues(*dorv) && !_PyObject_MakeInstanceAttributesFromDict(owner, dorv)) JUMP_TO_JUMP_TARGET();
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
|
||||
if (!_PyObject_InlineValues(owner)->valid) JUMP_TO_JUMP_TARGET();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1766,8 +1765,7 @@
|
|||
(void)null;
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t index = (uint16_t)CURRENT_OPERAND();
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
attr = _PyDictOrValues_GetValues(dorv)->values[index];
|
||||
attr = _PyObject_InlineValues(owner)->values[index];
|
||||
if (attr == NULL) JUMP_TO_JUMP_TARGET();
|
||||
STAT_INC(LOAD_ATTR, hit);
|
||||
Py_INCREF(attr);
|
||||
|
@ -1784,8 +1782,7 @@
|
|||
(void)null;
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t index = (uint16_t)CURRENT_OPERAND();
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
attr = _PyDictOrValues_GetValues(dorv)->values[index];
|
||||
attr = _PyObject_InlineValues(owner)->values[index];
|
||||
if (attr == NULL) JUMP_TO_JUMP_TARGET();
|
||||
STAT_INC(LOAD_ATTR, hit);
|
||||
Py_INCREF(attr);
|
||||
|
@ -1837,9 +1834,8 @@
|
|||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
if (_PyDictOrValues_IsValues(dorv)) JUMP_TO_JUMP_TARGET();
|
||||
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
|
||||
PyManagedDictPointer *managed_dict = _PyObject_ManagedDictPointer(owner);
|
||||
PyDictObject *dict = managed_dict->dict;
|
||||
if (dict == NULL) JUMP_TO_JUMP_TARGET();
|
||||
assert(PyDict_CheckExact((PyObject *)dict));
|
||||
break;
|
||||
|
@ -1852,8 +1848,8 @@
|
|||
oparg = CURRENT_OPARG();
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t hint = (uint16_t)CURRENT_OPERAND();
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
|
||||
PyManagedDictPointer *managed_dict = _PyObject_ManagedDictPointer(owner);
|
||||
PyDictObject *dict = managed_dict->dict;
|
||||
if (hint >= (size_t)dict->ma_keys->dk_nentries) JUMP_TO_JUMP_TARGET();
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
|
||||
if (DK_IS_UNICODE(dict->ma_keys)) {
|
||||
|
@ -1967,12 +1963,13 @@
|
|||
|
||||
/* _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */
|
||||
|
||||
case _GUARD_DORV_VALUES: {
|
||||
case _GUARD_DORV_NO_DICT: {
|
||||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
if (!_PyDictOrValues_IsValues(dorv)) JUMP_TO_JUMP_TARGET();
|
||||
assert(Py_TYPE(owner)->tp_dictoffset < 0);
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
|
||||
if (_PyObject_ManagedDictPointer(owner)->dict) JUMP_TO_JUMP_TARGET();
|
||||
if (_PyObject_InlineValues(owner)->valid == 0) JUMP_TO_JUMP_TARGET();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1982,9 +1979,9 @@
|
|||
owner = stack_pointer[-1];
|
||||
value = stack_pointer[-2];
|
||||
uint16_t index = (uint16_t)CURRENT_OPERAND();
|
||||
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
|
||||
STAT_INC(STORE_ATTR, hit);
|
||||
PyDictValues *values = _PyDictOrValues_GetValues(dorv);
|
||||
assert(_PyObject_ManagedDictPointer(owner)->dict == NULL);
|
||||
PyDictValues *values = _PyObject_InlineValues(owner);
|
||||
PyObject *old_value = values->values[index];
|
||||
values->values[index] = value;
|
||||
if (old_value == NULL) {
|
||||
|
@ -2568,9 +2565,8 @@
|
|||
case _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT: {
|
||||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
|
||||
PyDictOrValues *dorv = _PyObject_DictOrValuesPointer(owner);
|
||||
if (!_PyDictOrValues_IsValues(*dorv) && !_PyObject_MakeInstanceAttributesFromDict(owner, dorv)) JUMP_TO_JUMP_TARGET();
|
||||
assert(Py_TYPE(owner)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
|
||||
if (!_PyObject_InlineValues(owner)->valid) JUMP_TO_JUMP_TARGET();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2658,9 +2654,9 @@
|
|||
case _CHECK_ATTR_METHOD_LAZY_DICT: {
|
||||
PyObject *owner;
|
||||
owner = stack_pointer[-1];
|
||||
Py_ssize_t dictoffset = Py_TYPE(owner)->tp_dictoffset;
|
||||
assert(dictoffset > 0);
|
||||
PyObject *dict = *(PyObject **)((char *)owner + dictoffset);
|
||||
uint16_t dictoffset = (uint16_t)CURRENT_OPERAND();
|
||||
char *ptr = ((char *)owner) + MANAGED_DICT_OFFSET + dictoffset;
|
||||
PyObject *dict = *(PyObject **)ptr;
|
||||
/* This object has a __dict__, just not yet created */
|
||||
if (dict != NULL) JUMP_TO_JUMP_TARGET();
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue