@@ -230,7 +230,8 @@ def __init__(self, inst: parser.InstDef):
230
230
self .kind = inst .kind
231
231
self .name = inst .name
232
232
self .block = inst .block
233
- self .block_text , self .predictions = extract_block_text (self .block )
233
+ self .block_text , self .check_eval_breaker , self .predictions = \
234
+ extract_block_text (self .block )
234
235
self .always_exits = always_exits (self .block_text )
235
236
self .cache_effects = [
236
237
effect for effect in inst .inputs if isinstance (effect , parser .CacheEffect )
@@ -1016,6 +1017,8 @@ def write_instr(self, instr: Instruction) -> None:
1016
1017
if not instr .always_exits :
1017
1018
for prediction in instr .predictions :
1018
1019
self .out .emit (f"PREDICT({ prediction } );" )
1020
+ if instr .check_eval_breaker :
1021
+ self .out .emit ("CHECK_EVAL_BREAKER();" )
1019
1022
self .out .emit (f"DISPATCH();" )
1020
1023
1021
1024
def write_super (self , sup : SuperInstruction ) -> None :
@@ -1091,7 +1094,7 @@ def wrap_super_or_macro(self, up: SuperOrMacroInstruction):
1091
1094
self .out .emit (f"DISPATCH();" )
1092
1095
1093
1096
1094
- def extract_block_text (block : parser .Block ) -> tuple [list [str ], list [str ]]:
1097
+ def extract_block_text (block : parser .Block ) -> tuple [list [str ], bool , list [str ]]:
1095
1098
# Get lines of text with proper dedent
1096
1099
blocklines = block .text .splitlines (True )
1097
1100
@@ -1111,6 +1114,12 @@ def extract_block_text(block: parser.Block) -> tuple[list[str], list[str]]:
1111
1114
while blocklines and not blocklines [- 1 ].strip ():
1112
1115
blocklines .pop ()
1113
1116
1117
+ # Separate CHECK_EVAL_BREAKER() macro from end
1118
+ check_eval_breaker = \
1119
+ blocklines != [] and blocklines [- 1 ].strip () == "CHECK_EVAL_BREAKER();"
1120
+ if check_eval_breaker :
1121
+ del blocklines [- 1 ]
1122
+
1114
1123
# Separate PREDICT(...) macros from end
1115
1124
predictions : list [str ] = []
1116
1125
while blocklines and (
@@ -1119,7 +1128,7 @@ def extract_block_text(block: parser.Block) -> tuple[list[str], list[str]]:
1119
1128
predictions .insert (0 , m .group (1 ))
1120
1129
blocklines .pop ()
1121
1130
1122
- return blocklines , predictions
1131
+ return blocklines , check_eval_breaker , predictions
1123
1132
1124
1133
1125
1134
def always_exits (lines : list [str ]) -> bool :
0 commit comments