@@ -1717,15 +1717,15 @@ _Py_Specialize_BinarySubscr(
1717
1717
PyObject * container = PyStackRef_AsPyObjectBorrow (container_st );
1718
1718
PyObject * sub = PyStackRef_AsPyObjectBorrow (sub_st );
1719
1719
1720
- assert (ENABLE_SPECIALIZATION );
1720
+ assert (ENABLE_SPECIALIZATION_FT );
1721
1721
assert (_PyOpcode_Caches [BINARY_SUBSCR ] ==
1722
1722
INLINE_CACHE_ENTRIES_BINARY_SUBSCR );
1723
- _PyBinarySubscrCache * cache = (_PyBinarySubscrCache * )(instr + 1 );
1724
1723
PyTypeObject * container_type = Py_TYPE (container );
1724
+ uint8_t specialized_op ;
1725
1725
if (container_type == & PyList_Type ) {
1726
1726
if (PyLong_CheckExact (sub )) {
1727
1727
if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1728
- instr -> op . code = BINARY_SUBSCR_LIST_INT ;
1728
+ specialized_op = BINARY_SUBSCR_LIST_INT ;
1729
1729
goto success ;
1730
1730
}
1731
1731
SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1738,7 +1738,7 @@ _Py_Specialize_BinarySubscr(
1738
1738
if (container_type == & PyTuple_Type ) {
1739
1739
if (PyLong_CheckExact (sub )) {
1740
1740
if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1741
- instr -> op . code = BINARY_SUBSCR_TUPLE_INT ;
1741
+ specialized_op = BINARY_SUBSCR_TUPLE_INT ;
1742
1742
goto success ;
1743
1743
}
1744
1744
SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1751,7 +1751,7 @@ _Py_Specialize_BinarySubscr(
1751
1751
if (container_type == & PyUnicode_Type ) {
1752
1752
if (PyLong_CheckExact (sub )) {
1753
1753
if (_PyLong_IsNonNegativeCompact ((PyLongObject * )sub )) {
1754
- instr -> op . code = BINARY_SUBSCR_STR_INT ;
1754
+ specialized_op = BINARY_SUBSCR_STR_INT ;
1755
1755
goto success ;
1756
1756
}
1757
1757
SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
@@ -1762,9 +1762,10 @@ _Py_Specialize_BinarySubscr(
1762
1762
goto fail ;
1763
1763
}
1764
1764
if (container_type == & PyDict_Type ) {
1765
- instr -> op . code = BINARY_SUBSCR_DICT ;
1765
+ specialized_op = BINARY_SUBSCR_DICT ;
1766
1766
goto success ;
1767
1767
}
1768
+ #ifndef Py_GIL_DISABLED
1768
1769
PyTypeObject * cls = Py_TYPE (container );
1769
1770
PyObject * descriptor = _PyType_Lookup (cls , & _Py_ID (__getitem__ ));
1770
1771
if (descriptor && Py_TYPE (descriptor ) == & PyFunction_Type ) {
@@ -1797,21 +1798,17 @@ _Py_Specialize_BinarySubscr(
1797
1798
// struct _specialization_cache):
1798
1799
ht -> _spec_cache .getitem = descriptor ;
1799
1800
ht -> _spec_cache .getitem_version = version ;
1800
- instr -> op . code = BINARY_SUBSCR_GETITEM ;
1801
+ specialized_op = BINARY_SUBSCR_GETITEM ;
1801
1802
goto success ;
1802
1803
}
1804
+ #endif // Py_GIL_DISABLED
1803
1805
SPECIALIZATION_FAIL (BINARY_SUBSCR ,
1804
1806
binary_subscr_fail_kind (container_type , sub ));
1805
1807
fail :
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 );
1810
1809
return ;
1811
1810
success :
1812
- STAT_INC (BINARY_SUBSCR , success );
1813
- assert (!PyErr_Occurred ());
1814
- cache -> counter = adaptive_counter_cooldown ();
1811
+ specialize (instr , specialized_op );
1815
1812
}
1816
1813
1817
1814
0 commit comments