cpython: ac30a1b1cf17 (original) (raw)

--- a/Python/ceval.c +++ b/Python/ceval.c @@ -742,7 +742,6 @@ int enum why_code { WHY_NOT = 0x0001, /* No error / WHY_EXCEPTION = 0x0002, / Exception occurred */

@@ -753,7 +752,7 @@ enum why_code { static void save_exc_state(PyThreadState *, PyFrameObject *); static void swap_exc_state(PyThreadState *, PyFrameObject *); static void restore_and_clear_exc_state(PyThreadState *, PyFrameObject *); -static enum why_code do_raise(PyObject *, PyObject *); +static int do_raise(PyObject *, PyObject *); static int unpack_iterable(PyObject *, int, int, PyObject **); /* Records whether tracing is on for any thread. Counts the number of @@ -798,12 +797,6 @@ PyEval_EvalFrameEx(PyFrameObject f, int register int opcode; / Current opcode / register int oparg; / Current opcode argument, if any / register enum why_code why; / Reason for block stack unwind */

#endif why = WHY_NOT;

-

+

for (;;) { #ifdef WITH_TSC @@ -1255,10 +1243,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int ticked = 1; #endif if (_Py_atomic_load_relaxed(&pendingcalls_to_do)) {

#ifdef WITH_THREAD if (_Py_atomic_load_relaxed(&gil_drop_request)) { @@ -1276,13 +1262,12 @@ PyEval_EvalFrameEx(PyFrameObject f, int #endif / Check for asynchronous exceptions. */ if (tstate->async_exc != NULL) {

@@ -1293,6 +1278,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int if (_Py_TracingPossible && tstate->c_tracefunc != NULL && !tstate->tracing) {

@@ -1307,10 +1293,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int stack_pointer = f->f_stacktop; f->f_stacktop = NULL; }

/* Extract opcode and argument */ @@ -1357,87 +1342,99 @@ PyEval_EvalFrameEx(PyFrameObject *f, int TARGET(NOP) FAST_DISPATCH();

-

+

PREDICTED_WITH_ARG(STORE_FAST);

-

+

-

+

-

+

-

+

-

+

-

-

-

+

+

+

@@ -1450,416 +1447,467 @@ PyEval_EvalFrameEx(PyFrameObject *f, int DISPATCH(); } STACKADJ(-1);

-

-

-

-

-

-

-

+

+

+

+

+

+

+

-

-

-

-

-

-

-

+

+

+

+

+

+

+

+

-

-

-

-

+

-

-

-

-

+

+

+

+

+

+

-

-

-

-

-

-

-

+

+

+

+

+

+

+

-

+

-

+

#ifdef CASE_TOO_BIG default: switch (opcode) { #endif

-

+

-

+

-

+

@@ -1867,39 +1915,38 @@ PyEval_EvalFrameEx(PyFrameObject f, int / and repeat... */ f->f_lasti--; goto fast_yield; -

+

-

+

-

+

PREDICTED(END_FINALLY);

@@ -1912,255 +1959,281 @@ PyEval_EvalFrameEx(PyFrameObject *f, int assert(b->b_type == EXCEPT_HANDLER); UNWIND_EXCEPT_HANDLER(b); why = WHY_NOT;

-

+

+

-

PREDICTED_WITH_ARG(UNPACK_SEQUENCE);

-

+

-

+

+

+

-

-

-

+

-

+

-

+

-

+

@@ -2169,252 +2242,277 @@ PyEval_EvalFrameEx(PyFrameObject *f, int UNBOUNDLOCAL_ERROR_MSG, PyTuple_GetItem(co->co_varnames, oparg) );

-

-

-

-

-

-

+

-

+

+

+

+

-

-

+

+

+

+

-

+

-

-

+

+

-

+

-

+

-

+

PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE);

PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE);

@@ -2422,58 +2520,63 @@ PyEval_EvalFrameEx(PyFrameObject *f, int else if (err == 0) ; else

-

+

-

+

PREDICTED_WITH_ARG(JUMP_ABSOLUTE);

#if FAST_LOOPS /* Enabling this path speeds-up all while and for-loops by bypassing @@ -2487,60 +2590,60 @@ PyEval_EvalFrameEx(PyFrameObject *f, int #else DISPATCH(); #endif -

+

PREDICTED_WITH_ARG(FOR_ITER);

-

+

-

+

TARGET_WITH_IMPL(SETUP_LOOP, _setup_finally) TARGET_WITH_IMPL(SETUP_EXCEPT, _setup_finally) TARGET(SETUP_FINALLY)

@@ -2549,37 +2652,35 @@ PyEval_EvalFrameEx(PyFrameObject *f, int PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, STACK_LEVEL()); DISPATCH(); -

+

@@ -2606,42 +2707,42 @@ PyEval_EvalFrameEx(PyFrameObject *f, int */ PyObject *exit_func;

@@ -2652,56 +2753,53 @@ PyEval_EvalFrameEx(PyFrameObject f, int block->b_level--; } / XXX Not the fastest way to call it... */

-

+

if (err < 0)

#ifdef WITH_TSC

#else

#endif stack_pointer = sp;

TARGET_WITH_IMPL(CALL_FUNCTION_VAR, _call_function_var_kw) TARGET_WITH_IMPL(CALL_FUNCTION_KW, _call_function_var_kw) TARGET(CALL_FUNCTION_VAR_KW)

@@ -2724,137 +2822,156 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_INCREF(func); sp = stack_pointer; READ_TIMESTAMP(intr0);

while (stack_pointer > pfunc) {

TARGET_WITH_IMPL(MAKE_CLOSURE, _make_function) TARGET(MAKE_FUNCTION)

-

+

+

/* XXX Maybe this should be a separate opcode? */

-

+

#if USE_COMPUTED_GOTOS _unknown_opcode: @@ -2865,8 +2982,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int PyFrame_GetLineNumber(f), opcode); PyErr_SetString(PyExc_SystemError, "unknown opcode");

#ifdef CASE_TOO_BIG } @@ -2874,71 +2990,31 @@ PyEval_EvalFrameEx(PyFrameObject f, int } / switch */

-

+ +error: READ_TIMESTAMP(inst1);

-

-#ifdef CHECKEXC

-#endif

-#ifdef CHECKEXC

-#endif

-

-

-#ifdef CHECKEXC

-#endif -

-

-

-

-

+

+

+

+ +fast_block_end:

/* Unwind stacks if a (pseudo) exception occurred / - -fast_block_end: while (why != WHY_NOT && f->f_iblock > 0) { / Peek at the current block. */ PyTryBlock b = &f->f_blockstack[f->f_iblock - 1]; @@ -3022,8 +3098,8 @@ fast_block_end: assert(why != WHY_YIELD); / Pop remaining stack entries. */ while (!EMPTY()) {

raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(cause);

} /* Iterate v argcnt times and store the results on the stack (via decreasing