diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-21 15:52:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 15:52:04 +0100 |
commit | a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57 (patch) | |
tree | 026af8576d2d3e05b56c475574606f13f69cf040 /Python/bytecodes.c | |
parent | 4b7c4880a0b264373e65235701bb78cbf19266b5 (diff) | |
download | cpython-a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57.tar.gz cpython-a4fd7aa4a6420cef1c22ec64eab54d8aea41cc57.zip |
GH-115776: Allow any fixed sized object to have inline values (GH-123192)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 5adcd77b4d5..250e2d12a9d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2012,9 +2012,10 @@ dummy_func( DEOPT_IF(!_PyObject_InlineValues(owner_o)->valid); } - split op(_LOAD_ATTR_INSTANCE_VALUE, (index/1, owner -- attr, null if (oparg & 1))) { + split op(_LOAD_ATTR_INSTANCE_VALUE, (offset/1, owner -- attr, null if (oparg & 1))) { PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); - PyObject *attr_o = _PyObject_InlineValues(owner_o)->values[index]; + PyObject **value_ptr = (PyObject**)(((char *)owner_o) + offset); + PyObject *attr_o = *value_ptr; DEOPT_IF(attr_o == NULL); STAT_INC(LOAD_ATTR, hit); Py_INCREF(attr_o); @@ -2196,16 +2197,17 @@ dummy_func( EXIT_IF(_PyObject_InlineValues(owner_o)->valid == 0); } - op(_STORE_ATTR_INSTANCE_VALUE, (index/1, value, owner --)) { + op(_STORE_ATTR_INSTANCE_VALUE, (offset/1, value, owner --)) { PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); STAT_INC(STORE_ATTR, hit); assert(_PyObject_GetManagedDict(owner_o) == NULL); - PyDictValues *values = _PyObject_InlineValues(owner_o); - - PyObject *old_value = values->values[index]; - values->values[index] = PyStackRef_AsPyObjectSteal(value); + PyObject **value_ptr = (PyObject**)(((char *)owner_o) + offset); + PyObject *old_value = *value_ptr; + *value_ptr = PyStackRef_AsPyObjectSteal(value); if (old_value == NULL) { + PyDictValues *values = _PyObject_InlineValues(owner_o); + int index = value_ptr - values->values; _PyDictValues_AddToInsertionOrder(values, index); } else { |