[前][次][番号順一覧][スレッド一覧]

ruby-changes:69143

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:59 +0900 (JST)
Subject: [ruby-changes:69143] 2ff26b9ec2 (master): Fix opt_aset comptime_key check

https://git.ruby-lang.org/ruby.git/commit/?id=2ff26b9ec2

From 2ff26b9ec28c9a4e0ae7a4a009da99fd200cc5e0 Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Fri, 17 Sep 2021 08:38:14 -0700
Subject: Fix opt_aset comptime_key check

---
 bootstraptest/test_yjit.rb | 10 ++++++++++
 yjit_codegen.c             |  3 +--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 1ff6b13f5c..8cb4432b6a 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1996,3 +1996,13 @@ assert_equal 'true', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_yjit.rb#L1996
   eq(1, 2)
   eq(1, 2)
 }
+
+# aset on array with invalid key
+assert_normal_exit %q{
+  def foo(arr)
+    arr[:foo] = 123
+  end
+
+  foo([1]) rescue nil
+  foo([1]) rescue nil
+}
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 0aabbec403..5c5fba3627 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -2187,14 +2187,13 @@ gen_opt_aset(jitstate_t *jit, ctx_t *ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2187
 
     VALUE comptime_recv = jit_peek_at_stack(jit, ctx, 2);
     VALUE comptime_key  = jit_peek_at_stack(jit, ctx, 1);
-    VALUE comptime_val  = jit_peek_at_stack(jit, ctx, 0);
 
     // Get the operands from the stack
     x86opnd_t recv = ctx_stack_opnd(ctx, 2);
     x86opnd_t key = ctx_stack_opnd(ctx, 1);
     x86opnd_t val = ctx_stack_opnd(ctx, 0);
 
-    if (CLASS_OF(comptime_recv) == rb_cArray && FIXNUM_P(comptime_val)) {
+    if (CLASS_OF(comptime_recv) == rb_cArray && FIXNUM_P(comptime_key)) {
         uint8_t* side_exit = yjit_side_exit(jit, ctx);
 
         // Guard receiver is an Array
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]