@@ -39,7 +39,7 @@ PyFrame_GetLineNumber(PyFrameObject *f)
3939 return f -> f_lineno ;
4040 }
4141 else {
42- return PyCode_Addr2Line (f -> f_frame -> f_code , f -> f_frame -> f_lasti * sizeof ( _Py_CODEUNIT ) );
42+ return _PyInterpreterFrame_GetLine (f -> f_frame );
4343 }
4444}
4545
@@ -58,10 +58,11 @@ frame_getlineno(PyFrameObject *f, void *closure)
5858static PyObject *
5959frame_getlasti (PyFrameObject * f , void * closure )
6060{
61- if (f -> f_frame -> f_lasti < 0 ) {
61+ int lasti = _PyInterpreterFrame_LASTI (f -> f_frame );
62+ if (lasti < 0 ) {
6263 return PyLong_FromLong (-1 );
6364 }
64- return PyLong_FromLong (f -> f_frame -> f_lasti * sizeof (_Py_CODEUNIT ));
65+ return PyLong_FromLong (lasti * sizeof (_Py_CODEUNIT ));
6566}
6667
6768static PyObject *
@@ -419,12 +420,11 @@ _PyFrame_GetState(PyFrameObject *frame)
419420 }
420421 case FRAME_OWNED_BY_THREAD :
421422 {
422- if (frame -> f_frame -> f_lasti < 0 ) {
423+ if (_PyInterpreterFrame_LASTI ( frame -> f_frame ) < 0 ) {
423424 return FRAME_CREATED ;
424425 }
425- uint8_t * code = (uint8_t * )frame -> f_frame -> f_code -> co_code_adaptive ;
426- int opcode = code [frame -> f_frame -> f_lasti * sizeof (_Py_CODEUNIT )];
427- switch (_PyOpcode_Deopt [opcode ]) {
426+ switch (_PyOpcode_Deopt [_Py_OPCODE (* frame -> f_frame -> prev_instr )])
427+ {
428428 case COPY_FREE_VARS :
429429 case MAKE_CELL :
430430 case RETURN_GENERATOR :
@@ -555,7 +555,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
555555
556556 int64_t best_stack = OVERFLOWED ;
557557 int best_addr = -1 ;
558- int64_t start_stack = stacks [f -> f_frame -> f_lasti ];
558+ int64_t start_stack = stacks [_PyInterpreterFrame_LASTI ( f -> f_frame ) ];
559559 int err = -1 ;
560560 const char * msg = "cannot find bytecode for specified line" ;
561561 for (int i = 0 ; i < len ; i ++ ) {
@@ -598,7 +598,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
598598 }
599599 /* Finally set the new lasti and return OK. */
600600 f -> f_lineno = 0 ;
601- f -> f_frame -> f_lasti = best_addr ;
601+ f -> f_frame -> prev_instr = _PyCode_CODE ( f -> f_frame -> f_code ) + best_addr ;
602602 return 0 ;
603603}
604604
@@ -880,10 +880,11 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
880880 // This only works when opcode is a non-quickened form:
881881 assert (_PyOpcode_Deopt [opcode ] == opcode );
882882 int check_oparg = 0 ;
883- for (int i = 0 ; i < frame -> f_lasti ; i ++ ) {
884- _Py_CODEUNIT instruction = _PyCode_CODE (frame -> f_code )[i ];
885- int check_opcode = _PyOpcode_Deopt [_Py_OPCODE (instruction )];
886- check_oparg |= _Py_OPARG (instruction );
883+ for (_Py_CODEUNIT * instruction = _PyCode_CODE (frame -> f_code );
884+ instruction < frame -> prev_instr ; instruction ++ )
885+ {
886+ int check_opcode = _PyOpcode_Deopt [_Py_OPCODE (* instruction )];
887+ check_oparg |= _Py_OPARG (* instruction );
887888 if (check_opcode == opcode && check_oparg == oparg ) {
888889 return 1 ;
889890 }
@@ -893,7 +894,7 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
893894 else {
894895 check_oparg = 0 ;
895896 }
896- i += _PyOpcode_Caches [check_opcode ];
897+ instruction += _PyOpcode_Caches [check_opcode ];
897898 }
898899 return 0 ;
899900}
@@ -914,8 +915,8 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
914915 fast = _PyFrame_GetLocalsArray (frame );
915916 // COPY_FREE_VARS has no quickened forms, so no need to use _PyOpcode_Deopt
916917 // here:
917- if ( frame -> f_lasti < 0 && _Py_OPCODE ( _PyCode_CODE ( co )[ 0 ]) == COPY_FREE_VARS )
918- {
918+ int lasti = _PyInterpreterFrame_LASTI ( frame );
919+ if ( lasti < 0 && _Py_OPCODE ( _PyCode_CODE ( co )[ 0 ]) == COPY_FREE_VARS ) {
919920 /* Free vars have not been initialized -- Do that */
920921 PyCodeObject * co = frame -> f_code ;
921922 PyObject * closure = frame -> f_func -> func_closure ;
@@ -926,7 +927,7 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
926927 frame -> localsplus [offset + i ] = o ;
927928 }
928929 // COPY_FREE_VARS doesn't have inline CACHEs, either:
929- frame -> f_lasti = 0 ;
930+ frame -> prev_instr = _PyCode_CODE ( frame -> f_code ) ;
930931 }
931932 for (int i = 0 ; i < co -> co_nlocalsplus ; i ++ ) {
932933 _PyLocals_Kind kind = _PyLocals_GetKind (co -> co_localspluskinds , i );
0 commit comments