mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)
This commit is contained in:
parent
e647dbaded
commit
121057aa36
14 changed files with 272 additions and 250 deletions
|
@ -292,7 +292,7 @@ dummy_func(
|
|||
BINARY_SUBSCR_TUPLE_INT,
|
||||
};
|
||||
|
||||
inst(BINARY_SUBSCR, (unused/4, container, sub -- res)) {
|
||||
inst(BINARY_SUBSCR, (unused/1, container, sub -- res)) {
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
|
@ -339,7 +339,7 @@ dummy_func(
|
|||
ERROR_IF(err, error);
|
||||
}
|
||||
|
||||
inst(BINARY_SUBSCR_LIST_INT, (unused/4, list, sub -- res)) {
|
||||
inst(BINARY_SUBSCR_LIST_INT, (unused/1, list, sub -- res)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
|
||||
DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR);
|
||||
|
@ -356,7 +356,7 @@ dummy_func(
|
|||
Py_DECREF(list);
|
||||
}
|
||||
|
||||
inst(BINARY_SUBSCR_TUPLE_INT, (unused/4, tuple, sub -- res)) {
|
||||
inst(BINARY_SUBSCR_TUPLE_INT, (unused/1, tuple, sub -- res)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR);
|
||||
DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR);
|
||||
|
@ -373,7 +373,7 @@ dummy_func(
|
|||
Py_DECREF(tuple);
|
||||
}
|
||||
|
||||
inst(BINARY_SUBSCR_DICT, (unused/4, dict, sub -- res)) {
|
||||
inst(BINARY_SUBSCR_DICT, (unused/1, dict, sub -- res)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR);
|
||||
STAT_INC(BINARY_SUBSCR, hit);
|
||||
|
@ -389,14 +389,16 @@ dummy_func(
|
|||
DECREF_INPUTS();
|
||||
}
|
||||
|
||||
inst(BINARY_SUBSCR_GETITEM, (unused/1, type_version/2, func_version/1, container, sub -- unused)) {
|
||||
inst(BINARY_SUBSCR_GETITEM, (unused/1, container, sub -- unused)) {
|
||||
PyTypeObject *tp = Py_TYPE(container);
|
||||
DEOPT_IF(tp->tp_version_tag != type_version, BINARY_SUBSCR);
|
||||
assert(tp->tp_flags & Py_TPFLAGS_HEAPTYPE);
|
||||
PyObject *cached = ((PyHeapTypeObject *)tp)->_spec_cache.getitem;
|
||||
DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR);
|
||||
PyHeapTypeObject *ht = (PyHeapTypeObject *)tp;
|
||||
PyObject *cached = ht->_spec_cache.getitem;
|
||||
DEOPT_IF(cached == NULL, BINARY_SUBSCR);
|
||||
assert(PyFunction_Check(cached));
|
||||
PyFunctionObject *getitem = (PyFunctionObject *)cached;
|
||||
DEOPT_IF(getitem->func_version != func_version, BINARY_SUBSCR);
|
||||
uint32_t cached_version = ht->_spec_cache.getitem_version;
|
||||
DEOPT_IF(getitem->func_version != cached_version, BINARY_SUBSCR);
|
||||
PyCodeObject *code = (PyCodeObject *)getitem->func_code;
|
||||
assert(code->co_argcount == 2);
|
||||
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), BINARY_SUBSCR);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue