mirror of
https://github.com/python/cpython.git
synced 2025-10-29 12:44:56 +00:00
GH-109214: Convert _SAVE_CURRENT_IP to _SET_IP in tier 2 trace creation. (GH-110755)
This commit is contained in:
parent
fb7843ee89
commit
19b7ead5eb
8 changed files with 22 additions and 59 deletions
4
Python/abstract_interp_cases.c.h
generated
4
Python/abstract_interp_cases.c.h
generated
|
|
@ -920,10 +920,6 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _SAVE_CURRENT_IP: {
|
||||
break;
|
||||
}
|
||||
|
||||
case _EXIT_TRACE: {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -803,7 +803,6 @@ dummy_func(
|
|||
}
|
||||
|
||||
macro(RETURN_VALUE) =
|
||||
_SET_IP + // Tier 2 only; special-cased oparg
|
||||
_SAVE_CURRENT_IP + // Sets frame->prev_instr
|
||||
_POP_FRAME;
|
||||
|
||||
|
|
@ -828,7 +827,6 @@ dummy_func(
|
|||
|
||||
macro(RETURN_CONST) =
|
||||
LOAD_CONST +
|
||||
_SET_IP + // Tier 2 only; special-cased oparg
|
||||
_SAVE_CURRENT_IP + // Sets frame->prev_instr
|
||||
_POP_FRAME;
|
||||
|
||||
|
|
@ -3099,7 +3097,6 @@ dummy_func(
|
|||
_CHECK_FUNCTION_EXACT_ARGS +
|
||||
_CHECK_STACK_SPACE +
|
||||
_INIT_CALL_PY_EXACT_ARGS +
|
||||
_SET_IP + // Tier 2 only; special-cased oparg
|
||||
_SAVE_CURRENT_IP + // Sets frame->prev_instr
|
||||
_PUSH_FRAME;
|
||||
|
||||
|
|
@ -3109,7 +3106,6 @@ dummy_func(
|
|||
_CHECK_FUNCTION_EXACT_ARGS +
|
||||
_CHECK_STACK_SPACE +
|
||||
_INIT_CALL_PY_EXACT_ARGS +
|
||||
_SET_IP + // Tier 2 only; special-cased oparg
|
||||
_SAVE_CURRENT_IP + // Sets frame->prev_instr
|
||||
_PUSH_FRAME;
|
||||
|
||||
|
|
@ -3948,17 +3944,13 @@ dummy_func(
|
|||
}
|
||||
|
||||
op(_SET_IP, (--)) {
|
||||
TIER_TWO_ONLY
|
||||
frame->prev_instr = ip_offset + oparg;
|
||||
}
|
||||
|
||||
op(_SAVE_CURRENT_IP, (--)) {
|
||||
#if TIER_ONE
|
||||
TIER_ONE_ONLY
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
}
|
||||
|
||||
op(_EXIT_TRACE, (--)) {
|
||||
|
|
|
|||
|
|
@ -372,6 +372,9 @@ static inline void _Py_LeaveRecursiveCallPy(PyThreadState *tstate) {
|
|||
/* Marker to specify tier 1 only instructions */
|
||||
#define TIER_ONE_ONLY
|
||||
|
||||
/* Marker to specify tier 2 only instructions */
|
||||
#define TIER_TWO_ONLY
|
||||
|
||||
/* Implementation of "macros" that modify the instruction pointer,
|
||||
* stack pointer, or frame pointer.
|
||||
* These need to treated differently by tier 1 and 2. */
|
||||
|
|
|
|||
12
Python/executor_cases.c.h
generated
12
Python/executor_cases.c.h
generated
|
|
@ -3270,21 +3270,11 @@
|
|||
}
|
||||
|
||||
case _SET_IP: {
|
||||
TIER_TWO_ONLY
|
||||
frame->prev_instr = ip_offset + oparg;
|
||||
break;
|
||||
}
|
||||
|
||||
case _SAVE_CURRENT_IP: {
|
||||
#if TIER_ONE
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case _EXIT_TRACE: {
|
||||
frame->prev_instr--; // Back up to just before destination
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
|
|
|
|||
28
Python/generated_cases.c.h
generated
28
Python/generated_cases.c.h
generated
|
|
@ -989,13 +989,8 @@
|
|||
PyObject *retval;
|
||||
// _SAVE_CURRENT_IP
|
||||
{
|
||||
#if TIER_ONE
|
||||
TIER_ONE_ONLY
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
}
|
||||
// _POP_FRAME
|
||||
retval = stack_pointer[-1];
|
||||
|
|
@ -1056,13 +1051,8 @@
|
|||
}
|
||||
// _SAVE_CURRENT_IP
|
||||
{
|
||||
#if TIER_ONE
|
||||
TIER_ONE_ONLY
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
}
|
||||
// _POP_FRAME
|
||||
retval = value;
|
||||
|
|
@ -3941,13 +3931,8 @@
|
|||
// _SAVE_CURRENT_IP
|
||||
next_instr += 3;
|
||||
{
|
||||
#if TIER_ONE
|
||||
TIER_ONE_ONLY
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
}
|
||||
// _PUSH_FRAME
|
||||
STACK_SHRINK(oparg);
|
||||
|
|
@ -4019,13 +4004,8 @@
|
|||
// _SAVE_CURRENT_IP
|
||||
next_instr += 3;
|
||||
{
|
||||
#if TIER_ONE
|
||||
TIER_ONE_ONLY
|
||||
frame->prev_instr = next_instr - 1;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
// Relies on a preceding _SET_IP
|
||||
frame->prev_instr--;
|
||||
#endif
|
||||
}
|
||||
// _PUSH_FRAME
|
||||
STACK_SHRINK(oparg);
|
||||
|
|
|
|||
|
|
@ -648,6 +648,7 @@ translate_bytecode_to_trace(
|
|||
uint32_t orig_oparg = oparg; // For OPARG_TOP/BOTTOM
|
||||
for (int i = 0; i < nuops; i++) {
|
||||
oparg = orig_oparg;
|
||||
uint32_t uop = expansion->uops[i].uop;
|
||||
uint64_t operand = 0;
|
||||
// Add one to account for the actual opcode/oparg pair:
|
||||
int offset = expansion->uops[i].offset + 1;
|
||||
|
|
@ -680,6 +681,7 @@ translate_bytecode_to_trace(
|
|||
break;
|
||||
case OPARG_SET_IP: // op==_SET_IP; oparg=next instr
|
||||
oparg = INSTR_IP(instr + offset, code);
|
||||
uop = _SET_IP;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -690,8 +692,8 @@ translate_bytecode_to_trace(
|
|||
expansion->uops[i].offset);
|
||||
Py_FatalError("garbled expansion");
|
||||
}
|
||||
ADD_TO_TRACE(expansion->uops[i].uop, oparg, operand);
|
||||
if (expansion->uops[i].uop == _POP_FRAME) {
|
||||
ADD_TO_TRACE(uop, oparg, operand);
|
||||
if (uop == _POP_FRAME) {
|
||||
TRACE_STACK_POP();
|
||||
DPRINTF(2,
|
||||
"Returning to %s (%s:%d) at byte offset %d\n",
|
||||
|
|
@ -701,7 +703,7 @@ translate_bytecode_to_trace(
|
|||
2 * INSTR_IP(instr, code));
|
||||
goto top;
|
||||
}
|
||||
if (expansion->uops[i].uop == _PUSH_FRAME) {
|
||||
if (uop == _PUSH_FRAME) {
|
||||
assert(i + 1 == nuops);
|
||||
int func_version_offset =
|
||||
offsetof(_PyCallCache, func_version)/sizeof(_Py_CODEUNIT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue