Skip to content

Commit feb7d34

Browse files
committed
Pass type version to specialize_dict_access
1 parent 945b61c commit feb7d34

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Python/specialize.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ analyze_descriptor(PyTypeObject *type, PyObject *name, PyObject **descr, unsigne
968968
static int
969969
specialize_inline_values_access(
970970
PyObject *owner, _Py_CODEUNIT *instr, PyTypeObject *type,
971+
unsigned int tp_version,
971972
PyObject *name, int base_op, int values_op)
972973
{
973974
PyDictKeysObject *keys = ((PyHeapTypeObject *)type)->ht_cached_keys;
@@ -986,7 +987,7 @@ specialize_inline_values_access(
986987
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_OUT_OF_RANGE);
987988
return 0;
988989
}
989-
write_u32(cache->version, type->tp_version_tag);
990+
write_u32(cache->version, tp_version);
990991
cache->index = (uint16_t)offset;
991992
specialize(instr, values_op);
992993
return 1;
@@ -995,6 +996,7 @@ specialize_inline_values_access(
995996
static int
996997
specialize_managed_dict_access(
997998
PyObject *owner, _Py_CODEUNIT *instr, PyTypeObject *type,
999+
unsigned int tp_version,
9981000
PyObject *name, int base_op, int hint_op)
9991001
{
10001002
PyDictObject *dict = _PyObject_GetManagedDict(owner);
@@ -1018,15 +1020,15 @@ specialize_managed_dict_access(
10181020
return 0;
10191021
}
10201022
cache->index = (uint16_t)index;
1021-
write_u32(cache->version, type->tp_version_tag);
1023+
write_u32(cache->version, tp_version);
10221024
specialize(instr, hint_op);
10231025
return 1;
10241026
}
10251027

10261028
static int
10271029
specialize_dict_access(
10281030
PyObject *owner, _Py_CODEUNIT *instr, PyTypeObject *type,
1029-
DescriptorClassification kind, PyObject *name,
1031+
unsigned int tp_version, DescriptorClassification kind, PyObject *name,
10301032
int base_op, int values_op, int hint_op)
10311033
{
10321034
assert(kind == NON_OVERRIDING || kind == NON_DESCRIPTOR || kind == ABSENT ||
@@ -1042,11 +1044,11 @@ specialize_dict_access(
10421044
!(base_op == STORE_ATTR && _PyObject_GetManagedDict(owner) != NULL))
10431045
{
10441046
return specialize_inline_values_access(
1045-
owner, instr, type, name, base_op, values_op);
1047+
owner, instr, type, tp_version, name, base_op, values_op);
10461048
}
10471049
else {
10481050
return specialize_managed_dict_access(
1049-
owner, instr, type, name, base_op, hint_op);
1051+
owner, instr, type, tp_version, name, base_op, hint_op);
10501052
}
10511053
}
10521054

@@ -1294,7 +1296,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
12941296
try_instance:
12951297
FT_UNIMPLEMENTED();
12961298

1297-
if (specialize_dict_access(owner, instr, type, kind, name, LOAD_ATTR,
1299+
if (specialize_dict_access(owner, instr, type, tp_version, kind, name, LOAD_ATTR,
12981300
LOAD_ATTR_INSTANCE_VALUE, LOAD_ATTR_WITH_HINT))
12991301
{
13001302
return 0;
@@ -1442,8 +1444,8 @@ _Py_Specialize_StoreAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *na
14421444
SPECIALIZATION_FAIL(STORE_ATTR, SPEC_FAIL_ATTR_CLASS_ATTR_SIMPLE);
14431445
goto fail;
14441446
case ABSENT:
1445-
if (specialize_dict_access(owner, instr, type, kind, name, STORE_ATTR,
1446-
STORE_ATTR_INSTANCE_VALUE, STORE_ATTR_WITH_HINT))
1447+
if (specialize_dict_access(owner, instr, type, tp_version, kind, name, STORE_ATTR,
1448+
STORE_ATTR_INSTANCE_VALUE, STORE_ATTR_WITH_HINT))
14471449
{
14481450
goto success;
14491451
}

0 commit comments

Comments
 (0)