@@ -233,7 +233,7 @@ static uint8_t adaptive_opcodes[256] = {
233
233
static uint8_t cache_requirements [256 ] = {
234
234
[LOAD_ATTR ] = 2 , /* _PyAdaptiveEntry and _PyAttrCache */
235
235
[LOAD_GLOBAL ] = 2 , /* _PyAdaptiveEntry and _PyLoadGlobalCache */
236
- [LOAD_METHOD ] = 4 , /* _PyAdaptiveEntry, _PyAttrCache and 2 _PyObjectCache */
236
+ [LOAD_METHOD ] = 3 , /* _PyAdaptiveEntry, _PyAttrCache and _PyObjectCache */
237
237
[BINARY_SUBSCR ] = 0 ,
238
238
[STORE_ATTR ] = 2 , /* _PyAdaptiveEntry and _PyAttrCache */
239
239
};
@@ -817,7 +817,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
817
817
_PyAdaptiveEntry * cache0 = & cache -> adaptive ;
818
818
_PyAttrCache * cache1 = & cache [-1 ].attr ;
819
819
_PyObjectCache * cache2 = & cache [-2 ].obj ;
820
- _PyObjectCache * cache3 = & cache [-3 ].obj ;
821
820
822
821
PyTypeObject * owner_cls = Py_TYPE (owner );
823
822
if (PyModule_CheckExact (owner )) {
@@ -852,10 +851,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
852
851
int owner_is_class = PyType_Check (owner );
853
852
owner_cls = owner_is_class ? (PyTypeObject * )owner : owner_cls ;
854
853
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
- }
859
854
PyObject * descr = NULL ;
860
855
DesciptorClassification kind = 0 ;
861
856
kind = analyze_descriptor (owner_cls , name , & descr , 0 );
@@ -880,9 +875,8 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
880
875
assert (kind == METHOD );
881
876
// If o.__dict__ changes, the method might be found in o.__dict__
882
877
// instead of old type lookup. So record o.__dict__'s keys.
883
- // Not required for class methods -- tp_version_tag is enough for those.
884
878
uint32_t keys_version = UINT32_MAX ;
885
- if (owner_has_dict && ! owner_is_class ) {
879
+ if (owner_has_dict ) {
886
880
// _PyDictKeys_GetVersionForCurrentState isn't accurate for
887
881
// custom dict subclasses at the moment.
888
882
if (!PyDict_CheckExact (owner_dict )) {
@@ -929,7 +923,6 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
929
923
* battle-tested.
930
924
*/
931
925
cache2 -> obj = descr ;
932
- cache3 -> obj = (PyObject * )owner_cls ; // borrowed - cache the type
933
926
cache1 -> dk_version_or_hint = keys_version ;
934
927
* instr = _Py_MAKECODEUNIT (owner_is_class ? LOAD_METHOD_CLASS :
935
928
LOAD_METHOD_CACHED , _Py_OPARG (* instr ));
0 commit comments