diff -r 470954641f3b Python/ceval.c --- a/Python/ceval.c Sun Jun 05 12:07:48 2016 +0000 +++ b/Python/ceval.c Tue Jun 07 21:39:27 2016 +0300 @@ -1000,8 +1000,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int /* OpCode prediction macros Some opcodes tend to come in pairs thus making it possible to predict the second code when the first is run. For example, - COMPARE_OP is often followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And, - those opcodes are often followed by a POP_TOP. + COMPARE_OP is often followed by POP_JUMP_IF_FALSE or POP_JUMP_IF_TRUE. + And, those opcodes are often followed by a POP_TOP. Verifying the prediction costs a single high-speed test of a register variable against a constant. If the pairing was good, then the @@ -1379,6 +1379,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int FAST_DISPATCH(); } + PREDICTED(LOAD_CONST); TARGET(LOAD_CONST) { PyObject *value = GETITEM(consts, oparg); Py_INCREF(value); @@ -1393,6 +1394,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int FAST_DISPATCH(); } + PREDICTED(POP_TOP); TARGET(POP_TOP) { PyObject *value = POP(); Py_DECREF(value); @@ -1432,6 +1434,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int STACKADJ(2); SET_TOP(top); SET_SECOND(second); + PREDICT(BINARY_SUBSCR); FAST_DISPATCH(); } @@ -1590,6 +1593,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int DISPATCH(); } + PREDICTED(BINARY_SUBSCR); TARGET(BINARY_SUBSCR) { PyObject *sub = POP(); PyObject *container = TOP(); @@ -1695,6 +1699,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1707,6 +1712,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1719,6 +1725,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1731,6 +1738,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(quotient); if (quotient == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1743,6 +1751,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(quotient); if (quotient == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1755,6 +1764,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(mod); if (mod == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1774,6 +1784,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(sum); if (sum == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1786,6 +1797,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(diff); if (diff == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1798,6 +1810,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1810,6 +1823,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1822,6 +1836,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1834,6 +1849,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1846,6 +1862,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(res); if (res == NULL) goto error; + PREDICT(STORE_FAST); DISPATCH(); } @@ -1972,6 +1989,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_DECREF(iter); SET_TOP(awaitable); + PREDICT(LOAD_CONST); DISPATCH(); } @@ -2014,9 +2032,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int Py_DECREF(next_iter); PUSH(awaitable); + PREDICT(LOAD_CONST); DISPATCH(); } + PREDICTED(GET_AWAITABLE); TARGET(GET_AWAITABLE) { PyObject *iterable = TOP(); PyObject *iter = _PyCoro_GetAwaitableIter(iterable); @@ -2044,6 +2064,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int goto error; } + PREDICT(LOAD_CONST); DISPATCH(); } @@ -2099,6 +2120,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int DISPATCH(); } + PREDICTED(POP_BLOCK); TARGET(POP_BLOCK) { PyTryBlock *b = PyFrame_BlockPop(f); UNWIND_BLOCK(b); @@ -2243,6 +2265,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int goto error; } Py_DECREF(seq); + PREDICT(STORE_FAST); DISPATCH(); } @@ -2433,6 +2456,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int PyObject *cell = freevars[oparg]; Py_INCREF(cell); PUSH(cell); + PREDICT(BUILD_TUPLE); DISPATCH(); } @@ -2489,6 +2513,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int DISPATCH(); } + PREDICTED(BUILD_TUPLE); TARGET(BUILD_TUPLE) { PyObject *tup = PyTuple_New(oparg); if (tup == NULL) @@ -2946,6 +2971,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int if (iter == NULL) goto error; PREDICT(FOR_ITER); + PREDICT(CALL_FUNCTION); DISPATCH(); } @@ -2974,6 +3000,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int if (iter == NULL) goto error; } + PREDICT(LOAD_CONST); DISPATCH(); } @@ -2999,6 +3026,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int STACKADJ(-1); Py_DECREF(iter); JUMPBY(oparg); + PREDICT(POP_BLOCK); DISPATCH(); } @@ -3048,6 +3076,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int if (res == NULL) goto error; PUSH(res); + PREDICT(GET_AWAITABLE); DISPATCH(); } @@ -3084,6 +3113,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int STACK_LEVEL()); PUSH(res); + PREDICT(POP_TOP); + PREDICT(STORE_FAST); DISPATCH(); } @@ -3196,6 +3227,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int DISPATCH(); } + PREDICTED(CALL_FUNCTION); TARGET(CALL_FUNCTION) { PyObject **sp, *res; PCALL(PCALL_ALL); @@ -3384,6 +3416,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int SET_TOP(slice); if (slice == NULL) goto error; + PREDICT(BINARY_SUBSCR); DISPATCH(); }