@@ -131,15 +131,21 @@ def _blocks(self) -> typing.Generator[_Block, None, None]:
131131
132132 def _body (self ) -> str :
133133 lines = []
134+ hot = True
134135 for block in self ._blocks ():
136+ if hot != block .hot :
137+ hot = block .hot
138+ lines .append (f"# JIT: { 'HOT' if hot else 'COLD' } " .ljust (80 , "#" ))
135139 lines .extend (block .noise )
136140 lines .extend (block .instructions )
137141 return "\n " .join (lines )
138142
139143 def _predecessors (self , block : _Block ) -> typing .Generator [_Block , None , None ]:
140- for block in self ._blocks ():
141- if block .target is block or (block .fallthrough and block .link is block ):
142- yield block
144+ for predecessor in self ._blocks ():
145+ if predecessor .target is block or (
146+ predecessor .fallthrough and predecessor .link is block
147+ ):
148+ yield predecessor
143149
144150 def _insert_continue_label (self ) -> None :
145151 for end in reversed (list (self ._blocks ())):
@@ -153,7 +159,7 @@ def _insert_continue_label(self) -> None:
153159 end .link , align .link , continuation .link = align , continuation , end .link
154160
155161 def _mark_hot_blocks (self ) -> None :
156- todo = [ self . _lookup_label ( f" { self .prefix } _JIT_CONTINUE" ) ]
162+ todo = list ( self ._blocks ())[ - 1 : ]
157163 while todo :
158164 block = todo .pop ()
159165 block .hot = True
@@ -227,7 +233,6 @@ class OptimizerAArch64(Optimizer):
227233
228234
229235class OptimizerX86 (Optimizer ):
230-
231236 _branches = _X86_BRANCHES
232237 _re_branch = re .compile (
233238 rf"\s*(?P<instruction>{ '|' .join (_X86_BRANCHES )} )\s+(?P<target>[\w.]+)"
@@ -237,7 +242,6 @@ class OptimizerX86(Optimizer):
237242
238243
239244class OptimizerX86Windows (OptimizerX86 ):
240-
241245 def _preprocess (self , text : str ) -> str :
242246 text = super ()._preprocess (text )
243247 # rex64 jumpq *__imp__JIT_CONTINUE(%rip) -> jmp _JIT_CONTINUE
0 commit comments