Files
ruby/basic_object.rb
T
Max Bernstein f4c7ad48ce ZJIT: Inline ISEQs marked :always_inline
Add a new `Primitive.attr :always_inline`. Force inline ISEQs with this
attribute. This is helpful for e.g. `BasicObject#!=`, which is otherwise
megamorphic, and very small.

Other JITs also have a "always inline small methods" policy but I didn't
want to wade into that yet.
2026-10-21 20:48:24 -04:00

19 lines
652 B
Ruby

# ZJIT uses a Ruby definition of BasicObject#!= so it can inline the call to #==.
# Register it only for ZJIT, leaving the C definition in place otherwise.
class BasicObject
with_zjit do
if Primitive.rb_builtin_basic_definition_p(:!=)
undef :!=
def !=(other) # :nodoc:
# Keep the replacement classified as a basic method like the C definition,
# and have ZJIT inline it even when its size heuristics would say no.
Primitive.attr! :c_trace, :always_inline
# Negate truthiness without calling a possibly redefined #!.
Primitive.rb_builtin_bool_negate(self == other)
end
end
end
end