summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-02-17 19:10:14 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-02-17 19:10:14 (GMT)
commit6354386d6568e83e0c81c745e79223b570673fe7 (patch)
tree850ae0f2b43705b95d92cf7b236e2a055be497d9 /Python
parent54e5b89d77ca81f7d81010de288fb5c7d266af94 (diff)
downloadcpython-6354386d6568e83e0c81c745e79223b570673fe7.zip
cpython-6354386d6568e83e0c81c745e79223b570673fe7.tar.gz
cpython-6354386d6568e83e0c81c745e79223b570673fe7.tar.bz2
Move some opcodes to top of big eval_frame switch statement. Skip
things_to_do block for a few common opcodes that don't do any real work. Closes SF patch #512256.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c89
1 files changed, 45 insertions, 44 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 202c868..dc00e42 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -680,6 +680,7 @@ eval_frame(PyFrameObject *f)
#endif
}
+ fast_next_opcode:
/* Extract opcode and argument */
#if defined(Py_DEBUG) || defined(LLTRACE)
@@ -724,10 +725,53 @@ eval_frame(PyFrameObject *f)
/* case STOP_CODE: this is an error! */
+ case SET_LINENO:
+#ifdef LLTRACE
+ if (lltrace)
+ printf("--- %s:%d \n", filename, oparg);
+#endif
+ f->f_lineno = oparg;
+ if (tstate->c_tracefunc == NULL || tstate->tracing)
+ goto fast_next_opcode;
+ /* Trace each line of code reached */
+ f->f_lasti = INSTR_OFFSET();
+ /* Inline call_trace() for performance: */
+ tstate->tracing++;
+ tstate->use_tracing = 0;
+ err = (tstate->c_tracefunc)(tstate->c_traceobj, f,
+ PyTrace_LINE, Py_None);
+ tstate->use_tracing = (tstate->c_tracefunc
+ || tstate->c_profilefunc);
+ tstate->tracing--;
+ break;
+
+ case LOAD_FAST:
+ x = GETLOCAL(oparg);
+ if (x != NULL) {
+ Py_INCREF(x);
+ PUSH(x);
+ goto fast_next_opcode;
+ }
+ format_exc_check_arg(PyExc_UnboundLocalError,
+ UNBOUNDLOCAL_ERROR_MSG,
+ PyTuple_GetItem(co->co_varnames, oparg));
+ break;
+
+ case LOAD_CONST:
+ x = GETCONST(oparg);
+ Py_INCREF(x);
+ PUSH(x);
+ goto fast_next_opcode;
+
+ case STORE_FAST:
+ v = POP();
+ SETLOCAL(oparg, v);
+ goto fast_next_opcode;
+
case POP_TOP:
v = POP();
Py_DECREF(v);
- continue;
+ goto fast_next_opcode;
case ROT_TWO:
v = POP();
@@ -1617,12 +1661,6 @@ eval_frame(PyFrameObject *f)
PyExc_NameError, GLOBAL_NAME_ERROR_MSG, w);
break;
- case LOAD_CONST:
- x = GETCONST(oparg);
- Py_INCREF(x);
- PUSH(x);
- break;
-
case LOAD_NAME:
w = GETNAMEV(oparg);
if ((x = f->f_locals) == NULL) {
@@ -1664,23 +1702,6 @@ eval_frame(PyFrameObject *f)
PUSH(x);
break;
- case LOAD_FAST:
- x = GETLOCAL(oparg);
- if (x != NULL) {
- Py_INCREF(x);
- PUSH(x);
- continue;
- }
- format_exc_check_arg(PyExc_UnboundLocalError,
- UNBOUNDLOCAL_ERROR_MSG,
- PyTuple_GetItem(co->co_varnames, oparg));
- break;
-
- case STORE_FAST:
- v = POP();
- SETLOCAL(oparg, v);
- continue;
-
case DELETE_FAST:
x = GETLOCAL(oparg);
if (x == NULL) {
@@ -1949,26 +1970,6 @@ eval_frame(PyFrameObject *f)
STACK_LEVEL());
continue;
- case SET_LINENO:
-#ifdef LLTRACE
- if (lltrace)
- printf("--- %s:%d \n", filename, oparg);
-#endif
- f->f_lineno = oparg;
- if (tstate->c_tracefunc == NULL || tstate->tracing)
- continue;
- /* Trace each line of code reached */
- f->f_lasti = INSTR_OFFSET();
- /* Inline call_trace() for performance: */
- tstate->tracing++;
- tstate->use_tracing = 0;
- err = (tstate->c_tracefunc)(tstate->c_traceobj, f,
- PyTrace_LINE, Py_None);
- tstate->use_tracing = (tstate->c_tracefunc
- || tstate->c_profilefunc);
- tstate->tracing--;
- break;
-
case CALL_FUNCTION:
{
int na = oparg & 0xff;