8000 Move `_EXIT_TRACE` logic to a separate label · python/cpython@fdf1a2f · GitHub
[go: up one dir, main page]

Skip to content

Commit fdf1a2f

Browse files
committed
Move _EXIT_TRACE logic to a separate label
Using `GOTO_TIER_ONE()` macro. This should make things simpler for Justin.
1 parent e02409d commit fdf1a2f

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4024,10 +4024,7 @@ dummy_func(
40244024

40254025
op(_EXIT_TRACE, (--)) {
40264026
TIER_TWO_ONLY
4027-
_PyFrame_SetStackPointer(frame, stack_pointer);
4028-
Py_DECREF(current_executor);
4029-
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
4030-
goto enter_tier_one;
4027+
GOTO_TIER_ONE();
40314028
}
40324029

40334030
op(_INSERT, (unused[oparg], top -- top, unused[oparg])) {

Python/ceval.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,13 +1027,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10271027
}
10281028
}
10291029

1030+
// Jump here from ERROR_IF(..., unbound_local_error)
10301031
unbound_local_error_tier_two:
10311032
_PyEval_FormatExcCheckArg(tstate, PyExc_UnboundLocalError,
10321033
UNBOUNDLOCAL_ERROR_MSG,
10331034
PyTuple_GetItem(_PyFrame_GetCode(frame)->co_localsplusnames, oparg)
10341035
);
10351036
goto error_tier_two;
10361037

1038+
// JUMP to any of these from ERROR_IF(..., error)
10371039
pop_4_error_tier_two:
10381040
STACK_SHRINK(1);
10391041
pop_3_error_tier_two:
@@ -1050,6 +1052,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10501052
Py_DECREF(current_executor);
10511053
goto resume_with_error;
10521054

1055+
// Jump here from DEOPT_IF()
10531056
deoptimize:
10541057
// On DEOPT_IF we just repeat the last instruction.
10551058
// This presumes nothing was popped from the stack (nor pushed).
@@ -1058,10 +1061,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10581061
frame->return_offset = 0; // Dispatch to frame->instr_ptr
10591062
_PyFrame_SetStackPointer(frame, stack_pointer);
10601063
Py_DECREF(current_executor);
1064+
// Fall through
1065+
// Jump here from ENTER_EXECUTOR
10611066
enter_tier_one:
10621067
next_instr = frame->instr_ptr;
10631068
goto resume_frame;
10641069

1070+
// Jump here from _EXIT_TRACE
1071+
exit_trace:
1072+
_PyFrame_SetStackPointer(frame, stack_pointer);
1073+
Py_DECREF(current_executor);
1074+
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
1075+
goto enter_tier_one;
10651076
}
10661077
#if defined(__GNUC__)
10671078
# pragma GCC diagnostic pop

Python/ceval_macros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,5 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
395395
/* Tier-switching macros. */
396396

397397
#define GOTO_TIER_TWO() goto enter_tier_two;
398+
399+
#define GOTO_TIER_ONE() goto exit_trace;

Python/executor_cases.c.h

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0