Index: Python/ceval.c =================================================================== --- Python/ceval.c (revision 61316) +++ Python/ceval.c (working copy) @@ -519,16 +519,9 @@ #endif register PyObject **stack_pointer; /* Next free slot in value stack */ register unsigned char *next_instr; - register int opcode; /* Current opcode */ - register int oparg; /* Current opcode argument, if any */ register enum why_code why; /* Reason for block stack unwind */ register int err; /* Error status -- nonzero if error */ register PyObject *x; /* Result object -- NULL if error */ - register PyObject *v; /* Temporary objects popped off stack */ - register PyObject *w; - register PyObject *u; - register PyObject *t; - register PyObject *stream = NULL; /* for PRINT opcodes */ register PyObject **fastlocals, **freevars; PyObject *retval = NULL; /* Return value */ PyThreadState *tstate = PyThreadState_GET(); @@ -595,9 +588,6 @@ READ_TIMESTAMP(inst1); READ_TIMESTAMP(loop0); READ_TIMESTAMP(loop1); - - /* shut up the compiler */ - opcode = 0; #endif /* Code access macros */ @@ -772,7 +762,6 @@ why = WHY_NOT; err = 0; x = Py_None; /* Not a reference, just anything non-NULL */ - w = NULL; if (throwflag) { /* support for generator.throw() */ why = WHY_EXCEPTION; @@ -780,6 +769,13 @@ } for (;;) { + int opcode; /* Current opcode */ + int oparg = 0; /* Current opcode argument, if any */ + PyObject *v; /* Temporary objects popped off stack */ + PyObject *w; + PyObject *u; + PyObject *t; + PyObject *stream = NULL; /* for PRINT opcodes */ #ifdef WITH_TSC if (inst1 == 0) { /* Almost surely, the opcode executed a break @@ -806,9 +802,11 @@ ``things_to_do'' is set, i.e. when an asynchronous event needs attention (e.g. a signal handler or async I/O handler); see Py_AddPendingCall() and - Py_MakePendingCalls() above. */ + Py_MakePendingCalls() above. - if (--_Py_Ticker < 0) { + Post-decrement saves a memory reference. */ + + if (_Py_Ticker-- < 0) { if (*next_instr == SETUP_FINALLY) { /* Make the last opcode before a try: finally: block uninterruptable. */ @@ -888,11 +886,11 @@ /* Extract opcode and argument */ opcode = NEXTOP(); - 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(); - dispatch_opcode: + + /* Target for EXTENDED_ARG. */ + dispatch_opcode: #ifdef DYNAMIC_EXECUTION_PROFILE #ifdef DXPAIRS dxpairs[lastopcode][opcode]++; @@ -932,21 +930,22 @@ goto fast_next_opcode; case LOAD_FAST: - x = GETLOCAL(oparg); - if (x != NULL) { - Py_INCREF(x); - PUSH(x); + w = GETLOCAL(oparg); + if (w != NULL) { + Py_INCREF(w); + PUSH(w); goto fast_next_opcode; } + x = NULL; format_exc_check_arg(PyExc_UnboundLocalError, UNBOUNDLOCAL_ERROR_MSG, PyTuple_GetItem(co->co_varnames, oparg)); break; case LOAD_CONST: - x = GETITEM(consts, oparg); - Py_INCREF(x); - PUSH(x); + w = GETITEM(consts, oparg); + Py_INCREF(w); + PUSH(w); goto fast_next_opcode; PREDICTED_WITH_ARG(STORE_FAST); @@ -1552,7 +1551,7 @@ break; case PRINT_ITEM_TO: - w = stream = POP(); + stream = POP(); /* fall through to PRINT_ITEM */ case PRINT_ITEM: @@ -1565,6 +1564,9 @@ err = -1; } } + else { + w = stream; + } /* PyFile_SoftSpace() can exececute arbitrary code if sys.stdout is an instance with a __getattr__. If __getattr__ raises an exception, w will @@ -1606,7 +1608,7 @@ break; case PRINT_NEWLINE_TO: - w = stream = POP(); + stream = POP(); /* fall through to PRINT_NEWLINE */ case PRINT_NEWLINE: @@ -1616,6 +1618,9 @@ PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); } + else { + w = stream; + } if (w != NULL) { err = PyFile_WriteString("\n", w); if (err == 0) @@ -2622,7 +2627,7 @@ assert(why != WHY_YIELD); /* Pop remaining stack entries. */ while (!EMPTY()) { - v = POP(); + PyObject *v = POP(); Py_XDECREF(v); }