@@ -62,7 +62,7 @@ static int import_all_from(PyObject *, PyObject *);
6262static void format_exc_check_arg (PyObject * , const char * , PyObject * );
6363static void format_exc_unbound (PyCodeObject * co , int oparg );
6464static PyObject * unicode_concatenate (PyObject * , PyObject * ,
65- PyFrameObject * , const unsigned short * );
65+ PyFrameObject * , const _Py_CODEUNIT * );
6666static PyObject * special_lookup (PyObject * , _Py_Identifier * );
6767
6868#define NAME_ERROR_MSG \
@@ -725,7 +725,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
725725 int lastopcode = 0 ;
726726#endif
727727 PyObject * * stack_pointer ; /* Next free slot in value stack */
728- const unsigned short * next_instr ;
728+ const _Py_CODEUNIT * next_instr ;
729729 int opcode ; /* Current opcode */
730730 int oparg ; /* Current opcode argument, if any */
731731 enum why_code why ; /* Reason for block stack unwind */
@@ -743,7 +743,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
743743 time it is tested. */
744744 int instr_ub = -1 , instr_lb = 0 , instr_prev = -1 ;
745745
746- const unsigned short * first_instr ;
746+ const _Py_CODEUNIT * first_instr ;
747747 PyObject * names ;
748748 PyObject * consts ;
749749
@@ -864,23 +864,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
864864
865865/* Code access macros */
866866
867- #ifdef WORDS_BIGENDIAN
868- #define OPCODE (word ) ((word) >> 8)
869- #define OPARG (word ) ((word) & 255)
870- #else
871- #define OPCODE (word ) ((word) & 255)
872- #define OPARG (word ) ((word) >> 8)
873- #endif
874867/* The integer overflow is checked by an assertion below. */
875- #define INSTR_OFFSET () (2* (int)(next_instr - first_instr))
868+ #define INSTR_OFFSET () (sizeof(_Py_CODEUNIT) * (int)(next_instr - first_instr))
876869#define NEXTOPARG () do { \
877- unsigned short word = *next_instr; \
878- opcode = OPCODE (word); \
879- oparg = OPARG (word); \
870+ _Py_CODEUNIT word = *next_instr; \
871+ opcode = _Py_OPCODE (word); \
872+ oparg = _Py_OPARG (word); \
880873 next_instr++; \
881874 } while (0)
882- #define JUMPTO (x ) (next_instr = first_instr + (x)/2 )
883- #define JUMPBY (x ) (next_instr += (x)/2 )
875+ #define JUMPTO (x ) (next_instr = first_instr + (x) / sizeof(_Py_CODEUNIT) )
876+ #define JUMPBY (x ) (next_instr += (x) / sizeof(_Py_CODEUNIT) )
884877
885878/* OpCode prediction macros
886879 Some opcodes tend to come in pairs thus making it possible to
@@ -913,10 +906,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
913906#else
914907#define PREDICT (op ) \
915908 do{ \
916- unsigned short word = *next_instr; \
917- opcode = OPCODE (word); \
909+ _Py_CODEUNIT word = *next_instr; \
910+ opcode = _Py_OPCODE (word); \
918911 if (opcode == op){ \
919- oparg = OPARG (word); \
912+ oparg = _Py_OPARG (word); \
920913 next_instr++; \
921914 goto PRED_##op; \
922915 } \
@@ -1056,9 +1049,9 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
10561049 freevars = f -> f_localsplus + co -> co_nlocals ;
10571050 assert (PyBytes_Check (co -> co_code ));
10581051 assert (PyBytes_GET_SIZE (co -> co_code ) <= INT_MAX );
1059- assert (PyBytes_GET_SIZE (co -> co_code ) % 2 == 0 );
1060- assert (_Py_IS_ALIGNED (PyBytes_AS_STRING (co -> co_code ), 2 ));
1061- first_instr = (unsigned short * ) PyBytes_AS_STRING (co -> co_code );
1052+ assert (PyBytes_GET_SIZE (co -> co_code ) % sizeof ( _Py_CODEUNIT ) == 0 );
1053+ assert (_Py_IS_ALIGNED (PyBytes_AS_STRING (co -> co_code ), sizeof ( _Py_CODEUNIT ) ));
1054+ first_instr = (_Py_CODEUNIT * ) PyBytes_AS_STRING (co -> co_code );
10621055 /*
10631056 f->f_lasti refers to the index of the last instruction,
10641057 unless it's -1 in which case next_instr should be first_instr.
@@ -1074,10 +1067,11 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
10741067 FOR_ITER is effectively a single opcode and f->f_lasti will point
10751068 to the beginning of the combined pair.)
10761069 */
1070+ assert (f -> f_lasti >= -1 );
10771071 next_instr = first_instr ;
10781072 if (f -> f_lasti >= 0 ) {
1079- assert (f -> f_lasti % 2 == 0 );
1080- next_instr += f -> f_lasti / 2 + 1 ;
1073+ assert (f -> f_lasti % sizeof ( _Py_CODEUNIT ) == 0 );
1074+ next_instr += f -> f_lasti / sizeof ( _Py_CODEUNIT ) + 1 ;
10811075 }
10821076 stack_pointer = f -> f_stacktop ;
10831077 assert (stack_pointer != NULL );
@@ -1125,7 +1119,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
11251119 Py_MakePendingCalls() above. */
11261120
11271121 if (_Py_atomic_load_relaxed (& eval_breaker )) {
1128- if (OPCODE (* next_instr ) == SETUP_FINALLY ) {
1122+ if (_Py_OPCODE (* next_instr ) == SETUP_FINALLY ) {
11291123 /* Make the last opcode before
11301124 a try: finally: block uninterruptible. */
11311125 goto fast_next_opcode ;
@@ -2049,7 +2043,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
20492043 f -> f_stacktop = stack_pointer ;
20502044 why = WHY_YIELD ;
20512045 /* and repeat... */
2052- f -> f_lasti -= 2 ;
2046+ f -> f_lasti -= sizeof ( _Py_CODEUNIT ) ;
20532047 goto fast_yield ;
20542048 }
20552049
@@ -5321,7 +5315,7 @@ format_exc_unbound(PyCodeObject *co, int oparg)
53215315
53225316static PyObject *
53235317unicode_concatenate (PyObject * v , PyObject * w ,
5324- PyFrameObject * f , const unsigned short * next_instr )
5318+ PyFrameObject * f , const _Py_CODEUNIT * next_instr )
53255319{
53265320 PyObject * res ;
53275321 if (Py_REFCNT (v ) == 2 ) {
0 commit comments