Skip to content

Commit 0b0f7be

Browse files
authored
GH-123232: Fix "not specialized" stats (GH-123236)
1 parent 5fce482 commit 0b0f7be

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ dummy_func(
672672
PyObject *slice = _PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
673673
PyStackRef_AsPyObjectSteal(stop));
674674
PyObject *res_o;
675+
OPCODE_DEFERRED_INC(BINARY_SLICE);
675676
// Can't use ERROR_IF() here, because we haven't
676677
// DECREF'ed container yet, and we still own slice.
677678
if (slice == NULL) {
@@ -689,6 +690,7 @@ dummy_func(
689690
inst(STORE_SLICE, (v, container, start, stop -- )) {
690691
PyObject *slice = _PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
691692
PyStackRef_AsPyObjectSteal(stop));
693+
OPCODE_DEFERRED_INC(STORE_SLICE);
692694
int err;
693695
if (slice == NULL) {
694696
err = 1;

Python/executor_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/specialize.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,18 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
144144
fprintf(out, "opcode[BINARY_SLICE].specializable : 1\n");
145145
fprintf(out, "opcode[STORE_SLICE].specializable : 1\n");
146146
for (int i = 0; i < 256; i++) {
147-
if (_PyOpcode_Caches[i] && i != JUMP_BACKWARD) {
148-
fprintf(out, "opcode[%s].specializable : 1\n", _PyOpcode_OpName[i]);
147+
if (_PyOpcode_Caches[i]) {
148+
/* Ignore jumps as they cannot be specialized */
149+
switch (i) {
150+
case POP_JUMP_IF_FALSE:
151+
case POP_JUMP_IF_TRUE:
152+
case POP_JUMP_IF_NONE:
153+
case POP_JUMP_IF_NOT_NONE:
154+
case JUMP_BACKWARD:
155+
break;
156+
default:
157+
fprintf(out, "opcode[%s].specializable : 1\n", _PyOpcode_OpName[i]);
158+
}
149159
}
150160
PRINT_STAT(i, specialization.success);
151161
PRINT_STAT(i, specialization.failure);

0 commit comments

Comments
 (0)