Skip to content

Commit da2cfc4

Browse files
authored
GH-113464: Remove the extra jump via _SIDE_EXIT in _EXIT_TRACE (GH-118545)
1 parent 0b7814e commit da2cfc4

File tree

6 files changed

+31
-53
lines changed

6 files changed

+31
-53
lines changed

Include/internal/pycore_uop_ids.h

+18-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -4133,7 +4133,7 @@ dummy_func(
41334133
}
41344134

41354135
tier2 op(_EXIT_TRACE, (--)) {
4136-
EXIT_IF(1);
4136+
EXIT_TO_TRACE();
41374137
}
41384138

41394139
tier2 op(_CHECK_VALIDITY, (--)) {
@@ -4266,10 +4266,6 @@ dummy_func(
42664266
EXIT_TO_TIER1();
42674267
}
42684268

4269-
tier2 op(_SIDE_EXIT, (--)) {
4270-
EXIT_TO_TRACE();
4271-
}
4272-
42734269
tier2 op(_ERROR_POP_N, (target/2, unused[oparg] --)) {
42744270
frame->instr_ptr = ((_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive) + target;
42754271
SYNC_SP();

Python/executor_cases.c.h

+1-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ count_exits(_PyUOpInstruction *buffer, int length)
976976
int exit_count = 0;
977977
for (int i = 0; i < length; i++) {
978978
int opcode = buffer[i].opcode;
979-
if (opcode == _SIDE_EXIT || opcode == _DYNAMIC_EXIT) {
979+
if (opcode == _EXIT_TRACE || opcode == _DYNAMIC_EXIT) {
980980
exit_count++;
981981
}
982982
}
@@ -1021,7 +1021,7 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
10211021
int32_t target = (int32_t)uop_get_target(inst);
10221022
if (_PyUop_Flags[opcode] & (HAS_EXIT_FLAG | HAS_DEOPT_FLAG)) {
10231023
uint16_t exit_op = (_PyUop_Flags[opcode] & HAS_EXIT_FLAG) ?
1024-
_SIDE_EXIT : _DEOPT;
1024+
_EXIT_TRACE : _DEOPT;
10251025
int32_t jump_target = target;
10261026
if (is_for_iter_test[opcode]) {
10271027
/* Target the POP_TOP immediately after the END_FOR,
@@ -1112,7 +1112,7 @@ sanity_check(_PyExecutorObject *executor)
11121112
CHECK(target_unused(opcode));
11131113
break;
11141114
case UOP_FORMAT_EXIT:
1115-
CHECK(opcode == _SIDE_EXIT);
1115+
CHECK(opcode == _EXIT_TRACE);
11161116
CHECK(inst->exit_index < executor->exit_count);
11171117
break;
11181118
case UOP_FORMAT_JUMP:
@@ -1138,9 +1138,9 @@ sanity_check(_PyExecutorObject *executor)
11381138
uint16_t opcode = inst->opcode;
11391139
CHECK(
11401140
opcode == _DEOPT ||
1141-
opcode == _SIDE_EXIT ||
1141+
opcode == _EXIT_TRACE ||
11421142
opcode == _ERROR_POP_N);
1143-
if (opcode == _SIDE_EXIT) {
1143+
if (opcode == _EXIT_TRACE) {
11441144
CHECK(inst->format == UOP_FORMAT_EXIT);
11451145
}
11461146
}
@@ -1178,7 +1178,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
11781178
dest--;
11791179
*dest = buffer[i];
11801180
assert(opcode != _POP_JUMP_IF_FALSE && opcode != _POP_JUMP_IF_TRUE);
1181-
if (opcode == _SIDE_EXIT) {
1181+
if (opcode == _EXIT_TRACE) {
11821182
executor->exits[next_exit].target = buffer[i].target;
11831183
dest->exit_index = next_exit;
11841184
dest->format = UOP_FORMAT_EXIT;
@@ -1398,14 +1398,13 @@ counter_optimize(
13981398
return 0;
13991399
}
14001400
_Py_CODEUNIT *target = instr + 1 + _PyOpcode_Caches[JUMP_BACKWARD] - oparg;
1401-
_PyUOpInstruction buffer[5] = {
1402-
{ .opcode = _START_EXECUTOR, .jump_target = 4, .format=UOP_FORMAT_JUMP },
1401+
_PyUOpInstruction buffer[4] = {
1402+
{ .opcode = _START_EXECUTOR, .jump_target = 3, .format=UOP_FORMAT_JUMP },
14031403
{ .opcode = _LOAD_CONST_INLINE_BORROW, .operand = (uintptr_t)self },
14041404
{ .opcode = _INTERNAL_INCREMENT_OPT_COUNTER },
1405-
{ .opcode = _EXIT_TRACE, .jump_target = 4, .format=UOP_FORMAT_JUMP },
1406-
{ .opcode = _SIDE_EXIT, .target = (uint32_t)(target - _PyCode_CODE(code)), .format=UOP_FORMAT_TARGET }
1405+
{ .opcode = _EXIT_TRACE, .target = (uint32_t)(target - _PyCode_CODE(code)), .format=UOP_FORMAT_TARGET }
14071406
};
1408-
_PyExecutorObject *executor = make_executor_from_uops(buffer, 5, &EMPTY_FILTER);
1407+
_PyExecutorObject *executor = make_executor_from_uops(buffer, 4, &EMPTY_FILTER);
14091408
if (executor == NULL) {
14101409
return -1;
14111410
}

Python/optimizer_cases.c.h

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)