Improve YJIT performance warning regression test

[Bug #20522]
This commit is contained in:
Jean Boussier 2024-06-04 19:39:17 +02:00
parent f567633a16
commit f8abd24b1f
3 changed files with 16 additions and 7 deletions

View File

@ -5015,12 +5015,13 @@ assert_normal_exit %q{
}
# compiling code shouldn't emit warnings as it may call into more Ruby code
assert_normal_exit %q{
assert_equal 'ok', <<~'RUBY'
# [Bug #20522]
$VERBOSE = true
Warning[:performance] = true
module StrictWarnings
def warn(msg, category: nil, **)
def warn(msg, **)
raise msg
end
end
@ -5032,9 +5033,14 @@ assert_normal_exit %q{
end
end
shape_max_variations = 8
if defined?(RubyVM::Shape::SHAPE_MAX_VARIATIONS) && RubyVM::Shape::SHAPE_MAX_VARIATIONS != shape_max_variations
raise "Expected SHAPE_MAX_VARIATIONS to be #{shape_max_variations}, got: #{RubyVM::Shape::SHAPE_MAX_VARIATIONS}"
end
100.times do |i|
klass = Class.new(A)
7.times do |j|
(shape_max_variations - 1).times do |j|
obj = klass.new
obj.instance_variable_set("@base_#{i}", 42)
obj.instance_variable_set("@ivar_#{j}", 42)
@ -5044,6 +5050,9 @@ assert_normal_exit %q{
begin
obj.compiled_method(true)
rescue
# expected
end
end
}
:ok
RUBY

View File

@ -504,7 +504,7 @@ module RubyVM::RJIT
shape = C.rb_shape_get_shape_by_id(shape_id)
current_capacity = shape.capacity
dest_shape = C.rb_shape_get_next(shape, comptime_receiver, ivar_name)
dest_shape = C.rb_shape_get_next_no_warnings(shape, comptime_receiver, ivar_name)
new_shape_id = C.rb_shape_id(dest_shape)
if new_shape_id == C::OBJ_TOO_COMPLEX_SHAPE_ID

View File

@ -171,9 +171,9 @@ module RubyVM::RJIT # :nodoc: all
me_addr == 0 ? nil : rb_method_entry_t.new(me_addr)
end
def rb_shape_get_next(shape, obj, id)
def rb_shape_get_next_no_warnings(shape, obj, id)
_shape = shape.to_i
shape_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_shape_get_next((rb_shape_t *)NUM2SIZET(_shape), obj, (ID)NUM2SIZET(id)))'
shape_addr = Primitive.cexpr! 'SIZET2NUM((size_t)rb_shape_get_next_no_warnings((rb_shape_t *)NUM2SIZET(_shape), obj, (ID)NUM2SIZET(id)))'
rb_shape_t.new(shape_addr)
end