diff --git a/iseq.c b/iseq.c index 7fbb906525..b3c7ad53d3 100644 --- a/iseq.c +++ b/iseq.c @@ -427,11 +427,14 @@ rb_iseq_memsize(const rb_iseq_t *iseq) return size; } +static unsigned long fresh_iseq_unique_id = 0; /* -- Remove In 3.0 -- */ + static rb_iseq_t * iseq_alloc(void) { rb_iseq_t *iseq = iseq_imemo_alloc(); iseq->body = ZALLOC(struct rb_iseq_constant_body); + iseq->body->iseq_unique_id = fresh_iseq_unique_id++; /* -- Remove In 3.0 -- */ return iseq; } diff --git a/vm_args.c b/vm_args.c index 97b1d4ac60..41824527de 100644 --- a/vm_args.c +++ b/vm_args.c @@ -593,8 +593,12 @@ VALUE rb_iseq_location(const rb_iseq_t *iseq); */ static st_table *caller_to_callees = 0; -static VALUE rb_warn_check(const rb_execution_context_t * const ec, const void *const callee) +static VALUE rb_warn_check(const rb_execution_context_t * const ec, const rb_iseq_t *const iseq) { + if (!iseq) return 0; + + const void *const callee = (void *)iseq->body->iseq_unique_id; + const rb_control_frame_t * const cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); if (!cfp) return 0; diff --git a/vm_core.h b/vm_core.h index f7ec156cc5..4b1b9e43d0 100644 --- a/vm_core.h +++ b/vm_core.h @@ -447,6 +447,8 @@ struct rb_iseq_constant_body { long unsigned total_calls; /* number of total calls with `mjit_exec()` */ struct rb_mjit_unit *jit_unit; #endif + + unsigned long iseq_unique_id; /* -- Remove In 3.0 -- */ }; /* T_IMEMO/iseq */