YJIT: Fallback setivar if the receiver isn't T_OBJECT (#8160)
Followup: https://github.com/ruby/ruby/pull/8152 If the receiver is a T_MODULE or T_CLASS and has a lot of ivars, `get_next_shape_internal` will return `NULL`. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
This commit is contained in:
parent
3c41a04b6c
commit
e20f1e443f
Notes:
git
2023-08-02 15:33:32 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
@ -1238,6 +1238,29 @@ class TestYJIT < Test::Unit::TestCase
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_setivar_on_class
|
||||||
|
# Bug in https://github.com/ruby/ruby/pull/8152
|
||||||
|
assert_compiles(<<~RUBY, result: :ok)
|
||||||
|
class Base
|
||||||
|
def self.or_equal
|
||||||
|
@or_equal ||= Object.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.or_equal # ensure compiled
|
||||||
|
|
||||||
|
class Child < Base
|
||||||
|
end
|
||||||
|
|
||||||
|
200.times do |iv| # Need to be more than MAX_IVAR
|
||||||
|
Child.instance_variable_set("@_iv_\#{iv}", Object.new)
|
||||||
|
end
|
||||||
|
|
||||||
|
Child.or_equal
|
||||||
|
:ok
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
def test_nested_send
|
def test_nested_send
|
||||||
#[Bug #19464]
|
#[Bug #19464]
|
||||||
assert_compiles(<<~RUBY, result: [:ok, :ok])
|
assert_compiles(<<~RUBY, result: [:ok, :ok])
|
||||||
|
@ -2204,7 +2204,7 @@ fn gen_setinstancevariable(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get the next shape information if it needs transition
|
// Get the next shape information if it needs transition
|
||||||
let new_shape = if !shape_too_complex && ivar_index.is_none() {
|
let new_shape = if !shape_too_complex && receiver_t_object && ivar_index.is_none() {
|
||||||
let shape = comptime_receiver.shape_of();
|
let shape = comptime_receiver.shape_of();
|
||||||
|
|
||||||
let current_capacity = unsafe { (*shape).capacity };
|
let current_capacity = unsafe { (*shape).capacity };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user