@@ -60,6 +60,13 @@ def iter_opnames(ex):
6060def get_opnames (ex ):
6161 return list (iter_opnames (ex ))
6262
63+ def iter_ops (ex ):
64+ for item in ex :
65+ yield item
66+
67+ def get_ops (ex ):
68+ return list (iter_ops (ex ))
69+
6370
6471@requires_specialization
6572@unittest .skipIf (Py_GIL_DISABLED , "optimizer not yet supported in free-threaded builds" )
@@ -3003,14 +3010,22 @@ def f():
30033010 # Outer loop warms up later, linking to the inner one.
30043011 # Therefore, we have at least two executors.
30053012 self .assertGreaterEqual (len (all_executors ), 2 )
3013+ executor_ids = [id (e ) for e in all_executors ]
30063014 for executor in all_executors :
3007- opnames = list (get_opnames (executor ))
3015+ ops = list (get_ops (executor ))
30083016 # Assert all executors first terminator ends in
30093017 # _EXIT_TRACE or _JUMP_TO_TOP, not _DEOPT
3010- for idx , op in enumerate (opnames ):
3011- if op == "_EXIT_TRACE" or op == "_JUMP_TO_TOP" :
3018+ for idx , op in enumerate (ops ):
3019+ opname = op [0 ]
3020+ if opname == "_EXIT_TRACE" :
3021+ # All executors exits should point to another valid executor
3022+ exit = op [3 ]
3023+ link_to = _testinternalcapi .get_exit_executor (exit )
3024+ self .assertIn (id (link_to ), executor_ids )
3025+ break
3026+ elif opname == "_JUMP_TO_TOP" :
30123027 break
3013- elif op == "_DEOPT" :
3028+ elif opname == "_DEOPT" :
30143029 self .fail (f"_DEOPT encountered first at executor"
30153030 f" { executor } at offset { idx } rather"
30163031 f" than expected _EXIT_TRACE" )
0 commit comments