mirror of
https://github.com/python/cpython.git
synced 2024-11-27 20:04:41 +08:00
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.
This commit is contained in:
parent
54e5b89d77
commit
6354386d65
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user