operand = 0;
if (frame->owner < FRAME_OWNED_BY_INTERPRETER) {
- if (new_func != NULL) {
+ // Don't add nested code objects to the dependency.
+ // It causes endless re-traces.
+ if (new_func != NULL && !(new_code->co_flags & CO_NESTED)) {
operand = (uintptr_t)new_func;
DPRINTF(2, "Adding %p func to op\n", (void *)operand);
_Py_BloomFilter_Add(dependencies, new_func);
}
op(_PY_FRAME_KW, (callable, self_or_null, args[oparg], kwnames -- new_frame)) {
- new_frame = PyJitRef_NULL;
- ctx->done = true;
+ assert((this_instr + 2)->opcode == _PUSH_FRAME);
+ PyCodeObject *co = get_code_with_logging((this_instr + 2));
+ if (co == NULL) {
+ ctx->done = true;
+ break;
+ }
+
+ new_frame = PyJitRef_Wrap((JitOptSymbol *)frame_new(ctx, co, 0, NULL, 0));
}
op(_CHECK_AND_ALLOCATE_OBJECT, (type_version/2, callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
ctx->curr_frame_depth++;
stack_pointer = ctx->frame->stack_pointer;
uint64_t operand = this_instr->operand0;
- if (operand == 0 || (operand & 1)) {
- // It's either a code object or NULL
+ if (operand == 0) {
ctx->done = true;
break;
}
- PyFunctionObject *func = (PyFunctionObject *)operand;
- PyCodeObject *co = (PyCodeObject *)func->func_code;
- _Py_BloomFilter_Add(dependencies, co);
- assert(PyFunction_Check(func));
- ctx->frame->func = func;
+ if (!(operand & 1)) {
+ PyFunctionObject *func = (PyFunctionObject *)operand;
+ PyCodeObject *co = (PyCodeObject *)func->func_code;
+ _Py_BloomFilter_Add(dependencies, co);
+ ctx->frame->func = func;
+ }
}
op(_UNPACK_SEQUENCE, (seq -- values[oparg], top[0])) {
ctx->curr_frame_depth++;
stack_pointer = ctx->frame->stack_pointer;
uint64_t operand = this_instr->operand0;
- if (operand == 0 || (operand & 1)) {
+ if (operand == 0) {
ctx->done = true;
break;
}
- PyFunctionObject *func = (PyFunctionObject *)operand;
- PyCodeObject *co = (PyCodeObject *)func->func_code;
- _Py_BloomFilter_Add(dependencies, co);
- assert(PyFunction_Check(func));
- ctx->frame->func = func;
+ if (!(operand & 1)) {
+ PyFunctionObject *func = (PyFunctionObject *)operand;
+ PyCodeObject *co = (PyCodeObject *)func->func_code;
+ _Py_BloomFilter_Add(dependencies, co);
+ ctx->frame->func = func;
+ }
break;
}
case _PY_FRAME_KW: {
JitOptRef new_frame;
- new_frame = PyJitRef_NULL;
- ctx->done = true;
+ assert((this_instr + 2)->opcode == _PUSH_FRAME);
+ PyCodeObject *co = get_code_with_logging((this_instr + 2));
+ if (co == NULL) {
+ ctx->done = true;
+ break;
+ }
+ new_frame = PyJitRef_Wrap((JitOptSymbol *)frame_new(ctx, co, 0, NULL, 0));
stack_pointer[-3 - oparg] = new_frame;
stack_pointer += -2 - oparg;
assert(WITHIN_STACK_BOUNDS());