From 04e56958e6a3c3278d0d3a087954ee8aca2fbd10 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun 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. --- test/ruby/test_jit.rb | 10 ++++++++++ tool/ruby_vm/views/_mjit_compile_insn_body.erb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index ebf4a222e2..9e4367b6d1 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -719,6 +719,16 @@ class TestJIT < Test::Unit::TestCase 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 a2a750fbdc..bc77b02b71 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 @@ % # #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\((?[^)]+)\)/ % # #define TOPN(n) (*(GET_SP()-(n)-1)) % num = Regexp.last_match[:num] -- cgit v1.2.3