Skip to content

Commit ab45c1d

Browse files
Fix BINARY_SUBSCR_GETITEM stats (GH-93903)
1 parent d5be9a5 commit ab45c1d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Python/ceval.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -2240,16 +2240,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
22402240
PyFunctionObject *getitem = (PyFunctionObject *)cached;
22412241
DEOPT_IF(getitem->func_version != cache->func_version, BINARY_SUBSCR);
22422242
PyCodeObject *code = (PyCodeObject *)getitem->func_code;
2243-
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
22442243
assert(code->co_argcount == 2);
2245-
_PyInterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
2244+
STAT_INC(BINARY_SUBSCR, hit);
2245+
2246+
Py_INCREF(getitem);
2247+
_PyInterpreterFrame *new_frame = _PyFrame_Push(tstate, getitem);
22462248
if (new_frame == NULL) {
22472249
goto error;
22482250
}
2249-
CALL_STAT_INC(frames_pushed);
2250-
Py_INCREF(getitem);
2251-
_PyFrame_InitializeSpecials(new_frame, getitem,
2252-
NULL, code->co_nlocalsplus);
2251+
CALL_STAT_INC(inlined_py_calls);
22532252
STACK_SHRINK(2);
22542253
new_frame->localsplus[0] = container;
22552254
new_frame->localsplus[1] = sub;

Python/specialize.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ _Py_Specialize_BinarySubscr(
12121212
write_u32(cache->type_version, cls->tp_version_tag);
12131213
int version = _PyFunction_GetVersionForCurrentState(func);
12141214
if (version == 0 || version != (uint16_t)version) {
1215-
SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_VERSIONS);
1215+
SPECIALIZATION_FAIL(BINARY_SUBSCR, version == 0 ?
1216+
SPEC_FAIL_OUT_OF_VERSIONS : SPEC_FAIL_OUT_OF_RANGE);
12161217
goto fail;
12171218
}
12181219
cache->func_version = version;

0 commit comments

Comments
 (0)