summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-05-04 07:50:24 (GMT)
committerGitHub <noreply@github.com>2024-05-04 07:50:24 (GMT)
commitda2cfc4cb6b756b819b45bf34dd735c27b74d803 (patch)
tree8255981000069b9235bb0bdfee4b0bbf3f2425a5 /Python
parent0b7814e0b638631fa2f5c81bcbab7b94064948d7 (diff)
downloadcpython-da2cfc4cb6b756b819b45bf34dd735c27b74d803.zip
cpython-da2cfc4cb6b756b819b45bf34dd735c27b74d803.tar.gz
cpython-da2cfc4cb6b756b819b45bf34dd735c27b74d803.tar.bz2
GH-113464: Remove the extra jump via `_SIDE_EXIT` in `_EXIT_TRACE` (GH-118545)
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c6
-rw-r--r--Python/executor_cases.c.h10
-rw-r--r--Python/optimizer.c21
-rw-r--r--Python/optimizer_cases.c.h4
4 files changed, 12 insertions, 29 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index e8383ed..ddada96 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -4133,7 +4133,7 @@ dummy_func(
}
tier2 op(_EXIT_TRACE, (--)) {
- EXIT_IF(1);
+ EXIT_TO_TRACE();
}
tier2 op(_CHECK_VALIDITY, (--)) {
@@ -4266,10 +4266,6 @@ dummy_func(
EXIT_TO_TIER1();
}
- tier2 op(_SIDE_EXIT, (--)) {
- EXIT_TO_TRACE();
- }
-
tier2 op(_ERROR_POP_N, (target/2, unused[oparg] --)) {
frame->instr_ptr = ((_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive) + target;
SYNC_SP();
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index c3ee6e9..d0b794c 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -4127,10 +4127,7 @@
}
case _EXIT_TRACE: {
- if (1) {
- UOP_STAT_INC(uopcode, miss);
- JUMP_TO_JUMP_TARGET();
- }
+ EXIT_TO_TRACE();
break;
}
@@ -4319,11 +4316,6 @@
break;
}
- case _SIDE_EXIT: {
- EXIT_TO_TRACE();
- break;
- }
-
case _ERROR_POP_N: {
oparg = CURRENT_OPARG();
uint32_t target = (uint32_t)CURRENT_OPERAND();
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 56768ae..c0e1be9 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -976,7 +976,7 @@ count_exits(_PyUOpInstruction *buffer, int length)
int exit_count = 0;
for (int i = 0; i < length; i++) {
int opcode = buffer[i].opcode;
- if (opcode == _SIDE_EXIT || opcode == _DYNAMIC_EXIT) {
+ if (opcode == _EXIT_TRACE || opcode == _DYNAMIC_EXIT) {
exit_count++;
}
}
@@ -1021,7 +1021,7 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
int32_t target = (int32_t)uop_get_target(inst);
if (_PyUop_Flags[opcode] & (HAS_EXIT_FLAG | HAS_DEOPT_FLAG)) {
uint16_t exit_op = (_PyUop_Flags[opcode] & HAS_EXIT_FLAG) ?
- _SIDE_EXIT : _DEOPT;
+ _EXIT_TRACE : _DEOPT;
int32_t jump_target = target;
if (is_for_iter_test[opcode]) {
/* Target the POP_TOP immediately after the END_FOR,
@@ -1112,7 +1112,7 @@ sanity_check(_PyExecutorObject *executor)
CHECK(target_unused(opcode));
break;
case UOP_FORMAT_EXIT:
- CHECK(opcode == _SIDE_EXIT);
+ CHECK(opcode == _EXIT_TRACE);
CHECK(inst->exit_index < executor->exit_count);
break;
case UOP_FORMAT_JUMP:
@@ -1138,9 +1138,9 @@ sanity_check(_PyExecutorObject *executor)
uint16_t opcode = inst->opcode;
CHECK(
opcode == _DEOPT ||
- opcode == _SIDE_EXIT ||
+ opcode == _EXIT_TRACE ||
opcode == _ERROR_POP_N);
- if (opcode == _SIDE_EXIT) {
+ if (opcode == _EXIT_TRACE) {
CHECK(inst->format == UOP_FORMAT_EXIT);
}
}
@@ -1178,7 +1178,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
dest--;
*dest = buffer[i];
assert(opcode != _POP_JUMP_IF_FALSE && opcode != _POP_JUMP_IF_TRUE);
- if (opcode == _SIDE_EXIT) {
+ if (opcode == _EXIT_TRACE) {
executor->exits[next_exit].target = buffer[i].target;
dest->exit_index = next_exit;
dest->format = UOP_FORMAT_EXIT;
@@ -1398,14 +1398,13 @@ counter_optimize(
return 0;
}
_Py_CODEUNIT *target = instr + 1 + _PyOpcode_Caches[JUMP_BACKWARD] - oparg;
- _PyUOpInstruction buffer[5] = {
- { .opcode = _START_EXECUTOR, .jump_target = 4, .format=UOP_FORMAT_JUMP },
+ _PyUOpInstruction buffer[4] = {
+ { .opcode = _START_EXECUTOR, .jump_target = 3, .format=UOP_FORMAT_JUMP },
{ .opcode = _LOAD_CONST_INLINE_BORROW, .operand = (uintptr_t)self },
{ .opcode = _INTERNAL_INCREMENT_OPT_COUNTER },
- { .opcode = _EXIT_TRACE, .jump_target = 4, .format=UOP_FORMAT_JUMP },
- { .opcode = _SIDE_EXIT, .target = (uint32_t)(target - _PyCode_CODE(code)), .format=UOP_FORMAT_TARGET }
+ { .opcode = _EXIT_TRACE, .target = (uint32_t)(target - _PyCode_CODE(code)), .format=UOP_FORMAT_TARGET }
};
- _PyExecutorObject *executor = make_executor_from_uops(buffer, 5, &EMPTY_FILTER);
+ _PyExecutorObject *executor = make_executor_from_uops(buffer, 4, &EMPTY_FILTER);
if (executor == NULL) {
return -1;
}
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index e680d76..b602d66 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -2140,10 +2140,6 @@
break;
}
- case _SIDE_EXIT: {
- break;
- }
-
case _ERROR_POP_N: {
stack_pointer += -oparg;
break;