diff --git a/Python/ceval.c b/Python/ceval.c index 9110e80..0808a95 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -903,8 +903,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) { \ if (!lltrace && !_Py_TracingPossible) { \ f->f_lasti = INSTR_OFFSET(); \ - opcode = NEXTOP(); \ - oparg = NEXTARG(); \ + NEXTOPARG(); \ goto *opcode_targets[opcode]; \ } \ goto fast_next_opcode; \ @@ -914,8 +913,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) { \ if (!_Py_TracingPossible) { \ f->f_lasti = INSTR_OFFSET(); \ - opcode = NEXTOP(); \ - oparg = NEXTARG(); \ + NEXTOPARG(); \ goto *opcode_targets[opcode]; \ } \ goto fast_next_opcode; \ @@ -981,9 +979,15 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* Code access macros */ +#ifdef WORDS_BIGENDIAN + #define OPOF(word) ((word)>>8) + #define ARGOF(word) ((word)&255) +#else + #define OPOF(word) ((word)&255) + #define ARGOF(word) ((word)>>8) +#endif #define INSTR_OFFSET() ((int)(next_instr - first_instr)) -#define NEXTOP() (next_instr+=2, next_instr[-2]) -#define NEXTARG() (next_instr[-1]) +#define NEXTOPARG() (oparg = *(unsigned short*)next_instr, opcode = OPOF(oparg), oparg = ARGOF(oparg), next_instr += 2) #define PEEKARG() (next_instr[1]) #define JUMPTO(x) (next_instr = first_instr + (x)) #define JUMPBY(x) (next_instr += (x)) @@ -1021,9 +1025,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) #define PREDICT(op) \ do{ \ if (*next_instr == op){ \ - opcode = op; \ - oparg = PEEKARG(); \ - next_instr += 2; \ + NEXTOPARG(); \ goto PRED_##op; \ } \ } while(0) @@ -1313,8 +1315,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* Extract opcode and argument */ - opcode = NEXTOP(); - oparg = NEXTARG(); + NEXTOPARG(); dispatch_opcode: #ifdef DYNAMIC_EXECUTION_PROFILE #ifdef DXPAIRS @@ -3432,8 +3433,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) } TARGET(EXTENDED_ARG) { - opcode = NEXTOP(); - oparg = oparg<<8 | NEXTARG(); + int oldoparg = oparg; + NEXTOPARG(); + oparg |= oldoparg << 8; goto dispatch_opcode; } @@ -5298,10 +5300,11 @@ unicode_concatenate(PyObject *v, PyObject *w, * 'variable'. We try to delete the variable now to reduce * the refcnt to 1. */ - switch (*next_instr) { + int opcode, oparg; + NEXTOPARG(); + switch (opcode) { case STORE_FAST: { - int oparg = PEEKARG(); PyObject **fastlocals = f->f_localsplus; if (GETLOCAL(oparg) == v) SETLOCAL(oparg, NULL); @@ -5311,7 +5314,7 @@ unicode_concatenate(PyObject *v, PyObject *w, { PyObject **freevars = (f->f_localsplus + f->f_code->co_nlocals); - PyObject *c = freevars[PEEKARG()]; + PyObject *c = freevars[oparg]; if (PyCell_GET(c) == v) PyCell_Set(c, NULL); break; @@ -5319,7 +5322,7 @@ unicode_concatenate(PyObject *v, PyObject *w, case STORE_NAME: { PyObject *names = f->f_code->co_names; - PyObject *name = GETITEM(names, PEEKARG()); + PyObject *name = GETITEM(names, oparg); PyObject *locals = f->f_locals; if (PyDict_CheckExact(locals) && PyDict_GetItem(locals, name) == v) {