@@ -19,12 +19,16 @@ class HoleValue(enum.Enum):
1919 CODE = enum .auto ()
2020 # The base address of the read-only data for this uop:
2121 DATA = enum .auto ()
22+ # The base address of the machine code for the error jump target (exposed as _JIT_ERROR_TARGET):
23+ ERROR_TARGET = enum .auto ()
2224 # The address of the current executor (exposed as _JIT_EXECUTOR):
2325 EXECUTOR = enum .auto ()
2426 # The base address of the "global" offset table located in the read-only data.
2527 # Shouldn't be present in the final stencils, since these are all replaced with
2628 # equivalent DATA values:
2729 GOT = enum .auto ()
30+ # The base address of the machine code for the jump target (exposed as _JIT_JUMP_TARGET):
31+ JUMP_TARGET = enum .auto ()
2832 # The current uop's oparg (exposed as _JIT_OPARG):
2933 OPARG = enum .auto ()
3034 # The current uop's operand0 on 64-bit platforms (exposed as _JIT_OPERAND0):
@@ -39,10 +43,9 @@ class HoleValue(enum.Enum):
3943 OPERAND1_LO = enum .auto ()
4044 # The current uop's target (exposed as _JIT_TARGET):
4145 TARGET = enum .auto ()
42- # The base address of the machine code for the jump target (exposed as _JIT_JUMP_TARGET):
43- JUMP_TARGET = enum .auto ()
44- # The base address of the machine code for the error jump target (exposed as _JIT_ERROR_TARGET):
45- ERROR_TARGET = enum .auto ()
46+ # Writable data, which we don't support! Optimistically remove their data
47+ # from the stencil, and raise later if they're actually used:
48+ WRITABLE = enum .auto ()
4649 # A hardcoded value of zero (used for symbol lookups):
4750 ZERO = enum .auto ()
4851
@@ -96,9 +99,11 @@ class HoleValue(enum.Enum):
9699_HOLE_EXPRS = {
97100 HoleValue .CODE : "(uintptr_t)code" ,
98101 HoleValue .DATA : "(uintptr_t)data" ,
102+ HoleValue .ERROR_TARGET : "state->instruction_starts[instruction->error_target]" ,
99103 HoleValue .EXECUTOR : "(uintptr_t)executor" ,
100104 # These should all have been turned into DATA values by process_relocations:
101105 # HoleValue.GOT: "",
106+ HoleValue .JUMP_TARGET : "state->instruction_starts[instruction->jump_target]" ,
102107 HoleValue .OPARG : "instruction->oparg" ,
103108 HoleValue .OPERAND0 : "instruction->operand0" ,
104109 HoleValue .OPERAND0_HI : "(instruction->operand0 >> 32)" ,
@@ -107,8 +112,8 @@ class HoleValue(enum.Enum):
107112 HoleValue .OPERAND1_HI : "(instruction->operand1 >> 32)" ,
108113 HoleValue .OPERAND1_LO : "(instruction->operand1 & UINT32_MAX)" ,
109114 HoleValue .TARGET : "instruction->target" ,
110- HoleValue . JUMP_TARGET : "state->instruction_starts[instruction->jump_target]" ,
111- HoleValue .ERROR_TARGET : "state->instruction_starts[instruction->error_target] " ,
115+ # These should all have raised an error if they were actually used:
116+ # HoleValue.WRITABLE : "",
112117 HoleValue .ZERO : "" ,
113118}
114119
@@ -246,6 +251,12 @@ def process_relocations(self, known_symbols: dict[str, int]) -> None:
246251 self .data .pad (8 )
247252 for stencil in [self .code , self .data ]:
248253 for hole in stencil .holes :
254+ if hole .symbol in self .symbols :
255+ value , _ = self .symbols [hole .symbol ]
256+ if value is HoleValue .WRITABLE :
257+ raise ValueError (
258+ f"Writable data ({ hole .symbol } ) is not supported!"
259+ )
249260 if hole .value is HoleValue .GOT :
250261 assert hole .symbol is not None
251262 hole .value = HoleValue .DATA
0 commit comments