-
-
Notifications
You must be signed in to change notification settings - Fork 941
Description
Math and bitwise operations can be optimized to avoid a full dynamic dispatch when both sides are core numeric types and the operator has not been redefined.
There's a series of these optimizations in CRuby that have been expanded over time, starting here: https://github.com/ruby/ruby/blob/63b082cf0e87942dcea28cbdeb1c8a9e616e903a/vm_insnhelper.c#L6710
We currently do a similar optimization when the RHS is a literal numeric type, via the MathLinker class for invokedynamic and the operator CallSite subclasses for non-indy, but we should explore the value of doing so when the RHS is not a literal value.
Given that we already can inline through such calls using indy, there may be little to gain from adding additional override checks and static calls, but the extent of these optimizations in CRuby makes me want to give it a try.