@@ -2102,25 +2102,24 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
21022102 SET_TOP (res );
21032103 if (res == NULL )
21042104 goto error ;
2105+ JUMPBY (INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
21052106 DISPATCH ();
21062107 }
21072108
21082109 TARGET (BINARY_SUBSCR_ADAPTIVE ) {
2109- SpecializedCacheEntry * cache = GET_CACHE () ;
2110- if (cache -> adaptive . counter == 0 ) {
2110+ _PyBinarySubscrCache * cache = ( _PyBinarySubscrCache * ) next_instr ;
2111+ if (cache -> counter == 0 ) {
21112112 PyObject * sub = TOP ();
21122113 PyObject * container = SECOND ();
21132114 next_instr -- ;
2114- if (_Py_Specialize_BinarySubscr (container , sub , next_instr , cache ) < 0 ) {
2115+ if (_Py_Specialize_BinarySubscr (container , sub , next_instr ) < 0 ) {
21152116 goto error ;
21162117 }
21172118 DISPATCH ();
21182119 }
21192120 else {
21202121 STAT_INC (BINARY_SUBSCR , deferred );
2121- cache -> adaptive .counter -- ;
2122- assert (cache -> adaptive .original_oparg == 0 );
2123- /* No need to set oparg here; it isn't used by BINARY_SUBSCR */
2122+ cache -> counter -- ;
21242123 JUMP_TO_INSTRUCTION (BINARY_SUBSCR );
21252124 }
21262125 }
@@ -2146,6 +2145,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
21462145 Py_DECREF (sub );
21472146 SET_TOP (res );
21482147 Py_DECREF (list );
2148+ JUMPBY (INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
21492149 NOTRACE_DISPATCH ();
21502150 }
21512151
@@ -2170,6 +2170,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
21702170 Py_DECREF (sub );
21712171 SET_TOP (res );
21722172 Py_DECREF (tuple );
2173+ JUMPBY (INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
21732174 NOTRACE_DISPATCH ();
21742175 }
21752176
@@ -2188,18 +2189,22 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
21882189 Py_DECREF (sub );
21892190 SET_TOP (res );
21902191 Py_DECREF (dict );
2192+ JUMPBY (INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
21912193 DISPATCH ();
21922194 }
21932195
21942196 TARGET (BINARY_SUBSCR_GETITEM ) {
21952197 PyObject * sub = TOP ();
21962198 PyObject * container = SECOND ();
2197- SpecializedCacheEntry * caches = GET_CACHE ();
2198- _PyAdaptiveEntry * cache0 = & caches [0 ].adaptive ;
2199- _PyObjectCache * cache1 = & caches [-1 ].obj ;
2200- PyFunctionObject * getitem = (PyFunctionObject * )cache1 -> obj ;
2201- DEOPT_IF (Py_TYPE (container )-> tp_version_tag != cache0 -> version , BINARY_SUBSCR );
2202- DEOPT_IF (getitem -> func_version != cache0 -> index , BINARY_SUBSCR );
2199+ _PyBinarySubscrCache * cache = (_PyBinarySubscrCache * )next_instr ;
2200+ uint32_t type_version = read32 (& cache -> type_version );
2201+ PyTypeObject * tp = Py_TYPE (container );
2202+ DEOPT_IF (tp -> tp_version_tag != type_version , BINARY_SUBSCR );
2203+ assert (tp -> tp_flags & Py_TPFLAGS_HEAPTYPE );
2204+ PyObject * cached = ((PyHeapTypeObject * )tp )-> _spec_cache .getitem ;
2205+ assert (PyFunction_Check (cached ));
2206+ PyFunctionObject * getitem = (PyFunctionObject * )cached ;
2207+ DEOPT_IF (getitem -> func_version != cache -> func_version , BINARY_SUBSCR );
22032208 PyCodeObject * code = (PyCodeObject * )getitem -> func_code ;
22042209 size_t size = code -> co_nlocalsplus + code -> co_stacksize + FRAME_SPECIALS_SIZE ;
22052210 assert (code -> co_argcount == 2 );
@@ -2218,6 +2223,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
22182223 new_frame -> localsplus [i ] = NULL ;
22192224 }
22202225 _PyFrame_SetStackPointer (frame , stack_pointer );
2226+ frame -> f_lasti += INLINE_CACHE_ENTRIES_BINARY_SUBSCR ;
22212227 new_frame -> previous = frame ;
22222228 frame = cframe .current_frame = new_frame ;
22232229 CALL_STAT_INC (inlined_py_calls );
@@ -5605,7 +5611,7 @@ MISS_WITH_CACHE(PRECALL)
56055611MISS_WITH_CACHE (CALL )
56065612MISS_WITH_INLINE_CACHE (BINARY_OP )
56075613MISS_WITH_INLINE_CACHE (COMPARE_OP )
5608- MISS_WITH_CACHE (BINARY_SUBSCR )
5614+ MISS_WITH_INLINE_CACHE (BINARY_SUBSCR )
56095615MISS_WITH_INLINE_CACHE (UNPACK_SEQUENCE )
56105616MISS_WITH_OPARG_COUNTER (STORE_SUBSCR )
56115617
0 commit comments