From a1953703a725edb6c72452d274cb7b5fac508086 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 10 Jul 2023 19:18:53 -0700 Subject: [PATCH 1/6] macro(FOR_ITER_RANGE) = _ITER_NEXT_RANGE + _FOR_ITER_END (Plus a skipped cache entry.) --- Python/bytecodes.c | 32 ++-- Python/executor_cases.c.h | 79 ++++++---- Python/generated_cases.c.h | 312 ++++++++++++++++++++----------------- Python/opcode_metadata.h | 2 + 4 files changed, 244 insertions(+), 181 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 2f6b8c5ae2f9cb..434eb5521d76cb 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2432,27 +2432,41 @@ dummy_func( // Common case: no jump, leave it to the code generator } - inst(FOR_ITER_RANGE, (unused/1, iter -- iter, next)) { + op(_ITER_NEXT_RANGE, (iter -- iter, next)) { _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { + next = NULL; + } + else { + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + ERROR_IF(next == NULL, error); + } + } + + op(_FOR_ITER_END, (iter, next -- iter, next)) { + if (next == NULL) { + // You might expect STACK_SHRINK(2) here. + // But we're taking a dangerous shortcut here: + // This op is always the second half of a + // (_ITER_NEXT_RANGE, _FOR_ITER_END) pair, + // and and the code generator hasn't increased + // the stack pointer to account for 'next' yet. STACK_SHRINK(1); - Py_DECREF(r); + Py_DECREF(iter); SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); // Jump over END_FOR instruction. JUMPBY(oparg + 1); DISPATCH(); } - long value = r->start; - r->start = value + r->step; - r->len--; - next = PyLong_FromLong(value); - if (next == NULL) { - goto error; - } } + macro(FOR_ITER_RANGE) = unused/1 + _ITER_NEXT_RANGE + _FOR_ITER_END; + inst(FOR_ITER_GEN, (unused/1, iter -- iter, unused)) { DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 681efb97d89a5f..0e90a37c006187 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1980,12 +1980,35 @@ break; } + case _ITER_NEXT_RANGE: { + PyObject *iter = stack_pointer[-1]; + PyObject *next; + #line 2436 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + STAT_INC(FOR_ITER, hit); + if (r->len <= 0) { + next = NULL; + } + else { + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + if (next == NULL) goto error; + } + #line 2001 "Python/executor_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = next; + break; + } + case WITH_EXCEPT_START: { PyObject *val = stack_pointer[-1]; PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2542 "Python/bytecodes.c" + #line 2556 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -2006,7 +2029,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 2010 "Python/executor_cases.c.h" + #line 2033 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; break; @@ -2015,7 +2038,7 @@ case PUSH_EXC_INFO: { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2581 "Python/bytecodes.c" + #line 2595 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -2025,7 +2048,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 2029 "Python/executor_cases.c.h" + #line 2052 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -2034,7 +2057,7 @@ case EXIT_INIT_CHECK: { PyObject *should_be_none = stack_pointer[-1]; - #line 2980 "Python/bytecodes.c" + #line 2994 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -2042,7 +2065,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 2046 "Python/executor_cases.c.h" + #line 2069 "Python/executor_cases.c.h" STACK_SHRINK(1); break; } @@ -2050,7 +2073,7 @@ case MAKE_FUNCTION: { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3394 "Python/bytecodes.c" + #line 3408 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -2062,7 +2085,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 2066 "Python/executor_cases.c.h" + #line 2089 "Python/executor_cases.c.h" stack_pointer[-1] = func; break; } @@ -2070,7 +2093,7 @@ case SET_FUNCTION_ATTRIBUTE: { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3408 "Python/bytecodes.c" + #line 3422 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -2095,7 +2118,7 @@ default: Py_UNREACHABLE(); } - #line 2099 "Python/executor_cases.c.h" + #line 2122 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; break; @@ -2106,15 +2129,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3458 "Python/bytecodes.c" + #line 3472 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 2112 "Python/executor_cases.c.h" + #line 2135 "Python/executor_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3460 "Python/bytecodes.c" + #line 3474 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 2118 "Python/executor_cases.c.h" + #line 2141 "Python/executor_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -2124,14 +2147,14 @@ case CONVERT_VALUE: { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3464 "Python/bytecodes.c" + #line 3478 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 2135 "Python/executor_cases.c.h" + #line 2158 "Python/executor_cases.c.h" stack_pointer[-1] = result; break; } @@ -2139,7 +2162,7 @@ case FORMAT_SIMPLE: { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3473 "Python/bytecodes.c" + #line 3487 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -2150,7 +2173,7 @@ else { res = value; } - #line 2154 "Python/executor_cases.c.h" + #line 2177 "Python/executor_cases.c.h" stack_pointer[-1] = res; break; } @@ -2159,12 +2182,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3486 "Python/bytecodes.c" + #line 3500 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 2168 "Python/executor_cases.c.h" + #line 2191 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2173,10 +2196,10 @@ case COPY: { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3493 "Python/bytecodes.c" + #line 3507 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 2180 "Python/executor_cases.c.h" + #line 2203 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; break; @@ -2187,7 +2210,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3498 "Python/bytecodes.c" + #line 3512 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2202,12 +2225,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 2206 "Python/executor_cases.c.h" + #line 2229 "Python/executor_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3513 "Python/bytecodes.c" + #line 3527 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2211 "Python/executor_cases.c.h" + #line 2234 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2216,9 +2239,9 @@ case SWAP: { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3518 "Python/bytecodes.c" + #line 3532 "Python/bytecodes.c" assert(oparg >= 2); - #line 2222 "Python/executor_cases.c.h" + #line 2245 "Python/executor_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; break; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index eb3de5e5bca97f..6811084bb61a7b 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3484,37 +3484,61 @@ } TARGET(FOR_ITER_RANGE) { - PyObject *iter = stack_pointer[-1]; - PyObject *next; - #line 2436 "Python/bytecodes.c" - _PyRangeIterObject *r = (_PyRangeIterObject *)iter; - DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); - STAT_INC(FOR_ITER, hit); - if (r->len <= 0) { - STACK_SHRINK(1); - Py_DECREF(r); - SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); - // Jump over END_FOR instruction. - JUMPBY(oparg + 1); - DISPATCH(); + PyObject *_tmp_1; + PyObject *_tmp_2 = stack_pointer[-1]; + { + PyObject *iter = _tmp_2; + PyObject *next; + #line 2436 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + STAT_INC(FOR_ITER, hit); + if (r->len <= 0) { + next = NULL; + } + else { + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + if (next == NULL) goto error; + } + #line 3507 "Python/generated_cases.c.h" + _tmp_2 = iter; + _tmp_1 = next; } - long value = r->start; - r->start = value + r->step; - r->len--; - next = PyLong_FromLong(value); - if (next == NULL) { - goto error; + { + PyObject *next = _tmp_1; + PyObject *iter = _tmp_2; + #line 2452 "Python/bytecodes.c" + if (next == NULL) { + // You might expect STACK_SHRINK(2) here. + // But we're taking a dangerous shortcut here: + // This op is always the second half of a + // (_ITER_NEXT_RANGE, _FOR_ITER_END) pair, + // and and the code generator hasn't increased + // the stack pointer to account for 'next' yet. + STACK_SHRINK(1); + Py_DECREF(iter); + SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); + // Jump over END_FOR instruction. + JUMPBY(oparg + 1); + DISPATCH(); + } + #line 3529 "Python/generated_cases.c.h" + _tmp_2 = iter; + _tmp_1 = next; } - #line 3509 "Python/generated_cases.c.h" - STACK_GROW(1); - stack_pointer[-1] = next; next_instr += 1; + STACK_GROW(1); + stack_pointer[-1] = _tmp_1; + stack_pointer[-2] = _tmp_2; DISPATCH(); } TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2457 "Python/bytecodes.c" + #line 2471 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3530,14 +3554,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3534 "Python/generated_cases.c.h" + #line 3558 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2475 "Python/bytecodes.c" + #line 2489 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3560,16 +3584,16 @@ Py_DECREF(enter); goto error; } - #line 3564 "Python/generated_cases.c.h" + #line 3588 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2498 "Python/bytecodes.c" + #line 2512 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3573 "Python/generated_cases.c.h" + #line 3597 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3580,7 +3604,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2507 "Python/bytecodes.c" + #line 2521 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3606,16 +3630,16 @@ Py_DECREF(enter); goto error; } - #line 3610 "Python/generated_cases.c.h" + #line 3634 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2533 "Python/bytecodes.c" + #line 2547 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3619 "Python/generated_cases.c.h" + #line 3643 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3627,7 +3651,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2542 "Python/bytecodes.c" + #line 2556 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3648,7 +3672,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3652 "Python/generated_cases.c.h" + #line 3676 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3657,7 +3681,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2581 "Python/bytecodes.c" + #line 2595 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3667,7 +3691,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3671 "Python/generated_cases.c.h" + #line 3695 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3681,7 +3705,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2593 "Python/bytecodes.c" + #line 2607 "Python/bytecodes.c" assert(oparg & 1); /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); @@ -3698,7 +3722,7 @@ res2 = Py_NewRef(descr); assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; - #line 3702 "Python/generated_cases.c.h" + #line 3726 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3712,7 +3736,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2612 "Python/bytecodes.c" + #line 2626 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3722,7 +3746,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3726 "Python/generated_cases.c.h" + #line 3750 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3737,7 +3761,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2624 "Python/bytecodes.c" + #line 2638 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3750,11 +3774,11 @@ keys_version, LOAD_ATTR); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3754 "Python/generated_cases.c.h" + #line 3778 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2637 "Python/bytecodes.c" + #line 2651 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3758 "Python/generated_cases.c.h" + #line 3782 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3768,7 +3792,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2641 "Python/bytecodes.c" + #line 2655 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3776,11 +3800,11 @@ assert(self_cls->tp_dictoffset == 0); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3780 "Python/generated_cases.c.h" + #line 3804 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2649 "Python/bytecodes.c" + #line 2663 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3784 "Python/generated_cases.c.h" + #line 3808 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3794,7 +3818,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2653 "Python/bytecodes.c" + #line 2667 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3808,7 +3832,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3812 "Python/generated_cases.c.h" + #line 3836 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3817,16 +3841,16 @@ } TARGET(KW_NAMES) { - #line 2669 "Python/bytecodes.c" + #line 2683 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - #line 3825 "Python/generated_cases.c.h" + #line 3849 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2675 "Python/bytecodes.c" + #line 2689 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3839,7 +3863,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3843 "Python/generated_cases.c.h" + #line 3867 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3849,7 +3873,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2721 "Python/bytecodes.c" + #line 2735 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3931,7 +3955,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3935 "Python/generated_cases.c.h" + #line 3959 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3943,7 +3967,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2809 "Python/bytecodes.c" + #line 2823 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3953,7 +3977,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3957 "Python/generated_cases.c.h" + #line 3981 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3962,7 +3986,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2821 "Python/bytecodes.c" + #line 2835 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3988,7 +4012,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3992 "Python/generated_cases.c.h" + #line 4016 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3996,7 +4020,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2849 "Python/bytecodes.c" + #line 2863 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4032,7 +4056,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4036 "Python/generated_cases.c.h" + #line 4060 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -4040,7 +4064,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2887 "Python/bytecodes.c" + #line 2901 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4050,7 +4074,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 4054 "Python/generated_cases.c.h" + #line 4078 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4063,7 +4087,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2899 "Python/bytecodes.c" + #line 2913 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4074,7 +4098,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4078 "Python/generated_cases.c.h" + #line 4102 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4088,7 +4112,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2913 "Python/bytecodes.c" + #line 2927 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4099,7 +4123,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4103 "Python/generated_cases.c.h" + #line 4127 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4112,7 +4136,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; - #line 2927 "Python/bytecodes.c" + #line 2941 "Python/bytecodes.c" /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -4163,12 +4187,12 @@ * as it will be checked after start_frame */ tstate->py_recursion_remaining--; goto start_frame; - #line 4167 "Python/generated_cases.c.h" + #line 4191 "Python/generated_cases.c.h" } TARGET(EXIT_INIT_CHECK) { PyObject *should_be_none = stack_pointer[-1]; - #line 2980 "Python/bytecodes.c" + #line 2994 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -4176,7 +4200,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 4180 "Python/generated_cases.c.h" + #line 4204 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -4186,7 +4210,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2990 "Python/bytecodes.c" + #line 3004 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4208,7 +4232,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4212 "Python/generated_cases.c.h" + #line 4236 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4222,7 +4246,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3015 "Python/bytecodes.c" + #line 3029 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4250,7 +4274,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4254 "Python/generated_cases.c.h" + #line 4278 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4264,7 +4288,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3046 "Python/bytecodes.c" + #line 3060 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4296,7 +4320,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4300 "Python/generated_cases.c.h" + #line 4324 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4310,7 +4334,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3081 "Python/bytecodes.c" + #line 3095 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4342,7 +4366,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4346 "Python/generated_cases.c.h" + #line 4370 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4356,7 +4380,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3116 "Python/bytecodes.c" + #line 3130 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4381,7 +4405,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4385 "Python/generated_cases.c.h" + #line 4409 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4394,7 +4418,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3143 "Python/bytecodes.c" + #line 3157 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4421,7 +4445,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4425 "Python/generated_cases.c.h" + #line 4449 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4433,7 +4457,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3173 "Python/bytecodes.c" + #line 3187 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4451,14 +4475,14 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4455 "Python/generated_cases.c.h" + #line 4479 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3193 "Python/bytecodes.c" + #line 3207 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4489,7 +4513,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4493 "Python/generated_cases.c.h" + #line 4517 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4502,7 +4526,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3227 "Python/bytecodes.c" + #line 3241 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4531,7 +4555,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4535 "Python/generated_cases.c.h" + #line 4559 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4544,7 +4568,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3259 "Python/bytecodes.c" + #line 3273 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4573,7 +4597,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4577 "Python/generated_cases.c.h" + #line 4601 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4586,7 +4610,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3291 "Python/bytecodes.c" + #line 3305 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4614,7 +4638,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4618 "Python/generated_cases.c.h" + #line 4642 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4624,9 +4648,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3322 "Python/bytecodes.c" + #line 3336 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4630 "Python/generated_cases.c.h" + #line 4654 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4635,7 +4659,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3326 "Python/bytecodes.c" + #line 3340 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4697,14 +4721,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4701 "Python/generated_cases.c.h" + #line 4725 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3388 "Python/bytecodes.c" + #line 3402 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4708 "Python/generated_cases.c.h" + #line 4732 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4715,7 +4739,7 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3394 "Python/bytecodes.c" + #line 3408 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4727,7 +4751,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4731 "Python/generated_cases.c.h" + #line 4755 "Python/generated_cases.c.h" stack_pointer[-1] = func; DISPATCH(); } @@ -4735,7 +4759,7 @@ TARGET(SET_FUNCTION_ATTRIBUTE) { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3408 "Python/bytecodes.c" + #line 3422 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -4760,14 +4784,14 @@ default: Py_UNREACHABLE(); } - #line 4764 "Python/generated_cases.c.h" + #line 4788 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3435 "Python/bytecodes.c" + #line 3449 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4788,7 +4812,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4792 "Python/generated_cases.c.h" + #line 4816 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4796,15 +4820,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3458 "Python/bytecodes.c" + #line 3472 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4802 "Python/generated_cases.c.h" + #line 4826 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3460 "Python/bytecodes.c" + #line 3474 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4808 "Python/generated_cases.c.h" + #line 4832 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4814,14 +4838,14 @@ TARGET(CONVERT_VALUE) { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3464 "Python/bytecodes.c" + #line 3478 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 4825 "Python/generated_cases.c.h" + #line 4849 "Python/generated_cases.c.h" stack_pointer[-1] = result; DISPATCH(); } @@ -4829,7 +4853,7 @@ TARGET(FORMAT_SIMPLE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3473 "Python/bytecodes.c" + #line 3487 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -4840,7 +4864,7 @@ else { res = value; } - #line 4844 "Python/generated_cases.c.h" + #line 4868 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -4849,12 +4873,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3486 "Python/bytecodes.c" + #line 3500 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 4858 "Python/generated_cases.c.h" + #line 4882 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -4863,10 +4887,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3493 "Python/bytecodes.c" + #line 3507 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4870 "Python/generated_cases.c.h" + #line 4894 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4878,7 +4902,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3498 "Python/bytecodes.c" + #line 3512 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4893,12 +4917,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4897 "Python/generated_cases.c.h" + #line 4921 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3513 "Python/bytecodes.c" + #line 3527 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4902 "Python/generated_cases.c.h" + #line 4926 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4908,16 +4932,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3518 "Python/bytecodes.c" + #line 3532 "Python/bytecodes.c" assert(oparg >= 2); - #line 4914 "Python/generated_cases.c.h" + #line 4938 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3522 "Python/bytecodes.c" + #line 3536 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4929,48 +4953,48 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4933 "Python/generated_cases.c.h" + #line 4957 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3536 "Python/bytecodes.c" + #line 3550 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4939 "Python/generated_cases.c.h" + #line 4963 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3540 "Python/bytecodes.c" + #line 3554 "Python/bytecodes.c" CHECK_EVAL_BREAKER(); INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP); - #line 4947 "Python/generated_cases.c.h" + #line 4971 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3545 "Python/bytecodes.c" + #line 3559 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsTrue(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4958 "Python/generated_cases.c.h" + #line 4982 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3553 "Python/bytecodes.c" + #line 3567 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsFalse(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4969 "Python/generated_cases.c.h" + #line 4993 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3561 "Python/bytecodes.c" + #line 3575 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4982,12 +5006,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4986 "Python/generated_cases.c.h" + #line 5010 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3575 "Python/bytecodes.c" + #line 3589 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4999,30 +5023,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5003 "Python/generated_cases.c.h" + #line 5027 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3589 "Python/bytecodes.c" + #line 3603 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 5014 "Python/generated_cases.c.h" + #line 5038 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3597 "Python/bytecodes.c" + #line 3611 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 5021 "Python/generated_cases.c.h" + #line 5045 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3602 "Python/bytecodes.c" + #line 3616 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 5028 "Python/generated_cases.c.h" + #line 5052 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 4a41cd86a4287b..1231860deee843 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -37,6 +37,7 @@ #define _LOAD_LOCALS 315 #define _LOAD_FROM_DICT_OR_GLOBALS 316 #define IS_NONE 317 +#define _ITER_NEXT_RANGE 318 #ifndef NEED_OPCODE_METADATA extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump); @@ -1313,5 +1314,6 @@ const char * const _PyOpcode_uop_name[512] = { [315] = "_LOAD_LOCALS", [316] = "_LOAD_FROM_DICT_OR_GLOBALS", [317] = "IS_NONE", + [318] = "_ITER_NEXT_RANGE", }; #endif // NEED_OPCODE_METADATA From aafc5c35d81304d638956001df18e313f727ebdd Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Jul 2023 10:55:45 -0700 Subject: [PATCH 2/6] macro(FOR_ITER_RANGE) = _ITER_CHECK_RANGE + _ITER_NEXT_RANGE + _FOR_ITER_END --- Python/bytecodes.c | 11 +- Python/executor_cases.c.h | 71 +++++----- Python/generated_cases.c.h | 260 +++++++++++++++++++------------------ Python/opcode_metadata.h | 6 +- 4 files changed, 187 insertions(+), 161 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 434eb5521d76cb..954e7128b5065d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2432,9 +2432,15 @@ dummy_func( // Common case: no jump, leave it to the code generator } - op(_ITER_NEXT_RANGE, (iter -- iter, next)) { + op(_ITER_CHECK_RANGE, (iter -- iter)) { _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + } + + // NOTE: next may be NULL (TODO: Can we show this in the type?) + op(_ITER_NEXT_RANGE, (iter -- iter, next)) { + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { next = NULL; @@ -2465,7 +2471,8 @@ dummy_func( } } - macro(FOR_ITER_RANGE) = unused/1 + _ITER_NEXT_RANGE + _FOR_ITER_END; + macro(FOR_ITER_RANGE) = + unused/1 + _ITER_CHECK_RANGE + _ITER_NEXT_RANGE + _FOR_ITER_END; inst(FOR_ITER_GEN, (unused/1, iter -- iter, unused)) { DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 0e90a37c006187..ea19c9fce1454a 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1980,12 +1980,21 @@ break; } - case _ITER_NEXT_RANGE: { + case _ITER_CHECK_RANGE: { PyObject *iter = stack_pointer[-1]; - PyObject *next; #line 2436 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + #line 1989 "Python/executor_cases.c.h" + break; + } + + case _ITER_NEXT_RANGE: { + PyObject *iter = stack_pointer[-1]; + PyObject *next; + #line 2442 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { next = NULL; @@ -1997,7 +2006,7 @@ next = PyLong_FromLong(value); if (next == NULL) goto error; } - #line 2001 "Python/executor_cases.c.h" + #line 2010 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; break; @@ -2008,7 +2017,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2556 "Python/bytecodes.c" + #line 2563 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -2029,7 +2038,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 2033 "Python/executor_cases.c.h" + #line 2042 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; break; @@ -2038,7 +2047,7 @@ case PUSH_EXC_INFO: { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2595 "Python/bytecodes.c" + #line 2602 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -2048,7 +2057,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 2052 "Python/executor_cases.c.h" + #line 2061 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -2057,7 +2066,7 @@ case EXIT_INIT_CHECK: { PyObject *should_be_none = stack_pointer[-1]; - #line 2994 "Python/bytecodes.c" + #line 3001 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -2065,7 +2074,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 2069 "Python/executor_cases.c.h" + #line 2078 "Python/executor_cases.c.h" STACK_SHRINK(1); break; } @@ -2073,7 +2082,7 @@ case MAKE_FUNCTION: { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3408 "Python/bytecodes.c" + #line 3415 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -2085,7 +2094,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 2089 "Python/executor_cases.c.h" + #line 2098 "Python/executor_cases.c.h" stack_pointer[-1] = func; break; } @@ -2093,7 +2102,7 @@ case SET_FUNCTION_ATTRIBUTE: { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3422 "Python/bytecodes.c" + #line 3429 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -2118,7 +2127,7 @@ default: Py_UNREACHABLE(); } - #line 2122 "Python/executor_cases.c.h" + #line 2131 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; break; @@ -2129,15 +2138,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3472 "Python/bytecodes.c" + #line 3479 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 2135 "Python/executor_cases.c.h" + #line 2144 "Python/executor_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3474 "Python/bytecodes.c" + #line 3481 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 2141 "Python/executor_cases.c.h" + #line 2150 "Python/executor_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -2147,14 +2156,14 @@ case CONVERT_VALUE: { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3478 "Python/bytecodes.c" + #line 3485 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 2158 "Python/executor_cases.c.h" + #line 2167 "Python/executor_cases.c.h" stack_pointer[-1] = result; break; } @@ -2162,7 +2171,7 @@ case FORMAT_SIMPLE: { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3487 "Python/bytecodes.c" + #line 3494 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -2173,7 +2182,7 @@ else { res = value; } - #line 2177 "Python/executor_cases.c.h" + #line 2186 "Python/executor_cases.c.h" stack_pointer[-1] = res; break; } @@ -2182,12 +2191,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3500 "Python/bytecodes.c" + #line 3507 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 2191 "Python/executor_cases.c.h" + #line 2200 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2196,10 +2205,10 @@ case COPY: { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3507 "Python/bytecodes.c" + #line 3514 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 2203 "Python/executor_cases.c.h" + #line 2212 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; break; @@ -2210,7 +2219,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3512 "Python/bytecodes.c" + #line 3519 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2225,12 +2234,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 2229 "Python/executor_cases.c.h" + #line 2238 "Python/executor_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3527 "Python/bytecodes.c" + #line 3534 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2234 "Python/executor_cases.c.h" + #line 2243 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2239,9 +2248,9 @@ case SWAP: { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3532 "Python/bytecodes.c" + #line 3539 "Python/bytecodes.c" assert(oparg >= 2); - #line 2245 "Python/executor_cases.c.h" + #line 2254 "Python/executor_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; break; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 6811084bb61a7b..b5b70d2f0abbf8 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3488,10 +3488,18 @@ PyObject *_tmp_2 = stack_pointer[-1]; { PyObject *iter = _tmp_2; - PyObject *next; #line 2436 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + #line 3495 "Python/generated_cases.c.h" + _tmp_2 = iter; + } + { + PyObject *iter = _tmp_2; + PyObject *next; + #line 2442 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { next = NULL; @@ -3503,14 +3511,14 @@ next = PyLong_FromLong(value); if (next == NULL) goto error; } - #line 3507 "Python/generated_cases.c.h" + #line 3515 "Python/generated_cases.c.h" _tmp_2 = iter; _tmp_1 = next; } { PyObject *next = _tmp_1; PyObject *iter = _tmp_2; - #line 2452 "Python/bytecodes.c" + #line 2458 "Python/bytecodes.c" if (next == NULL) { // You might expect STACK_SHRINK(2) here. // But we're taking a dangerous shortcut here: @@ -3525,7 +3533,7 @@ JUMPBY(oparg + 1); DISPATCH(); } - #line 3529 "Python/generated_cases.c.h" + #line 3537 "Python/generated_cases.c.h" _tmp_2 = iter; _tmp_1 = next; } @@ -3538,7 +3546,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2471 "Python/bytecodes.c" + #line 2478 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3554,14 +3562,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3558 "Python/generated_cases.c.h" + #line 3566 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2489 "Python/bytecodes.c" + #line 2496 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3584,16 +3592,16 @@ Py_DECREF(enter); goto error; } - #line 3588 "Python/generated_cases.c.h" + #line 3596 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2512 "Python/bytecodes.c" + #line 2519 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3597 "Python/generated_cases.c.h" + #line 3605 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3604,7 +3612,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2521 "Python/bytecodes.c" + #line 2528 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3630,16 +3638,16 @@ Py_DECREF(enter); goto error; } - #line 3634 "Python/generated_cases.c.h" + #line 3642 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2547 "Python/bytecodes.c" + #line 2554 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3643 "Python/generated_cases.c.h" + #line 3651 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3651,7 +3659,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2556 "Python/bytecodes.c" + #line 2563 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3672,7 +3680,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3676 "Python/generated_cases.c.h" + #line 3684 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3681,7 +3689,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2595 "Python/bytecodes.c" + #line 2602 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3691,7 +3699,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3695 "Python/generated_cases.c.h" + #line 3703 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3705,7 +3713,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2607 "Python/bytecodes.c" + #line 2614 "Python/bytecodes.c" assert(oparg & 1); /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); @@ -3722,7 +3730,7 @@ res2 = Py_NewRef(descr); assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; - #line 3726 "Python/generated_cases.c.h" + #line 3734 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3736,7 +3744,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2626 "Python/bytecodes.c" + #line 2633 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3746,7 +3754,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3750 "Python/generated_cases.c.h" + #line 3758 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3761,7 +3769,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2638 "Python/bytecodes.c" + #line 2645 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3774,11 +3782,11 @@ keys_version, LOAD_ATTR); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3778 "Python/generated_cases.c.h" + #line 3786 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2651 "Python/bytecodes.c" + #line 2658 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3782 "Python/generated_cases.c.h" + #line 3790 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3792,7 +3800,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2655 "Python/bytecodes.c" + #line 2662 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3800,11 +3808,11 @@ assert(self_cls->tp_dictoffset == 0); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3804 "Python/generated_cases.c.h" + #line 3812 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2663 "Python/bytecodes.c" + #line 2670 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3808 "Python/generated_cases.c.h" + #line 3816 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3818,7 +3826,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2667 "Python/bytecodes.c" + #line 2674 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3832,7 +3840,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3836 "Python/generated_cases.c.h" + #line 3844 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3841,16 +3849,16 @@ } TARGET(KW_NAMES) { - #line 2683 "Python/bytecodes.c" + #line 2690 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - #line 3849 "Python/generated_cases.c.h" + #line 3857 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2689 "Python/bytecodes.c" + #line 2696 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3863,7 +3871,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3867 "Python/generated_cases.c.h" + #line 3875 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3873,7 +3881,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2735 "Python/bytecodes.c" + #line 2742 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3955,7 +3963,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3959 "Python/generated_cases.c.h" + #line 3967 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3967,7 +3975,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2823 "Python/bytecodes.c" + #line 2830 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3977,7 +3985,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3981 "Python/generated_cases.c.h" + #line 3989 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3986,7 +3994,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2835 "Python/bytecodes.c" + #line 2842 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4012,7 +4020,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4016 "Python/generated_cases.c.h" + #line 4024 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -4020,7 +4028,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2863 "Python/bytecodes.c" + #line 2870 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4056,7 +4064,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4060 "Python/generated_cases.c.h" + #line 4068 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -4064,7 +4072,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2901 "Python/bytecodes.c" + #line 2908 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4074,7 +4082,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 4078 "Python/generated_cases.c.h" + #line 4086 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4087,7 +4095,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2913 "Python/bytecodes.c" + #line 2920 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4098,7 +4106,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4102 "Python/generated_cases.c.h" + #line 4110 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4112,7 +4120,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2927 "Python/bytecodes.c" + #line 2934 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4123,7 +4131,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4127 "Python/generated_cases.c.h" + #line 4135 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4136,7 +4144,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; - #line 2941 "Python/bytecodes.c" + #line 2948 "Python/bytecodes.c" /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -4187,12 +4195,12 @@ * as it will be checked after start_frame */ tstate->py_recursion_remaining--; goto start_frame; - #line 4191 "Python/generated_cases.c.h" + #line 4199 "Python/generated_cases.c.h" } TARGET(EXIT_INIT_CHECK) { PyObject *should_be_none = stack_pointer[-1]; - #line 2994 "Python/bytecodes.c" + #line 3001 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -4200,7 +4208,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 4204 "Python/generated_cases.c.h" + #line 4212 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -4210,7 +4218,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3004 "Python/bytecodes.c" + #line 3011 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4232,7 +4240,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4236 "Python/generated_cases.c.h" + #line 4244 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4246,7 +4254,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3029 "Python/bytecodes.c" + #line 3036 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4274,7 +4282,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4278 "Python/generated_cases.c.h" + #line 4286 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4288,7 +4296,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3060 "Python/bytecodes.c" + #line 3067 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4320,7 +4328,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4324 "Python/generated_cases.c.h" + #line 4332 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4334,7 +4342,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3095 "Python/bytecodes.c" + #line 3102 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4366,7 +4374,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4370 "Python/generated_cases.c.h" + #line 4378 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4380,7 +4388,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3130 "Python/bytecodes.c" + #line 3137 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4405,7 +4413,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4409 "Python/generated_cases.c.h" + #line 4417 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4418,7 +4426,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3157 "Python/bytecodes.c" + #line 3164 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4445,7 +4453,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4449 "Python/generated_cases.c.h" + #line 4457 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4457,7 +4465,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3187 "Python/bytecodes.c" + #line 3194 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4475,14 +4483,14 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4479 "Python/generated_cases.c.h" + #line 4487 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3207 "Python/bytecodes.c" + #line 3214 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4513,7 +4521,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4517 "Python/generated_cases.c.h" + #line 4525 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4526,7 +4534,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3241 "Python/bytecodes.c" + #line 3248 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4555,7 +4563,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4559 "Python/generated_cases.c.h" + #line 4567 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4568,7 +4576,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3273 "Python/bytecodes.c" + #line 3280 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4597,7 +4605,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4601 "Python/generated_cases.c.h" + #line 4609 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4610,7 +4618,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3305 "Python/bytecodes.c" + #line 3312 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4638,7 +4646,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4642 "Python/generated_cases.c.h" + #line 4650 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4648,9 +4656,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3336 "Python/bytecodes.c" + #line 3343 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4654 "Python/generated_cases.c.h" + #line 4662 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4659,7 +4667,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3340 "Python/bytecodes.c" + #line 3347 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4721,14 +4729,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4725 "Python/generated_cases.c.h" + #line 4733 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3402 "Python/bytecodes.c" + #line 3409 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4732 "Python/generated_cases.c.h" + #line 4740 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4739,7 +4747,7 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3408 "Python/bytecodes.c" + #line 3415 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4751,7 +4759,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4755 "Python/generated_cases.c.h" + #line 4763 "Python/generated_cases.c.h" stack_pointer[-1] = func; DISPATCH(); } @@ -4759,7 +4767,7 @@ TARGET(SET_FUNCTION_ATTRIBUTE) { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3422 "Python/bytecodes.c" + #line 3429 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -4784,14 +4792,14 @@ default: Py_UNREACHABLE(); } - #line 4788 "Python/generated_cases.c.h" + #line 4796 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3449 "Python/bytecodes.c" + #line 3456 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4812,7 +4820,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4816 "Python/generated_cases.c.h" + #line 4824 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4820,15 +4828,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3472 "Python/bytecodes.c" + #line 3479 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4826 "Python/generated_cases.c.h" + #line 4834 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3474 "Python/bytecodes.c" + #line 3481 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4832 "Python/generated_cases.c.h" + #line 4840 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4838,14 +4846,14 @@ TARGET(CONVERT_VALUE) { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3478 "Python/bytecodes.c" + #line 3485 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 4849 "Python/generated_cases.c.h" + #line 4857 "Python/generated_cases.c.h" stack_pointer[-1] = result; DISPATCH(); } @@ -4853,7 +4861,7 @@ TARGET(FORMAT_SIMPLE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3487 "Python/bytecodes.c" + #line 3494 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -4864,7 +4872,7 @@ else { res = value; } - #line 4868 "Python/generated_cases.c.h" + #line 4876 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -4873,12 +4881,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3500 "Python/bytecodes.c" + #line 3507 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 4882 "Python/generated_cases.c.h" + #line 4890 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -4887,10 +4895,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3507 "Python/bytecodes.c" + #line 3514 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4894 "Python/generated_cases.c.h" + #line 4902 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4902,7 +4910,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3512 "Python/bytecodes.c" + #line 3519 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4917,12 +4925,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4921 "Python/generated_cases.c.h" + #line 4929 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3527 "Python/bytecodes.c" + #line 3534 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4926 "Python/generated_cases.c.h" + #line 4934 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4932,16 +4940,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3532 "Python/bytecodes.c" + #line 3539 "Python/bytecodes.c" assert(oparg >= 2); - #line 4938 "Python/generated_cases.c.h" + #line 4946 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3536 "Python/bytecodes.c" + #line 3543 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4953,48 +4961,48 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4957 "Python/generated_cases.c.h" + #line 4965 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3550 "Python/bytecodes.c" + #line 3557 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4963 "Python/generated_cases.c.h" + #line 4971 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3554 "Python/bytecodes.c" + #line 3561 "Python/bytecodes.c" CHECK_EVAL_BREAKER(); INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP); - #line 4971 "Python/generated_cases.c.h" + #line 4979 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3559 "Python/bytecodes.c" + #line 3566 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsTrue(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4982 "Python/generated_cases.c.h" + #line 4990 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3567 "Python/bytecodes.c" + #line 3574 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsFalse(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4993 "Python/generated_cases.c.h" + #line 5001 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3575 "Python/bytecodes.c" + #line 3582 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5006,12 +5014,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5010 "Python/generated_cases.c.h" + #line 5018 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3589 "Python/bytecodes.c" + #line 3596 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5023,30 +5031,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5027 "Python/generated_cases.c.h" + #line 5035 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3603 "Python/bytecodes.c" + #line 3610 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 5038 "Python/generated_cases.c.h" + #line 5046 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3611 "Python/bytecodes.c" + #line 3618 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 5045 "Python/generated_cases.c.h" + #line 5053 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3616 "Python/bytecodes.c" + #line 3623 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 5052 "Python/generated_cases.c.h" + #line 5060 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 1231860deee843..fc4da28b1bd798 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -37,7 +37,8 @@ #define _LOAD_LOCALS 315 #define _LOAD_FROM_DICT_OR_GLOBALS 316 #define IS_NONE 317 -#define _ITER_NEXT_RANGE 318 +#define _ITER_CHECK_RANGE 318 +#define _ITER_NEXT_RANGE 319 #ifndef NEED_OPCODE_METADATA extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump); @@ -1314,6 +1315,7 @@ const char * const _PyOpcode_uop_name[512] = { [315] = "_LOAD_LOCALS", [316] = "_LOAD_FROM_DICT_OR_GLOBALS", [317] = "IS_NONE", - [318] = "_ITER_NEXT_RANGE", + [318] = "_ITER_CHECK_RANGE", + [319] = "_ITER_NEXT_RANGE", }; #endif // NEED_OPCODE_METADATA From f9efab685b3dfb6e205985bc3082df7888e464ef Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Jul 2023 15:40:28 -0700 Subject: [PATCH 3/6] macro(FOR_ITER_RANGE) = _ITER_CHECK_RANGE + _ITER_JUMP_RANGE + _ITER_NEXT_RANGE --- Python/bytecodes.c | 38 ++--- Python/executor_cases.c.h | 77 +++++----- Python/generated_cases.c.h | 291 ++++++++++++++++++------------------- 3 files changed, 190 insertions(+), 216 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 954e7128b5065d..74e2f284de49f4 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2437,42 +2437,32 @@ dummy_func( DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); } - // NOTE: next may be NULL (TODO: Can we show this in the type?) - op(_ITER_NEXT_RANGE, (iter -- iter, next)) { + op(_ITER_JUMP_RANGE, (iter -- iter)) { _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { - next = NULL; - } - else { - long value = r->start; - r->start = value + r->step; - r->len--; - next = PyLong_FromLong(value); - ERROR_IF(next == NULL, error); - } - } - - op(_FOR_ITER_END, (iter, next -- iter, next)) { - if (next == NULL) { - // You might expect STACK_SHRINK(2) here. - // But we're taking a dangerous shortcut here: - // This op is always the second half of a - // (_ITER_NEXT_RANGE, _FOR_ITER_END) pair, - // and and the code generator hasn't increased - // the stack pointer to account for 'next' yet. STACK_SHRINK(1); - Py_DECREF(iter); SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); - // Jump over END_FOR instruction. + /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(oparg + 1); DISPATCH(); } } + op(_ITER_NEXT_RANGE, (iter -- iter, next)) { + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + assert(r->len > 0); + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + ERROR_IF(next == NULL, error); + } + macro(FOR_ITER_RANGE) = - unused/1 + _ITER_CHECK_RANGE + _ITER_NEXT_RANGE + _FOR_ITER_END; + unused/1 + _ITER_CHECK_RANGE + _ITER_JUMP_RANGE + _ITER_NEXT_RANGE; inst(FOR_ITER_GEN, (unused/1, iter -- iter, unused)) { DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index ea19c9fce1454a..1fff8414322cf8 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1992,21 +1992,16 @@ case _ITER_NEXT_RANGE: { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2442 "Python/bytecodes.c" + #line 2454 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); - STAT_INC(FOR_ITER, hit); - if (r->len <= 0) { - next = NULL; - } - else { - long value = r->start; - r->start = value + r->step; - r->len--; - next = PyLong_FromLong(value); - if (next == NULL) goto error; - } - #line 2010 "Python/executor_cases.c.h" + assert(r->len > 0); + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + if (next == NULL) goto error; + #line 2005 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; break; @@ -2017,7 +2012,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2563 "Python/bytecodes.c" + #line 2553 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -2038,7 +2033,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 2042 "Python/executor_cases.c.h" + #line 2037 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; break; @@ -2047,7 +2042,7 @@ case PUSH_EXC_INFO: { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2602 "Python/bytecodes.c" + #line 2592 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -2057,7 +2052,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 2061 "Python/executor_cases.c.h" + #line 2056 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -2066,7 +2061,7 @@ case EXIT_INIT_CHECK: { PyObject *should_be_none = stack_pointer[-1]; - #line 3001 "Python/bytecodes.c" + #line 2991 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -2074,7 +2069,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 2078 "Python/executor_cases.c.h" + #line 2073 "Python/executor_cases.c.h" STACK_SHRINK(1); break; } @@ -2082,7 +2077,7 @@ case MAKE_FUNCTION: { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3415 "Python/bytecodes.c" + #line 3405 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -2094,7 +2089,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 2098 "Python/executor_cases.c.h" + #line 2093 "Python/executor_cases.c.h" stack_pointer[-1] = func; break; } @@ -2102,7 +2097,7 @@ case SET_FUNCTION_ATTRIBUTE: { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3429 "Python/bytecodes.c" + #line 3419 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -2127,7 +2122,7 @@ default: Py_UNREACHABLE(); } - #line 2131 "Python/executor_cases.c.h" + #line 2126 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; break; @@ -2138,15 +2133,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3479 "Python/bytecodes.c" + #line 3469 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 2144 "Python/executor_cases.c.h" + #line 2139 "Python/executor_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3481 "Python/bytecodes.c" + #line 3471 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 2150 "Python/executor_cases.c.h" + #line 2145 "Python/executor_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -2156,14 +2151,14 @@ case CONVERT_VALUE: { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3485 "Python/bytecodes.c" + #line 3475 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 2167 "Python/executor_cases.c.h" + #line 2162 "Python/executor_cases.c.h" stack_pointer[-1] = result; break; } @@ -2171,7 +2166,7 @@ case FORMAT_SIMPLE: { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3494 "Python/bytecodes.c" + #line 3484 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -2182,7 +2177,7 @@ else { res = value; } - #line 2186 "Python/executor_cases.c.h" + #line 2181 "Python/executor_cases.c.h" stack_pointer[-1] = res; break; } @@ -2191,12 +2186,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3507 "Python/bytecodes.c" + #line 3497 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 2200 "Python/executor_cases.c.h" + #line 2195 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2205,10 +2200,10 @@ case COPY: { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3514 "Python/bytecodes.c" + #line 3504 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 2212 "Python/executor_cases.c.h" + #line 2207 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; break; @@ -2219,7 +2214,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3519 "Python/bytecodes.c" + #line 3509 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2234,12 +2229,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 2238 "Python/executor_cases.c.h" + #line 2233 "Python/executor_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3534 "Python/bytecodes.c" + #line 3524 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2243 "Python/executor_cases.c.h" + #line 2238 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2248,9 +2243,9 @@ case SWAP: { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3539 "Python/bytecodes.c" + #line 3529 "Python/bytecodes.c" assert(oparg >= 2); - #line 2254 "Python/executor_cases.c.h" + #line 2249 "Python/executor_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; break; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index b5b70d2f0abbf8..a39ee1bb138b6a 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3496,44 +3496,33 @@ } { PyObject *iter = _tmp_2; - PyObject *next; - #line 2442 "Python/bytecodes.c" + #line 2441 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); STAT_INC(FOR_ITER, hit); if (r->len <= 0) { - next = NULL; - } - else { - long value = r->start; - r->start = value + r->step; - r->len--; - next = PyLong_FromLong(value); - if (next == NULL) goto error; - } - #line 3515 "Python/generated_cases.c.h" - _tmp_2 = iter; - _tmp_1 = next; - } - { - PyObject *next = _tmp_1; - PyObject *iter = _tmp_2; - #line 2458 "Python/bytecodes.c" - if (next == NULL) { - // You might expect STACK_SHRINK(2) here. - // But we're taking a dangerous shortcut here: - // This op is always the second half of a - // (_ITER_NEXT_RANGE, _FOR_ITER_END) pair, - // and and the code generator hasn't increased - // the stack pointer to account for 'next' yet. STACK_SHRINK(1); - Py_DECREF(iter); SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); - // Jump over END_FOR instruction. + /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(oparg + 1); DISPATCH(); } - #line 3537 "Python/generated_cases.c.h" + #line 3511 "Python/generated_cases.c.h" + _tmp_2 = iter; + } + { + PyObject *iter = _tmp_2; + PyObject *next; + #line 2454 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + assert(r->len > 0); + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + if (next == NULL) goto error; + #line 3526 "Python/generated_cases.c.h" _tmp_2 = iter; _tmp_1 = next; } @@ -3546,7 +3535,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2478 "Python/bytecodes.c" + #line 2468 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3562,14 +3551,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3566 "Python/generated_cases.c.h" + #line 3555 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2496 "Python/bytecodes.c" + #line 2486 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3592,16 +3581,16 @@ Py_DECREF(enter); goto error; } - #line 3596 "Python/generated_cases.c.h" + #line 3585 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2519 "Python/bytecodes.c" + #line 2509 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3605 "Python/generated_cases.c.h" + #line 3594 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3612,7 +3601,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2528 "Python/bytecodes.c" + #line 2518 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3638,16 +3627,16 @@ Py_DECREF(enter); goto error; } - #line 3642 "Python/generated_cases.c.h" + #line 3631 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2554 "Python/bytecodes.c" + #line 2544 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3651 "Python/generated_cases.c.h" + #line 3640 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3659,7 +3648,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2563 "Python/bytecodes.c" + #line 2553 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3680,7 +3669,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3684 "Python/generated_cases.c.h" + #line 3673 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3689,7 +3678,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2602 "Python/bytecodes.c" + #line 2592 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3699,7 +3688,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3703 "Python/generated_cases.c.h" + #line 3692 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3713,7 +3702,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2614 "Python/bytecodes.c" + #line 2604 "Python/bytecodes.c" assert(oparg & 1); /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); @@ -3730,7 +3719,7 @@ res2 = Py_NewRef(descr); assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; - #line 3734 "Python/generated_cases.c.h" + #line 3723 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3744,7 +3733,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2633 "Python/bytecodes.c" + #line 2623 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3754,7 +3743,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3758 "Python/generated_cases.c.h" + #line 3747 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3769,7 +3758,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2645 "Python/bytecodes.c" + #line 2635 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3782,11 +3771,11 @@ keys_version, LOAD_ATTR); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3786 "Python/generated_cases.c.h" + #line 3775 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2658 "Python/bytecodes.c" + #line 2648 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3790 "Python/generated_cases.c.h" + #line 3779 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3800,7 +3789,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2662 "Python/bytecodes.c" + #line 2652 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3808,11 +3797,11 @@ assert(self_cls->tp_dictoffset == 0); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3812 "Python/generated_cases.c.h" + #line 3801 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2670 "Python/bytecodes.c" + #line 2660 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3816 "Python/generated_cases.c.h" + #line 3805 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3826,7 +3815,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2674 "Python/bytecodes.c" + #line 2664 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3840,7 +3829,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3844 "Python/generated_cases.c.h" + #line 3833 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3849,16 +3838,16 @@ } TARGET(KW_NAMES) { - #line 2690 "Python/bytecodes.c" + #line 2680 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - #line 3857 "Python/generated_cases.c.h" + #line 3846 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2696 "Python/bytecodes.c" + #line 2686 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3871,7 +3860,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3875 "Python/generated_cases.c.h" + #line 3864 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3881,7 +3870,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2742 "Python/bytecodes.c" + #line 2732 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3963,7 +3952,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3967 "Python/generated_cases.c.h" + #line 3956 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3975,7 +3964,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2830 "Python/bytecodes.c" + #line 2820 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3985,7 +3974,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3989 "Python/generated_cases.c.h" + #line 3978 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3994,7 +3983,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2842 "Python/bytecodes.c" + #line 2832 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4020,7 +4009,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4024 "Python/generated_cases.c.h" + #line 4013 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -4028,7 +4017,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2870 "Python/bytecodes.c" + #line 2860 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4064,7 +4053,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4068 "Python/generated_cases.c.h" + #line 4057 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -4072,7 +4061,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2908 "Python/bytecodes.c" + #line 2898 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4082,7 +4071,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 4086 "Python/generated_cases.c.h" + #line 4075 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4095,7 +4084,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2920 "Python/bytecodes.c" + #line 2910 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4106,7 +4095,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4110 "Python/generated_cases.c.h" + #line 4099 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4120,7 +4109,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2934 "Python/bytecodes.c" + #line 2924 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4131,7 +4120,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4135 "Python/generated_cases.c.h" + #line 4124 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4144,7 +4133,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; - #line 2948 "Python/bytecodes.c" + #line 2938 "Python/bytecodes.c" /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -4195,12 +4184,12 @@ * as it will be checked after start_frame */ tstate->py_recursion_remaining--; goto start_frame; - #line 4199 "Python/generated_cases.c.h" + #line 4188 "Python/generated_cases.c.h" } TARGET(EXIT_INIT_CHECK) { PyObject *should_be_none = stack_pointer[-1]; - #line 3001 "Python/bytecodes.c" + #line 2991 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -4208,7 +4197,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 4212 "Python/generated_cases.c.h" + #line 4201 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -4218,7 +4207,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3011 "Python/bytecodes.c" + #line 3001 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4240,7 +4229,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4244 "Python/generated_cases.c.h" + #line 4233 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4254,7 +4243,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3036 "Python/bytecodes.c" + #line 3026 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4282,7 +4271,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4286 "Python/generated_cases.c.h" + #line 4275 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4296,7 +4285,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3067 "Python/bytecodes.c" + #line 3057 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4328,7 +4317,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4332 "Python/generated_cases.c.h" + #line 4321 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4342,7 +4331,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3102 "Python/bytecodes.c" + #line 3092 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4374,7 +4363,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4378 "Python/generated_cases.c.h" + #line 4367 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4388,7 +4377,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3137 "Python/bytecodes.c" + #line 3127 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4413,7 +4402,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4417 "Python/generated_cases.c.h" + #line 4406 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4426,7 +4415,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3164 "Python/bytecodes.c" + #line 3154 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4453,7 +4442,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4457 "Python/generated_cases.c.h" + #line 4446 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4465,7 +4454,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3194 "Python/bytecodes.c" + #line 3184 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4483,14 +4472,14 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4487 "Python/generated_cases.c.h" + #line 4476 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3214 "Python/bytecodes.c" + #line 3204 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4521,7 +4510,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4525 "Python/generated_cases.c.h" + #line 4514 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4534,7 +4523,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3248 "Python/bytecodes.c" + #line 3238 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4563,7 +4552,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4567 "Python/generated_cases.c.h" + #line 4556 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4576,7 +4565,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3280 "Python/bytecodes.c" + #line 3270 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4605,7 +4594,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4609 "Python/generated_cases.c.h" + #line 4598 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4618,7 +4607,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3312 "Python/bytecodes.c" + #line 3302 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4646,7 +4635,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4650 "Python/generated_cases.c.h" + #line 4639 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4656,9 +4645,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3343 "Python/bytecodes.c" + #line 3333 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4662 "Python/generated_cases.c.h" + #line 4651 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4667,7 +4656,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3347 "Python/bytecodes.c" + #line 3337 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4729,14 +4718,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4733 "Python/generated_cases.c.h" + #line 4722 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3409 "Python/bytecodes.c" + #line 3399 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4740 "Python/generated_cases.c.h" + #line 4729 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4747,7 +4736,7 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3415 "Python/bytecodes.c" + #line 3405 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4759,7 +4748,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4763 "Python/generated_cases.c.h" + #line 4752 "Python/generated_cases.c.h" stack_pointer[-1] = func; DISPATCH(); } @@ -4767,7 +4756,7 @@ TARGET(SET_FUNCTION_ATTRIBUTE) { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3429 "Python/bytecodes.c" + #line 3419 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -4792,14 +4781,14 @@ default: Py_UNREACHABLE(); } - #line 4796 "Python/generated_cases.c.h" + #line 4785 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3456 "Python/bytecodes.c" + #line 3446 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4820,7 +4809,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4824 "Python/generated_cases.c.h" + #line 4813 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4828,15 +4817,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3479 "Python/bytecodes.c" + #line 3469 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4834 "Python/generated_cases.c.h" + #line 4823 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3481 "Python/bytecodes.c" + #line 3471 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4840 "Python/generated_cases.c.h" + #line 4829 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4846,14 +4835,14 @@ TARGET(CONVERT_VALUE) { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3485 "Python/bytecodes.c" + #line 3475 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 4857 "Python/generated_cases.c.h" + #line 4846 "Python/generated_cases.c.h" stack_pointer[-1] = result; DISPATCH(); } @@ -4861,7 +4850,7 @@ TARGET(FORMAT_SIMPLE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3494 "Python/bytecodes.c" + #line 3484 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -4872,7 +4861,7 @@ else { res = value; } - #line 4876 "Python/generated_cases.c.h" + #line 4865 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -4881,12 +4870,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3507 "Python/bytecodes.c" + #line 3497 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 4890 "Python/generated_cases.c.h" + #line 4879 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -4895,10 +4884,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3514 "Python/bytecodes.c" + #line 3504 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4902 "Python/generated_cases.c.h" + #line 4891 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4910,7 +4899,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3519 "Python/bytecodes.c" + #line 3509 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4925,12 +4914,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4929 "Python/generated_cases.c.h" + #line 4918 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3534 "Python/bytecodes.c" + #line 3524 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4934 "Python/generated_cases.c.h" + #line 4923 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4940,16 +4929,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3539 "Python/bytecodes.c" + #line 3529 "Python/bytecodes.c" assert(oparg >= 2); - #line 4946 "Python/generated_cases.c.h" + #line 4935 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3543 "Python/bytecodes.c" + #line 3533 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4961,48 +4950,48 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4965 "Python/generated_cases.c.h" + #line 4954 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3557 "Python/bytecodes.c" + #line 3547 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4971 "Python/generated_cases.c.h" + #line 4960 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3561 "Python/bytecodes.c" + #line 3551 "Python/bytecodes.c" CHECK_EVAL_BREAKER(); INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP); - #line 4979 "Python/generated_cases.c.h" + #line 4968 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3566 "Python/bytecodes.c" + #line 3556 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsTrue(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4990 "Python/generated_cases.c.h" + #line 4979 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3574 "Python/bytecodes.c" + #line 3564 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsFalse(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5001 "Python/generated_cases.c.h" + #line 4990 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3582 "Python/bytecodes.c" + #line 3572 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5014,12 +5003,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5018 "Python/generated_cases.c.h" + #line 5007 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3596 "Python/bytecodes.c" + #line 3586 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5031,30 +5020,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5035 "Python/generated_cases.c.h" + #line 5024 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3610 "Python/bytecodes.c" + #line 3600 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 5046 "Python/generated_cases.c.h" + #line 5035 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3618 "Python/bytecodes.c" + #line 3608 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 5053 "Python/generated_cases.c.h" + #line 5042 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3623 "Python/bytecodes.c" + #line 3613 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 5060 "Python/generated_cases.c.h" + #line 5049 "Python/generated_cases.c.h" } From efd447268aab87cd88311af020805bc6e131fb86 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Jul 2023 16:10:13 -0700 Subject: [PATCH 4/6] Tier 2 translation, with test This was remarkably straightforward --- Lib/test/test_capi/test_misc.py | 25 ++++++- Python/bytecodes.c | 7 ++ Python/executor_cases.c.h | 73 +++++++++++-------- Python/generated_cases.c.h | 124 ++++++++++++++++---------------- Python/opcode_metadata.h | 6 +- Python/optimizer.c | 22 ++++++ 6 files changed, 160 insertions(+), 97 deletions(-) diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index 9c14a501875b6d..abdf7ed8976350 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -2443,7 +2443,6 @@ def testfunc(x): i += 1 opt = _testinternalcapi.get_uop_optimizer() - with temporary_optimizer(opt): testfunc(1000) @@ -2580,13 +2579,33 @@ def testfunc(n): ex = get_first_executor(testfunc) self.assertIsNotNone(ex) - # for i, (opname, oparg) in enumerate(ex): - # print(f"{i:4d}: {opname:<20s} {oparg:4d}") uops = {opname for opname, _ in ex} # Since there is no JUMP_FORWARD instruction, # look for indirect evidence: the += operator self.assertIn("_BINARY_OP_ADD_INT", uops) + def test_for_iter_range(self): + def testfunc(n): + total = 0 + for i in range(n): + total += i + return total + # import dis; dis.dis(testfunc) + + opt = _testinternalcapi.get_uop_optimizer() + with temporary_optimizer(opt): + total = testfunc(10) + self.assertEqual(total, 45) + + ex = get_first_executor(testfunc) + self.assertIsNotNone(ex) + # for i, (opname, oparg) in enumerate(ex): + # print(f"{i:4d}: {opname:<20s} {oparg:3d}") + uops = {opname for opname, _ in ex} + self.assertIn("_ITER_EXHAUSTED_RANGE", uops) + # Verification that the jump goes past END_FOR + # is done by manual inspection of the output + if __name__ == "__main__": unittest.main() diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 74e2f284de49f4..b931df6cb81c56 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2450,6 +2450,13 @@ dummy_func( } } + // Only used by Tier 2 + op(_ITER_EXHAUSTED_RANGE, (iter -- iter, exhausted)) { + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + exhausted = r->len <= 0 ? Py_True : Py_False; + } + op(_ITER_NEXT_RANGE, (iter -- iter, next)) { _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 1fff8414322cf8..e82f64e9ea437c 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1989,10 +1989,23 @@ break; } + case _ITER_EXHAUSTED_RANGE: { + PyObject *iter = stack_pointer[-1]; + PyObject *exhausted; + #line 2455 "Python/bytecodes.c" + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + exhausted = r->len <= 0 ? Py_True : Py_False; + #line 2000 "Python/executor_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = exhausted; + break; + } + case _ITER_NEXT_RANGE: { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2454 "Python/bytecodes.c" + #line 2461 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); assert(r->len > 0); @@ -2001,7 +2014,7 @@ r->len--; next = PyLong_FromLong(value); if (next == NULL) goto error; - #line 2005 "Python/executor_cases.c.h" + #line 2018 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; break; @@ -2012,7 +2025,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2553 "Python/bytecodes.c" + #line 2560 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -2033,7 +2046,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 2037 "Python/executor_cases.c.h" + #line 2050 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; break; @@ -2042,7 +2055,7 @@ case PUSH_EXC_INFO: { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2592 "Python/bytecodes.c" + #line 2599 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -2052,7 +2065,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 2056 "Python/executor_cases.c.h" + #line 2069 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -2061,7 +2074,7 @@ case EXIT_INIT_CHECK: { PyObject *should_be_none = stack_pointer[-1]; - #line 2991 "Python/bytecodes.c" + #line 2998 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -2069,7 +2082,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 2073 "Python/executor_cases.c.h" + #line 2086 "Python/executor_cases.c.h" STACK_SHRINK(1); break; } @@ -2077,7 +2090,7 @@ case MAKE_FUNCTION: { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3405 "Python/bytecodes.c" + #line 3412 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -2089,7 +2102,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 2093 "Python/executor_cases.c.h" + #line 2106 "Python/executor_cases.c.h" stack_pointer[-1] = func; break; } @@ -2097,7 +2110,7 @@ case SET_FUNCTION_ATTRIBUTE: { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3419 "Python/bytecodes.c" + #line 3426 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -2122,7 +2135,7 @@ default: Py_UNREACHABLE(); } - #line 2126 "Python/executor_cases.c.h" + #line 2139 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; break; @@ -2133,15 +2146,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3469 "Python/bytecodes.c" + #line 3476 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 2139 "Python/executor_cases.c.h" + #line 2152 "Python/executor_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3471 "Python/bytecodes.c" + #line 3478 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 2145 "Python/executor_cases.c.h" + #line 2158 "Python/executor_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -2151,14 +2164,14 @@ case CONVERT_VALUE: { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3475 "Python/bytecodes.c" + #line 3482 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 2162 "Python/executor_cases.c.h" + #line 2175 "Python/executor_cases.c.h" stack_pointer[-1] = result; break; } @@ -2166,7 +2179,7 @@ case FORMAT_SIMPLE: { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3484 "Python/bytecodes.c" + #line 3491 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -2177,7 +2190,7 @@ else { res = value; } - #line 2181 "Python/executor_cases.c.h" + #line 2194 "Python/executor_cases.c.h" stack_pointer[-1] = res; break; } @@ -2186,12 +2199,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3497 "Python/bytecodes.c" + #line 3504 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 2195 "Python/executor_cases.c.h" + #line 2208 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2200,10 +2213,10 @@ case COPY: { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3504 "Python/bytecodes.c" + #line 3511 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 2207 "Python/executor_cases.c.h" + #line 2220 "Python/executor_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; break; @@ -2214,7 +2227,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3509 "Python/bytecodes.c" + #line 3516 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2229,12 +2242,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 2233 "Python/executor_cases.c.h" + #line 2246 "Python/executor_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3524 "Python/bytecodes.c" + #line 3531 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2238 "Python/executor_cases.c.h" + #line 2251 "Python/executor_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; break; @@ -2243,9 +2256,9 @@ case SWAP: { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3529 "Python/bytecodes.c" + #line 3536 "Python/bytecodes.c" assert(oparg >= 2); - #line 2249 "Python/executor_cases.c.h" + #line 2262 "Python/executor_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; break; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index a39ee1bb138b6a..ad75e0f6346a46 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3513,7 +3513,7 @@ { PyObject *iter = _tmp_2; PyObject *next; - #line 2454 "Python/bytecodes.c" + #line 2461 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); assert(r->len > 0); @@ -3535,7 +3535,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2468 "Python/bytecodes.c" + #line 2475 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3558,7 +3558,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2486 "Python/bytecodes.c" + #line 2493 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3583,7 +3583,7 @@ } #line 3585 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2509 "Python/bytecodes.c" + #line 2516 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3601,7 +3601,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2518 "Python/bytecodes.c" + #line 2525 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3629,7 +3629,7 @@ } #line 3631 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2544 "Python/bytecodes.c" + #line 2551 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3648,7 +3648,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2553 "Python/bytecodes.c" + #line 2560 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3678,7 +3678,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2592 "Python/bytecodes.c" + #line 2599 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3702,7 +3702,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2604 "Python/bytecodes.c" + #line 2611 "Python/bytecodes.c" assert(oparg & 1); /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); @@ -3733,7 +3733,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2623 "Python/bytecodes.c" + #line 2630 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3758,7 +3758,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2635 "Python/bytecodes.c" + #line 2642 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3773,7 +3773,7 @@ assert(descr != NULL); #line 3775 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2648 "Python/bytecodes.c" + #line 2655 "Python/bytecodes.c" res = Py_NewRef(descr); #line 3779 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); @@ -3789,7 +3789,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2652 "Python/bytecodes.c" + #line 2659 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3799,7 +3799,7 @@ assert(descr != NULL); #line 3801 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2660 "Python/bytecodes.c" + #line 2667 "Python/bytecodes.c" res = Py_NewRef(descr); #line 3805 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); @@ -3815,7 +3815,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2664 "Python/bytecodes.c" + #line 2671 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3838,7 +3838,7 @@ } TARGET(KW_NAMES) { - #line 2680 "Python/bytecodes.c" + #line 2687 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); kwnames = GETITEM(FRAME_CO_CONSTS, oparg); @@ -3847,7 +3847,7 @@ } TARGET(INSTRUMENTED_CALL) { - #line 2686 "Python/bytecodes.c" + #line 2693 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3870,7 +3870,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2732 "Python/bytecodes.c" + #line 2739 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3964,7 +3964,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2820 "Python/bytecodes.c" + #line 2827 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3983,7 +3983,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2832 "Python/bytecodes.c" + #line 2839 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4017,7 +4017,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2860 "Python/bytecodes.c" + #line 2867 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4061,7 +4061,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2898 "Python/bytecodes.c" + #line 2905 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4084,7 +4084,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2910 "Python/bytecodes.c" + #line 2917 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4109,7 +4109,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2924 "Python/bytecodes.c" + #line 2931 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4133,7 +4133,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; - #line 2938 "Python/bytecodes.c" + #line 2945 "Python/bytecodes.c" /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -4189,7 +4189,7 @@ TARGET(EXIT_INIT_CHECK) { PyObject *should_be_none = stack_pointer[-1]; - #line 2991 "Python/bytecodes.c" + #line 2998 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -4207,7 +4207,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3001 "Python/bytecodes.c" + #line 3008 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4243,7 +4243,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3026 "Python/bytecodes.c" + #line 3033 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4285,7 +4285,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3057 "Python/bytecodes.c" + #line 3064 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4331,7 +4331,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3092 "Python/bytecodes.c" + #line 3099 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4377,7 +4377,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3127 "Python/bytecodes.c" + #line 3134 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4415,7 +4415,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3154 "Python/bytecodes.c" + #line 3161 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4454,7 +4454,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3184 "Python/bytecodes.c" + #line 3191 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4479,7 +4479,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3204 "Python/bytecodes.c" + #line 3211 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4523,7 +4523,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3238 "Python/bytecodes.c" + #line 3245 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4565,7 +4565,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3270 "Python/bytecodes.c" + #line 3277 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4607,7 +4607,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3302 "Python/bytecodes.c" + #line 3309 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4645,7 +4645,7 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3333 "Python/bytecodes.c" + #line 3340 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); #line 4651 "Python/generated_cases.c.h" } @@ -4656,7 +4656,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3337 "Python/bytecodes.c" + #line 3344 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4722,7 +4722,7 @@ Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3399 "Python/bytecodes.c" + #line 3406 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } #line 4729 "Python/generated_cases.c.h" @@ -4736,7 +4736,7 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3405 "Python/bytecodes.c" + #line 3412 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4756,7 +4756,7 @@ TARGET(SET_FUNCTION_ATTRIBUTE) { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3419 "Python/bytecodes.c" + #line 3426 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -4788,7 +4788,7 @@ } TARGET(RETURN_GENERATOR) { - #line 3446 "Python/bytecodes.c" + #line 3453 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4817,13 +4817,13 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3469 "Python/bytecodes.c" + #line 3476 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); #line 4823 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3471 "Python/bytecodes.c" + #line 3478 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } #line 4829 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); @@ -4835,7 +4835,7 @@ TARGET(CONVERT_VALUE) { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3475 "Python/bytecodes.c" + #line 3482 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; @@ -4850,7 +4850,7 @@ TARGET(FORMAT_SIMPLE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3484 "Python/bytecodes.c" + #line 3491 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -4870,7 +4870,7 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3497 "Python/bytecodes.c" + #line 3504 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); @@ -4884,7 +4884,7 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3504 "Python/bytecodes.c" + #line 3511 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); #line 4891 "Python/generated_cases.c.h" @@ -4899,7 +4899,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3509 "Python/bytecodes.c" + #line 3516 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4917,7 +4917,7 @@ #line 4918 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3524 "Python/bytecodes.c" + #line 3531 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 4923 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -4929,7 +4929,7 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3529 "Python/bytecodes.c" + #line 3536 "Python/bytecodes.c" assert(oparg >= 2); #line 4935 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; @@ -4938,7 +4938,7 @@ } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3533 "Python/bytecodes.c" + #line 3540 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4954,14 +4954,14 @@ } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3547 "Python/bytecodes.c" + #line 3554 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); #line 4960 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3551 "Python/bytecodes.c" + #line 3558 "Python/bytecodes.c" CHECK_EVAL_BREAKER(); INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP); #line 4968 "Python/generated_cases.c.h" @@ -4969,7 +4969,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3556 "Python/bytecodes.c" + #line 3563 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; @@ -4980,7 +4980,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3564 "Python/bytecodes.c" + #line 3571 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; @@ -4991,7 +4991,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3572 "Python/bytecodes.c" + #line 3579 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5008,7 +5008,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3586 "Python/bytecodes.c" + #line 3593 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5025,7 +5025,7 @@ } TARGET(EXTENDED_ARG) { - #line 3600 "Python/bytecodes.c" + #line 3607 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; @@ -5035,14 +5035,14 @@ } TARGET(CACHE) { - #line 3608 "Python/bytecodes.c" + #line 3615 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); #line 5042 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3613 "Python/bytecodes.c" + #line 3620 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); #line 5049 "Python/generated_cases.c.h" diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index fc4da28b1bd798..286564c123e4cb 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -38,7 +38,8 @@ #define _LOAD_FROM_DICT_OR_GLOBALS 316 #define IS_NONE 317 #define _ITER_CHECK_RANGE 318 -#define _ITER_NEXT_RANGE 319 +#define _ITER_EXHAUSTED_RANGE 319 +#define _ITER_NEXT_RANGE 320 #ifndef NEED_OPCODE_METADATA extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump); @@ -1316,6 +1317,7 @@ const char * const _PyOpcode_uop_name[512] = { [316] = "_LOAD_FROM_DICT_OR_GLOBALS", [317] = "IS_NONE", [318] = "_ITER_CHECK_RANGE", - [319] = "_ITER_NEXT_RANGE", + [319] = "_ITER_EXHAUSTED_RANGE", + [320] = "_ITER_NEXT_RANGE", }; #endif // NEED_OPCODE_METADATA diff --git a/Python/optimizer.c b/Python/optimizer.c index 7fc40e66057d30..8dc6e325dfe68b 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -479,6 +479,28 @@ translate_bytecode_to_trace( break; } + case FOR_ITER_RANGE: + { + // Assume jump unlikely (can a for-loop exit be likely?) + // Reserve 9 entries (4 here, 3 stub, plus SAVE_IP + EXIT_TRACE) + if (trace_length + 9 > max_length) { + DPRINTF(1, "Ran out of space for FOR_ITER_RANGE\n"); + goto done; + } + _Py_CODEUNIT *target_instr = // +1 at the end skips over END_FOR + instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[opcode]] + oparg + 1; + max_length -= 3; // Really the start of the stubs + ADD_TO_TRACE(_ITER_CHECK_RANGE, 0); + ADD_TO_TRACE(_ITER_EXHAUSTED_RANGE, 0); + ADD_TO_TRACE(_POP_JUMP_IF_TRUE, max_length); + ADD_TO_TRACE(_ITER_NEXT_RANGE, 0); + + ADD_TO_STUB(max_length + 0, POP_TOP, 0); + ADD_TO_STUB(max_length + 1, SAVE_IP, INSTR_IP(target_instr, code)); + ADD_TO_STUB(max_length + 2, EXIT_TRACE, 0); + break; + } + default: { const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode]; From 6b8fb785a280a850917885b79a1734d4a227876f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 11 Jul 2023 17:50:38 -0700 Subject: [PATCH 5/6] Fix memory leak and restore original comment --- Python/bytecodes.c | 3 +- Python/executor_cases.c.h | 32 ++--- Python/generated_cases.c.h | 253 +++++++++++++++++++------------------ 3 files changed, 145 insertions(+), 143 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b931df6cb81c56..98d82403d46d94 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2443,8 +2443,9 @@ dummy_func( STAT_INC(FOR_ITER, hit); if (r->len <= 0) { STACK_SHRINK(1); + Py_DECREF(r); SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); - /* Jump forward oparg, then skip following END_FOR instruction */ + // Jump over END_FOR instruction. JUMPBY(oparg + 1); DISPATCH(); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index e82f64e9ea437c..5a314424a91afa 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1992,7 +1992,7 @@ case _ITER_EXHAUSTED_RANGE: { PyObject *iter = stack_pointer[-1]; PyObject *exhausted; - #line 2455 "Python/bytecodes.c" + #line 2456 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); exhausted = r->len <= 0 ? Py_True : Py_False; @@ -2005,7 +2005,7 @@ case _ITER_NEXT_RANGE: { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2461 "Python/bytecodes.c" + #line 2462 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); assert(r->len > 0); @@ -2025,7 +2025,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2560 "Python/bytecodes.c" + #line 2561 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -2055,7 +2055,7 @@ case PUSH_EXC_INFO: { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2599 "Python/bytecodes.c" + #line 2600 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -2074,7 +2074,7 @@ case EXIT_INIT_CHECK: { PyObject *should_be_none = stack_pointer[-1]; - #line 2998 "Python/bytecodes.c" + #line 2999 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -2090,7 +2090,7 @@ case MAKE_FUNCTION: { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3412 "Python/bytecodes.c" + #line 3413 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -2110,7 +2110,7 @@ case SET_FUNCTION_ATTRIBUTE: { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3426 "Python/bytecodes.c" + #line 3427 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -2146,13 +2146,13 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3476 "Python/bytecodes.c" + #line 3477 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); #line 2152 "Python/executor_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3478 "Python/bytecodes.c" + #line 3479 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } #line 2158 "Python/executor_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); @@ -2164,7 +2164,7 @@ case CONVERT_VALUE: { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3482 "Python/bytecodes.c" + #line 3483 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; @@ -2179,7 +2179,7 @@ case FORMAT_SIMPLE: { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3491 "Python/bytecodes.c" + #line 3492 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -2199,7 +2199,7 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3504 "Python/bytecodes.c" + #line 3505 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); @@ -2213,7 +2213,7 @@ case COPY: { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3511 "Python/bytecodes.c" + #line 3512 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); #line 2220 "Python/executor_cases.c.h" @@ -2227,7 +2227,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3516 "Python/bytecodes.c" + #line 3517 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2245,7 +2245,7 @@ #line 2246 "Python/executor_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3531 "Python/bytecodes.c" + #line 3532 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 2251 "Python/executor_cases.c.h" STACK_SHRINK(1); @@ -2256,7 +2256,7 @@ case SWAP: { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3536 "Python/bytecodes.c" + #line 3537 "Python/bytecodes.c" assert(oparg >= 2); #line 2262 "Python/executor_cases.c.h" stack_pointer[-1] = bottom; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index ad75e0f6346a46..750fe810adff7e 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3502,18 +3502,19 @@ STAT_INC(FOR_ITER, hit); if (r->len <= 0) { STACK_SHRINK(1); + Py_DECREF(r); SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER); - /* Jump forward oparg, then skip following END_FOR instruction */ + // Jump over END_FOR instruction. JUMPBY(oparg + 1); DISPATCH(); } - #line 3511 "Python/generated_cases.c.h" + #line 3512 "Python/generated_cases.c.h" _tmp_2 = iter; } { PyObject *iter = _tmp_2; PyObject *next; - #line 2461 "Python/bytecodes.c" + #line 2462 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; assert(Py_TYPE(r) == &PyRangeIter_Type); assert(r->len > 0); @@ -3522,7 +3523,7 @@ r->len--; next = PyLong_FromLong(value); if (next == NULL) goto error; - #line 3526 "Python/generated_cases.c.h" + #line 3527 "Python/generated_cases.c.h" _tmp_2 = iter; _tmp_1 = next; } @@ -3535,7 +3536,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2475 "Python/bytecodes.c" + #line 2476 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3551,14 +3552,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3555 "Python/generated_cases.c.h" + #line 3556 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2493 "Python/bytecodes.c" + #line 2494 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3581,16 +3582,16 @@ Py_DECREF(enter); goto error; } - #line 3585 "Python/generated_cases.c.h" + #line 3586 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2516 "Python/bytecodes.c" + #line 2517 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3594 "Python/generated_cases.c.h" + #line 3595 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3601,7 +3602,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2525 "Python/bytecodes.c" + #line 2526 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3627,16 +3628,16 @@ Py_DECREF(enter); goto error; } - #line 3631 "Python/generated_cases.c.h" + #line 3632 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2551 "Python/bytecodes.c" + #line 2552 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3640 "Python/generated_cases.c.h" + #line 3641 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3648,7 +3649,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2560 "Python/bytecodes.c" + #line 2561 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3669,7 +3670,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3673 "Python/generated_cases.c.h" + #line 3674 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3678,7 +3679,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2599 "Python/bytecodes.c" + #line 2600 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3688,7 +3689,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3692 "Python/generated_cases.c.h" + #line 3693 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3702,7 +3703,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2611 "Python/bytecodes.c" + #line 2612 "Python/bytecodes.c" assert(oparg & 1); /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); @@ -3719,7 +3720,7 @@ res2 = Py_NewRef(descr); assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; - #line 3723 "Python/generated_cases.c.h" + #line 3724 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3733,7 +3734,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2630 "Python/bytecodes.c" + #line 2631 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3743,7 +3744,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3747 "Python/generated_cases.c.h" + #line 3748 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3758,7 +3759,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2642 "Python/bytecodes.c" + #line 2643 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3771,11 +3772,11 @@ keys_version, LOAD_ATTR); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3775 "Python/generated_cases.c.h" + #line 3776 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2655 "Python/bytecodes.c" + #line 2656 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3779 "Python/generated_cases.c.h" + #line 3780 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3789,7 +3790,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2659 "Python/bytecodes.c" + #line 2660 "Python/bytecodes.c" assert((oparg & 1) == 0); PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3797,11 +3798,11 @@ assert(self_cls->tp_dictoffset == 0); STAT_INC(LOAD_ATTR, hit); assert(descr != NULL); - #line 3801 "Python/generated_cases.c.h" + #line 3802 "Python/generated_cases.c.h" Py_DECREF(self); - #line 2667 "Python/bytecodes.c" + #line 2668 "Python/bytecodes.c" res = Py_NewRef(descr); - #line 3805 "Python/generated_cases.c.h" + #line 3806 "Python/generated_cases.c.h" STACK_GROW((0 ? 1 : 0)); stack_pointer[-1] = res; if (0) { stack_pointer[-(1 + (0 ? 1 : 0))] = res2; } @@ -3815,7 +3816,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2671 "Python/bytecodes.c" + #line 2672 "Python/bytecodes.c" assert(oparg & 1); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3829,7 +3830,7 @@ assert(_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)); res2 = Py_NewRef(descr); res = self; - #line 3833 "Python/generated_cases.c.h" + #line 3834 "Python/generated_cases.c.h" STACK_GROW((1 ? 1 : 0)); stack_pointer[-1] = res; if (1) { stack_pointer[-(1 + (1 ? 1 : 0))] = res2; } @@ -3838,16 +3839,16 @@ } TARGET(KW_NAMES) { - #line 2687 "Python/bytecodes.c" + #line 2688 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - #line 3846 "Python/generated_cases.c.h" + #line 3847 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2693 "Python/bytecodes.c" + #line 2694 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3860,7 +3861,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3864 "Python/generated_cases.c.h" + #line 3865 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3870,7 +3871,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2739 "Python/bytecodes.c" + #line 2740 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3952,7 +3953,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3956 "Python/generated_cases.c.h" + #line 3957 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3964,7 +3965,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2827 "Python/bytecodes.c" + #line 2828 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3974,7 +3975,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3978 "Python/generated_cases.c.h" + #line 3979 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3983,7 +3984,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2839 "Python/bytecodes.c" + #line 2840 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4009,7 +4010,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4013 "Python/generated_cases.c.h" + #line 4014 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -4017,7 +4018,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2867 "Python/bytecodes.c" + #line 2868 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -4053,7 +4054,7 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 4057 "Python/generated_cases.c.h" + #line 4058 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -4061,7 +4062,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2905 "Python/bytecodes.c" + #line 2906 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4071,7 +4072,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 4075 "Python/generated_cases.c.h" + #line 4076 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4084,7 +4085,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2917 "Python/bytecodes.c" + #line 2918 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4095,7 +4096,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4099 "Python/generated_cases.c.h" + #line 4100 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4109,7 +4110,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2931 "Python/bytecodes.c" + #line 2932 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4120,7 +4121,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4124 "Python/generated_cases.c.h" + #line 4125 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4133,7 +4134,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; - #line 2945 "Python/bytecodes.c" + #line 2946 "Python/bytecodes.c" /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -4184,12 +4185,12 @@ * as it will be checked after start_frame */ tstate->py_recursion_remaining--; goto start_frame; - #line 4188 "Python/generated_cases.c.h" + #line 4189 "Python/generated_cases.c.h" } TARGET(EXIT_INIT_CHECK) { PyObject *should_be_none = stack_pointer[-1]; - #line 2998 "Python/bytecodes.c" + #line 2999 "Python/bytecodes.c" assert(STACK_LEVEL() == 2); if (should_be_none != Py_None) { PyErr_Format(PyExc_TypeError, @@ -4197,7 +4198,7 @@ Py_TYPE(should_be_none)->tp_name); goto error; } - #line 4201 "Python/generated_cases.c.h" + #line 4202 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -4207,7 +4208,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3008 "Python/bytecodes.c" + #line 3009 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4229,7 +4230,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4233 "Python/generated_cases.c.h" + #line 4234 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4243,7 +4244,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3033 "Python/bytecodes.c" + #line 3034 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4271,7 +4272,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4275 "Python/generated_cases.c.h" + #line 4276 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4285,7 +4286,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3064 "Python/bytecodes.c" + #line 3065 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4317,7 +4318,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4321 "Python/generated_cases.c.h" + #line 4322 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4331,7 +4332,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3099 "Python/bytecodes.c" + #line 3100 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4363,7 +4364,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4367 "Python/generated_cases.c.h" + #line 4368 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4377,7 +4378,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3134 "Python/bytecodes.c" + #line 3135 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4402,7 +4403,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4406 "Python/generated_cases.c.h" + #line 4407 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4415,7 +4416,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3161 "Python/bytecodes.c" + #line 3162 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4442,7 +4443,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4446 "Python/generated_cases.c.h" + #line 4447 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4454,7 +4455,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3191 "Python/bytecodes.c" + #line 3192 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4472,14 +4473,14 @@ SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4476 "Python/generated_cases.c.h" + #line 4477 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3211 "Python/bytecodes.c" + #line 3212 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4510,7 +4511,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4514 "Python/generated_cases.c.h" + #line 4515 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4523,7 +4524,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3245 "Python/bytecodes.c" + #line 3246 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4552,7 +4553,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4556 "Python/generated_cases.c.h" + #line 4557 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4565,7 +4566,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3277 "Python/bytecodes.c" + #line 3278 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4594,7 +4595,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4598 "Python/generated_cases.c.h" + #line 4599 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4607,7 +4608,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3309 "Python/bytecodes.c" + #line 3310 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4635,7 +4636,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4639 "Python/generated_cases.c.h" + #line 4640 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4645,9 +4646,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3340 "Python/bytecodes.c" + #line 3341 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4651 "Python/generated_cases.c.h" + #line 4652 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4656,7 +4657,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3344 "Python/bytecodes.c" + #line 3345 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4718,14 +4719,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4722 "Python/generated_cases.c.h" + #line 4723 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3406 "Python/bytecodes.c" + #line 3407 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4729 "Python/generated_cases.c.h" + #line 4730 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4736,7 +4737,7 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; PyObject *func; - #line 3412 "Python/bytecodes.c" + #line 3413 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4748,7 +4749,7 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4752 "Python/generated_cases.c.h" + #line 4753 "Python/generated_cases.c.h" stack_pointer[-1] = func; DISPATCH(); } @@ -4756,7 +4757,7 @@ TARGET(SET_FUNCTION_ATTRIBUTE) { PyObject *func = stack_pointer[-1]; PyObject *attr = stack_pointer[-2]; - #line 3426 "Python/bytecodes.c" + #line 3427 "Python/bytecodes.c" assert(PyFunction_Check(func)); PyFunctionObject *func_obj = (PyFunctionObject *)func; switch(oparg) { @@ -4781,14 +4782,14 @@ default: Py_UNREACHABLE(); } - #line 4785 "Python/generated_cases.c.h" + #line 4786 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3453 "Python/bytecodes.c" + #line 3454 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4809,7 +4810,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4813 "Python/generated_cases.c.h" + #line 4814 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4817,15 +4818,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3476 "Python/bytecodes.c" + #line 3477 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4823 "Python/generated_cases.c.h" + #line 4824 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3478 "Python/bytecodes.c" + #line 3479 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4829 "Python/generated_cases.c.h" + #line 4830 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4835,14 +4836,14 @@ TARGET(CONVERT_VALUE) { PyObject *value = stack_pointer[-1]; PyObject *result; - #line 3482 "Python/bytecodes.c" + #line 3483 "Python/bytecodes.c" convertion_func_ptr conv_fn; assert(oparg >= FVC_STR && oparg <= FVC_ASCII); conv_fn = CONVERSION_FUNCTIONS[oparg]; result = conv_fn(value); Py_DECREF(value); if (result == NULL) goto pop_1_error; - #line 4846 "Python/generated_cases.c.h" + #line 4847 "Python/generated_cases.c.h" stack_pointer[-1] = result; DISPATCH(); } @@ -4850,7 +4851,7 @@ TARGET(FORMAT_SIMPLE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 3491 "Python/bytecodes.c" + #line 3492 "Python/bytecodes.c" /* If value is a unicode object, then we know the result * of format(value) is value itself. */ if (!PyUnicode_CheckExact(value)) { @@ -4861,7 +4862,7 @@ else { res = value; } - #line 4865 "Python/generated_cases.c.h" + #line 4866 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -4870,12 +4871,12 @@ PyObject *fmt_spec = stack_pointer[-1]; PyObject *value = stack_pointer[-2]; PyObject *res; - #line 3504 "Python/bytecodes.c" + #line 3505 "Python/bytecodes.c" res = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_DECREF(fmt_spec); if (res == NULL) goto pop_2_error; - #line 4879 "Python/generated_cases.c.h" + #line 4880 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -4884,10 +4885,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3511 "Python/bytecodes.c" + #line 3512 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4891 "Python/generated_cases.c.h" + #line 4892 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4899,7 +4900,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3516 "Python/bytecodes.c" + #line 3517 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4914,12 +4915,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4918 "Python/generated_cases.c.h" + #line 4919 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3531 "Python/bytecodes.c" + #line 3532 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4923 "Python/generated_cases.c.h" + #line 4924 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4929,16 +4930,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3536 "Python/bytecodes.c" + #line 3537 "Python/bytecodes.c" assert(oparg >= 2); - #line 4935 "Python/generated_cases.c.h" + #line 4936 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3540 "Python/bytecodes.c" + #line 3541 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4950,48 +4951,48 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4954 "Python/generated_cases.c.h" + #line 4955 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3554 "Python/bytecodes.c" + #line 3555 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4960 "Python/generated_cases.c.h" + #line 4961 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3558 "Python/bytecodes.c" + #line 3559 "Python/bytecodes.c" CHECK_EVAL_BREAKER(); INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP); - #line 4968 "Python/generated_cases.c.h" + #line 4969 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3563 "Python/bytecodes.c" + #line 3564 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsTrue(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4979 "Python/generated_cases.c.h" + #line 4980 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3571 "Python/bytecodes.c" + #line 3572 "Python/bytecodes.c" PyObject *cond = POP(); assert(PyBool_Check(cond)); _Py_CODEUNIT *here = next_instr - 1; int offset = Py_IsFalse(cond) * oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4990 "Python/generated_cases.c.h" + #line 4991 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3579 "Python/bytecodes.c" + #line 3580 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5003,12 +5004,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5007 "Python/generated_cases.c.h" + #line 5008 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3593 "Python/bytecodes.c" + #line 3594 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -5020,30 +5021,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 5024 "Python/generated_cases.c.h" + #line 5025 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3607 "Python/bytecodes.c" + #line 3608 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 5035 "Python/generated_cases.c.h" + #line 5036 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3615 "Python/bytecodes.c" + #line 3616 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 5042 "Python/generated_cases.c.h" + #line 5043 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3620 "Python/bytecodes.c" + #line 3621 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 5049 "Python/generated_cases.c.h" + #line 5050 "Python/generated_cases.c.h" } From 4ccb8739c982df0597615ae4c160f0d673f70b51 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 12 Jul 2023 09:48:20 -0700 Subject: [PATCH 6/6] Fix crash if stub doesn't need to be moved (I wasn't updating trace_length in this case.) --- Python/optimizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/optimizer.c b/Python/optimizer.c index c987fe57cfb485..abd2351f6b78bd 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -596,8 +596,8 @@ translate_bytecode_to_trace( } } } - trace_length += buffer_size - max_length; } + trace_length += buffer_size - max_length; return trace_length; } else {