mirror of
https://github.com/python/cpython.git
synced 2024-11-29 21:05:33 +08:00
SF patch #864059: optimize eval_frame
Simplified version of Neal Norwitz's patch which adds gotos for opcodes that set "why". This skips a number of tests where the outcome of the tests are known in advance.
This commit is contained in:
parent
7dcf9f89d3
commit
1dd8309246
@ -1578,12 +1578,12 @@ eval_frame(PyFrameObject *f)
|
|||||||
#endif
|
#endif
|
||||||
case BREAK_LOOP:
|
case BREAK_LOOP:
|
||||||
why = WHY_BREAK;
|
why = WHY_BREAK;
|
||||||
break;
|
goto fast_block_end;
|
||||||
|
|
||||||
case CONTINUE_LOOP:
|
case CONTINUE_LOOP:
|
||||||
retval = PyInt_FromLong(oparg);
|
retval = PyInt_FromLong(oparg);
|
||||||
why = WHY_CONTINUE;
|
why = WHY_CONTINUE;
|
||||||
break;
|
goto fast_block_end;
|
||||||
|
|
||||||
case RAISE_VARARGS:
|
case RAISE_VARARGS:
|
||||||
u = v = w = NULL;
|
u = v = w = NULL;
|
||||||
@ -1620,14 +1620,13 @@ eval_frame(PyFrameObject *f)
|
|||||||
case RETURN_VALUE:
|
case RETURN_VALUE:
|
||||||
retval = POP();
|
retval = POP();
|
||||||
why = WHY_RETURN;
|
why = WHY_RETURN;
|
||||||
break;
|
goto fast_block_end;
|
||||||
|
|
||||||
case YIELD_VALUE:
|
case YIELD_VALUE:
|
||||||
retval = POP();
|
retval = POP();
|
||||||
f->f_stacktop = stack_pointer;
|
f->f_stacktop = stack_pointer;
|
||||||
why = WHY_YIELD;
|
why = WHY_YIELD;
|
||||||
break;
|
goto fast_yield;
|
||||||
|
|
||||||
|
|
||||||
case EXEC_STMT:
|
case EXEC_STMT:
|
||||||
w = TOP();
|
w = TOP();
|
||||||
@ -2327,6 +2326,7 @@ eval_frame(PyFrameObject *f)
|
|||||||
|
|
||||||
/* Unwind stacks if a (pseudo) exception occurred */
|
/* Unwind stacks if a (pseudo) exception occurred */
|
||||||
|
|
||||||
|
fast_block_end:
|
||||||
while (why != WHY_NOT && why != WHY_YIELD && f->f_iblock > 0) {
|
while (why != WHY_NOT && why != WHY_YIELD && f->f_iblock > 0) {
|
||||||
PyTryBlock *b = PyFrame_BlockPop(f);
|
PyTryBlock *b = PyFrame_BlockPop(f);
|
||||||
|
|
||||||
@ -2410,6 +2410,7 @@ eval_frame(PyFrameObject *f)
|
|||||||
if (why != WHY_RETURN && why != WHY_YIELD)
|
if (why != WHY_RETURN && why != WHY_YIELD)
|
||||||
retval = NULL;
|
retval = NULL;
|
||||||
|
|
||||||
|
fast_yield:
|
||||||
if (tstate->use_tracing) {
|
if (tstate->use_tracing) {
|
||||||
if (tstate->c_tracefunc
|
if (tstate->c_tracefunc
|
||||||
&& (why == WHY_RETURN || why == WHY_YIELD)) {
|
&& (why == WHY_RETURN || why == WHY_YIELD)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user