8000 Revert "Fix buildbot errors: cache the type/class and compare that too" · python/cpython@33445d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 33445d5

Browse files
Revert "Fix buildbot errors: cache the type/class and compare that too"
This reverts commit a12406b.
1 parent a12406b commit 33445d5

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Python/ceval.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4289,9 +4289,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
42894289
_PyAdaptiveEntry *cache0 = &caches[0].adaptive;
42904290
_PyAttrCache *cache1 = &caches[-1].attr;
42914291
_PyObjectCache *cache2 = &caches[-2].obj;
4292-
_PyObjectCache *cache3 = &caches[-3].obj;
42934292

4294-
DEOPT_IF((PyObject *)self_cls != cache3->obj, LOAD_METHOD);
42954293
DEOPT_IF(self_cls->tp_version_tag != cache1->tp_version, LOAD_METHOD);
42964294
assert(cache1->dk_version_or_hint != 0);
42974295
assert(cache1->tp_version != 0);
@@ -4337,13 +4335,13 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
43374335
_PyAdaptiveEntry *cache0 = &caches[0].adaptive;
43384336
_PyAttrCache *cache1 = &caches[-1].attr;
43394337
_PyObjectCache *cache2 = &caches[-2].obj;
4340-
_PyObjectCache *cache3 = &caches[-3].obj;
43414338

43424339
PyObject *cls = TOP();
43434340
PyTypeObject *cls_type = Py_TYPE(cls);
43444341
assert(cls_type->tp_dictoffset > 0);
43454342
PyObject *dict = *(PyObject **) ((char *)cls + cls_type->tp_dictoffset);
4346-
DEOPT_IF(cls != cache3->obj, LOAD_METHOD);
4343+
DEOPT_IF(((PyDictObject *)dict)->ma_keys->dk_version !=
4344+
cache1->dk_version_or_hint, LOAD_METHOD);
43474345
DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != cache1->tp_version,
43484346
LOAD_METHOD);
43494347

Python/specialize.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static uint8_t adaptive_opcodes[256] = {
233233
static uint8_t cache_requirements[256] = {
234234
[LOAD_ATTR] = 2, /* _PyAdaptiveEntry and _PyAttrCache */
235235
[LOAD_GLOBAL] = 2, /* _PyAdaptiveEntry and _PyLoadGlobalCache */
236-
[LOAD_METHOD] = 4, /* _PyAdaptiveEntry, _PyAttrCache and 2 _PyObjectCache */
236+
[LOAD_METHOD] = 3, /* _PyAdaptiveEntry, _PyAttrCache and _PyObjectCache */
237237
[BINARY_SUBSCR] = 0,
238238
[STORE_ATTR] = 2, /* _PyAdaptiveEntry and _PyAttrCache */
239239
};
@@ -817,7 +817,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
817817
_PyAdaptiveEntry *cache0 = &cache->adaptive;
818818
_PyAttrCache *cache1 = &cache[-1].attr;
819819
_PyObjectCache *cache2 = &cache[-2].obj;
820-
_PyObjectCache *cache3 = &cache[-3].obj;
821820

822821
PyTypeObject *owner_cls = Py_TYPE(owner);
823822
if (PyModule_CheckExact(owner)) {
@@ -852,10 +851,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
852851
int owner_is_class = PyType_Check(owner);
853852
owner_cls = owner_is_class ? (PyTypeObject *)owner : owner_cls;
854853

855-
if ((owner_cls->tp_flags & Py_TPFLAGS_VALID_VERSION_TAG) == 0) {
856-
SPECIALIZATION_FAIL(LOAD_METHOD, SPEC_FAIL_OUT_OF_RANGE);
857-
goto fail;
858-
}
859854
PyObject *descr = NULL;
860855
DesciptorClassification kind = 0;
861856
kind = analyze_descriptor(owner_cls, name, &descr, 0);
@@ -880,9 +875,8 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
880875
assert(kind == METHOD);
881876
// If o.__dict__ changes, the method might be found in o.__dict__
882877
// instead of old type lookup. So record o.__dict__'s keys.
883-
// Not required for class methods -- tp_version_tag is enough for those.
884878
uint32_t keys_version = UINT32_MAX;
885-
if (owner_has_dict && !owner_is_class) {
879+
if (owner_has_dict) {
886880
// _PyDictKeys_GetVersionForCurrentState isn't accurate for
887881
// custom dict subclasses at the moment.
888882
if (!PyDict_CheckExact(owner_dict)) {
@@ -929,7 +923,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
929923
* battle-tested.
930924
*/
931925
cache2->obj = descr;
932-
cache3->obj = (PyObject *)owner_cls; // borrowed - cache the type
933926
cache1->dk_version_or_hint = keys_version;
934927
*instr = _Py_MAKECODEUNIT(owner_is_class ? LOAD_METHOD_CLASS :
935928
LOAD_METHOD_CACHED, _Py_OPARG(*instr));

0 commit comments

Comments
 (0)
0