gh-125039: Make `this_instr`/`prev_instr` const in cases generator (GH-125071)

This commit is contained in:
Tomas R. 2024-10-09 14:54:39 +02:00 committed by GitHub
parent 3024b16d51
commit 6b533a659b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 79 additions and 78 deletions

View File

@ -450,7 +450,7 @@ class TestGeneratedCases(unittest.TestCase):
""" """
output = """ output = """
TARGET(OP) { TARGET(OP) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(OP); INSTRUCTION_STATS(OP);
@ -503,7 +503,7 @@ class TestGeneratedCases(unittest.TestCase):
next_instr += 6; next_instr += 6;
INSTRUCTION_STATS(OP); INSTRUCTION_STATS(OP);
PREDICTED(OP); PREDICTED(OP);
_Py_CODEUNIT *this_instr = next_instr - 6; _Py_CODEUNIT* const this_instr = next_instr - 6;
(void)this_instr; (void)this_instr;
_PyStackRef left; _PyStackRef left;
_PyStackRef right; _PyStackRef right;
@ -536,7 +536,7 @@ class TestGeneratedCases(unittest.TestCase):
} }
TARGET(OP1) { TARGET(OP1) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(OP1); INSTRUCTION_STATS(OP1);

View File

@ -0,0 +1 @@
Make ``this_instr`` and ``prev_instr`` const in cases generator.

View File

@ -14,7 +14,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(BINARY_OP); INSTRUCTION_STATS(BINARY_OP);
PREDICTED(BINARY_OP); PREDICTED(BINARY_OP);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef lhs; _PyStackRef lhs;
_PyStackRef rhs; _PyStackRef rhs;
@ -422,7 +422,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(BINARY_SUBSCR); INSTRUCTION_STATS(BINARY_SUBSCR);
PREDICTED(BINARY_SUBSCR); PREDICTED(BINARY_SUBSCR);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef container; _PyStackRef container;
_PyStackRef sub; _PyStackRef sub;
@ -858,7 +858,7 @@
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL); INSTRUCTION_STATS(CALL);
PREDICTED(CALL); PREDICTED(CALL);
_Py_CODEUNIT *this_instr = next_instr - 4; _Py_CODEUNIT* const this_instr = next_instr - 4;
(void)this_instr; (void)this_instr;
_PyStackRef *callable; _PyStackRef *callable;
_PyStackRef *self_or_null; _PyStackRef *self_or_null;
@ -1012,7 +1012,7 @@
} }
TARGET(CALL_ALLOC_AND_ENTER_INIT) { TARGET(CALL_ALLOC_AND_ENTER_INIT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_ALLOC_AND_ENTER_INIT); INSTRUCTION_STATS(CALL_ALLOC_AND_ENTER_INIT);
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
@ -1107,7 +1107,7 @@
} }
TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_BOUND_METHOD_EXACT_ARGS); INSTRUCTION_STATS(CALL_BOUND_METHOD_EXACT_ARGS);
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
@ -1210,7 +1210,7 @@
} }
TARGET(CALL_BOUND_METHOD_GENERAL) { TARGET(CALL_BOUND_METHOD_GENERAL) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_BOUND_METHOD_GENERAL); INSTRUCTION_STATS(CALL_BOUND_METHOD_GENERAL);
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
@ -1625,7 +1625,7 @@
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(CALL_FUNCTION_EX); INSTRUCTION_STATS(CALL_FUNCTION_EX);
PREDICTED(CALL_FUNCTION_EX); PREDICTED(CALL_FUNCTION_EX);
_Py_CODEUNIT *this_instr = next_instr - 1; _Py_CODEUNIT* const this_instr = next_instr - 1;
(void)this_instr; (void)this_instr;
_PyStackRef func; _PyStackRef func;
_PyStackRef callargs; _PyStackRef callargs;
@ -1871,7 +1871,7 @@
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_KW); INSTRUCTION_STATS(CALL_KW);
PREDICTED(CALL_KW); PREDICTED(CALL_KW);
_Py_CODEUNIT *this_instr = next_instr - 4; _Py_CODEUNIT* const this_instr = next_instr - 4;
(void)this_instr; (void)this_instr;
_PyStackRef *callable; _PyStackRef *callable;
_PyStackRef *self_or_null; _PyStackRef *self_or_null;
@ -2024,7 +2024,7 @@
} }
TARGET(CALL_KW_BOUND_METHOD) { TARGET(CALL_KW_BOUND_METHOD) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_KW_BOUND_METHOD); INSTRUCTION_STATS(CALL_KW_BOUND_METHOD);
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
@ -2223,7 +2223,7 @@
} }
TARGET(CALL_KW_PY) { TARGET(CALL_KW_PY) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_KW_PY); INSTRUCTION_STATS(CALL_KW_PY);
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
@ -2795,7 +2795,7 @@
} }
TARGET(CALL_PY_EXACT_ARGS) { TARGET(CALL_PY_EXACT_ARGS) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_PY_EXACT_ARGS); INSTRUCTION_STATS(CALL_PY_EXACT_ARGS);
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
@ -2876,7 +2876,7 @@
} }
TARGET(CALL_PY_GENERAL) { TARGET(CALL_PY_GENERAL) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(CALL_PY_GENERAL); INSTRUCTION_STATS(CALL_PY_GENERAL);
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
@ -3157,7 +3157,7 @@
} }
TARGET(CLEANUP_THROW) { TARGET(CLEANUP_THROW) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(CLEANUP_THROW); INSTRUCTION_STATS(CLEANUP_THROW);
@ -3201,7 +3201,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(COMPARE_OP); INSTRUCTION_STATS(COMPARE_OP);
PREDICTED(COMPARE_OP); PREDICTED(COMPARE_OP);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef left; _PyStackRef left;
_PyStackRef right; _PyStackRef right;
@ -3381,7 +3381,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(CONTAINS_OP); INSTRUCTION_STATS(CONTAINS_OP);
PREDICTED(CONTAINS_OP); PREDICTED(CONTAINS_OP);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef left; _PyStackRef left;
_PyStackRef right; _PyStackRef right;
@ -3720,7 +3720,7 @@
} }
TARGET(END_ASYNC_FOR) { TARGET(END_ASYNC_FOR) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(END_ASYNC_FOR); INSTRUCTION_STATS(END_ASYNC_FOR);
@ -3781,7 +3781,7 @@
} }
TARGET(ENTER_EXECUTOR) { TARGET(ENTER_EXECUTOR) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(ENTER_EXECUTOR); INSTRUCTION_STATS(ENTER_EXECUTOR);
@ -3896,7 +3896,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(FOR_ITER); INSTRUCTION_STATS(FOR_ITER);
PREDICTED(FOR_ITER); PREDICTED(FOR_ITER);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef iter; _PyStackRef iter;
_PyStackRef next; _PyStackRef next;
@ -4357,7 +4357,7 @@
} }
TARGET(INSTRUMENTED_CALL) { TARGET(INSTRUMENTED_CALL) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(INSTRUMENTED_CALL); INSTRUCTION_STATS(INSTRUMENTED_CALL);
@ -4530,7 +4530,7 @@
} }
TARGET(INSTRUMENTED_CALL_KW) { TARGET(INSTRUMENTED_CALL_KW) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(INSTRUMENTED_CALL_KW); INSTRUCTION_STATS(INSTRUMENTED_CALL_KW);
@ -4554,7 +4554,7 @@
} }
TARGET(INSTRUMENTED_END_FOR) { TARGET(INSTRUMENTED_END_FOR) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_END_FOR); INSTRUCTION_STATS(INSTRUMENTED_END_FOR);
@ -4579,7 +4579,7 @@
} }
TARGET(INSTRUMENTED_END_SEND) { TARGET(INSTRUMENTED_END_SEND) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_END_SEND); INSTRUCTION_STATS(INSTRUMENTED_END_SEND);
@ -4606,7 +4606,7 @@
} }
TARGET(INSTRUMENTED_FOR_ITER) { TARGET(INSTRUMENTED_FOR_ITER) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_FOR_ITER); INSTRUCTION_STATS(INSTRUMENTED_FOR_ITER);
@ -4647,7 +4647,7 @@
} }
TARGET(INSTRUMENTED_INSTRUCTION) { TARGET(INSTRUMENTED_INSTRUCTION) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_INSTRUCTION); INSTRUCTION_STATS(INSTRUMENTED_INSTRUCTION);
@ -4666,7 +4666,7 @@
} }
TARGET(INSTRUMENTED_JUMP_BACKWARD) { TARGET(INSTRUMENTED_JUMP_BACKWARD) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_JUMP_BACKWARD); INSTRUCTION_STATS(INSTRUMENTED_JUMP_BACKWARD);
@ -4690,7 +4690,7 @@
} }
TARGET(INSTRUMENTED_JUMP_FORWARD) { TARGET(INSTRUMENTED_JUMP_FORWARD) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_JUMP_FORWARD); INSTRUCTION_STATS(INSTRUMENTED_JUMP_FORWARD);
@ -4699,8 +4699,8 @@
} }
TARGET(INSTRUMENTED_LINE) { TARGET(INSTRUMENTED_LINE) {
_Py_CODEUNIT *prev_instr = frame->instr_ptr; _Py_CODEUNIT* const prev_instr = frame->instr_ptr;
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_LINE); INSTRUCTION_STATS(INSTRUMENTED_LINE);
@ -4734,7 +4734,7 @@
} }
TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) { TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_LOAD_SUPER_ATTR); INSTRUCTION_STATS(INSTRUMENTED_LOAD_SUPER_ATTR);
@ -4748,7 +4748,7 @@
} }
TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_FALSE); INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_FALSE);
@ -4765,7 +4765,7 @@
} }
TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NONE); INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NONE);
@ -4788,7 +4788,7 @@
} }
TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NOT_NONE); INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NOT_NONE);
@ -4811,7 +4811,7 @@
} }
TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_TRUE); INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_TRUE);
@ -4828,7 +4828,7 @@
} }
TARGET(INSTRUMENTED_RESUME) { TARGET(INSTRUMENTED_RESUME) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_RESUME); INSTRUCTION_STATS(INSTRUMENTED_RESUME);
@ -4878,7 +4878,7 @@
} }
TARGET(INSTRUMENTED_RETURN_CONST) { TARGET(INSTRUMENTED_RETURN_CONST) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_RETURN_CONST); INSTRUCTION_STATS(INSTRUMENTED_RETURN_CONST);
@ -4931,7 +4931,7 @@
} }
TARGET(INSTRUMENTED_RETURN_VALUE) { TARGET(INSTRUMENTED_RETURN_VALUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_RETURN_VALUE); INSTRUCTION_STATS(INSTRUMENTED_RETURN_VALUE);
@ -4976,7 +4976,7 @@
} }
TARGET(INSTRUMENTED_YIELD_VALUE) { TARGET(INSTRUMENTED_YIELD_VALUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_YIELD_VALUE); INSTRUCTION_STATS(INSTRUMENTED_YIELD_VALUE);
@ -5087,7 +5087,7 @@
} }
TARGET(JUMP_BACKWARD) { TARGET(JUMP_BACKWARD) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(JUMP_BACKWARD); INSTRUCTION_STATS(JUMP_BACKWARD);
@ -5220,7 +5220,7 @@
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR); INSTRUCTION_STATS(LOAD_ATTR);
PREDICTED(LOAD_ATTR); PREDICTED(LOAD_ATTR);
_Py_CODEUNIT *this_instr = next_instr - 10; _Py_CODEUNIT* const this_instr = next_instr - 10;
(void)this_instr; (void)this_instr;
_PyStackRef owner; _PyStackRef owner;
_PyStackRef attr; _PyStackRef attr;
@ -5294,7 +5294,7 @@
} }
TARGET(LOAD_ATTR_CLASS) { TARGET(LOAD_ATTR_CLASS) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_CLASS); INSTRUCTION_STATS(LOAD_ATTR_CLASS);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5329,7 +5329,7 @@
} }
TARGET(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK) { TARGET(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK); INSTRUCTION_STATS(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5370,7 +5370,7 @@
} }
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN); INSTRUCTION_STATS(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5406,7 +5406,7 @@
} }
TARGET(LOAD_ATTR_INSTANCE_VALUE) { TARGET(LOAD_ATTR_INSTANCE_VALUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_INSTANCE_VALUE); INSTRUCTION_STATS(LOAD_ATTR_INSTANCE_VALUE);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5451,7 +5451,7 @@
} }
TARGET(LOAD_ATTR_METHOD_LAZY_DICT) { TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_METHOD_LAZY_DICT); INSTRUCTION_STATS(LOAD_ATTR_METHOD_LAZY_DICT);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5494,7 +5494,7 @@
} }
TARGET(LOAD_ATTR_METHOD_NO_DICT) { TARGET(LOAD_ATTR_METHOD_NO_DICT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_METHOD_NO_DICT); INSTRUCTION_STATS(LOAD_ATTR_METHOD_NO_DICT);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5530,7 +5530,7 @@
} }
TARGET(LOAD_ATTR_METHOD_WITH_VALUES) { TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_METHOD_WITH_VALUES); INSTRUCTION_STATS(LOAD_ATTR_METHOD_WITH_VALUES);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5578,7 +5578,7 @@
} }
TARGET(LOAD_ATTR_MODULE) { TARGET(LOAD_ATTR_MODULE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_MODULE); INSTRUCTION_STATS(LOAD_ATTR_MODULE);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5621,7 +5621,7 @@
} }
TARGET(LOAD_ATTR_NONDESCRIPTOR_NO_DICT) { TARGET(LOAD_ATTR_NONDESCRIPTOR_NO_DICT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_NO_DICT); INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_NO_DICT);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5652,7 +5652,7 @@
} }
TARGET(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES) { TARGET(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES); INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5694,7 +5694,7 @@
} }
TARGET(LOAD_ATTR_PROPERTY) { TARGET(LOAD_ATTR_PROPERTY) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_PROPERTY); INSTRUCTION_STATS(LOAD_ATTR_PROPERTY);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5759,7 +5759,7 @@
} }
TARGET(LOAD_ATTR_SLOT) { TARGET(LOAD_ATTR_SLOT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_SLOT); INSTRUCTION_STATS(LOAD_ATTR_SLOT);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -5796,7 +5796,7 @@
} }
TARGET(LOAD_ATTR_WITH_HINT) { TARGET(LOAD_ATTR_WITH_HINT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 10; next_instr += 10;
INSTRUCTION_STATS(LOAD_ATTR_WITH_HINT); INSTRUCTION_STATS(LOAD_ATTR_WITH_HINT);
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
@ -6101,7 +6101,7 @@
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(LOAD_GLOBAL); INSTRUCTION_STATS(LOAD_GLOBAL);
PREDICTED(LOAD_GLOBAL); PREDICTED(LOAD_GLOBAL);
_Py_CODEUNIT *this_instr = next_instr - 5; _Py_CODEUNIT* const this_instr = next_instr - 5;
(void)this_instr; (void)this_instr;
_PyStackRef *res; _PyStackRef *res;
_PyStackRef null = PyStackRef_NULL; _PyStackRef null = PyStackRef_NULL;
@ -6142,7 +6142,7 @@
} }
TARGET(LOAD_GLOBAL_BUILTIN) { TARGET(LOAD_GLOBAL_BUILTIN) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(LOAD_GLOBAL_BUILTIN); INSTRUCTION_STATS(LOAD_GLOBAL_BUILTIN);
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
@ -6185,7 +6185,7 @@
} }
TARGET(LOAD_GLOBAL_MODULE) { TARGET(LOAD_GLOBAL_MODULE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(LOAD_GLOBAL_MODULE); INSTRUCTION_STATS(LOAD_GLOBAL_MODULE);
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
@ -6299,7 +6299,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(LOAD_SUPER_ATTR); INSTRUCTION_STATS(LOAD_SUPER_ATTR);
PREDICTED(LOAD_SUPER_ATTR); PREDICTED(LOAD_SUPER_ATTR);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef global_super_st; _PyStackRef global_super_st;
_PyStackRef class_st; _PyStackRef class_st;
@ -6654,7 +6654,7 @@
} }
TARGET(POP_JUMP_IF_FALSE) { TARGET(POP_JUMP_IF_FALSE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(POP_JUMP_IF_FALSE); INSTRUCTION_STATS(POP_JUMP_IF_FALSE);
@ -6673,7 +6673,7 @@
} }
TARGET(POP_JUMP_IF_NONE) { TARGET(POP_JUMP_IF_NONE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(POP_JUMP_IF_NONE); INSTRUCTION_STATS(POP_JUMP_IF_NONE);
@ -6708,7 +6708,7 @@
} }
TARGET(POP_JUMP_IF_NOT_NONE) { TARGET(POP_JUMP_IF_NOT_NONE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(POP_JUMP_IF_NOT_NONE); INSTRUCTION_STATS(POP_JUMP_IF_NOT_NONE);
@ -6743,7 +6743,7 @@
} }
TARGET(POP_JUMP_IF_TRUE) { TARGET(POP_JUMP_IF_TRUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(POP_JUMP_IF_TRUE); INSTRUCTION_STATS(POP_JUMP_IF_TRUE);
@ -6811,7 +6811,7 @@
} }
TARGET(RAISE_VARARGS) { TARGET(RAISE_VARARGS) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(RAISE_VARARGS); INSTRUCTION_STATS(RAISE_VARARGS);
@ -6836,7 +6836,7 @@
} }
TARGET(RERAISE) { TARGET(RERAISE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
(void)this_instr; (void)this_instr;
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(RERAISE); INSTRUCTION_STATS(RERAISE);
@ -6886,7 +6886,7 @@
next_instr += 1; next_instr += 1;
INSTRUCTION_STATS(RESUME); INSTRUCTION_STATS(RESUME);
PREDICTED(RESUME); PREDICTED(RESUME);
_Py_CODEUNIT *this_instr = next_instr - 1; _Py_CODEUNIT* const this_instr = next_instr - 1;
(void)this_instr; (void)this_instr;
// _MAYBE_INSTRUMENT // _MAYBE_INSTRUMENT
{ {
@ -7049,7 +7049,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(SEND); INSTRUCTION_STATS(SEND);
PREDICTED(SEND); PREDICTED(SEND);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef receiver; _PyStackRef receiver;
_PyStackRef v; _PyStackRef v;
@ -7288,7 +7288,7 @@
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(STORE_ATTR); INSTRUCTION_STATS(STORE_ATTR);
PREDICTED(STORE_ATTR); PREDICTED(STORE_ATTR);
_Py_CODEUNIT *this_instr = next_instr - 5; _Py_CODEUNIT* const this_instr = next_instr - 5;
(void)this_instr; (void)this_instr;
_PyStackRef owner; _PyStackRef owner;
_PyStackRef v; _PyStackRef v;
@ -7329,7 +7329,7 @@
} }
TARGET(STORE_ATTR_INSTANCE_VALUE) { TARGET(STORE_ATTR_INSTANCE_VALUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(STORE_ATTR_INSTANCE_VALUE); INSTRUCTION_STATS(STORE_ATTR_INSTANCE_VALUE);
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
@ -7378,7 +7378,7 @@
} }
TARGET(STORE_ATTR_SLOT) { TARGET(STORE_ATTR_SLOT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(STORE_ATTR_SLOT); INSTRUCTION_STATS(STORE_ATTR_SLOT);
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
@ -7411,7 +7411,7 @@
} }
TARGET(STORE_ATTR_WITH_HINT) { TARGET(STORE_ATTR_WITH_HINT) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 5; next_instr += 5;
INSTRUCTION_STATS(STORE_ATTR_WITH_HINT); INSTRUCTION_STATS(STORE_ATTR_WITH_HINT);
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
@ -7625,7 +7625,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(STORE_SUBSCR); INSTRUCTION_STATS(STORE_SUBSCR);
PREDICTED(STORE_SUBSCR); PREDICTED(STORE_SUBSCR);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef container; _PyStackRef container;
_PyStackRef sub; _PyStackRef sub;
@ -7748,7 +7748,7 @@
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(TO_BOOL); INSTRUCTION_STATS(TO_BOOL);
PREDICTED(TO_BOOL); PREDICTED(TO_BOOL);
_Py_CODEUNIT *this_instr = next_instr - 4; _Py_CODEUNIT* const this_instr = next_instr - 4;
(void)this_instr; (void)this_instr;
_PyStackRef value; _PyStackRef value;
_PyStackRef res; _PyStackRef res;
@ -7784,7 +7784,7 @@
} }
TARGET(TO_BOOL_ALWAYS_TRUE) { TARGET(TO_BOOL_ALWAYS_TRUE) {
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; _Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
next_instr += 4; next_instr += 4;
INSTRUCTION_STATS(TO_BOOL_ALWAYS_TRUE); INSTRUCTION_STATS(TO_BOOL_ALWAYS_TRUE);
static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size"); static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
@ -7984,7 +7984,7 @@
next_instr += 2; next_instr += 2;
INSTRUCTION_STATS(UNPACK_SEQUENCE); INSTRUCTION_STATS(UNPACK_SEQUENCE);
PREDICTED(UNPACK_SEQUENCE); PREDICTED(UNPACK_SEQUENCE);
_Py_CODEUNIT *this_instr = next_instr - 2; _Py_CODEUNIT* const this_instr = next_instr - 2;
(void)this_instr; (void)this_instr;
_PyStackRef seq; _PyStackRef seq;
_PyStackRef *output; _PyStackRef *output;

View File

@ -150,9 +150,9 @@ def generate_tier1(
out.emit(f"TARGET({name}) {{\n") out.emit(f"TARGET({name}) {{\n")
unused_guard = "(void)this_instr;\n" if inst.family is None else "" unused_guard = "(void)this_instr;\n" if inst.family is None else ""
if inst.properties.needs_prev: if inst.properties.needs_prev:
out.emit(f"_Py_CODEUNIT *prev_instr = frame->instr_ptr;\n") out.emit(f"_Py_CODEUNIT* const prev_instr = frame->instr_ptr;\n")
if needs_this and not inst.is_target: if needs_this and not inst.is_target:
out.emit(f"_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;\n") out.emit(f"_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;\n")
out.emit(unused_guard) out.emit(unused_guard)
else: else:
out.emit(f"frame->instr_ptr = next_instr;\n") out.emit(f"frame->instr_ptr = next_instr;\n")
@ -161,7 +161,7 @@ def generate_tier1(
if inst.is_target: if inst.is_target:
out.emit(f"PREDICTED({name});\n") out.emit(f"PREDICTED({name});\n")
if needs_this: if needs_this:
out.emit(f"_Py_CODEUNIT *this_instr = next_instr - {inst.size};\n") out.emit(f"_Py_CODEUNIT* const this_instr = next_instr - {inst.size};\n")
out.emit(unused_guard) out.emit(unused_guard)
if inst.family is not None: if inst.family is not None:
out.emit( out.emit(