@@ -1717,15 +1717,15 @@ _Py_Specialize_BinarySubscr(
17171717 PyObject * container = PyStackRef_AsPyObjectBorrow (container_st );
17181718 PyObject * sub = PyStackRef_AsPyObjectBorrow (sub_st );
17191719
1720- assert (ENABLE_SPECIALIZATION );
1720+ assert (ENABLE_SPECIALIZATION_FT );
17211721 assert (_PyOpcode_Caches [BINARY_SUBSCR ] ==
17221722 INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
1723- _PyBinarySubscrCache * cache = (_PyBinarySubscrCache * )(instr + 1 );
17241723 PyTypeObject * container_type = Py_TYPE (container );
1724+ uint8_t specialized_op ;
17251725 if (container_type == & PyList_Type ) {
17261726 if (PyLong_CheckExact (sub )) {
17271727 if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1728- instr -> op . code = BINARY_SUBSCR_LIST_INT ;
1728+ specialized_op = BINARY_SUBSCR_LIST_INT ;
17291729 goto success ;
17301730 }
17311731 SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1738,7 +1738,7 @@ _Py_Specialize_BinarySubscr(
17381738 if (container_type == & PyTuple_Type ) {
17391739 if (PyLong_CheckExact (sub )) {
17401740 if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1741- instr -> op . code = BINARY_SUBSCR_TUPLE_INT ;
1741+ specialized_op = BINARY_SUBSCR_TUPLE_INT ;
17421742 goto success ;
17431743 }
17441744 SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1751,7 +1751,7 @@ _Py_Specialize_BinarySubscr(
17511751 if (container_type == & PyUnicode_Type ) {
17521752 if (PyLong_CheckExact (sub )) {
17531753 if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1754- instr -> op . code = BINARY_SUBSCR_STR_INT ;
1754+ specialized_op = BINARY_SUBSCR_STR_INT ;
17551755 goto success ;
17561756 }
17571757 SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1762,9 +1762,10 @@ _Py_Specialize_BinarySubscr(
17621762 goto fail ;
17631763 }
17641764 if (container_type == & PyDict_Type ) {
1765- instr -> op . code = BINARY_SUBSCR_DICT ;
1765+ specialized_op = BINARY_SUBSCR_DICT ;
17661766 goto success ;
17671767 }
1768+ #ifndef Py_GIL_DISABLED
17681769 PyTypeObject * cls = Py_TYPE (container );
17691770 PyObject * descriptor = _PyType_Lookup (cls , & _Py_ID (__getitem__ ));
17701771 if (descriptor && Py_TYPE (descriptor ) == & PyFunction_Type ) {
@@ -1797,21 +1798,17 @@ _Py_Specialize_BinarySubscr(
17971798 // struct _specialization_cache):
17981799 ht -> _spec_cache .getitem = descriptor ;
17991800 ht -> _spec_cache .getitem_version = version ;
1800- instr -> op . code = BINARY_SUBSCR_GETITEM ;
1801+ specialized_op = BINARY_SUBSCR_GETITEM ;
18011802 goto success ;
18021803 }
1804+ #endif // Py_GIL_DISABLED
18031805 SPECIALIZATION_FAIL (BINARY_SUBSCR ,
18041806 binary_subscr_fail_kind (container_type , sub ));
18051807fail :
1806- STAT_INC (BINARY_SUBSCR , failure );
1807- assert (!PyErr_Occurred ());
1808- instr -> op .code = BINARY_SUBSCR ;
1809- cache -> counter = adaptive_counter_backoff (cache -> counter );
1808+ unspecialize (instr );
18101809 return ;
18111810success :
1812- STAT_INC (BINARY_SUBSCR , success );
1813- assert (!PyErr_Occurred ());
1814- cache -> counter = adaptive_counter_cooldown ();
1811+ specialize (instr , specialized_op );
18151812}
18161813
18171814
0 commit comments