pop_1_error:
// Dummy locals.
PyObject *dummy;
+ _Py_CODEUNIT *this_instr;
PyObject *attr;
PyObject *attrs;
PyObject *bottom;
if (code_version != global_version) {
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
ERROR_IF(err, error);
- next_instr--;
+ next_instr = this_instr;
}
else {
if (oparg < RESUME_AFTER_YIELD_FROM) {
CHECK_EVAL_BREAKER();
}
- next_instr[-1].op.code = RESUME_CHECK;
+ this_instr->op.code = RESUME_CHECK;
}
}
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
goto error;
}
- next_instr--;
+ next_instr = this_instr;
}
else {
if (oparg < 2) {
}
_PyFrame_SetStackPointer(frame, stack_pointer);
int err = _Py_call_instrumentation(
- tstate, oparg > 0, frame, next_instr-1);
+ tstate, oparg > 0, frame, this_instr);
stack_pointer = _PyFrame_GetStackPointer(frame);
ERROR_IF(err, error);
- if (frame->instr_ptr != next_instr-1) {
+ if (frame->instr_ptr != this_instr) {
/* Instrumentation has jumped */
- next_instr = frame->instr_ptr;
+ next_instr = this_instr;
DISPATCH();
}
}
macro(END_FOR) = POP_TOP + POP_TOP;
inst(INSTRUMENTED_END_FOR, (receiver, value --)) {
+ TIER_ONE_ONLY
/* Need to create a fake StopIteration error here,
* to conform to PEP 380 */
if (PyGen_Check(receiver)) {
PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr)) {
goto error;
}
PyErr_SetRaisedException(NULL);
}
inst(INSTRUMENTED_END_SEND, (receiver, value -- value)) {
+ TIER_ONE_ONLY
if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) {
PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr)) {
goto error;
}
PyErr_SetRaisedException(NULL);
inst(TO_BOOL, (unused/1, unused/2, value -- res)) {
#if ENABLE_SPECIALIZATION
- _PyToBoolCache *cache = (_PyToBoolCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_ToBool(value, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(TO_BOOL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
int err = PyObject_IsTrue(value);
DECREF_INPUTS();
// So the inputs are the same as for all BINARY_OP
// specializations, but there is no output.
// At the end we just skip over the STORE_FAST.
- op(_BINARY_OP_INPLACE_ADD_UNICODE, (left, right --)) {
- _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
- assert(true_next.op.code == STORE_FAST);
- PyObject **target_local = &GETLOCAL(true_next.op.arg);
+ op(_BINARY_OP_INPLACE_ADD_UNICODE, (unused/1, left, right --)) {
+ assert(next_instr->op.code == STORE_FAST);
+ PyObject **target_local = &GETLOCAL(next_instr->op.arg);
DEOPT_IF(*target_local != left);
STAT_INC(BINARY_OP, hit);
/* Handle `left = left + right` or `left += right` for str.
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
ERROR_IF(*target_local == NULL, error);
// The STORE_FAST is already done.
- SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
+ assert(next_instr->op.code == STORE_FAST);
+ SKIP_OVER(1);
}
macro(BINARY_OP_INPLACE_ADD_UNICODE) =
inst(BINARY_SUBSCR, (unused/1, container, sub -- res)) {
#if ENABLE_SPECIALIZATION
- _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinarySubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
res = PyObject_GetItem(container, sub);
DECREF_INPUTS();
STACK_SHRINK(2);
new_frame->localsplus[0] = container;
new_frame->localsplus[1] = sub;
- SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
- assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR;
DISPATCH_INLINED(new_frame);
}
inst(STORE_SUBSCR, (unused/1, v, container, sub -- )) {
#if ENABLE_SPECIALIZATION
- _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_StoreSubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
/* container[sub] = v */
int err = PyObject_SetItem(container, sub, v);
case 0:
if (do_raise(tstate, exc, cause)) {
assert(oparg == 0);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
break;
inst(INSTRUMENTED_RETURN_VALUE, (retval --)) {
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_RETURN,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
STACK_SHRINK(1);
assert(EMPTY());
PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_RETURN,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
Py_INCREF(retval);
assert(EMPTY());
inst(SEND, (unused/1, receiver, v -- receiver, retval)) {
#if ENABLE_SPECIALIZATION
- _PySendCache *cache = (_PySendCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_Send(receiver, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(SEND, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert(frame != &entry_frame);
if ((tstate->interp->eval_frame == NULL) &&
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
- assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg);
DISPATCH_INLINED(gen_frame);
}
if (retval == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
) {
- monitor_raise(tstate, frame, next_instr-1);
+ monitor_raise(tstate, frame, this_instr);
}
if (_PyGen_FetchStopIterationValue(&retval) == 0) {
assert(retval != NULL);
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
- assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg);
DISPATCH_INLINED(gen_frame);
}
_PyFrame_SetStackPointer(frame, stack_pointer - 1);
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_YIELD,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
tstate->exc_info = gen->gi_exc_state.previous_item;
gen->gi_exc_state.previous_item = NULL;
assert(exc && PyExceptionInstance_Check(exc));
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
else {
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
}
}
else {
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
}
inst(UNPACK_SEQUENCE, (unused/1, seq -- unused[oparg])) {
#if ENABLE_SPECIALIZATION
- _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_UnpackSequence(seq, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(UNPACK_SEQUENCE, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject **top = stack_pointer + oparg - 1;
int res = _PyEval_UnpackIterable(tstate, seq, oparg, -1, top);
inst(STORE_ATTR, (unused/1, unused/3, v, owner --)) {
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_StoreAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyObject_SetAttr(owner, name, v);
inst(LOAD_GLOBAL, (unused/1, unused/1, unused/1, unused/1 -- res, null if (oparg & 1))) {
#if ENABLE_SPECIALIZATION
- _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_GLOBAL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
if (PyDict_CheckExact(GLOBALS())
ERROR_IF(_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0, error);
}
- inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/9, unused, unused, unused -- unused, unused if (oparg & 1))) {
- _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
+ inst(INSTRUMENTED_LOAD_SUPER_ATTR, (unused/1, unused, unused, unused -- unused, unused if (oparg & 1))) {
// cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
// don't want to specialize instrumented instructions
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
}
};
inst(LOAD_SUPER_ATTR, (unused/1, global_super, class, self -- attr, null if (oparg & 1))) {
+ TIER_ONE_ONLY
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
- int load_method = oparg & 1;
#if ENABLE_SPECIALIZATION
- _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ int load_method = oparg & 1;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_LoadSuperAttr(global_super, class, next_instr, load_method);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_SUPER_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
ERROR_IF(err, error);
}
if (super == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
if (err < 0) {
Py_CLEAR(super);
}
inst(LOAD_ATTR, (unused/9, owner -- attr, self_or_null if (oparg & 1))) {
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
if (oparg & 1) {
// Manipulate stack directly because we exit with DISPATCH_INLINED().
STACK_SHRINK(1);
new_frame->localsplus[0] = owner;
- SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
- assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}
STACK_SHRINK(1);
new_frame->localsplus[0] = owner;
new_frame->localsplus[1] = Py_NewRef(name);
- SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
- assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}
inst(COMPARE_OP, (unused/1, left, right -- res)) {
#if ENABLE_SPECIALIZATION
- _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(COMPARE_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert((oparg >> 5) <= Py_GE);
res = PyObject_RichCompare(left, right, oparg >> 5);
inst(JUMP_BACKWARD, (--)) {
CHECK_EVAL_BREAKER();
- _Py_CODEUNIT *here = next_instr - 1;
assert(oparg <= INSTR_OFFSET());
JUMPBY(1-oparg);
#if ENABLE_SPECIALIZATION
- here[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
- if (here[1].cache > tstate->interp->optimizer_backedge_threshold &&
+ this_instr[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
+ if (this_instr[1].cache > tstate->interp->optimizer_backedge_threshold &&
// Double-check that the opcode isn't instrumented or something:
- here->op.code == JUMP_BACKWARD)
+ this_instr->op.code == JUMP_BACKWARD)
{
OPT_STAT_INC(attempts);
- int optimized = _PyOptimizer_BackEdge(frame, here, next_instr, stack_pointer);
+ int optimized = _PyOptimizer_BackEdge(frame, this_instr, next_instr, stack_pointer);
ERROR_IF(optimized < 0, error);
if (optimized) {
// Rewind and enter the executor:
- assert(here->op.code == ENTER_EXECUTOR);
- next_instr = here;
+ assert(this_instr->op.code == ENTER_EXECUTOR);
+ next_instr = this_instr;
}
- here[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) - 1);
+ this_instr[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) - 1);
}
#endif /* ENABLE_SPECIALIZATION */
}
assert(PyBool_Check(cond));
int flag = Py_IsFalse(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
}
assert(PyBool_Check(cond));
int flag = Py_IsTrue(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
}
inst(FOR_ITER, (unused/1, iter -- iter, next)) {
#if ENABLE_SPECIALIZATION
- _PyForIterCache *cache = (_PyForIterCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_ForIter(iter, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(FOR_ITER, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
/* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
next = (*Py_TYPE(iter)->tp_iternext)(iter);
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, next_instr-1);
+ monitor_raise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
- assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
- next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
+ assert(next_instr[oparg].op.code == END_FOR ||
+ next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
// Common case: no jump, leave it to the code generator
}
- inst(INSTRUMENTED_FOR_ITER, ( -- )) {
- _Py_CODEUNIT *here = frame->instr_ptr;
+ inst(INSTRUMENTED_FOR_ITER, (unused/1 -- )) {
_Py_CODEUNIT *target;
PyObject *iter = TOP();
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
if (next != NULL) {
PUSH(next);
- target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER;
+ target = next_instr;
}
else {
if (_PyErr_Occurred(tstate)) {
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, here);
+ monitor_raise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
- assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
- next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
+ assert(next_instr[oparg].op.code == END_FOR ||
+ next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
STACK_SHRINK(1);
Py_DECREF(iter);
/* Skip END_FOR */
- target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1;
+ target = next_instr + oparg + 1;
}
- INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, target, PY_MONITORING_EVENT_BRANCH);
}
op(_ITER_CHECK_LIST, (iter -- iter)) {
}
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
}
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
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();
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
assert(next_instr[oparg].op.code == END_FOR ||
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
- assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg);
DISPATCH_INLINED(gen_frame);
}
unused/2 +
_LOAD_ATTR_METHOD_LAZY_DICT;
- inst(INSTRUMENTED_CALL, ( -- )) {
+ inst(INSTRUMENTED_CALL, (unused/3 -- )) {
int is_meth = PEEK(oparg + 1) != NULL;
int total_args = oparg + is_meth;
PyObject *function = PEEK(oparg + 2);
&_PyInstrumentation_MISSING : PEEK(total_args);
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, function, arg);
+ frame, this_instr, function, arg);
ERROR_IF(err, error);
- _PyCallCache *cache = (_PyCallCache *)next_instr;
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
GO_TO_INSTRUCTION(CALL);
}
total_args++;
}
#if ENABLE_SPECIALIZATION
- _PyCallCache *cache = (_PyCallCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_Call(callable, next_instr, total_args);
DISPATCH_SAME_OPARG();
}
STAT_INC(CALL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) {
args--;
if (new_frame == NULL) {
goto error;
}
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}
if (res == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
if (err < 0) {
Py_CLEAR(res);
}
}
// Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
STACK_SHRINK(oparg + 2);
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}
* 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``)
* 3. Pushes the frame for ``__init__`` to the frame stack
* */
- _PyCallCache *cache = (_PyCallCache *)next_instr;
+ _PyCallCache *cache = (_PyCallCache *)&this_instr[1];
DEOPT_IF(null != NULL);
DEOPT_IF(!PyType_Check(callable));
PyTypeObject *tp = (PyTypeObject *)callable;
for (int i = 0; i < oparg; i++) {
init_frame->localsplus[i+1] = args[i];
}
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
STACK_SHRINK(oparg+2);
_PyFrame_SetStackPointer(frame, stack_pointer);
Py_DECREF(self);
Py_DECREF(callable);
STACK_SHRINK(3);
- // CALL + POP_TOP
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1);
- assert(next_instr[-1].op.code == POP_TOP);
+ // Skip POP_TOP
+ assert(next_instr->op.code == POP_TOP);
+ SKIP_OVER(1);
DISPATCH();
}
: PEEK(total_args + 1);
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr - 1, function, arg);
+ frame, this_instr, function, arg);
ERROR_IF(err, error);
GO_TO_INSTRUCTION(CALL_KW);
}
if (new_frame == NULL) {
goto error;
}
- assert(next_instr - frame->instr_ptr == 1);
+ assert(next_instr - this_instr == 1);
frame->return_offset = 1;
DISPATCH_INLINED(new_frame);
}
if (res == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
if (err < 0) {
Py_CLEAR(res);
}
PyTuple_GET_ITEM(callargs, 0) : Py_None;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
if (err) goto error;
result = PyObject_Call(func, callargs, kwargs);
if (result == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
if (err < 0) {
Py_CLEAR(result);
}
if (new_frame == NULL) {
goto error;
}
- assert(next_instr - frame->instr_ptr == 1);
+ assert(next_instr - this_instr == 1);
frame->return_offset = 1;
DISPATCH_INLINED(new_frame);
}
inst(BINARY_OP, (unused/1, lhs, rhs -- res)) {
#if ENABLE_SPECIALIZATION
- _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_INPLACE_XOR);
inst(INSTRUMENTED_INSTRUCTION, ( -- )) {
int next_opcode = _Py_call_instrumentation_instruction(
- tstate, frame, next_instr-1);
+ tstate, frame, this_instr);
ERROR_IF(next_opcode < 0, error);
- next_instr--;
+ next_instr = this_instr;
if (_PyOpcode_Caches[next_opcode]) {
- _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
}
assert(next_opcode > 0 && next_opcode < 256);
opcode = next_opcode;
}
inst(INSTRUMENTED_JUMP_FORWARD, ( -- )) {
- _Py_CODEUNIT *here = frame->instr_ptr;
- INSTRUMENTED_JUMP(here, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
+ INSTRUMENTED_JUMP(this_instr, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
}
inst(INSTRUMENTED_JUMP_BACKWARD, ( -- )) {
- _Py_CODEUNIT *here = frame->instr_ptr;
CHECK_EVAL_BREAKER();
- INSTRUMENTED_JUMP(here, next_instr + 1 - oparg, PY_MONITORING_EVENT_JUMP);
+ INSTRUMENTED_JUMP(this_instr, next_instr + 1 - oparg, PY_MONITORING_EVENT_JUMP);
}
inst(INSTRUMENTED_POP_JUMP_IF_TRUE, (unused/1 -- )) {
PyObject *cond = POP();
assert(PyBool_Check(cond));
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsTrue(cond);
int offset = flag * oparg;
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
}
inst(INSTRUMENTED_POP_JUMP_IF_FALSE, (unused/1 -- )) {
PyObject *cond = POP();
assert(PyBool_Check(cond));
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsFalse(cond);
int offset = flag * oparg;
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
}
inst(INSTRUMENTED_POP_JUMP_IF_NONE, (unused/1 -- )) {
PyObject *value = POP();
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsNone(value);
int offset;
if (flag) {
offset = 0;
}
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
}
inst(INSTRUMENTED_POP_JUMP_IF_NOT_NONE, (unused/1 -- )) {
PyObject *value = POP();
- _Py_CODEUNIT *here = frame->instr_ptr;
int offset;
int nflag = Py_IsNone(value);
if (nflag) {
offset = oparg;
}
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | !nflag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | !nflag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
}
inst(EXTENDED_ARG, ( -- )) {
op(_SAVE_RETURN_OFFSET, (--)) {
#if TIER_ONE
- frame->return_offset = (uint16_t)(next_instr - frame->instr_ptr);
+ frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
#if TIER_TWO
frame->return_offset = oparg;
// Do not edit!
TARGET(NOP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(NOP);
DISPATCH();
}
TARGET(RESUME) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RESUME);
PREDICTED(RESUME);
+ _Py_CODEUNIT *this_instr = next_instr - 1;
static_assert(0 == 0, "incorrect cache size");
TIER_ONE_ONLY
assert(frame == tstate->current_frame);
if (code_version != global_version) {
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
if (err) goto error;
- next_instr--;
+ next_instr = this_instr;
}
else {
if (oparg < RESUME_AFTER_YIELD_FROM) {
CHECK_EVAL_BREAKER();
}
- next_instr[-1].op.code = RESUME_CHECK;
+ this_instr->op.code = RESUME_CHECK;
}
DISPATCH();
}
TARGET(RESUME_CHECK) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RESUME_CHECK);
#if defined(__EMSCRIPTEN__)
DEOPT_IF(_Py_emscripten_signal_clock == 0, RESUME);
_Py_emscripten_signal_clock -= Py_EMSCRIPTEN_SIGNAL_HANDLING;
}
TARGET(INSTRUMENTED_RESUME) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_RESUME);
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
uintptr_t code_version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
if (code_version != global_version) {
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
goto error;
}
- next_instr--;
+ next_instr = this_instr;
}
else {
if (oparg < 2) {
}
_PyFrame_SetStackPointer(frame, stack_pointer);
int err = _Py_call_instrumentation(
- tstate, oparg > 0, frame, next_instr-1);
+ tstate, oparg > 0, frame, this_instr);
stack_pointer = _PyFrame_GetStackPointer(frame);
if (err) goto error;
- if (frame->instr_ptr != next_instr-1) {
+ if (frame->instr_ptr != this_instr) {
/* Instrumentation has jumped */
- next_instr = frame->instr_ptr;
+ next_instr = this_instr;
DISPATCH();
}
}
}
TARGET(LOAD_FAST_CHECK) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FAST_CHECK);
PyObject *value;
value = GETLOCAL(oparg);
if (value == NULL) goto unbound_local_error;
}
TARGET(LOAD_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FAST);
PyObject *value;
value = GETLOCAL(oparg);
assert(value != NULL);
}
TARGET(LOAD_FAST_AND_CLEAR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FAST_AND_CLEAR);
PyObject *value;
value = GETLOCAL(oparg);
// do not use SETLOCAL here, it decrefs the old value
}
TARGET(LOAD_FAST_LOAD_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FAST_LOAD_FAST);
PyObject *value1;
PyObject *value2;
uint32_t oparg1 = oparg >> 4;
}
TARGET(LOAD_CONST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_CONST);
PyObject *value;
value = GETITEM(FRAME_CO_CONSTS, oparg);
Py_INCREF(value);
}
TARGET(STORE_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_FAST);
PyObject *value;
value = stack_pointer[-1];
SETLOCAL(oparg, value);
}
TARGET(STORE_FAST_LOAD_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_FAST_LOAD_FAST);
PyObject *value1;
PyObject *value2;
value1 = stack_pointer[-1];
}
TARGET(STORE_FAST_STORE_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_FAST_STORE_FAST);
PyObject *value1;
PyObject *value2;
value1 = stack_pointer[-1];
}
TARGET(POP_TOP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(POP_TOP);
PyObject *value;
value = stack_pointer[-1];
Py_DECREF(value);
}
TARGET(PUSH_NULL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(PUSH_NULL);
PyObject *res;
res = NULL;
STACK_GROW(1);
}
TARGET(END_FOR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(END_FOR);
PyObject *value;
// POP_TOP
value = stack_pointer[-1];
}
TARGET(INSTRUMENTED_END_FOR) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_END_FOR);
PyObject *value;
PyObject *receiver;
value = stack_pointer[-1];
receiver = stack_pointer[-2];
+ TIER_ONE_ONLY
/* Need to create a fake StopIteration error here,
* to conform to PEP 380 */
if (PyGen_Check(receiver)) {
PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr)) {
goto error;
}
PyErr_SetRaisedException(NULL);
}
TARGET(END_SEND) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(END_SEND);
PyObject *value;
PyObject *receiver;
value = stack_pointer[-1];
}
TARGET(INSTRUMENTED_END_SEND) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_END_SEND);
PyObject *value;
PyObject *receiver;
value = stack_pointer[-1];
receiver = stack_pointer[-2];
+ TIER_ONE_ONLY
if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) {
PyErr_SetObject(PyExc_StopIteration, value);
- if (monitor_stop_iteration(tstate, frame, next_instr-1)) {
+ if (monitor_stop_iteration(tstate, frame, this_instr)) {
goto error;
}
PyErr_SetRaisedException(NULL);
}
TARGET(UNARY_NEGATIVE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(UNARY_NEGATIVE);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
}
TARGET(UNARY_NOT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(UNARY_NOT);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
}
TARGET(TO_BOOL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL);
PREDICTED(TO_BOOL);
+ _Py_CODEUNIT *this_instr = next_instr - 4;
static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyToBoolCache *cache = (_PyToBoolCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_ToBool(value, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(TO_BOOL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
int err = PyObject_IsTrue(value);
Py_DECREF(value);
if (err < 0) goto pop_1_error;
res = err ? Py_True : Py_False;
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_BOOL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_BOOL);
PyObject *value;
value = stack_pointer[-1];
DEOPT_IF(!PyBool_Check(value), TO_BOOL);
STAT_INC(TO_BOOL, hit);
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_INT);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
res = Py_True;
}
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_LIST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_LIST);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
res = Py_SIZE(value) ? Py_True : Py_False;
Py_DECREF(value);
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_NONE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_NONE);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
STAT_INC(TO_BOOL, hit);
res = Py_False;
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_STR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_STR);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
res = Py_True;
}
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(TO_BOOL_ALWAYS_TRUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(TO_BOOL_ALWAYS_TRUE);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
- uint32_t version = read_u32(&next_instr[1].cache);
+ uint32_t version = read_u32(&this_instr[2].cache);
// This one is a bit weird, because we expect *some* failures:
assert(version);
DEOPT_IF(Py_TYPE(value)->tp_version_tag != version, TO_BOOL);
Py_DECREF(value);
res = Py_True;
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(UNARY_INVERT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(UNARY_INVERT);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
}
TARGET(BINARY_OP_MULTIPLY_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_MULTIPLY_INT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_ADD_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_ADD_INT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_SUBTRACT_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_SUBTRACT_INT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_MULTIPLY_FLOAT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_MULTIPLY_FLOAT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_ADD_FLOAT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_ADD_FLOAT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_SUBTRACT_FLOAT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_SUBTRACT_FLOAT);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_ADD_UNICODE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_ADD_UNICODE);
PyObject *right;
PyObject *left;
PyObject *res;
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_OP_INPLACE_ADD_UNICODE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP_INPLACE_ADD_UNICODE);
PyObject *right;
PyObject *left;
// _GUARD_BOTH_UNICODE
}
// _BINARY_OP_INPLACE_ADD_UNICODE
{
- _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
- assert(true_next.op.code == STORE_FAST);
- PyObject **target_local = &GETLOCAL(true_next.op.arg);
+ assert(next_instr->op.code == STORE_FAST);
+ PyObject **target_local = &GETLOCAL(next_instr->op.arg);
DEOPT_IF(*target_local != left, BINARY_OP);
STAT_INC(BINARY_OP, hit);
/* Handle `left = left + right` or `left += right` for str.
_Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc);
if (*target_local == NULL) goto pop_2_error;
// The STORE_FAST is already done.
- SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
+ assert(next_instr->op.code == STORE_FAST);
+ SKIP_OVER(1);
}
STACK_SHRINK(2);
DISPATCH();
}
TARGET(BINARY_SUBSCR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR);
PREDICTED(BINARY_SUBSCR);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_BINARY_SUBSCR == 1, "incorrect cache size");
PyObject *sub;
PyObject *container;
sub = stack_pointer[-1];
container = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinarySubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
res = PyObject_GetItem(container, sub);
Py_DECREF(container);
if (res == NULL) goto pop_2_error;
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_SLICE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BINARY_SLICE);
PyObject *stop;
PyObject *start;
PyObject *container;
}
TARGET(STORE_SLICE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_SLICE);
PyObject *stop;
PyObject *start;
PyObject *container;
}
TARGET(BINARY_SUBSCR_LIST_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR_LIST_INT);
PyObject *sub;
PyObject *list;
PyObject *res;
Py_DECREF(list);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_SUBSCR_STR_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR_STR_INT);
PyObject *sub;
PyObject *str;
PyObject *res;
Py_DECREF(str);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_SUBSCR_TUPLE_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR_TUPLE_INT);
PyObject *sub;
PyObject *tuple;
PyObject *res;
Py_DECREF(tuple);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_SUBSCR_DICT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR_DICT);
PyObject *sub;
PyObject *dict;
PyObject *res;
Py_DECREF(sub);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(BINARY_SUBSCR_GETITEM) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_SUBSCR_GETITEM);
PyObject *sub;
PyObject *container;
sub = stack_pointer[-1];
STACK_SHRINK(2);
new_frame->localsplus[0] = container;
new_frame->localsplus[1] = sub;
- SKIP_OVER(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
- assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR;
DISPATCH_INLINED(new_frame);
}
TARGET(LIST_APPEND) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LIST_APPEND);
PyObject *v;
PyObject *list;
v = stack_pointer[-1];
}
TARGET(SET_ADD) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(SET_ADD);
PyObject *v;
PyObject *set;
v = stack_pointer[-1];
}
TARGET(STORE_SUBSCR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(STORE_SUBSCR);
PREDICTED(STORE_SUBSCR);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size");
PyObject *sub;
PyObject *container;
container = stack_pointer[-2];
v = stack_pointer[-3];
#if ENABLE_SPECIALIZATION
- _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_StoreSubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
/* container[sub] = v */
int err = PyObject_SetItem(container, sub, v);
Py_DECREF(sub);
if (err) goto pop_3_error;
STACK_SHRINK(3);
- next_instr += 1;
DISPATCH();
}
TARGET(STORE_SUBSCR_LIST_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(STORE_SUBSCR_LIST_INT);
PyObject *sub;
PyObject *list;
PyObject *value;
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
Py_DECREF(list);
STACK_SHRINK(3);
- next_instr += 1;
DISPATCH();
}
TARGET(STORE_SUBSCR_DICT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(STORE_SUBSCR_DICT);
PyObject *sub;
PyObject *dict;
PyObject *value;
Py_DECREF(dict);
if (err) goto pop_3_error;
STACK_SHRINK(3);
- next_instr += 1;
DISPATCH();
}
TARGET(DELETE_SUBSCR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_SUBSCR);
PyObject *sub;
PyObject *container;
sub = stack_pointer[-1];
}
TARGET(CALL_INTRINSIC_1) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CALL_INTRINSIC_1);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
}
TARGET(CALL_INTRINSIC_2) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CALL_INTRINSIC_2);
PyObject *value1;
PyObject *value2;
PyObject *res;
}
TARGET(RAISE_VARARGS) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RAISE_VARARGS);
PyObject **args;
args = stack_pointer - oparg;
PyObject *cause = NULL, *exc = NULL;
case 0:
if (do_raise(tstate, exc, cause)) {
assert(oparg == 0);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
break;
}
TARGET(INTERPRETER_EXIT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INTERPRETER_EXIT);
PyObject *retval;
retval = stack_pointer[-1];
assert(frame == &entry_frame);
}
TARGET(RETURN_VALUE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RETURN_VALUE);
PyObject *retval;
retval = stack_pointer[-1];
STACK_SHRINK(1);
}
TARGET(INSTRUMENTED_RETURN_VALUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_RETURN_VALUE);
PyObject *retval;
retval = stack_pointer[-1];
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_RETURN,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
STACK_SHRINK(1);
assert(EMPTY());
}
TARGET(RETURN_CONST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RETURN_CONST);
PyObject *value;
PyObject *retval;
// LOAD_CONST
}
TARGET(INSTRUMENTED_RETURN_CONST) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_RETURN_CONST);
PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_RETURN,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
Py_INCREF(retval);
assert(EMPTY());
}
TARGET(GET_AITER) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_AITER);
PyObject *obj;
PyObject *iter;
obj = stack_pointer[-1];
}
TARGET(GET_ANEXT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_ANEXT);
PyObject *aiter;
PyObject *awaitable;
aiter = stack_pointer[-1];
}
TARGET(GET_AWAITABLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_AWAITABLE);
PyObject *iterable;
PyObject *iter;
iterable = stack_pointer[-1];
}
TARGET(SEND) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(SEND);
PREDICTED(SEND);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_SEND == 1, "incorrect cache size");
PyObject *v;
PyObject *receiver;
v = stack_pointer[-1];
receiver = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PySendCache *cache = (_PySendCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_Send(receiver, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(SEND, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert(frame != &entry_frame);
if ((tstate->interp->eval_frame == NULL) &&
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
- assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg);
DISPATCH_INLINED(gen_frame);
}
if (retval == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)
) {
- monitor_raise(tstate, frame, next_instr-1);
+ monitor_raise(tstate, frame, this_instr);
}
if (_PyGen_FetchStopIterationValue(&retval) == 0) {
assert(retval != NULL);
}
Py_DECREF(v);
stack_pointer[-1] = retval;
- next_instr += 1;
DISPATCH();
}
TARGET(SEND_GEN) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(SEND_GEN);
PyObject *v;
PyObject *receiver;
v = stack_pointer[-1];
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_SEND);
- assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_SEND == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_SEND + oparg);
DISPATCH_INLINED(gen_frame);
}
TARGET(INSTRUMENTED_YIELD_VALUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_YIELD_VALUE);
PyObject *retval;
retval = stack_pointer[-1];
assert(frame != &entry_frame);
_PyFrame_SetStackPointer(frame, stack_pointer - 1);
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_YIELD,
- frame, next_instr-1, retval);
+ frame, this_instr, retval);
if (err) goto error;
tstate->exc_info = gen->gi_exc_state.previous_item;
gen->gi_exc_state.previous_item = NULL;
}
TARGET(YIELD_VALUE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(YIELD_VALUE);
PyObject *retval;
retval = stack_pointer[-1];
// NOTE: It's important that YIELD_VALUE never raises an exception!
}
TARGET(POP_EXCEPT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(POP_EXCEPT);
PyObject *exc_value;
exc_value = stack_pointer[-1];
_PyErr_StackItem *exc_info = tstate->exc_info;
}
TARGET(RERAISE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RERAISE);
PyObject *exc;
PyObject **values;
exc = stack_pointer[-1];
assert(exc && PyExceptionInstance_Check(exc));
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
TARGET(END_ASYNC_FOR) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(END_ASYNC_FOR);
PyObject *exc;
PyObject *awaitable;
exc = stack_pointer[-1];
else {
Py_INCREF(exc);
_PyErr_SetRaisedException(tstate, exc);
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
STACK_SHRINK(2);
}
TARGET(CLEANUP_THROW) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CLEANUP_THROW);
PyObject *exc_value;
PyObject *last_sent_val;
PyObject *sub_iter;
}
else {
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
- monitor_reraise(tstate, frame, next_instr-1);
+ monitor_reraise(tstate, frame, this_instr);
goto exception_unwind;
}
STACK_SHRINK(1);
}
TARGET(LOAD_ASSERTION_ERROR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_ASSERTION_ERROR);
PyObject *value;
value = Py_NewRef(PyExc_AssertionError);
STACK_GROW(1);
}
TARGET(LOAD_BUILD_CLASS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_BUILD_CLASS);
PyObject *bc;
if (PyMapping_GetOptionalItem(BUILTINS(), &_Py_ID(__build_class__), &bc) < 0) goto error;
if (bc == NULL) {
}
TARGET(STORE_NAME) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_NAME);
PyObject *v;
v = stack_pointer[-1];
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
}
TARGET(DELETE_NAME) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_NAME);
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
PyObject *ns = LOCALS();
int err;
}
TARGET(UNPACK_SEQUENCE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(UNPACK_SEQUENCE);
PREDICTED(UNPACK_SEQUENCE);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
PyObject *seq;
seq = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_UnpackSequence(seq, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(UNPACK_SEQUENCE, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject **top = stack_pointer + oparg - 1;
int res = _PyEval_UnpackIterable(tstate, seq, oparg, -1, top);
if (res == 0) goto pop_1_error;
STACK_SHRINK(1);
STACK_GROW(oparg);
- next_instr += 1;
DISPATCH();
}
TARGET(UNPACK_SEQUENCE_TWO_TUPLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(UNPACK_SEQUENCE_TWO_TUPLE);
PyObject *seq;
PyObject **values;
seq = stack_pointer[-1];
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
- next_instr += 1;
DISPATCH();
}
TARGET(UNPACK_SEQUENCE_TUPLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(UNPACK_SEQUENCE_TUPLE);
PyObject *seq;
PyObject **values;
seq = stack_pointer[-1];
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
- next_instr += 1;
DISPATCH();
}
TARGET(UNPACK_SEQUENCE_LIST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(UNPACK_SEQUENCE_LIST);
PyObject *seq;
PyObject **values;
seq = stack_pointer[-1];
Py_DECREF(seq);
STACK_SHRINK(1);
STACK_GROW(oparg);
- next_instr += 1;
DISPATCH();
}
TARGET(UNPACK_EX) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(UNPACK_EX);
PyObject *seq;
seq = stack_pointer[-1];
int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
}
TARGET(STORE_ATTR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(STORE_ATTR);
PREDICTED(STORE_ATTR);
+ _Py_CODEUNIT *this_instr = next_instr - 5;
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
PyObject *owner;
PyObject *v;
owner = stack_pointer[-1];
v = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_StoreAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyObject_SetAttr(owner, name, v);
Py_DECREF(owner);
if (err) goto pop_2_error;
STACK_SHRINK(2);
- next_instr += 4;
DISPATCH();
}
TARGET(DELETE_ATTR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_ATTR);
PyObject *owner;
owner = stack_pointer[-1];
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
}
TARGET(STORE_GLOBAL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_GLOBAL);
PyObject *v;
v = stack_pointer[-1];
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
}
TARGET(DELETE_GLOBAL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_GLOBAL);
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err;
err = PyDict_DelItem(GLOBALS(), name);
}
TARGET(LOAD_LOCALS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_LOCALS);
PyObject *locals;
locals = LOCALS();
if (locals == NULL) {
}
TARGET(LOAD_FROM_DICT_OR_GLOBALS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FROM_DICT_OR_GLOBALS);
PyObject *mod_or_class_dict;
PyObject *v;
mod_or_class_dict = stack_pointer[-1];
}
TARGET(LOAD_NAME) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_NAME);
PyObject *v;
PyObject *mod_or_class_dict = LOCALS();
if (mod_or_class_dict == NULL) {
}
TARGET(LOAD_GLOBAL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(LOAD_GLOBAL);
PREDICTED(LOAD_GLOBAL);
+ _Py_CODEUNIT *this_instr = next_instr - 5;
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
PyObject *res;
PyObject *null = NULL;
#if ENABLE_SPECIALIZATION
- _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_GLOBAL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
if (PyDict_CheckExact(GLOBALS())
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = res;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 4;
DISPATCH();
}
TARGET(LOAD_GLOBAL_MODULE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(LOAD_GLOBAL_MODULE);
PyObject *res;
PyObject *null = NULL;
// _GUARD_GLOBALS_VERSION
{
- uint16_t version = read_u16(&next_instr[1].cache);
+ uint16_t version = read_u16(&this_instr[2].cache);
PyDictObject *dict = (PyDictObject *)GLOBALS();
DEOPT_IF(!PyDict_CheckExact(dict), LOAD_GLOBAL);
DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
}
// _LOAD_GLOBAL_MODULE
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
PyDictObject *dict = (PyDictObject *)GLOBALS();
PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
res = entries[index].me_value;
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = res;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 4;
DISPATCH();
}
TARGET(LOAD_GLOBAL_BUILTIN) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(LOAD_GLOBAL_BUILTIN);
PyObject *res;
PyObject *null = NULL;
// _GUARD_GLOBALS_VERSION
{
- uint16_t version = read_u16(&next_instr[1].cache);
+ uint16_t version = read_u16(&this_instr[2].cache);
PyDictObject *dict = (PyDictObject *)GLOBALS();
DEOPT_IF(!PyDict_CheckExact(dict), LOAD_GLOBAL);
DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
}
// _GUARD_BUILTINS_VERSION
{
- uint16_t version = read_u16(&next_instr[2].cache);
+ uint16_t version = read_u16(&this_instr[3].cache);
PyDictObject *dict = (PyDictObject *)BUILTINS();
DEOPT_IF(!PyDict_CheckExact(dict), LOAD_GLOBAL);
DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL);
}
// _LOAD_GLOBAL_BUILTINS
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
PyDictObject *bdict = (PyDictObject *)BUILTINS();
PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
res = entries[index].me_value;
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = res;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 4;
DISPATCH();
}
TARGET(DELETE_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_FAST);
PyObject *v = GETLOCAL(oparg);
if (v == NULL) goto unbound_local_error;
SETLOCAL(oparg, NULL);
}
TARGET(MAKE_CELL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MAKE_CELL);
// "initial" is probably NULL but not if it's an arg (or set
// via PyFrame_LocalsToFast() before MAKE_CELL has run).
PyObject *initial = GETLOCAL(oparg);
}
TARGET(DELETE_DEREF) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DELETE_DEREF);
PyObject *cell = GETLOCAL(oparg);
PyObject *oldobj = PyCell_GET(cell);
// Can't use ERROR_IF here.
}
TARGET(LOAD_FROM_DICT_OR_DEREF) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_FROM_DICT_OR_DEREF);
PyObject *class_dict;
PyObject *value;
class_dict = stack_pointer[-1];
}
TARGET(LOAD_DEREF) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LOAD_DEREF);
PyObject *value;
PyObject *cell = GETLOCAL(oparg);
value = PyCell_GET(cell);
}
TARGET(STORE_DEREF) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(STORE_DEREF);
PyObject *v;
v = stack_pointer[-1];
PyObject *cell = GETLOCAL(oparg);
}
TARGET(COPY_FREE_VARS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(COPY_FREE_VARS);
/* Copy closure variables to free variables */
PyCodeObject *co = _PyFrame_GetCode(frame);
assert(PyFunction_Check(frame->f_funcobj));
}
TARGET(BUILD_STRING) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_STRING);
PyObject **pieces;
PyObject *str;
pieces = stack_pointer - oparg;
}
TARGET(BUILD_TUPLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_TUPLE);
PyObject **values;
PyObject *tup;
values = stack_pointer - oparg;
}
TARGET(BUILD_LIST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_LIST);
PyObject **values;
PyObject *list;
values = stack_pointer - oparg;
}
TARGET(LIST_EXTEND) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(LIST_EXTEND);
PyObject *iterable;
PyObject *list;
iterable = stack_pointer[-1];
}
TARGET(SET_UPDATE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(SET_UPDATE);
PyObject *iterable;
PyObject *set;
iterable = stack_pointer[-1];
}
TARGET(BUILD_SET) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_SET);
PyObject **values;
PyObject *set;
values = stack_pointer - oparg;
}
TARGET(BUILD_MAP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_MAP);
PyObject **values;
PyObject *map;
values = stack_pointer - oparg*2;
}
TARGET(SETUP_ANNOTATIONS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(SETUP_ANNOTATIONS);
int err;
PyObject *ann_dict;
if (LOCALS() == NULL) {
}
TARGET(BUILD_CONST_KEY_MAP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_CONST_KEY_MAP);
PyObject *keys;
PyObject **values;
PyObject *map;
}
TARGET(DICT_UPDATE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DICT_UPDATE);
PyObject *update;
PyObject *dict;
update = stack_pointer[-1];
}
TARGET(DICT_MERGE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(DICT_MERGE);
PyObject *update;
PyObject *dict;
PyObject *callable;
}
TARGET(MAP_ADD) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MAP_ADD);
PyObject *value;
PyObject *key;
PyObject *dict;
}
TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) {
- _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_LOAD_SUPER_ATTR);
// cancel out the decrement that will happen in LOAD_SUPER_ATTR; we
// don't want to specialize instrumented instructions
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
GO_TO_INSTRUCTION(LOAD_SUPER_ATTR);
}
TARGET(LOAD_SUPER_ATTR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(LOAD_SUPER_ATTR);
PREDICTED(LOAD_SUPER_ATTR);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
PyObject *self;
PyObject *class;
self = stack_pointer[-1];
class = stack_pointer[-2];
global_super = stack_pointer[-3];
+ TIER_ONE_ONLY
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
- int load_method = oparg & 1;
#if ENABLE_SPECIALIZATION
- _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ int load_method = oparg & 1;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_LoadSuperAttr(global_super, class, next_instr, load_method);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_SUPER_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
PyObject *arg = oparg & 2 ? class : &_PyInstrumentation_MISSING;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
if (err) goto pop_3_error;
}
if (super == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, global_super, arg);
+ frame, this_instr, global_super, arg);
if (err < 0) {
Py_CLEAR(super);
}
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 1;
DISPATCH();
}
TARGET(LOAD_SUPER_ATTR_ATTR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(LOAD_SUPER_ATTR_ATTR);
PyObject *self;
PyObject *class;
PyObject *global_super;
if (attr == NULL) goto pop_3_error;
STACK_SHRINK(2);
stack_pointer[-1] = attr;
- next_instr += 1;
DISPATCH();
}
TARGET(LOAD_SUPER_ATTR_METHOD) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(LOAD_SUPER_ATTR_METHOD);
PyObject *self;
PyObject *class;
PyObject *global_super;
STACK_SHRINK(1);
stack_pointer[-2] = attr;
stack_pointer[-1] = self_or_null;
- next_instr += 1;
DISPATCH();
}
TARGET(LOAD_ATTR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR);
PREDICTED(LOAD_ATTR);
+ _Py_CODEUNIT *this_instr = next_instr - 10;
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
PyObject *owner;
PyObject *attr;
PyObject *self_or_null = NULL;
owner = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
if (oparg & 1) {
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = self_or_null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_INSTANCE_VALUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_INSTANCE_VALUE);
PyObject *owner;
PyObject *attr;
PyObject *null = NULL;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_INSTANCE_VALUE
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
attr = _PyDictOrValues_GetValues(dorv)->values[index];
DEOPT_IF(attr == NULL, LOAD_ATTR);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_MODULE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_MODULE);
PyObject *owner;
PyObject *attr;
PyObject *null = NULL;
// _CHECK_ATTR_MODULE
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
assert(dict != NULL);
}
// _LOAD_ATTR_MODULE
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
assert(index < dict->ma_keys->dk_nentries);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_WITH_HINT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_WITH_HINT);
PyObject *owner;
PyObject *attr;
PyObject *null = NULL;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_WITH_HINT
{
- uint16_t hint = read_u16(&next_instr[3].cache);
+ uint16_t hint = read_u16(&this_instr[4].cache);
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_SLOT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_SLOT);
PyObject *owner;
PyObject *attr;
PyObject *null = NULL;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_SLOT
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
char *addr = (char *)owner + index;
attr = *(PyObject **)addr;
DEOPT_IF(attr == NULL, LOAD_ATTR);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_CLASS) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_CLASS);
PyObject *owner;
PyObject *attr;
PyObject *null = NULL;
// _CHECK_ATTR_CLASS
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
DEOPT_IF(!PyType_Check(owner), LOAD_ATTR);
assert(type_version != 0);
DEOPT_IF(((PyTypeObject *)owner)->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_CLASS
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
STAT_INC(LOAD_ATTR, hit);
assert(descr != NULL);
attr = Py_NewRef(descr);
STACK_GROW(((oparg & 1) ? 1 : 0));
stack_pointer[-1 - (oparg & 1 ? 1 : 0)] = attr;
if (oparg & 1) { stack_pointer[-(oparg & 1 ? 1 : 0)] = null; }
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_PROPERTY) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_PROPERTY);
PyObject *owner;
owner = stack_pointer[-1];
- uint32_t type_version = read_u32(&next_instr[1].cache);
- uint32_t func_version = read_u32(&next_instr[3].cache);
- PyObject *fget = read_obj(&next_instr[5].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
+ uint32_t func_version = read_u32(&this_instr[4].cache);
+ PyObject *fget = read_obj(&this_instr[6].cache);
assert((oparg & 1) == 0);
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
// Manipulate stack directly because we exit with DISPATCH_INLINED().
STACK_SHRINK(1);
new_frame->localsplus[0] = owner;
- SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
- assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
PyObject *owner;
owner = stack_pointer[-1];
- uint32_t type_version = read_u32(&next_instr[1].cache);
- uint32_t func_version = read_u32(&next_instr[3].cache);
- PyObject *getattribute = read_obj(&next_instr[5].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
+ uint32_t func_version = read_u32(&this_instr[4].cache);
+ PyObject *getattribute = read_obj(&this_instr[6].cache);
assert((oparg & 1) == 0);
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
PyTypeObject *cls = Py_TYPE(owner);
STACK_SHRINK(1);
new_frame->localsplus[0] = owner;
new_frame->localsplus[1] = Py_NewRef(name);
- SKIP_OVER(INLINE_CACHE_ENTRIES_LOAD_ATTR);
- assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_LOAD_ATTR == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_LOAD_ATTR;
DISPATCH_INLINED(new_frame);
}
TARGET(STORE_ATTR_INSTANCE_VALUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(STORE_ATTR_INSTANCE_VALUE);
PyObject *owner;
PyObject *value;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
// _STORE_ATTR_INSTANCE_VALUE
value = stack_pointer[-2];
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
STAT_INC(STORE_ATTR, hit);
PyDictValues *values = _PyDictOrValues_GetValues(dorv);
Py_DECREF(owner);
}
STACK_SHRINK(2);
- next_instr += 4;
DISPATCH();
}
TARGET(STORE_ATTR_WITH_HINT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(STORE_ATTR_WITH_HINT);
PyObject *owner;
PyObject *value;
owner = stack_pointer[-1];
value = stack_pointer[-2];
- uint32_t type_version = read_u32(&next_instr[1].cache);
- uint16_t hint = read_u16(&next_instr[3].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
+ uint16_t hint = read_u16(&this_instr[4].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
dict->ma_version_tag = new_version;
Py_DECREF(owner);
STACK_SHRINK(2);
- next_instr += 4;
DISPATCH();
}
TARGET(STORE_ATTR_SLOT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 5;
+ INSTRUCTION_STATS(STORE_ATTR_SLOT);
PyObject *owner;
PyObject *value;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
// _STORE_ATTR_SLOT
value = stack_pointer[-2];
{
- uint16_t index = read_u16(&next_instr[3].cache);
+ uint16_t index = read_u16(&this_instr[4].cache);
char *addr = (char *)owner + index;
STAT_INC(STORE_ATTR, hit);
PyObject *old_value = *(PyObject **)addr;
Py_DECREF(owner);
}
STACK_SHRINK(2);
- next_instr += 4;
DISPATCH();
}
TARGET(COMPARE_OP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(COMPARE_OP);
PREDICTED(COMPARE_OP);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
PyObject *right;
PyObject *left;
right = stack_pointer[-1];
left = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(COMPARE_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert((oparg >> 5) <= Py_GE);
res = PyObject_RichCompare(left, right, oparg >> 5);
}
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(COMPARE_OP_FLOAT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(COMPARE_OP_FLOAT);
PyObject *right;
PyObject *left;
PyObject *res;
// It's always a bool, so we don't care about oparg & 16.
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(COMPARE_OP_INT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(COMPARE_OP_INT);
PyObject *right;
PyObject *left;
PyObject *res;
// It's always a bool, so we don't care about oparg & 16.
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(COMPARE_OP_STR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(COMPARE_OP_STR);
PyObject *right;
PyObject *left;
PyObject *res;
// It's always a bool, so we don't care about oparg & 16.
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(IS_OP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(IS_OP);
PyObject *right;
PyObject *left;
PyObject *b;
}
TARGET(CONTAINS_OP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CONTAINS_OP);
PyObject *right;
PyObject *left;
PyObject *b;
}
TARGET(CHECK_EG_MATCH) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CHECK_EG_MATCH);
PyObject *match_type;
PyObject *exc_value;
PyObject *rest;
}
TARGET(CHECK_EXC_MATCH) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CHECK_EXC_MATCH);
PyObject *right;
PyObject *left;
PyObject *b;
}
TARGET(IMPORT_NAME) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(IMPORT_NAME);
PyObject *fromlist;
PyObject *level;
PyObject *res;
}
TARGET(IMPORT_FROM) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(IMPORT_FROM);
PyObject *from;
PyObject *res;
from = stack_pointer[-1];
}
TARGET(JUMP_FORWARD) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(JUMP_FORWARD);
JUMPBY(oparg);
DISPATCH();
}
TARGET(JUMP_BACKWARD) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(JUMP_BACKWARD);
CHECK_EVAL_BREAKER();
- _Py_CODEUNIT *here = next_instr - 1;
assert(oparg <= INSTR_OFFSET());
JUMPBY(1-oparg);
#if ENABLE_SPECIALIZATION
- here[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
- if (here[1].cache > tstate->interp->optimizer_backedge_threshold &&
+ this_instr[1].cache += (1 << OPTIMIZER_BITS_IN_COUNTER);
+ if (this_instr[1].cache > tstate->interp->optimizer_backedge_threshold &&
// Double-check that the opcode isn't instrumented or something:
- here->op.code == JUMP_BACKWARD)
+ this_instr->op.code == JUMP_BACKWARD)
{
OPT_STAT_INC(attempts);
- int optimized = _PyOptimizer_BackEdge(frame, here, next_instr, stack_pointer);
+ int optimized = _PyOptimizer_BackEdge(frame, this_instr, next_instr, stack_pointer);
if (optimized < 0) goto error;
if (optimized) {
// Rewind and enter the executor:
- assert(here->op.code == ENTER_EXECUTOR);
- next_instr = here;
+ assert(this_instr->op.code == ENTER_EXECUTOR);
+ next_instr = this_instr;
}
- here[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) - 1);
+ this_instr[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) - 1);
}
#endif /* ENABLE_SPECIALIZATION */
DISPATCH();
}
TARGET(ENTER_EXECUTOR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(ENTER_EXECUTOR);
CHECK_EVAL_BREAKER();
PyCodeObject *code = _PyFrame_GetCode(frame);
}
TARGET(POP_JUMP_IF_FALSE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(POP_JUMP_IF_FALSE);
PyObject *cond;
cond = stack_pointer[-1];
assert(PyBool_Check(cond));
int flag = Py_IsFalse(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
STACK_SHRINK(1);
- next_instr += 1;
DISPATCH();
}
TARGET(POP_JUMP_IF_TRUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(POP_JUMP_IF_TRUE);
PyObject *cond;
cond = stack_pointer[-1];
assert(PyBool_Check(cond));
int flag = Py_IsTrue(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
STACK_SHRINK(1);
- next_instr += 1;
DISPATCH();
}
TARGET(POP_JUMP_IF_NONE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(POP_JUMP_IF_NONE);
PyObject *value;
PyObject *b;
PyObject *cond;
assert(PyBool_Check(cond));
int flag = Py_IsTrue(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
}
STACK_SHRINK(1);
- next_instr += 1;
DISPATCH();
}
TARGET(POP_JUMP_IF_NOT_NONE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(POP_JUMP_IF_NOT_NONE);
PyObject *value;
PyObject *b;
PyObject *cond;
assert(PyBool_Check(cond));
int flag = Py_IsFalse(cond);
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
JUMPBY(oparg * flag);
}
STACK_SHRINK(1);
- next_instr += 1;
DISPATCH();
}
TARGET(JUMP_BACKWARD_NO_INTERRUPT) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(JUMP_BACKWARD_NO_INTERRUPT);
/* This bytecode is used in the `yield from` or `await` loop.
* If there is an interrupt, we want it handled in the innermost
* generator or coroutine, so we deliberately do not check it here.
}
TARGET(GET_LEN) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_LEN);
PyObject *obj;
PyObject *len_o;
obj = stack_pointer[-1];
}
TARGET(MATCH_CLASS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MATCH_CLASS);
PyObject *names;
PyObject *type;
PyObject *subject;
}
TARGET(MATCH_MAPPING) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MATCH_MAPPING);
PyObject *subject;
PyObject *res;
subject = stack_pointer[-1];
}
TARGET(MATCH_SEQUENCE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MATCH_SEQUENCE);
PyObject *subject;
PyObject *res;
subject = stack_pointer[-1];
}
TARGET(MATCH_KEYS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MATCH_KEYS);
PyObject *keys;
PyObject *subject;
PyObject *values_or_none;
}
TARGET(GET_ITER) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_ITER);
PyObject *iterable;
PyObject *iter;
iterable = stack_pointer[-1];
}
TARGET(GET_YIELD_FROM_ITER) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(GET_YIELD_FROM_ITER);
PyObject *iterable;
PyObject *iter;
iterable = stack_pointer[-1];
}
TARGET(FOR_ITER) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(FOR_ITER);
PREDICTED(FOR_ITER);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
PyObject *iter;
PyObject *next;
iter = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyForIterCache *cache = (_PyForIterCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_ForIter(iter, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(FOR_ITER, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
/* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
next = (*Py_TYPE(iter)->tp_iternext)(iter);
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, next_instr-1);
+ monitor_raise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
- assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
- next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
+ assert(next_instr[oparg].op.code == END_FOR ||
+ next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
// Common case: no jump, leave it to the code generator
STACK_GROW(1);
stack_pointer[-1] = next;
- next_instr += 1;
DISPATCH();
}
TARGET(INSTRUMENTED_FOR_ITER) {
- _Py_CODEUNIT *here = frame->instr_ptr;
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_FOR_ITER);
_Py_CODEUNIT *target;
PyObject *iter = TOP();
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
if (next != NULL) {
PUSH(next);
- target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER;
+ target = next_instr;
}
else {
if (_PyErr_Occurred(tstate)) {
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
goto error;
}
- monitor_raise(tstate, frame, here);
+ monitor_raise(tstate, frame, this_instr);
_PyErr_Clear(tstate);
}
/* iterator ended normally */
- assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR ||
- next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == INSTRUMENTED_END_FOR);
+ assert(next_instr[oparg].op.code == END_FOR ||
+ next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
STACK_SHRINK(1);
Py_DECREF(iter);
/* Skip END_FOR */
- target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1;
+ target = next_instr + oparg + 1;
}
- INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH);
+ INSTRUMENTED_JUMP(this_instr, target, PY_MONITORING_EVENT_BRANCH);
DISPATCH();
}
TARGET(FOR_ITER_LIST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(FOR_ITER_LIST);
PyObject *iter;
PyObject *next;
// _ITER_CHECK_LIST
}
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
}
STACK_GROW(1);
stack_pointer[-1] = next;
- next_instr += 1;
DISPATCH();
}
TARGET(FOR_ITER_TUPLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(FOR_ITER_TUPLE);
PyObject *iter;
PyObject *next;
// _ITER_CHECK_TUPLE
}
Py_DECREF(iter);
STACK_SHRINK(1);
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
/* Jump forward oparg, then skip following END_FOR instruction */
JUMPBY(oparg + 1);
DISPATCH();
}
STACK_GROW(1);
stack_pointer[-1] = next;
- next_instr += 1;
DISPATCH();
}
TARGET(FOR_ITER_RANGE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(FOR_ITER_RANGE);
PyObject *iter;
PyObject *next;
// _ITER_CHECK_RANGE
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();
}
STACK_GROW(1);
stack_pointer[-1] = next;
- next_instr += 1;
DISPATCH();
}
TARGET(FOR_ITER_GEN) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(FOR_ITER_GEN);
PyObject *iter;
iter = stack_pointer[-1];
DEOPT_IF(tstate->interp->eval_frame, FOR_ITER);
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
- SKIP_OVER(INLINE_CACHE_ENTRIES_FOR_ITER);
assert(next_instr[oparg].op.code == END_FOR ||
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
- assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_FOR_ITER == next_instr - this_instr);
frame->return_offset = (uint16_t)(1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg);
DISPATCH_INLINED(gen_frame);
}
TARGET(BEFORE_ASYNC_WITH) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BEFORE_ASYNC_WITH);
PyObject *mgr;
PyObject *exit;
PyObject *res;
}
TARGET(BEFORE_WITH) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BEFORE_WITH);
PyObject *mgr;
PyObject *exit;
PyObject *res;
}
TARGET(WITH_EXCEPT_START) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(WITH_EXCEPT_START);
PyObject *val;
PyObject *lasti;
PyObject *exit_func;
}
TARGET(PUSH_EXC_INFO) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(PUSH_EXC_INFO);
PyObject *new_exc;
PyObject *prev_exc;
new_exc = stack_pointer[-1];
}
TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_METHOD_WITH_VALUES);
PyObject *owner;
PyObject *attr;
PyObject *self;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _GUARD_KEYS_VERSION
{
- uint32_t keys_version = read_u32(&next_instr[3].cache);
+ uint32_t keys_version = read_u32(&this_instr[4].cache);
PyTypeObject *owner_cls = Py_TYPE(owner);
PyHeapTypeObject *owner_heap_type = (PyHeapTypeObject *)owner_cls;
DEOPT_IF(owner_heap_type->ht_cached_keys->dk_version != keys_version, LOAD_ATTR);
}
// _LOAD_ATTR_METHOD_WITH_VALUES
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
assert(oparg & 1);
/* Cached method object */
STAT_INC(LOAD_ATTR, hit);
STACK_GROW(1);
stack_pointer[-2] = attr;
stack_pointer[-1] = self;
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_METHOD_NO_DICT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_METHOD_NO_DICT);
PyObject *owner;
PyObject *attr;
PyObject *self;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_METHOD_NO_DICT
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
assert(oparg & 1);
assert(Py_TYPE(owner)->tp_dictoffset == 0);
STAT_INC(LOAD_ATTR, hit);
STACK_GROW(1);
stack_pointer[-2] = attr;
stack_pointer[-1] = self;
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES);
PyObject *owner;
PyObject *attr;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _GUARD_KEYS_VERSION
{
- uint32_t keys_version = read_u32(&next_instr[3].cache);
+ uint32_t keys_version = read_u32(&this_instr[4].cache);
PyTypeObject *owner_cls = Py_TYPE(owner);
PyHeapTypeObject *owner_heap_type = (PyHeapTypeObject *)owner_cls;
DEOPT_IF(owner_heap_type->ht_cached_keys->dk_version != keys_version, LOAD_ATTR);
}
// _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
assert((oparg & 1) == 0);
STAT_INC(LOAD_ATTR, hit);
assert(descr != NULL);
attr = Py_NewRef(descr);
}
stack_pointer[-1] = attr;
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_NONDESCRIPTOR_NO_DICT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_NO_DICT);
PyObject *owner;
PyObject *attr;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_NONDESCRIPTOR_NO_DICT
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
assert((oparg & 1) == 0);
assert(Py_TYPE(owner)->tp_dictoffset == 0);
STAT_INC(LOAD_ATTR, hit);
attr = Py_NewRef(descr);
}
stack_pointer[-1] = attr;
- next_instr += 9;
DISPATCH();
}
TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 10;
+ INSTRUCTION_STATS(LOAD_ATTR_METHOD_LAZY_DICT);
PyObject *owner;
PyObject *attr;
PyObject *self;
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
- uint32_t type_version = read_u32(&next_instr[1].cache);
+ uint32_t type_version = read_u32(&this_instr[2].cache);
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
}
// _LOAD_ATTR_METHOD_LAZY_DICT
{
- PyObject *descr = read_obj(&next_instr[5].cache);
+ PyObject *descr = read_obj(&this_instr[6].cache);
assert(oparg & 1);
STAT_INC(LOAD_ATTR, hit);
assert(descr != NULL);
STACK_GROW(1);
stack_pointer[-2] = attr;
stack_pointer[-1] = self;
- next_instr += 9;
DISPATCH();
}
TARGET(INSTRUMENTED_CALL) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(INSTRUMENTED_CALL);
int is_meth = PEEK(oparg + 1) != NULL;
int total_args = oparg + is_meth;
PyObject *function = PEEK(oparg + 2);
&_PyInstrumentation_MISSING : PEEK(total_args);
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, function, arg);
+ frame, this_instr, function, arg);
if (err) goto error;
- _PyCallCache *cache = (_PyCallCache *)next_instr;
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
GO_TO_INSTRUCTION(CALL);
}
TARGET(CALL) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL);
PREDICTED(CALL);
+ _Py_CODEUNIT *this_instr = next_instr - 4;
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
PyObject **args;
PyObject *self_or_null;
total_args++;
}
#if ENABLE_SPECIALIZATION
- _PyCallCache *cache = (_PyCallCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_Call(callable, next_instr, total_args);
DISPATCH_SAME_OPARG();
}
STAT_INC(CALL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) {
args--;
if (new_frame == NULL) {
goto error;
}
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}
if (res == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
if (err < 0) {
Py_CLEAR(res);
}
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_BOUND_METHOD_EXACT_ARGS);
PyObject *null;
PyObject *callable;
PyObject *self;
self_or_null = self;
callable = func;
{
- uint32_t func_version = read_u32(&next_instr[1].cache);
+ uint32_t func_version = read_u32(&this_instr[2].cache);
DEOPT_IF(!PyFunction_Check(callable), CALL);
PyFunctionObject *func = (PyFunctionObject *)callable;
DEOPT_IF(func->func_version != func_version, CALL);
}
}
// _SAVE_RETURN_OFFSET
- next_instr += 3;
{
#if TIER_ONE
- frame->return_offset = (uint16_t)(next_instr - frame->instr_ptr);
+ frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
#if TIER_TWO
frame->return_offset = oparg;
}
TARGET(CALL_PY_EXACT_ARGS) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_PY_EXACT_ARGS);
PyObject *self_or_null;
PyObject *callable;
PyObject **args;
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
{
- uint32_t func_version = read_u32(&next_instr[1].cache);
+ uint32_t func_version = read_u32(&this_instr[2].cache);
DEOPT_IF(!PyFunction_Check(callable), CALL);
PyFunctionObject *func = (PyFunctionObject *)callable;
DEOPT_IF(func->func_version != func_version, CALL);
}
}
// _SAVE_RETURN_OFFSET
- next_instr += 3;
{
#if TIER_ONE
- frame->return_offset = (uint16_t)(next_instr - frame->instr_ptr);
+ frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
#if TIER_TWO
frame->return_offset = oparg;
}
TARGET(CALL_PY_WITH_DEFAULTS) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_PY_WITH_DEFAULTS);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
args = stack_pointer - oparg;
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
- uint32_t func_version = read_u32(&next_instr[1].cache);
+ uint32_t func_version = read_u32(&this_instr[2].cache);
DEOPT_IF(tstate->interp->eval_frame, CALL);
int argcount = oparg;
if (self_or_null != NULL) {
}
// Manipulate stack and cache directly since we leave using DISPATCH_INLINED().
STACK_SHRINK(oparg + 2);
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
DISPATCH_INLINED(new_frame);
}
TARGET(CALL_TYPE_1) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_TYPE_1);
PyObject **args;
PyObject *null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(CALL_STR_1) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_STR_1);
PyObject **args;
PyObject *null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_TUPLE_1) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_TUPLE_1);
PyObject **args;
PyObject *null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_ALLOC_AND_ENTER_INIT) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_ALLOC_AND_ENTER_INIT);
PyObject **args;
PyObject *null;
PyObject *callable;
* 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``)
* 3. Pushes the frame for ``__init__`` to the frame stack
* */
- _PyCallCache *cache = (_PyCallCache *)next_instr;
+ _PyCallCache *cache = (_PyCallCache *)&this_instr[1];
DEOPT_IF(null != NULL, CALL);
DEOPT_IF(!PyType_Check(callable), CALL);
PyTypeObject *tp = (PyTypeObject *)callable;
for (int i = 0; i < oparg; i++) {
init_frame->localsplus[i+1] = args[i];
}
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
- assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - frame->instr_ptr);
+ assert(1 + INLINE_CACHE_ENTRIES_CALL == next_instr - this_instr);
frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL;
STACK_SHRINK(oparg+2);
_PyFrame_SetStackPointer(frame, stack_pointer);
}
TARGET(EXIT_INIT_CHECK) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(EXIT_INIT_CHECK);
PyObject *should_be_none;
should_be_none = stack_pointer[-1];
assert(STACK_LEVEL() == 2);
}
TARGET(CALL_BUILTIN_CLASS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_BUILTIN_CLASS);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_BUILTIN_O) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_BUILTIN_O);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_BUILTIN_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_BUILTIN_FAST);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_BUILTIN_FAST_WITH_KEYWORDS);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_LEN) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_LEN);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(CALL_ISINSTANCE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_ISINSTANCE);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
DISPATCH();
}
TARGET(CALL_LIST_APPEND) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_LIST_APPEND);
PyObject **args;
PyObject *self;
PyObject *callable;
Py_DECREF(self);
Py_DECREF(callable);
STACK_SHRINK(3);
- // CALL + POP_TOP
- SKIP_OVER(INLINE_CACHE_ENTRIES_CALL + 1);
- assert(next_instr[-1].op.code == POP_TOP);
+ // Skip POP_TOP
+ assert(next_instr->op.code == POP_TOP);
+ SKIP_OVER(1);
DISPATCH();
}
TARGET(CALL_METHOD_DESCRIPTOR_O) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_O);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_METHOD_DESCRIPTOR_NOARGS) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_NOARGS);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(CALL_METHOD_DESCRIPTOR_FAST) {
+ frame->instr_ptr = next_instr;
+ next_instr += 4;
+ INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_FAST);
PyObject **args;
PyObject *self_or_null;
PyObject *callable;
STACK_SHRINK(oparg);
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 3;
CHECK_EVAL_BREAKER();
DISPATCH();
}
TARGET(INSTRUMENTED_CALL_KW) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_CALL_KW);
int is_meth = PEEK(oparg + 2) != NULL;
int total_args = oparg + is_meth;
PyObject *function = PEEK(oparg + 3);
: PEEK(total_args + 1);
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr - 1, function, arg);
+ frame, this_instr, function, arg);
if (err) goto error;
GO_TO_INSTRUCTION(CALL_KW);
}
TARGET(CALL_KW) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CALL_KW);
PREDICTED(CALL_KW);
+ _Py_CODEUNIT *this_instr = next_instr - 1;
PyObject *kwnames;
PyObject **args;
PyObject *self_or_null;
if (new_frame == NULL) {
goto error;
}
- assert(next_instr - frame->instr_ptr == 1);
+ assert(next_instr - this_instr == 1);
frame->return_offset = 1;
DISPATCH_INLINED(new_frame);
}
if (res == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, callable, arg);
+ frame, this_instr, callable, arg);
if (err < 0) {
Py_CLEAR(res);
}
}
TARGET(INSTRUMENTED_CALL_FUNCTION_EX) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_CALL_FUNCTION_EX);
GO_TO_INSTRUCTION(CALL_FUNCTION_EX);
}
TARGET(CALL_FUNCTION_EX) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CALL_FUNCTION_EX);
PREDICTED(CALL_FUNCTION_EX);
+ _Py_CODEUNIT *this_instr = next_instr - 1;
PyObject *kwargs = NULL;
PyObject *callargs;
PyObject *func;
PyTuple_GET_ITEM(callargs, 0) : Py_None;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
if (err) goto error;
result = PyObject_Call(func, callargs, kwargs);
if (result == NULL) {
_Py_call_instrumentation_exc2(
tstate, PY_MONITORING_EVENT_C_RAISE,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
}
else {
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_C_RETURN,
- frame, next_instr-1, func, arg);
+ frame, this_instr, func, arg);
if (err < 0) {
Py_CLEAR(result);
}
if (new_frame == NULL) {
goto error;
}
- assert(next_instr - frame->instr_ptr == 1);
+ assert(next_instr - this_instr == 1);
frame->return_offset = 1;
DISPATCH_INLINED(new_frame);
}
}
TARGET(MAKE_FUNCTION) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(MAKE_FUNCTION);
PyObject *codeobj;
PyObject *func;
codeobj = stack_pointer[-1];
}
TARGET(SET_FUNCTION_ATTRIBUTE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(SET_FUNCTION_ATTRIBUTE);
PyObject *func;
PyObject *attr;
func = stack_pointer[-1];
}
TARGET(RETURN_GENERATOR) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RETURN_GENERATOR);
assert(PyFunction_Check(frame->f_funcobj));
PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
}
TARGET(BUILD_SLICE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(BUILD_SLICE);
PyObject *step = NULL;
PyObject *stop;
PyObject *start;
}
TARGET(CONVERT_VALUE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CONVERT_VALUE);
PyObject *value;
PyObject *result;
value = stack_pointer[-1];
}
TARGET(FORMAT_SIMPLE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(FORMAT_SIMPLE);
PyObject *value;
PyObject *res;
value = stack_pointer[-1];
}
TARGET(FORMAT_WITH_SPEC) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(FORMAT_WITH_SPEC);
PyObject *fmt_spec;
PyObject *value;
PyObject *res;
}
TARGET(COPY) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(COPY);
PyObject *bottom;
PyObject *top;
bottom = stack_pointer[-1 - (oparg-1)];
}
TARGET(BINARY_OP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(BINARY_OP);
PREDICTED(BINARY_OP);
+ _Py_CODEUNIT *this_instr = next_instr - 2;
static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 1, "incorrect cache size");
PyObject *rhs;
PyObject *lhs;
rhs = stack_pointer[-1];
lhs = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_INPLACE_XOR);
if (res == NULL) goto pop_2_error;
STACK_SHRINK(1);
stack_pointer[-1] = res;
- next_instr += 1;
DISPATCH();
}
TARGET(SWAP) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(SWAP);
PyObject *top;
PyObject *bottom;
top = stack_pointer[-1];
}
TARGET(INSTRUMENTED_INSTRUCTION) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_INSTRUCTION);
int next_opcode = _Py_call_instrumentation_instruction(
- tstate, frame, next_instr-1);
+ tstate, frame, this_instr);
if (next_opcode < 0) goto error;
- next_instr--;
+ next_instr = this_instr;
if (_PyOpcode_Caches[next_opcode]) {
- _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
- INCREMENT_ADAPTIVE_COUNTER(cache->counter);
+ INCREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
}
assert(next_opcode > 0 && next_opcode < 256);
opcode = next_opcode;
}
TARGET(INSTRUMENTED_JUMP_FORWARD) {
- _Py_CODEUNIT *here = frame->instr_ptr;
- INSTRUMENTED_JUMP(here, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_JUMP_FORWARD);
+ INSTRUMENTED_JUMP(this_instr, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
DISPATCH();
}
TARGET(INSTRUMENTED_JUMP_BACKWARD) {
- _Py_CODEUNIT *here = frame->instr_ptr;
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(INSTRUMENTED_JUMP_BACKWARD);
CHECK_EVAL_BREAKER();
- INSTRUMENTED_JUMP(here, next_instr + 1 - oparg, PY_MONITORING_EVENT_JUMP);
+ INSTRUMENTED_JUMP(this_instr, next_instr + 1 - oparg, PY_MONITORING_EVENT_JUMP);
DISPATCH();
}
TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_TRUE);
PyObject *cond = POP();
assert(PyBool_Check(cond));
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsTrue(cond);
int offset = flag * oparg;
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
- next_instr += 1;
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
DISPATCH();
}
TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_FALSE);
PyObject *cond = POP();
assert(PyBool_Check(cond));
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsFalse(cond);
int offset = flag * oparg;
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
- next_instr += 1;
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
DISPATCH();
}
TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NONE);
PyObject *value = POP();
- _Py_CODEUNIT *here = frame->instr_ptr;
int flag = Py_IsNone(value);
int offset;
if (flag) {
offset = 0;
}
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | flag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | flag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
- next_instr += 1;
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
DISPATCH();
}
TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
+ _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
+ next_instr += 2;
+ INSTRUCTION_STATS(INSTRUMENTED_POP_JUMP_IF_NOT_NONE);
PyObject *value = POP();
- _Py_CODEUNIT *here = frame->instr_ptr;
int offset;
int nflag = Py_IsNone(value);
if (nflag) {
offset = oparg;
}
#if ENABLE_SPECIALIZATION
- next_instr->cache = (next_instr->cache << 1) | !nflag;
+ this_instr[1].cache = (this_instr[1].cache << 1) | !nflag;
#endif
- INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
- next_instr += 1;
+ INSTRUMENTED_JUMP(this_instr, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
DISPATCH();
}
TARGET(EXTENDED_ARG) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(EXTENDED_ARG);
assert(oparg);
opcode = next_instr->op.code;
oparg = oparg << 8 | next_instr->op.arg;
}
TARGET(CACHE) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(CACHE);
assert(0 && "Executing a cache.");
Py_UNREACHABLE();
}
TARGET(RESERVED) {
+ frame->instr_ptr = next_instr;
+ next_instr += 1;
+ INSTRUCTION_STATS(RESERVED);
assert(0 && "Executing RESERVED instruction.");
Py_UNREACHABLE();
}