@@ -1290,21 +1290,7 @@ def testfunc(n):
12901290 self .assertIsNotNone (ex )
12911291 self .assertIn ("_RETURN_GENERATOR" , get_opnames (ex ))
12921292
1293- def test_make_heap_safe_optimized (self ):
1294- def returns_owned (x ):
1295- return x + 1
1296- def testfunc (n ):
1297- a = 0
1298- for _ in range (n ):
1299- a = returns_owned (a )
1300- return a
1301- res , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
1302- self .assertEqual (res , TIER2_THRESHOLD )
1303- self .assertIsNotNone (ex )
1304- uops = get_opnames (ex )
1305- self .assertNotIn ("_MAKE_HEAP_SAFE" , uops )
1306- self .assertIn ("_RETURN_VALUE" , uops )
1307-
1293+ def test_make_heap_safe_optimized_immortal (self ):
13081294 def returns_immortal ():
13091295 return None
13101296 def testfunc (n ):
@@ -1319,12 +1305,12 @@ def testfunc(n):
13191305 self .assertNotIn ("_MAKE_HEAP_SAFE" , uops )
13201306 self .assertIn ("_RETURN_VALUE" , uops )
13211307
1322- def test_make_heap_safe_yield_correctness (self ):
1308+ def test_make_heap_safe_optimized_yield (self ):
13231309 def gen (n ):
1324- for i in range (n ):
1325- yield i + i
1310+ for _ in range (n ):
1311+ yield 1
13261312 def testfunc (n ):
1327- for x in gen (n ):
1313+ for _ in gen (n ):
13281314 pass
13291315 testfunc (TIER2_THRESHOLD * 2 )
13301316 gen_ex = get_first_executor (gen )
@@ -1333,6 +1319,21 @@ def testfunc(n):
13331319 self .assertNotIn ("_MAKE_HEAP_SAFE" , uops )
13341320 self .assertIn ("_YIELD_VALUE" , uops )
13351321
1322+ def test_make_heap_safe_not_optimized_for_owned (self ):
1323+ def returns_owned (x ):
1324+ return x + 1
1325+ def testfunc (n ):
1326+ a = 0
1327+ for _ in range (n ):
1328+ a = returns_owned (a )
1329+ return a
1330+ res , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
1331+ self .assertEqual (res , TIER2_THRESHOLD )
1332+ self .assertIsNotNone (ex )
1333+ uops = get_opnames (ex )
1334+ self .assertIn ("_MAKE_HEAP_SAFE" , uops )
1335+ self .assertIn ("_RETURN_VALUE" , uops )
1336+
13361337 def test_for_iter (self ):
13371338 def testfunc (n ):
13381339 t = 0
0 commit comments