@@ -204,7 +204,7 @@ dummy_func(
204
204
ptrdiff_t off = this_instr - _PyFrame_GetBytecode (frame );
205
205
frame -> tlbc_index = ((_PyThreadStateImpl * )tstate )-> tlbc_index ;
206
206
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
208
208
// follow
209
209
next_instr = frame -> instr_ptr ;
210
210
DISPATCH ();
@@ -1111,7 +1111,7 @@ dummy_func(
1111
1111
tstate -> current_frame = frame -> previous ;
1112
1112
assert (!_PyErr_Occurred (tstate ));
1113
1113
PyObject * result = PyStackRef_AsPyObjectSteal (retval );
1114
- SYNC_SP (); /* Not strictly necessary, but prevents warnings */
1114
+ LLTRACE_RESUME_FRAME ();
1115
1115
return result ;
1116
1116
}
1117
1117
@@ -1123,7 +1123,7 @@ dummy_func(
1123
1123
_PyStackRef temp = PyStackRef_MakeHeapSafe (retval );
1124
1124
DEAD (retval );
1125
1125
SAVE_STACK ();
1126
- assert (EMPTY () );
1126
+ assert (STACK_LEVEL () == 0 );
1127
1127
_Py_LeaveRecursiveCallPy (tstate );
1128
1128
// GH-99729: We need to unlink the frame *before* clearing it:
1129
1129
_PyInterpreterFrame * dying = frame ;
@@ -1223,8 +1223,9 @@ dummy_func(
1223
1223
{
1224
1224
PyGenObject * gen = (PyGenObject * )receiver_o ;
1225
1225
_PyInterpreterFrame * gen_frame = & gen -> gi_iframe ;
1226
- STACK_SHRINK (1 );
1227
1226
_PyFrame_StackPush (gen_frame , PyStackRef_MakeHeapSafe (v ));
1227
+ DEAD (v );
1228
+ SYNC_SP ();
1228
1229
gen -> gi_frame_state = FRAME_EXECUTING ;
1229
1230
gen -> gi_exc_state .previous_item = tstate -> exc_info ;
1230
1231
tstate -> exc_info = & gen -> gi_exc_state ;
@@ -2436,10 +2437,10 @@ dummy_func(
2436
2437
PyObject * name = GETITEM (FRAME_CO_NAMES , oparg >> 1 );
2437
2438
_PyInterpreterFrame * new_frame = _PyFrame_PushUnchecked (
2438
2439
tstate , PyStackRef_FromPyObjectNew (f ), 2 , frame );
2439
- // Manipulate stack directly because we exit with DISPATCH_INLINED().
2440
- STACK_SHRINK (1 );
2441
2440
new_frame -> localsplus [0 ] = owner ;
2442
2441
DEAD (owner );
2442
+ // Manipulate stack directly because we exit with DISPATCH_INLINED().
2443
+ SYNC_SP ();
2443
2444
new_frame -> localsplus [1 ] = PyStackRef_FromPyObjectNew (name );
2444
2445
frame -> return_offset = INSTRUCTION_SIZE ;
2445
2446
DISPATCH_INLINED (new_frame );
@@ -3083,12 +3084,11 @@ dummy_func(
3083
3084
macro (FOR_ITER ) = _SPECIALIZE_FOR_ITER + _FOR_ITER ;
3084
3085
3085
3086
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 );
3092
3092
INSTRUMENTED_JUMP (this_instr , next_instr , PY_MONITORING_EVENT_BRANCH_LEFT );
3093
3093
}
3094
3094
else {
@@ -3105,6 +3105,7 @@ dummy_func(
3105
3105
next_instr [oparg ].op .code == INSTRUMENTED_END_FOR );
3106
3106
/* Skip END_FOR */
3107
3107
JUMPBY (oparg + 1 );
3108
+ DISPATCH ();
3108
3109
}
3109
3110
}
3110
3111
@@ -4022,7 +4023,6 @@ dummy_func(
4022
4023
_PUSH_FRAME ;
4023
4024
4024
4025
inst (EXIT_INIT_CHECK , (should_be_none -- )) {
4025
- assert (STACK_LEVEL () == 2 );
4026
4026
if (!PyStackRef_IsNone (should_be_none )) {
4027
4027
PyErr_Format (PyExc_TypeError ,
4028
4028
"__init__() should return None, not '%.200s'" ,
@@ -4813,7 +4813,7 @@ dummy_func(
4813
4813
PyFunctionObject * func = (PyFunctionObject * )PyStackRef_AsPyObjectBorrow (frame -> f_funcobj );
4814
4814
PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (func );
4815
4815
ERROR_IF (gen == NULL , error );
4816
- assert (EMPTY () );
4816
+ assert (STACK_LEVEL () == 0 );
4817
4817
SAVE_STACK ();
4818
4818
_PyInterpreterFrame * gen_frame = & gen -> gi_iframe ;
4819
4819
frame -> instr_ptr ++ ;
@@ -4932,6 +4932,7 @@ dummy_func(
4932
4932
}
4933
4933
next_instr = frame -> instr_ptr ;
4934
4934
if (next_instr != this_instr ) {
4935
+ SYNC_SP ();
4935
4936
DISPATCH ();
4936
4937
}
4937
4938
}
@@ -4976,46 +4977,48 @@ dummy_func(
4976
4977
_CHECK_PERIODIC +
4977
4978
_MONITOR_JUMP_BACKWARD ;
4978
4979
4979
- inst (INSTRUMENTED_POP_JUMP_IF_TRUE , (unused /1 -- )) {
4980
- _PyStackRef cond = POP ();
4980
+ inst (INSTRUMENTED_POP_JUMP_IF_TRUE , (unused /1 , cond -- )) {
4981
4981
assert (PyStackRef_BoolCheck (cond ));
4982
4982
int jump = PyStackRef_IsTrue (cond );
4983
+ DEAD (cond );
4983
4984
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
4984
4985
if (jump ) {
4985
4986
INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
4986
4987
}
4987
4988
}
4988
4989
4989
- inst (INSTRUMENTED_POP_JUMP_IF_FALSE , (unused /1 -- )) {
4990
- _PyStackRef cond = POP ();
4990
+ inst (INSTRUMENTED_POP_JUMP_IF_FALSE , (unused /1 , cond -- )) {
4991
4991
assert (PyStackRef_BoolCheck (cond ));
4992
4992
int jump = PyStackRef_IsFalse (cond );
4993
+ DEAD (cond );
4993
4994
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
4994
4995
if (jump ) {
4995
4996
INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
4996
4997
}
4997
4998
}
4998
4999
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 );
5002
5002
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
5003
5003
if (jump ) {
5004
+ DEAD (value );
5004
5005
INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
5005
5006
}
5006
5007
else {
5007
- PyStackRef_CLOSE (value_stackref );
5008
+ PyStackRef_CLOSE (value );
5008
5009
}
5009
5010
}
5010
5011
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 );
5014
5014
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , jump );
5015
5015
if (jump ) {
5016
- PyStackRef_CLOSE (value_stackref );
5016
+ PyStackRef_CLOSE (value );
5017
5017
INSTRUMENTED_JUMP (this_instr , next_instr + oparg , PY_MONITORING_EVENT_BRANCH_RIGHT );
5018
5018
}
5019
+ else {
5020
+ DEAD (value );
5021
+ }
5019
5022
}
5020
5023
5021
5024
tier1 inst (EXTENDED_ARG , ( -- )) {
@@ -5219,22 +5222,26 @@ dummy_func(
5219
5222
}
5220
5223
5221
5224
label (pop_4_error ) {
5222
- STACK_SHRINK (4 );
5225
+ stack_pointer -= 4 ;
5226
+ assert (WITHIN_STACK_BOUNDS ());
5223
5227
goto error ;
5224
5228
}
5225
5229
5226
5230
label (pop_3_error ) {
5227
- STACK_SHRINK (3 );
5231
+ stack_pointer -= 3 ;
5232
+ assert (WITHIN_STACK_BOUNDS ());
5228
5233
goto error ;
5229
5234
}
5230
5235
5231
5236
label (pop_2_error ) {
5232
- STACK_SHRINK (2 );
5237
+ stack_pointer -= 2 ;
5238
+ assert (WITHIN_STACK_BOUNDS ());
5233
5239
goto error ;
5234
5240
}
5235
5241
5236
5242
label (pop_1_error ) {
5237
- STACK_SHRINK (1 );
5243
+ stack_pointer -= 1 ;
5244
+ assert (WITHIN_STACK_BOUNDS ());
5238
5245
goto error ;
5239
5246
}
5240
5247
0 commit comments