1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Takashi Kokubun 2020-04-18 01:38:52 -07:00
parent 0f7d3e4e40
commit 04e56958e6
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
2 changed files with 11 additions and 1 deletions

View file

@ -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;

View file

@ -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]