29
29
BEGIN_MARKER = "// BEGIN BYTECODES //"
30
30
END_MARKER = "// END BYTECODES //"
31
31
RE_PREDICTED = (
32
- r"^\s*(?:PREDICT\(| GO_TO_INSTRUCTION\(|DEOPT_IF\(.*?,\s*)(\w+)\);\s*(?://.*)?$"
32
+ r"^\s*(?:GO_TO_INSTRUCTION\(|DEOPT_IF\(.*?,\s*)(\w+)\);\s*(?://.*)?$"
33
33
)
34
34
UNUSED = "unused"
35
35
BITS_PER_CODE_UNIT = 16
@@ -234,7 +234,6 @@ class Instruction:
234
234
name : str
235
235
block : parser .Block
236
236
block_text : list [str ] # Block.text, less curlies, less PREDICT() calls
237
- predictions : list [str ] # Prediction targets (instruction names)
238
237
block_line : int # First line of block in original code
239
238
240
239
# Computed by constructor
@@ -255,7 +254,7 @@ def __init__(self, inst: parser.InstDef):
255
254
self .kind = inst .kind
256
255
self .name = inst .name
257
256
self .block = inst .block
258
- self .block_text , self .check_eval_breaker , self .predictions , self . block_line = \
257
+ self .block_text , self .check_eval_breaker , self .block_line = \
259
258
extract_block_text (self .block )
260
259
self .always_exits = always_exits (self .block_text )
261
260
self .cache_effects = [
@@ -642,7 +641,7 @@ def analyze(self) -> None:
642
641
def find_predictions (self ) -> None :
643
642
"""Find the instructions that need PREDICTED() labels."""
644
643
for instr in self .instrs .values ():
645
- targets = set (instr . predictions )
644
+ targets = set ()
646
645
for line in instr .block_text :
647
646
if m := re .match (RE_PREDICTED , line ):
648
647
targets .add (m .group (1 ))
@@ -1117,8 +1116,6 @@ def write_instr(self, instr: Instruction) -> None:
1117
1116
self .out .emit (f"PREDICTED({ name } );" )
1118
1117
instr .write (self .out )
1119
1118
if not instr .always_exits :
1120
- for prediction in instr .predictions :
1121
- self .out .emit (f"PREDICT({ prediction } );" )
1122
1119
if instr .check_eval_breaker :
1123
1120
self .out .emit ("CHECK_EVAL_BREAKER();" )
1124
1121
self .out .emit (f"DISPATCH();" )
@@ -1195,7 +1192,7 @@ def wrap_super_or_macro(self, up: SuperOrMacroInstruction):
1195
1192
self .out .emit (f"DISPATCH();" )
1196
1193
1197
1194
1198
- def extract_block_text (block : parser .Block ) -> tuple [list [str ], bool , list [ str ], int ]:
1195
+ def extract_block_text (block : parser .Block ) -> tuple [list [str ], bool , int ]:
1199
1196
# Get lines of text with proper dedent
1200
1197
blocklines = block .text .splitlines (True )
1201
1198
first_token : lx .Token = block .tokens [0 ] # IndexError means the context is broken
@@ -1225,15 +1222,7 @@ def extract_block_text(block: parser.Block) -> tuple[list[str], bool, list[str],
1225
1222
if check_eval_breaker :
1226
1223
del blocklines [- 1 ]
1227
1224
1228
- # Separate PREDICT(...) macros from end
1229
- predictions : list [str ] = []
1230
- while blocklines and (
1231
- m := re .match (r"^\s*PREDICT\((\w+)\);\s*(?://.*)?$" , blocklines [- 1 ])
1232
- ):
1233
- predictions .insert (0 , m .group (1 ))
1234
- blocklines .pop ()
1235
-
1236
- return blocklines , check_eval_breaker , predictions , block_line
1225
+ return blocklines , check_eval_breaker , block_line
1237
1226
1238
1227
1239
1228
def always_exits (lines : list [str ]) -> bool :
0 commit comments