diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-04-18 01:38:52 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2020-04-18 01:41:50 -0700 |
commit | 04e56958e6a3c3278d0d3a087954ee8aca2fbd10 (patch) | |
tree | a6bab2ce97050e8cacffa551d39fcb3778f7ea37 | |
parent | 0f7d3e4e405d17a1ea7db4862a1e6d65e1dfc86e (diff) |
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.
-rw-r--r-- | test/ruby/test_jit.rb | 10 | ||||
-rw-r--r-- | tool/ruby_vm/views/_mjit_compile_insn_body.erb | 2 |
2 files changed, 11 insertions, 1 deletions
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\((?<num>[^)]+)\)/ % # #define TOPN(n) (*(GET_SP()-(n)-1)) % num = Regexp.last_match[:num] |