Skip to content

Commit

Permalink
pythonGH-117062: Make _JUMP_TO_TOP a general absolute jump (pythonGH-…
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher authored Jun 24, 2024
1 parent ce1064e commit a47abdb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
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

0 comments on commit a47abdb

Please sign in to comment.