Skip to content

Commit eb8ce39

Browse files
committed
Refactor
1 parent 13a05a0 commit eb8ce39

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Python/specialize.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ specialize_dict_access(
975975
}
976976
write_u32(cache->version, type->tp_version_tag);
977977
cache->index = (uint16_t)offset;
978-
instr->op.code = values_op;
978+
specialize(instr, values_op);
979979
}
980980
else {
981981
PyDictObject *dict = _PyObject_GetManagedDict(owner);
@@ -999,7 +999,7 @@ specialize_dict_access(
999999
}
10001000
cache->index = (uint16_t)index;
10011001
write_u32(cache->version, type->tp_version_tag);
1002-
instr->op.code = hint_op;
1002+
specialize(instr, hint_op);
10031003
}
10041004
return 1;
10051005
}
@@ -1101,7 +1101,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11011101
write_u32(lm_cache->type_version, type->tp_version_tag);
11021102
/* borrowed */
11031103
write_obj(lm_cache->descr, fget);
1104-
instr->op.code = LOAD_ATTR_PROPERTY;
1104+
specialize(instr, LOAD_ATTR_PROPERTY);
11051105
return 0;
11061106
}
11071107
case OBJECT_SLOT:
@@ -1125,7 +1125,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11251125
assert(offset > 0);
11261126
cache->index = (uint16_t)offset;
11271127
write_u32(cache->version, type->tp_version_tag);
1128-
instr->op.code = LOAD_ATTR_SLOT;
1128+
specialize(instr, LOAD_ATTR_SLOT);
11291129
return 0;
11301130
}
11311131
case DUNDER_CLASS:
@@ -1134,7 +1134,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11341134
assert(offset == (uint16_t)offset);
11351135
cache->index = (uint16_t)offset;
11361136
write_u32(cache->version, type->tp_version_tag);
1137-
instr->op.code = LOAD_ATTR_SLOT;
1137+
specialize(instr, LOAD_ATTR_SLOT);
11381138
return 0;
11391139
}
11401140
case OTHER_SLOT:
@@ -1170,7 +1170,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11701170
/* borrowed */
11711171
write_obj(lm_cache->descr, descr);
11721172
write_u32(lm_cache->type_version, type->tp_version_tag);
1173-
instr->op.code = LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN;
1173+
specialize(instr, LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
11741174
return 0;
11751175
}
11761176
case BUILTIN_CLASSMETHOD:
@@ -1194,6 +1194,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11941194
if (shadow) {
11951195
goto try_instance;
11961196
}
1197+
set_counter((_Py_BackoffCounter*)instr + 1, adaptive_counter_cooldown());
11971198
return 0;
11981199
}
11991200
Py_UNREACHABLE();
@@ -1433,10 +1434,10 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
14331434
write_obj(cache->descr, descr);
14341435
if (metaclass_check) {
14351436
write_u32(cache->keys_version, Py_TYPE(cls)->tp_version_tag);
1436-
instr->op.code = LOAD_ATTR_CLASS_WITH_METACLASS_CHECK;
1437+
specialize(instr, LOAD_ATTR_CLASS_WITH_METACLASS_CHECK);
14371438
}
14381439
else {
1439-
instr->op.code = LOAD_ATTR_CLASS;
1440+
specialize(instr, LOAD_ATTR_CLASS);
14401441
}
14411442
return 0;
14421443
#ifdef Py_STATS
@@ -1472,7 +1473,7 @@ PyObject *descr, DescriptorClassification kind, bool is_method)
14721473
return 0;
14731474
}
14741475
write_u32(cache->keys_version, keys_version);
1475-
instr->op.code = is_method ? LOAD_ATTR_METHOD_WITH_VALUES : LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES;
1476+
specialize(instr, is_method ? LOAD_ATTR_METHOD_WITH_VALUES : LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES);
14761477
}
14771478
else {
14781479
Py_ssize_t dictoffset;
@@ -1487,7 +1488,7 @@ PyObject *descr, DescriptorClassification kind, bool is_method)
14871488
}
14881489
}
14891490
if (dictoffset == 0) {
1490-
instr->op.code = is_method ? LOAD_ATTR_METHOD_NO_DICT : LOAD_ATTR_NONDESCRIPTOR_NO_DICT;
1491+
specialize(instr, is_method ? LOAD_ATTR_METHOD_NO_DICT : LOAD_ATTR_NONDESCRIPTOR_NO_DICT);
14911492
}
14921493
else if (is_method) {
14931494
PyObject *dict = *(PyObject **) ((char *)owner + dictoffset);
@@ -1501,7 +1502,7 @@ PyObject *descr, DescriptorClassification kind, bool is_method)
15011502
dictoffset -= MANAGED_DICT_OFFSET;
15021503
assert(((uint16_t)dictoffset) == dictoffset);
15031504
cache->dict_offset = (uint16_t)dictoffset;
1504-
instr->op.code = LOAD_ATTR_METHOD_LAZY_DICT;
1505+
specialize(instr, LOAD_ATTR_METHOD_LAZY_DICT);
15051506
}
15061507
else {
15071508
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_CLASS_ATTR_SIMPLE);

0 commit comments

Comments
 (0)