Performance tweak: allow stack_pointer and oparg to be register variables.

SF patch #943898
This commit is contained in:
Armin Rigo 2004-06-17 10:22:40 +00:00
parent 64af6c545c
commit 8817fcdba5
1 changed files with 16 additions and 7 deletions

View File

@ -464,10 +464,10 @@ eval_frame(PyFrameObject *f)
#ifdef DXPAIRS #ifdef DXPAIRS
int lastopcode = 0; int lastopcode = 0;
#endif #endif
PyObject **stack_pointer; /* Next free slot in value stack */ register PyObject **stack_pointer; /* Next free slot in value stack */
register unsigned char *next_instr; register unsigned char *next_instr;
register int opcode=0; /* Current opcode */ register int opcode; /* Current opcode */
register int oparg=0; /* Current opcode argument, if any */ register int oparg; /* Current opcode argument, if any */
register enum why_code why; /* Reason for block stack unwind */ register enum why_code why; /* Reason for block stack unwind */
register int err; /* Error status -- nonzero if error */ register int err; /* Error status -- nonzero if error */
register PyObject *x; /* Result object -- NULL if error */ register PyObject *x; /* Result object -- NULL if error */
@ -807,6 +807,8 @@ eval_frame(PyFrameObject *f)
/* Extract opcode and argument */ /* Extract opcode and argument */
opcode = NEXTOP(); 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)) if (HAS_ARG(opcode))
oparg = NEXTARG(); oparg = NEXTARG();
dispatch_opcode: dispatch_opcode:
@ -2095,16 +2097,21 @@ eval_frame(PyFrameObject *f)
continue; continue;
case CALL_FUNCTION: case CALL_FUNCTION:
{
PyObject **sp;
PCALL(PCALL_ALL); PCALL(PCALL_ALL);
sp = stack_pointer;
#ifdef WITH_TSC #ifdef WITH_TSC
x = call_function(&stack_pointer, oparg, &intr0, &intr1); x = call_function(&sp, oparg, &intr0, &intr1);
#else #else
x = call_function(&stack_pointer, oparg); x = call_function(&sp, oparg);
#endif #endif
stack_pointer = sp;
PUSH(x); PUSH(x);
if (x != NULL) if (x != NULL)
continue; continue;
break; break;
}
case CALL_FUNCTION_VAR: case CALL_FUNCTION_VAR:
case CALL_FUNCTION_KW: case CALL_FUNCTION_KW:
@ -2114,7 +2121,7 @@ eval_frame(PyFrameObject *f)
int nk = (oparg>>8) & 0xff; int nk = (oparg>>8) & 0xff;
int flags = (opcode - CALL_FUNCTION) & 3; int flags = (opcode - CALL_FUNCTION) & 3;
int n = na + 2 * nk; int n = na + 2 * nk;
PyObject **pfunc, *func; PyObject **pfunc, *func, **sp;
PCALL(PCALL_ALL); PCALL(PCALL_ALL);
if (flags & CALL_FLAG_VAR) if (flags & CALL_FLAG_VAR)
n++; n++;
@ -2135,13 +2142,15 @@ eval_frame(PyFrameObject *f)
n++; n++;
} else } else
Py_INCREF(func); Py_INCREF(func);
sp = stack_pointer;
#ifdef WITH_TSC #ifdef WITH_TSC
rdtscll(intr0); rdtscll(intr0);
#endif #endif
x = ext_do_call(func, &stack_pointer, flags, na, nk); x = ext_do_call(func, &sp, flags, na, nk);
#ifdef WITH_TSC #ifdef WITH_TSC
rdtscll(intr1); rdtscll(intr1);
#endif #endif
stack_pointer = sp;
Py_DECREF(func); Py_DECREF(func);
while (stack_pointer > pfunc) { while (stack_pointer > pfunc) {