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

ruby-changes:60818

From: Takashi <ko1@a...>
Date: Sat, 18 Apr 2020 17:42:16 +0900 (JST)
Subject: [ruby-changes:60818] 04e56958e6 (master): Make sure newarraykwsplat accesses a correct index

https://git.ruby-lang.org/ruby.git/commit/?id=04e56958e6

From 04e56958e6a3c3278d0d3a087954ee8aca2fbd10 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sat, 18 Apr 2020 01:38:52 -0700
Subject: Make sure newarraykwsplat accesses a correct index

on stack when local_stack_p is enabled.

This fixes `RB_FL_TEST_RAW:"RB_FL_ABLE(obj)"` assertion failure
on power_assert's test with JIT enabled.

diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index ebf4a22..9e4367b 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -719,6 +719,16 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L719
     end
   end
 
+  def test_newarraykwsplat_on_stack
+    assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "[nil, [{:type=>:development}]]\n", success_count: 1, insns: %i[newarraykwsplat])
+    begin;
+      def arr
+        [nil, [:type => :development]]
+      end
+      p arr
+    end;
+  end
+
   def test_local_stack_on_exception
     assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2)
     begin;
diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
index a2a750f..bc77b02 100644
--- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb
+++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
@@ -101,7 +101,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn_body.erb#L101
 %         # #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
 %         num = Regexp.last_match[:num]
         fprintf(f, <%= to_cstr.call(line.sub(/\bSTACK_ADDR_FROM_TOP\(([^)]+)\)/, '%s')) %>,
-                (status->local_stack_p ? "stack + (stack_size - (<%= num %>))" : "STACK_ADDR_FROM_TOP(<%= num %>)"));
+                (status->local_stack_p ? "(stack + (stack_size - (<%= num %>)))" : "STACK_ADDR_FROM_TOP(<%= num %>)"));
 %       when /\bTOPN\((?<num>[^)]+)\)/
 %         # #define TOPN(n) (*(GET_SP()-(n)-1))
 %         num = Regexp.last_match[:num]
-- 
cgit v0.10.2


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

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