[Python-checkins] Fix BINARY_SUBSCR_GETITEM stats (GH-93903)
markshannon
webhook-mailer at python.org
Thu Jun 16 10:02:18 EDT 2022
https://github.com/python/cpython/commit/ab45c1dde0e46603342f751552f06b8deb294832
commit: ab45c1dde0e46603342f751552f06b8deb294832
branch: main
author: Ken Jin <kenjin at python.org>
committer: markshannon <mark at hotpy.org>
date: 2022-06-16T15:02:07+01:00
summary:
Fix BINARY_SUBSCR_GETITEM stats (GH-93903)
files:
M Python/ceval.c
M Python/specialize.c
diff --git a/Python/ceval.c b/Python/ceval.c
index f9ec640ef1722..ca3797c216094 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2240,16 +2240,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
PyFunctionObject *getitem = (PyFunctionObject *)cached;
DEOPT_IF(getitem->func_version != cache->func_version, BINARY_SUBSCR);
PyCodeObject *code = (PyCodeObject *)getitem->func_code;
- size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
assert(code->co_argcount == 2);
- _PyInterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
+ STAT_INC(BINARY_SUBSCR, hit);
+
+ Py_INCREF(getitem);
+ _PyInterpreterFrame *new_frame = _PyFrame_Push(tstate, getitem);
if (new_frame == NULL) {
goto error;
}
- CALL_STAT_INC(frames_pushed);
- Py_INCREF(getitem);
- _PyFrame_InitializeSpecials(new_frame, getitem,
- NULL, code->co_nlocalsplus);
+ CALL_STAT_INC(inlined_py_calls);
STACK_SHRINK(2);
new_frame->localsplus[0] = container;
new_frame->localsplus[1] = sub;
diff --git a/Python/specialize.c b/Python/specialize.c
index a3be97d40dfb5..24fbe2f426cbd 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -1212,7 +1212,8 @@ _Py_Specialize_BinarySubscr(
write_u32(cache->type_version, cls->tp_version_tag);
int version = _PyFunction_GetVersionForCurrentState(func);
if (version == 0 || version != (uint16_t)version) {
- SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_VERSIONS);
+ SPECIALIZATION_FAIL(BINARY_SUBSCR, version == 0 ?
+ SPEC_FAIL_OUT_OF_VERSIONS : SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
cache->func_version = version;
More information about the Python-checkins
mailing list