@@ -19,12 +19,16 @@ class HoleValue(enum.Enum):
19
19
CODE = enum .auto ()
20
20
# The base address of the read-only data for this uop:
21
21
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 ()
22
24
# The address of the current executor (exposed as _JIT_EXECUTOR):
23
25
EXECUTOR = enum .auto ()
24
26
# The base address of the "global" offset table located in the read-only data.
25
27
# Shouldn't be present in the final stencils, since these are all replaced with
26
28
# equivalent DATA values:
27
29
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 ()
28
32
# The current uop's oparg (exposed as _JIT_OPARG):
29
33
OPARG = enum .auto ()
30
34
# The current uop's operand0 on 64-bit platforms (exposed as _JIT_OPERAND0):
@@ -39,10 +43,9 @@ class HoleValue(enum.Enum):
39
43
OPERAND1_LO = enum .auto ()
40
44
# The current uop's target (exposed as _JIT_TARGET):
41
45
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 ()
46
49
# A hardcoded value of zero (used for symbol lookups):
47
50
ZERO = enum .auto ()
48
51
@@ -96,9 +99,11 @@ class HoleValue(enum.Enum):
96
99
_HOLE_EXPRS = {
97
100
HoleValue .CODE : "(uintptr_t)code" ,
98
101
HoleValue .DATA : "(uintptr_t)data" ,
102
+ HoleValue .ERROR_TARGET : "state->instruction_starts[instruction->error_target]" ,
99
103
HoleValue .EXECUTOR : "(uintptr_t)executor" ,
100
104
# These should all have been turned into DATA values by process_relocations:
101
105
# HoleValue.GOT: "",
106
+ HoleValue .JUMP_TARGET : "state->instruction_starts[instruction->jump_target]" ,
102
107
HoleValue .OPARG : "instruction->oparg" ,
103
108
HoleValue .OPERAND0 : "instruction->operand0" ,
104
109
HoleValue .OPERAND0_HI : "(instruction->operand0 >> 32)" ,
@@ -107,8 +112,8 @@ class HoleValue(enum.Enum):
107
112
HoleValue .OPERAND1_HI : "(instruction->operand1 >> 32)" ,
108
113
HoleValue .OPERAND1_LO : "(instruction->operand1 & UINT32_MAX)" ,
109
114
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 : "",
112
117
HoleValue .ZERO : "" ,
113
118
}
114
119
@@ -246,6 +251,12 @@ def process_relocations(self, known_symbols: dict[str, int]) -> None:
246
251
self .data .pad (8 )
247
252
for stencil in [self .code , self .data ]:
248
253
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
+ )
249
260
if hole .value is HoleValue .GOT :
250
261
assert hole .symbol is not None
251
262
hole .value = HoleValue .DATA
0 commit comments