@@ -43,13 +43,13 @@ def get_first_executor(func):
4343def get_all_executors (func ):
4444 code = func .__code__
4545 co_code = code .co_code
46- execs = []
46+ executors = []
4747 for i in range (0 , len (co_code ), 2 ):
4848 try :
49- execs .append (_opcode .get_executor (code , i ))
49+ executors .append (_opcode .get_executor (code , i ))
5050 except ValueError :
5151 pass
52- return execs
52+ return executors
5353
5454
5555def iter_opnames (ex ):
@@ -2647,10 +2647,23 @@ def f():
26472647 z = x + y
26482648
26492649 f ()
2650+ all_executors = get_all_executors (f )
26502651 # Inner loop warms up first.
26512652 # Outer loop warms up later, linking to the inner one.
2652- # Therefore, at least two executors.
2653- self .assertGreaterEqual (len (get_all_executors (f )), 2 )
2653+ # Therefore, we have at least two executors.
2654+ self .assertGreaterEqual (len (all_executors ), 2 )
2655+ for executor in all_executors :
2656+ opnames = list (get_opnames (executor ))
2657+ # Assert all executors first terminator ends in
2658+ # _JUMP_TO_TOP or _EXIT_TRACE, not _DEOPT
2659+ for idx , op in enumerate (opnames ):
2660+ if op == "_EXIT_TRACE" or op == "_JUMP_TO_TOP" :
2661+ break
2662+ elif op == "_DEOPT" :
2663+ self .fail (f"_DEOPT encountered first at executor"
2664+ f" { executor } at offset { idx } rather"
2665+ f" than expected _EXIT_TRACE" )
2666+
26542667
26552668
26562669def global_identity (x ):
0 commit comments