diff -r bb8b75c6bfdf Python/ceval.c --- a/Python/ceval.c Wed Dec 09 11:27:34 2015 +0200 +++ b/Python/ceval.c Wed Dec 09 11:46:52 2015 +0200 @@ -892,7 +892,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int TARGET_##op: \ opcode = op; \ if (HAS_ARG(op)) \ - oparg = NEXTARG(); \ + NEXTARG(oparg); \ case op: \ goto impl; \ @@ -900,7 +900,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int TARGET_##op: \ opcode = op; \ if (HAS_ARG(op)) \ - oparg = NEXTARG(); \ + NEXTARG(oparg); \ case op: @@ -996,8 +996,33 @@ PyEval_EvalFrameEx(PyFrameObject *f, int #define INSTR_OFFSET() ((int)(next_instr - first_instr)) #define NEXTOP() (*next_instr++) -#define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) -#define PEEKARG() ((next_instr[2]<<8) + next_instr[1]) +#if PY_LITTLE_ENDIAN +# define NEXTARG(oparg) do { \ + union { \ + unsigned short value; \ + unsigned char bytes[2]; \ + } u; \ + memcpy(&u.bytes, next_instr, 2); \ + (oparg) = (int)u.value; \ + next_instr += 2; \ + } while(0) +# define PEEKARG(oparg) do { \ + union { \ + unsigned short value; \ + unsigned char bytes[2]; \ + } u; \ + memcpy(&u.bytes, next_instr + 1, 2); \ + (oparg) = (int)u.value; \ + } while(0) +#else +# define PEEKARG(oparg) do { \ + (oparg) = (next_instr[2]<<8) + next_instr[1]; \ + } while(0) +# define NEXTARG(oparg) do { \ + (oparg) = (next_instr[1]<<8) + next_instr[0]; \ + next_instr += 2; \ + } while(0) +#endif #define JUMPTO(x) (next_instr = first_instr + (x)) #define JUMPBY(x) (next_instr += (x)) @@ -1035,7 +1060,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int #else #define PREDICT(op) if (*next_instr == op) goto PRED_##op #define PREDICTED(op) PRED_##op: next_instr++ -#define PREDICTED_WITH_ARG(op) PRED_##op: oparg = PEEKARG(); next_instr += 3 +#define PREDICTED_WITH_ARG(op) PRED_##op: PEEKARG(oparg); next_instr += 3 #endif @@ -1326,7 +1351,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int oparg = 0; /* allows oparg to be stored in a register because it doesn't have to be remembered across a full loop */ if (HAS_ARG(opcode)) - oparg = NEXTARG(); + NEXTARG(oparg); dispatch_opcode: #ifdef DYNAMIC_EXECUTION_PROFILE #ifdef DXPAIRS @@ -3432,8 +3457,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int } TARGET(EXTENDED_ARG) { + int oparg2; opcode = NEXTOP(); - oparg = oparg<<16 | NEXTARG(); + NEXTARG(oparg2); + oparg = oparg<<16 | oparg2; goto dispatch_opcode; } @@ -5287,8 +5314,9 @@ unicode_concatenate(PyObject *v, PyObjec switch (*next_instr) { case STORE_FAST: { - int oparg = PEEKARG(); PyObject **fastlocals = f->f_localsplus; + int oparg; + PEEKARG(oparg); if (GETLOCAL(oparg) == v) SETLOCAL(oparg, NULL); break; @@ -5297,7 +5325,10 @@ unicode_concatenate(PyObject *v, PyObjec { PyObject **freevars = (f->f_localsplus + f->f_code->co_nlocals); - PyObject *c = freevars[PEEKARG()]; + PyObject *c; + int oparg; + PEEKARG(oparg); + c = freevars[oparg]; if (PyCell_GET(c) == v) PyCell_Set(c, NULL); break; @@ -5305,8 +5336,11 @@ unicode_concatenate(PyObject *v, PyObjec case STORE_NAME: { PyObject *names = f->f_code->co_names; - PyObject *name = GETITEM(names, PEEKARG()); + PyObject *name; PyObject *locals = f->f_locals; + int oparg; + PEEKARG(oparg); + name = GETITEM(names, oparg); if (PyDict_CheckExact(locals) && PyDict_GetItem(locals, name) == v) { if (PyDict_DelItem(locals, name) != 0) {