@@ -204,7 +204,7 @@ dummy_func(
204204 ptrdiff_t off = this_instr - _PyFrame_GetBytecode (frame );
205205 frame -> tlbc_index = ((_PyThreadStateImpl * )tstate )-> tlbc_index ;
206206 frame -> instr_ptr = bytecode + off ;
207- // Make sure this_instr gets reset correctley for any uops that
207+ // Make sure this_instr gets reset correctly for any uops that
208208 // follow
209209 next_instr = frame -> instr_ptr ;
210210 DISPATCH ();
@@ -1111,7 +1111,7 @@ dummy_func(
11111111 tstate -> current_frame = frame -> previous ;
11121112 assert (!_PyErr_Occurred (tstate ));
11131113 PyObject * result = PyStackRef_AsPyObjectSteal (retval );
1114- SYNC_SP (); /* Not strictly necessary, but prevents warnings */
1114+ LLTRACE_RESUME_FRAME ();
11151115 return result ;
11161116 }
11171117
@@ -1123,7 +1123,7 @@ dummy_func(
11231123 _PyStackRef temp = PyStackRef_MakeHeapSafe (retval );
11241124 DEAD (retval );
11251125 SAVE_STACK ();
1126- assert (EMPTY () );
1126+ assert (STACK_LEVEL () == 0 );
11271127 _Py_LeaveRecursiveCallPy (tstate );
11281128 // GH-99729: We need to unlink the frame *before* clearing it:
11291129 _PyInterpreterFrame * dying = frame ;
@@ -1223,8 +1223,9 @@ dummy_func(
12231223 {
12241224 PyGenObject * gen = (PyGenObject * )receiver_o ;
12251225 _PyInterpreterFrame * gen_frame = & gen -> gi_iframe ;
1226- STACK_SHRINK (1 );
12271226 _PyFrame_StackPush (gen_frame , PyStackRef_MakeHeapSafe (v ));
1227+ DEAD (v );
1228+ SYNC_SP ();
12281229 gen -> gi_frame_state = FRAME_EXECUTING ;
12291230 gen -> gi_exc_state .previous_item = tstate -> exc_info ;
12301231 tstate -> exc_info = & gen -> gi_exc_state ;
@@ -2436,10 +2437,10 @@ dummy_func(
24362437 PyObject * name = GETITEM (FRAME_CO_NAMES , oparg >> 1 );
24372438 _PyInterpreterFrame * new_frame = _PyFrame_PushUnchecked (
24382439 tstate , PyStackRef_FromPyObjectNew (f ), 2 , frame );
2439- // Manipulate stack directly because we exit with DISPATCH_INLINED().
2440- STACK_SHRINK (1 );
24412440 new_frame -> localsplus [0 ] = owner ;
24422441 DEAD (owner );
2442+ // Manipulate stack directly because we exit with DISPATCH_INLINED().
2443+ SYNC_SP ();
24432444 new_frame -> localsplus [1 ] = PyStackRef_FromPyObjectNew (name );
24442445 frame -> return_offset = INSTRUCTION_SIZE ;
24452446 DISPATCH_INLINED (new_frame );
@@ -3083,12 +3084,11 @@ dummy_func(
30833084 macro (FOR_ITER ) = _SPECIALIZE_FOR_ITER + _FOR_ITER ;
30843085
30853086
3086- inst (INSTRUMENTED_FOR_ITER , (unused /1 -- )) {
3087- _PyStackRef iter_stackref = TOP ();
3088- PyObject * iter = PyStackRef_AsPyObjectBorrow (iter_stackref );
3089- PyObject * next = (* Py_TYPE (iter )-> tp_iternext )(iter );
3090- if (next != NULL ) {
3091- PUSH (PyStackRef_FromPyObjectSteal (next ));
3087+ inst (INSTRUMENTED_FOR_ITER , (unused /1 , iter -- iter , next )) {
3088+ PyObject * iter_o = PyStackRef_AsPyObjectBorrow (iter );
3089+ PyObject * next_o = (* Py_TYPE (iter_o )-> tp_iternext )(iter_o );
3090+ if (next_o != NULL ) {
3091+ next = PyStackRef_FromPyObjectSteal (next_o );
30923092 INSTRUMENTED_JUMP (this_instr , next_instr , PY_MONITORING_EVENT_BRANCH_LEFT );
30933093 }
30943094 else {
@@ -3105,6 +3105,7 @@ dummy_func(
31053105 next_instr [oparg ].op .code == INSTRUMENTED_END_FOR );
31063106 /* Skip END_FOR */
31073107 JUMPBY (oparg + 1 );
3108+ DISPATCH ();
31083109 }
31093110 }
31103111
@@ -4022,7 +4023,6 @@ dummy_func(
40224023 _PUSH_FRAME ;
40234024
40244025 inst (EXIT_INIT_CHECK , (should_be_none -- )) {
4025- assert (STACK_LEVEL () == 2 );
40264026 if (!PyStackRef_IsNone (should_be_none )) {
40274027 PyErr_Format (PyExc_TypeError ,
40284028 "__init__() should return None, not '%.200s'" ,
@@ -4813,7 +4813,7 @@ dummy_func(
48134813 PyFunctionObject * func = (PyFunctionObject * )PyStackRef_AsPyObjectBorrow (frame -> f_funcobj );
48144814 PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (func );
48154815 ERROR_IF (gen == NULL , error );
4816- assert (EMPTY () );
4816+ assert (STACK_LEVEL () == 0 );
48174817 SAVE_STACK ();
48184818 _PyInterpreterFrame * gen_frame = & gen -> gi_iframe ;
48194819 frame -> instr_ptr ++ ;
@@ -4932,6 +4932,7 @@ dummy_func(
49324932 }
49334933 next_instr = frame -> instr_ptr ;
49344934 if (next_instr != this_instr ) {
4935+ SYNC_SP ();
49354936 DISPATCH ();
49364937 }
49374938 }
@@ -4976,46 +4977,48 @@ dummy_func(
49764977 _CHECK_PERIODIC +
49774978 _MONITOR_JUMP_BACKWARD ;
49784979
4979- inst (INSTRUMENTED_POP_JUMP_IF_TRUE , (unused /1 -- )) {
4980- _PyStackRef cond = POP ();
4980+ inst (INSTRUMENTED_POP_JUMP_IF_TRUE , (unused /1 , cond -- )) {
49814981 assert (PyStackRef_BoolCheck (cond ));
49824982 int jump = PyStackRef_IsTrue (cond );
4983+ DEAD (cond );
49834984 RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
49844985 if (jump ) {
49854986 INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
49864987 }
49874988 }
49884989
4989- inst (INSTRUMENTED_POP_JUMP_IF_FALSE , (unused /1 -- )) {
4990- _PyStackRef cond = POP ();
4990+ inst (INSTRUMENTED_POP_JUMP_IF_FALSE , (unused /1 , cond -- )) {
49914991 assert (PyStackRef_BoolCheck (cond ));
49924992 int jump = PyStackRef_IsFalse (cond );
4993+ DEAD (cond );
49934994 RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
49944995 if (jump ) {
49954996 INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
49964997 }
49974998 }
49984999
4999- inst (INSTRUMENTED_POP_JUMP_IF_NONE , (unused /1 -- )) {
5000- _PyStackRef value_stackref = POP ();
5001- int jump = PyStackRef_IsNone (value_stackref );
5000+ inst (INSTRUMENTED_POP_JUMP_IF_NONE , (unused /1 , value -- )) {
5001+ int jump = PyStackRef_IsNone (value );
50025002 RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
50035003 if (jump ) {
5004+ DEAD (value );
50045005 INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
50055006 }
50065007 else {
5007- PyStackRef_CLOSE (value_stackref );
5008+ PyStackRef_CLOSE (value );
50085009 }
50095010 }
50105011
5011- inst (INSTRUMENTED_POP_JUMP_IF_NOT_NONE , (unused /1 -- )) {
5012- _PyStackRef value_stackref = POP ();
5013- int jump = !PyStackRef_IsNone (value_stackref );
5012+ inst (INSTRUMENTED_POP_JUMP_IF_NOT_NONE , (unused /1 , value -- )) {
5013+ int jump = !PyStackRef_IsNone (value );
50145014 RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
50155015 if (jump ) {
5016- PyStackRef_CLOSE (value_stackref );
5016+ PyStackRef_CLOSE (value );
50175017 INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
50185018 }
5019+ else {
5020+ DEAD (value );
5021+ }
50195022 }
50205023
50215024 tier1 inst (EXTENDED_ARG , ( -- )) {
@@ -5219,22 +5222,26 @@ dummy_func(
52195222 }
52205223
52215224 label (pop_4_error ) {
5222- STACK_SHRINK (4 );
5225+ stack_pointer -= 4 ;
5226+ assert (WITHIN_STACK_BOUNDS ());
52235227 goto error ;
52245228 }
52255229
52265230 label (pop_3_error ) {
5227- STACK_SHRINK (3 );
5231+ stack_pointer -= 3 ;
5232+ assert (WITHIN_STACK_BOUNDS ());
52285233 goto error ;
52295234 }
52305235
52315236 label (pop_2_error ) {
5232- STACK_SHRINK (2 );
5237+ stack_pointer -= 2 ;
5238+ assert (WITHIN_STACK_BOUNDS ());
52335239 goto error ;
52345240 }
52355241
52365242 label (pop_1_error ) {
5237- STACK_SHRINK (1 );
5243+ stack_pointer -= 1 ;
5244+ assert (WITHIN_STACK_BOUNDS ());
52385245 goto error ;
52395246 }
52405247
0 commit comments