File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -2557,8 +2557,30 @@ def testfunc(n):
25572557 self .assertIsNotNone (ex )
25582558 uops = get_opnames (ex )
25592559 self .assertIn ("_POP_TOP_NOP" , uops )
2560+ self .assertIn ("_PUSH_FRAME" , uops )
2561+ self .assertLessEqual (len (matching_opnames (ex , "_POP_TOP" )), 1 )
2562+
2563+ def test_store_fast_refcount_elimination_when_uninitialized (self ):
2564+ def foo ():
2565+ # Since y is known to be
2566+ # uninitialized (NULL) here,
2567+ # The refcount is eliminated in the STORE_FAST.
2568+ y = 2
2569+ return y
2570+ def testfunc (n ):
2571+ # The STORE_FAST for the range here needs a POP_TOP
2572+ # (for now, until we do loop peeling).
2573+ for _ in range (n ):
2574+ foo ()
2575+
2576+ res , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
2577+ self .assertIsNotNone (ex )
2578+ uops = get_opnames (ex )
2579+ self .assertIn ("_POP_TOP_NOP" , uops )
2580+ self .assertIn ("_PUSH_FRAME" , uops )
25602581 self .assertLessEqual (len (matching_opnames (ex , "_POP_TOP" )), 1 )
25612582
2583+
25622584 def test_float_op_refcount_elimination (self ):
25632585 def testfunc (args ):
25642586 a , b , n = args
Original file line number Diff line number Diff line change @@ -846,8 +846,12 @@ _Py_uop_frame_new(
846846 frame -> locals [i ] = args [i ];
847847 }
848848
849+ // If the args are known, then it's safe to just initialize
850+ // every other non-set local to null symbol.
851+ bool default_null = args != NULL ;
852+
849853 for (int i = arg_len ; i < co -> co_nlocalsplus ; i ++ ) {
850- JitOptRef local = _Py_uop_sym_new_unknown (ctx );
854+ JitOptRef local = default_null ? _Py_uop_sym_new_null ( ctx ) : _Py_uop_sym_new_unknown (ctx );
851855 frame -> locals [i ] = local ;
852856 }
853857
You can’t perform that action at this time.
0 commit comments