Skip to content

GH-117062: Make _JUMP_TO_TOP a general absolute jump #120854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4149,9 +4149,7 @@ dummy_func(
}

op(_JUMP_TO_TOP, (--)) {
#ifndef _Py_JIT
next_uop = &current_executor->trace[1];
#endif
JUMP_TO_JUMP_TARGET();
}

tier2 op(_SET_IP, (instr_ptr/4 --)) {
Expand Down
4 changes: 1 addition & 3 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,11 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
buffer[i].jump_target = 0;
}
}
if (opcode == _JUMP_TO_TOP) {
assert(buffer[0].opcode == _START_EXECUTOR);
buffer[i].format = UOP_FORMAT_JUMP;
buffer[i].jump_target = 1;
}
}
return next_spare;
}
Expand Down
3 changes: 0 additions & 3 deletions Tools/jit/_stencils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class HoleValue(enum.Enum):
ERROR_TARGET = enum.auto()
# The index of the exit to be jumped through (exposed as _JIT_EXIT_INDEX):
EXIT_INDEX = enum.auto()
# The base address of the machine code for the first uop (exposed as _JIT_TOP):
TOP = enum.auto()
# A hardcoded value of zero (used for symbol lookups):
ZERO = enum.auto()

Expand Down Expand Up @@ -110,7 +108,6 @@ class HoleValue(enum.Enum):
HoleValue.JUMP_TARGET: "instruction_starts[instruction->jump_target]",
HoleValue.ERROR_TARGET: "instruction_starts[instruction->error_target]",
HoleValue.EXIT_INDEX: "instruction->exit_index",
HoleValue.TOP: "instruction_starts[1]",
HoleValue.ZERO: "",
}

Expand Down
3 changes: 0 additions & 3 deletions Tools/jit/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
UOP_STAT_INC(uopcode, execution_count);

// The actual instruction definitions (only one will be used):
if (uopcode == _JUMP_TO_TOP) {
PATCH_JUMP(_JIT_TOP);
}
switch (uopcode) {
#include "executor_cases.c.h"
default:
Expand Down
Loading