@@ -106,8 +106,9 @@ class Emitter:
106106 out : CWriter
107107 labels : dict [str , Label ]
108108 _replacers : dict [str , ReplacementFunctionType ]
109+ cannot_escape : bool
109110
110- def __init__ (self , out : CWriter , labels : dict [str , Label ]):
111+ def __init__ (self , out : CWriter , labels : dict [str , Label ], cannot_escape : bool = False ):
111112 self ._replacers = {
112113 "EXIT_IF" : self .exit_if ,
113114 "DEOPT_IF" : self .deopt_if ,
@@ -127,6 +128,7 @@ def __init__(self, out: CWriter, labels: dict[str, Label]):
127128 }
128129 self .out = out
129130 self .labels = labels
131+ self .cannot_escape = cannot_escape
130132
131133 def dispatch (
132134 self ,
@@ -238,7 +240,8 @@ def decref_inputs(
238240 next (tkn_iter )
239241 self ._print_storage ("DECREF_INPUTS" , storage )
240242 try :
241- storage .close_inputs (self .out )
243+ if not self .cannot_escape :
244+ storage .close_inputs (self .out )
242245 except StackError as ex :
243246 raise analysis_error (ex .args [0 ], tkn )
244247 except Exception as ex :
@@ -476,7 +479,7 @@ def emit_SimpleStmt(
476479 reachable = True
477480 tkn = stmt .contents [- 1 ]
478481 try :
479- if stmt in uop .properties .escaping_calls :
482+ if stmt in uop .properties .escaping_calls and not self . cannot_escape :
480483 escape = uop .properties .escaping_calls [stmt ]
481484 if escape .kills is not None :
482485 self .stackref_kill (escape .kills , storage , True )
@@ -513,7 +516,7 @@ def emit_SimpleStmt(
513516 self .out .emit (tkn )
514517 else :
515518 self .out .emit (tkn )
516- if stmt in uop .properties .escaping_calls :
519+ if stmt in uop .properties .escaping_calls and not self . cannot_escape :
517520 self .emit_reload (storage )
518521 return reachable , None , storage
519522 except StackError as ex :
0 commit comments