https://github.com/python/cpython/commit/0b0f7befaddb2b5eff2811398a0f0d4604a82a90
commit: 0b0f7befaddb2b5eff2811398a0f0d4604a82a90
branch: main
author: Mark Shannon <[email protected]>
committer: markshannon <[email protected]>
date: 2024-08-23T10:46:03+01:00
summary:
GH-123232: Fix "not specialized" stats (GH-123236)
files:
M Python/bytecodes.c
M Python/executor_cases.c.h
M Python/generated_cases.c.h
M Python/specialize.c
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 62f6853fedf984..fefa3af37a16b0 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -672,6 +672,7 @@ dummy_func(
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
PyObject *res_o;
+ OPCODE_DEFERRED_INC(BINARY_SLICE);
// Can't use ERROR_IF() here, because we haven't
// DECREF'ed container yet, and we still own slice.
if (slice == NULL) {
@@ -689,6 +690,7 @@ dummy_func(
inst(STORE_SLICE, (v, container, start, stop -- )) {
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
+ OPCODE_DEFERRED_INC(STORE_SLICE);
int err;
if (slice == NULL) {
err = 1;
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 4274d51b3fa39c..8726adeeeadc10 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -797,6 +797,7 @@
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
PyObject *res_o;
+ OPCODE_DEFERRED_INC(BINARY_SLICE);
// Can't use ERROR_IF() here, because we haven't
// DECREF'ed container yet, and we still own slice.
if (slice == NULL) {
@@ -826,6 +827,7 @@
v = stack_pointer[-4];
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
+ OPCODE_DEFERRED_INC(STORE_SLICE);
int err;
if (slice == NULL) {
err = 1;
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index feb16ccaad3795..69f5dc5a54378f 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -377,6 +377,7 @@
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
PyObject *res_o;
+ OPCODE_DEFERRED_INC(BINARY_SLICE);
// Can't use ERROR_IF() here, because we haven't
// DECREF'ed container yet, and we still own slice.
if (slice == NULL) {
@@ -7090,6 +7091,7 @@
v = stack_pointer[-4];
PyObject *slice =
_PyBuildSlice_ConsumeRefs(PyStackRef_AsPyObjectSteal(start),
PyStackRef_AsPyObjectSteal(stop));
+ OPCODE_DEFERRED_INC(STORE_SLICE);
int err;
if (slice == NULL) {
err = 1;
diff --git a/Python/specialize.c b/Python/specialize.c
index 14f0c0756ff390..da618952e85978 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -144,8 +144,18 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
fprintf(out, "opcode[BINARY_SLICE].specializable : 1\n");
fprintf(out, "opcode[STORE_SLICE].specializable : 1\n");
for (int i = 0; i < 256; i++) {
- if (_PyOpcode_Caches[i] && i != JUMP_BACKWARD) {
- fprintf(out, "opcode[%s].specializable : 1\n",
_PyOpcode_OpName[i]);
+ if (_PyOpcode_Caches[i]) {
+ /* Ignore jumps as they cannot be specialized */
+ switch (i) {
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ case POP_JUMP_IF_NONE:
+ case POP_JUMP_IF_NOT_NONE:
+ case JUMP_BACKWARD:
+ break;
+ default:
+ fprintf(out, "opcode[%s].specializable : 1\n",
_PyOpcode_OpName[i]);
+ }
}
PRINT_STAT(i, specialization.success);
PRINT_STAT(i, specialization.failure);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]