Mailing List Archive

Record cache hits for BINARY_SUBSCR specializations (GH-29060)
https://github.com/python/cpython/commit/6e35b096ac07288a2e23909bb39f3a18c0c83951
commit: 6e35b096ac07288a2e23909bb39f3a18c0c83951
branch: main
author: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
committer: markshannon <mark@hotpy.org>
date: 2021-10-19T17:25:31+01:00
summary:

Record cache hits for BINARY_SUBSCR specializations (GH-29060)

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index 05bdcc5f7fab9..2fb60a84a112d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2242,6 +2242,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
Py_ssize_t index = ((PyLongObject*)sub)->ob_digit[0];
DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);

+ record_hit_inline(next_instr, oparg);
STAT_INC(BINARY_SUBSCR, hit);
PyObject *res = PyList_GET_ITEM(list, index);
assert(res != NULL);
@@ -2266,6 +2267,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
Py_ssize_t index = ((PyLongObject*)sub)->ob_digit[0];
DEOPT_IF(index >= PyTuple_GET_SIZE(tuple), BINARY_SUBSCR);

+ record_hit_inline(next_instr, oparg);
STAT_INC(BINARY_SUBSCR, hit);
PyObject *res = PyTuple_GET_ITEM(tuple, index);
assert(res != NULL);
@@ -2280,6 +2282,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
TARGET(BINARY_SUBSCR_DICT) {
PyObject *dict = SECOND();
DEOPT_IF(!PyDict_CheckExact(SECOND()), BINARY_SUBSCR);
+ record_hit_inline(next_instr, oparg);
STAT_INC(BINARY_SUBSCR, hit);
PyObject *sub = TOP();
PyObject *res = PyDict_GetItemWithError(dict, sub);

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins