summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2004-06-17 10:22:40 (GMT)
committerArmin Rigo <arigo@tunes.org>2004-06-17 10:22:40 (GMT)
commit8817fcdba5b43662787fb8d32f62e62a5fd61569 (patch)
treef956455b65333e4cb399a74e636ea178c4d57790 /Python
parent64af6c545c67972fc492af5a69223f6ac46982b5 (diff)
downloadcpython-8817fcdba5b43662787fb8d32f62e62a5fd61569.zip
cpython-8817fcdba5b43662787fb8d32f62e62a5fd61569.tar.gz
cpython-8817fcdba5b43662787fb8d32f62e62a5fd61569.tar.bz2
Performance tweak: allow stack_pointer and oparg to be register variables.
SF patch #943898
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index a52168c..f66e318 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -464,10 +464,10 @@ eval_frame(PyFrameObject *f)
#ifdef DXPAIRS
int lastopcode = 0;
#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 int opcode=0; /* Current opcode */
- register int oparg=0; /* Current opcode argument, if any */
+ 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 */
@@ -807,6 +807,8 @@ eval_frame(PyFrameObject *f)
/* 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:
@@ -2095,16 +2097,21 @@ eval_frame(PyFrameObject *f)
continue;
case CALL_FUNCTION:
+ {
+ PyObject **sp;
PCALL(PCALL_ALL);
+ sp = stack_pointer;
#ifdef WITH_TSC
- x = call_function(&stack_pointer, oparg, &intr0, &intr1);
+ x = call_function(&sp, oparg, &intr0, &intr1);
#else
- x = call_function(&stack_pointer, oparg);
+ x = call_function(&sp, oparg);
#endif
+ stack_pointer = sp;
PUSH(x);
if (x != NULL)
continue;
break;
+ }
case CALL_FUNCTION_VAR:
case CALL_FUNCTION_KW:
@@ -2114,7 +2121,7 @@ eval_frame(PyFrameObject *f)
int nk = (oparg>>8) & 0xff;
int flags = (opcode - CALL_FUNCTION) & 3;
int n = na + 2 * nk;
- PyObject **pfunc, *func;
+ PyObject **pfunc, *func, **sp;
PCALL(PCALL_ALL);
if (flags & CALL_FLAG_VAR)
n++;
@@ -2135,13 +2142,15 @@ eval_frame(PyFrameObject *f)
n++;
} else
Py_INCREF(func);
+ sp = stack_pointer;
#ifdef WITH_TSC
rdtscll(intr0);
#endif
- x = ext_do_call(func, &stack_pointer, flags, na, nk);
+ x = ext_do_call(func, &sp, flags, na, nk);
#ifdef WITH_TSC
rdtscll(intr1);
#endif
+ stack_pointer = sp;
Py_DECREF(func);
while (stack_pointer > pfunc) {