@@ -39,7 +39,7 @@ PyFrame_GetLineNumber(PyFrameObject *f)
39
39
return f -> f_lineno ;
40
40
}
41
41
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 );
43
43
}
44
44
}
45
45
@@ -58,10 +58,11 @@ frame_getlineno(PyFrameObject *f, void *closure)
58
58
static PyObject *
59
59
frame_getlasti (PyFrameObject * f , void * closure )
60
60
{
61
- if (f -> f_frame -> f_lasti < 0 ) {
61
+ int lasti = _PyInterpreterFrame_LASTI (f -> f_frame );
62
+ if (lasti < 0 ) {
62
63
return PyLong_FromLong (-1 );
63
64
}
64
- return PyLong_FromLong (f -> f_frame -> f_lasti * sizeof (_Py_CODEUNIT ));
65
+ return PyLong_FromLong (lasti * sizeof (_Py_CODEUNIT ));
65
66
}
66
67
67
68
static PyObject *
@@ -419,12 +420,11 @@ _PyFrame_GetState(PyFrameObject *frame)
419
420
}
420
421
case FRAME_OWNED_BY_THREAD :
421
422
{
422
- if (frame -> f_frame -> f_lasti < 0 ) {
423
+ if (_PyInterpreterFrame_LASTI ( frame -> f_frame ) < 0 ) {
423
424
return FRAME_CREATED ;
424
425
}
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
+ {
428
428
case COPY_FREE_VARS :
429
429
case MAKE_CELL :
430
430
case RETURN_GENERATOR :
@@ -555,7 +555,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
555
555
556
556
int64_t best_stack = OVERFLOWED ;
557
557
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 ) ];
559
559
int err = -1 ;
560
560
const char * msg = "cannot find bytecode for specified line" ;
561
561
for (int i = 0 ; i < len ; i ++ ) {
@@ -598,7 +598,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
598
598
}
599
599
/* Finally set the new lasti and return OK. */
600
600
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 ;
602
602
return 0 ;
603
603
}
604
604
@@ -880,10 +880,11 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
880
880
// This only works when opcode is a non-quickened form:
881
881
assert (_PyOpcode_Deopt [opcode ] == opcode );
882
882
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 );
887
888
if (check_opcode == opcode && check_oparg == oparg ) {
888
889
return 1 ;
889
890
}
@@ -893,7 +894,7 @@ _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
893
894
else {
894
895
check_oparg = 0 ;
895
896
}
896
- i += _PyOpcode_Caches [check_opcode ];
897
+ instruction += _PyOpcode_Caches [check_opcode ];
897
898
}
898
899
return 0 ;
899
900
}
@@ -914,8 +915,8 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
914
915
fast = _PyFrame_GetLocalsArray (frame );
915
916
// COPY_FREE_VARS has no quickened forms, so no need to use _PyOpcode_Deopt
916
917
// 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 ) {
919
920
/* Free vars have not been initialized -- Do that */
920
921
PyCodeObject * co = frame -> f_code ;
921
922
PyObject * closure = frame -> f_func -> func_closure ;
@@ -926,7 +927,7 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
926
927
frame -> localsplus [offset + i ] = o ;
927
928
}
928
929
// COPY_FREE_VARS doesn't have inline CACHEs, either:
929
- frame -> f_lasti = 0 ;
930
+ frame -> prev_instr = _PyCode_CODE ( frame -> f_code ) ;
930
931
}
931
932
for (int i = 0 ; i < co -> co_nlocalsplus ; i ++ ) {
932
933
_PyLocals_Kind kind = _PyLocals_GetKind (co -> co_localspluskinds , i );
0 commit comments