@@ -668,18 +668,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
668668#ifdef Py_STATS
669669#define INSTRUCTION_START (op ) \
670670 do { \
671- frame->prev_instr = next_instr; \
672- next_instr += OPSIZE(op); \
671+ frame->prev_instr = next_instr++; \
673672 OPCODE_EXE_INC(op); \
674673 if (_py_stats) _py_stats->opcode_stats[lastopcode].pair_count[op]++; \
675674 lastopcode = op; \
676675 } while (0)
677676#else
678- #define INSTRUCTION_START (op ) \
679- do { \
680- frame->prev_instr = next_instr; \
681- next_instr += OPSIZE(op); \
682- } while (0)
677+ #define INSTRUCTION_START (op ) (frame->prev_instr = next_instr++)
683678#endif
684679
685680#if USE_COMPUTED_GOTOS
@@ -711,6 +706,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
711706
712707#define DISPATCH_SAME_OPARG () \
713708 { \
709+ JUMPBY(-OPSIZE(opcode)); \
714710 opcode = _Py_OPCODE(*next_instr); \
715711 PRE_DISPATCH_GOTO(); \
716712 opcode |= cframe.use_tracing OR_DTRACE_LINE; \
@@ -720,7 +716,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
720716#define DISPATCH_INLINED (NEW_FRAME ) \
721717 do { \
722718 _PyFrame_SetStackPointer(frame, stack_pointer); \
723- frame->prev_instr = next_instr - OPSIZE(-1); \
719+ frame->prev_instr = next_instr - 1; \
724720 (NEW_FRAME)->previous = frame; \
725721 frame = cframe.current_frame = (NEW_FRAME); \
726722 CALL_STAT_INC(inlined_py_calls); \
@@ -750,7 +746,7 @@ GETITEM(PyObject *v, Py_ssize_t i) {
750746
751747/* Code access macros */
752748
753- #define VERBOSE 0
749+ #define VERBOSE 1
754750
755751/* The integer overflow is checked by an assertion below. */
756752#define INSTR_OFFSET () ((int)(next_instr - _PyCode_CODE(frame->f_code)))
@@ -759,10 +755,16 @@ GETITEM(PyObject *v, Py_ssize_t i) {
759755 opcode = _Py_OPCODE(word); \
760756 oparg1 = oparg = _Py_OPARG(word); \
761757 if (VERBOSE) fprintf(stderr, "[%d] next_instr = %p opcode = %d\n", __LINE__, next_instr, opcode); \
762- word = *(next_instr +1); \
758+ word = *(next_instr + 1); \
763759 oparg2 = _Py_OPARG2(word); \
764760 oparg3 = _Py_OPARG3(word); \
765- if (VERBOSE) fprintf(stderr, "%d (%d, %d, %d)\n", opcode, oparg, oparg2, oparg3); \
761+ if (VERBOSE) { \
762+ fprintf(stderr, "%d (%d, %d, %d)\n", opcode, oparg, oparg2, oparg3); \
763+ if(!_PyErr_Occurred(tstate)) PyObject_Print(frame->f_code->co_filename, stderr, 0); \
764+ fprintf(stderr, "\n name = "); \
765+ if(!_PyErr_Occurred(tstate)) PyObject_Print(frame->f_code->co_name, stderr, 0); \
766+ fprintf(stderr, "\n"); \
767+ } \
766768 } while (0)
767769#define JUMPTO (x ) (next_instr = _PyCode_CODE(frame->f_code) + (x))
768770#define JUMPBY (x ) (next_instr += (x))
@@ -896,6 +898,7 @@ GETITEM(PyObject *v, Py_ssize_t i) {
896898 /* This is only a single jump on release builds! */ \
897899 UPDATE_MISS_STATS ((INSTNAME )); \
898900 assert (_PyOpcode_Deopt [opcode ] == (INSTNAME )); \
901+ JUMPBY (1 - OPSIZE (opcode )); \
899902 GO_TO_INSTRUCTION (INSTNAME ); \
900903 }
901904
@@ -1125,7 +1128,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
11251128#endif
11261129 entry_frame .f_code = tstate -> interp -> interpreter_trampoline ;
11271130 entry_frame .prev_instr =
1128- _PyCode_CODE (tstate -> interp -> interpreter_trampoline );
1131+ _PyCode_CODE (tstate -> interp -> interpreter_trampoline ) + 1 ;
11291132 entry_frame .stacktop = 0 ;
11301133 entry_frame .owner = FRAME_OWNED_BY_CSTACK ;
11311134 entry_frame .yield_offset = 0 ;
@@ -1169,13 +1172,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
11691172 /* Jump back to the last instruction executed... */ \
11701173 if (VERBOSE ) { \
11711174 fprintf (stderr , "Jump back to the last instruction executed\n" ); \
1175+ fprintf (stderr , "frame->prev_instr = %p\n" , frame -> prev_instr ); \
11721176 fprintf (stderr , "_PyInterpreterFrame_LASTI(frame) = %d\n filename = " , _PyInterpreterFrame_LASTI (frame )); \
11731177 if (!_PyErr_Occurred (tstate )) PyObject_Print (frame -> f_code -> co_filename , stderr , 0 ); \
11741178 fprintf (stderr , "\n name = " ); \
11751179 if (!_PyErr_Occurred (tstate )) PyObject_Print (frame -> f_code -> co_name , stderr , 0 ); \
11761180 fprintf (stderr , "\n" ); \
11771181 } \
1178- next_instr = frame -> prev_instr + (_PyInterpreterFrame_LASTI (frame ) == -1 ? 1 : OPSIZE (-1 )); /* TODO: init frame to -OPSIZE? */ \
1182+ /* next_instr = frame->prev_instr + 1; */ \
1183+ next_instr = frame -> prev_instr + 1 ; \
11791184 stack_pointer = _PyFrame_GetStackPointer (frame ); \
11801185 /* Set stackdepth to -1. \
11811186 Update when returning or calling trace function. \
0 commit comments