@@ -1266,7 +1266,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
1266
1266
oparg = NEXTARG ();
1267
1267
if (opcode == EXTENDED_ARG ) {
1268
1268
opcode = NEXTOP ();
1269
- oparg = oparg <<16 | NEXTARG ();
1269
+ oparg = oparg <<8 | NEXTARG ();
1270
1270
}
1271
1271
assert (opcode == FOR_ITER );
1272
1272
@@ -1301,7 +1301,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
1301
1301
oparg = NEXTARG ();
1302
1302
if (opcode == EXTENDED_ARG ) {
1303
1303
opcode = NEXTOP ();
1304
- oparg = oparg <<16 | NEXTARG ();
1304
+ oparg = oparg <<8 | NEXTARG ();
1305
1305
}
1306
1306
assert (opcode == SETUP_WITH );
1307
1307
@@ -3872,7 +3872,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
3872
3872
/* restore this opcode and enable frame to handle it */
3873
3873
f -> f_execute = slp_eval_frame_iter ;
3874
3874
stackless_call_with_opcode :
3875
- next_instr -= (oparg >> 16 ) ? 6 : 3 ;
3875
+
3876
+ #define EXTENDED_ARG_OFFSET (x ) \
3877
+ (assert(sizeof(x) == 4), \
3878
+ (!((x) >> 8) ? 0 : \
3879
+ (!((x) >> 16) ? 2 : \
3880
+ (!((x) >> 24) ? 4 : 6 ))))
3881
+
3882
+ next_instr -= 2 + EXTENDED_ARG_OFFSET (oparg );
3876
3883
3877
3884
stackless_call :
3878
3885
/*
@@ -3882,7 +3889,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
3882
3889
3883
3890
/* the -1 is to adjust for the f_lasti change.
3884
3891
(look for the word 'Promise' above) */
3885
- f -> f_lasti = INSTR_OFFSET () - 1 ;
3892
+ f -> f_lasti = INSTR_OFFSET () - 2 ;
3886
3893
if (SLP_PEEK_NEXT_FRAME (tstate )-> f_back != f )
3887
3894
return retval ;
3888
3895
STACKLESS_UNPACK (tstate , retval );
@@ -3906,12 +3913,12 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
3906
3913
3907
3914
f -> f_stacktop = NULL ;
3908
3915
if (f -> f_execute == slp_eval_frame_iter ) {
3909
- next_instr += ( oparg >> 16 ) ? 6 : 3 ;
3916
+ next_instr += 2 + EXTENDED_ARG_OFFSET ( oparg ); ;
3910
3917
f -> f_execute = slp_eval_frame_value ;
3911
3918
goto stackless_iter_return ;
3912
3919
}
3913
3920
else if (f -> f_execute == slp_eval_frame_setup_with ) {
3914
- next_instr += ( oparg >> 16 ) ? 6 : 3 ;
3921
+ next_instr += 2 + EXTENDED_ARG_OFFSET ( oparg ) ;
3915
3922
f -> f_execute = slp_eval_frame_value ;
3916
3923
goto stackless_setup_with_return ;
3917
3924
}
@@ -3930,7 +3937,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
3930
3937
3931
3938
/* the -1 is to adjust for the f_lasti change.
3932
3939
(look for the word 'Promise' above) */
3933
- f -> f_lasti = INSTR_OFFSET () - 1 ;
3940
+ f -> f_lasti = INSTR_OFFSET () - 2 ;
3934
3941
return (PyObject * ) Py_UnwindToken ;
3935
3942
#endif
3936
3943
}
0 commit comments