Skip to content

Commit 0a87264

Browse files
committed
Enable specialization of method loads
1 parent ade57f2 commit 0a87264

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Python/specialize.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ specialize_dict_access(
10331033
static int
10341034
specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
10351035
PyObject *name, PyObject *descr,
1036+
unsigned int tp_version,
10361037
DescriptorClassification kind, bool is_method,
10371038
uint32_t shared_keys_version);
10381039
#ifndef Py_GIL_DISABLED
@@ -1105,14 +1106,14 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
11051106
return -1;
11061107
case METHOD:
11071108
{
1108-
FT_UNIMPLEMENTED();
11091109
if (shadow) {
1110+
FT_UNIMPLEMENTED();
11101111
goto try_instance;
11111112
}
11121113
int oparg = instr->op.arg;
11131114
if (oparg & 1) {
11141115
if (specialize_attr_loadclassattr(owner, instr, name, descr,
1115-
kind, true,
1116+
tp_version, kind, true,
11161117
shared_keys_version)) {
11171118
return 0;
11181119
}
@@ -1242,7 +1243,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
12421243
}
12431244
if ((instr->op.arg & 1) == 0) {
12441245
if (specialize_attr_loadclassattr(owner, instr, name, descr,
1245-
kind, false,
1246+
tp_version, kind, false,
12461247
shared_keys_version)) {
12471248
return 0;
12481249
}
@@ -1546,6 +1547,7 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
15461547
static int
15471548
specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
15481549
PyObject *name, PyObject *descr,
1550+
unsigned int tp_version,
15491551
DescriptorClassification kind, bool is_method,
15501552
uint32_t shared_keys_version)
15511553
{
@@ -1622,7 +1624,7 @@ specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
16221624
* PyType_Modified usages in typeobject.c). The MCACHE has been
16231625
* working since Python 2.6 and it's battle-tested.
16241626
*/
1625-
write_u32(cache->type_version, owner_cls->tp_version_tag);
1627+
write_u32(cache->type_version, tp_version);
16261628
write_obj(cache->descr, descr);
16271629
return 1;
16281630
}

0 commit comments

Comments
 (0)