From 0a82bfe5e18ac86da72c27389db6eb8da156a0b5 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 2 Feb 2023 09:13:19 +0900 Subject: use correct svar (#7225) * use correct svar Without this patch, svar location is used "nearest Ruby frame". It is almost correct but it doesn't correct when the `each` method is written in Ruby. ```ruby class C include Enumerable def each %w(bar baz).each{|e| yield e} end end C.new.grep(/(b.)/){|e| p [$1, e]} ``` This patch fix this issue by traversing ifunc's cfp. Note that if cfp doesn't specify this Thread's cfp stack, reserved svar location (`ec->root_svar`) is used. * make yjit-bindgen --------- Co-authored-by: Takashi Kokubun --- proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index c31017128e..b4f602a4cb 100644 --- a/proc.c +++ b/proc.c @@ -752,7 +752,7 @@ rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int m } arity.argc.min = min_argc; arity.argc.max = max_argc; - VALUE ret = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)data, arity.packed, 0); + VALUE ret = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)data, arity.packed, (VALUE)GET_EC()->cfp); return (struct vm_ifunc *)ret; } -- cgit v1.2.1