You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is also used very often in SFR, because of case...when patterns. It seems to be used most often with arrays and hashes, so I'm wondering if we could peek at the input and just guard on T_HASH and T_ARRAY 🤔
This will need extensive tests for corner cases, etc.
I meant knowing that we're receiving ::Array, ie. rb_cArray, but just now realized that at least for the Module#=== case we probably can find this from our receiver class being rb_cArray's singleton class.
If we want to implement the similar is_a? on the other hand we probably need to add an extra guard on the argument.
No problem @jhawthorn. I moved this PR to the shopify/ruby repo because I figured it's something we still cared about. Glad to hear you're planning to open a PR soon :)
We've just implemented fast paths for Kernel#is_a? and Object#instance_of?: ruby#7297 (comment)
I think we might be able to create a similar fast path for Module#=== that only generates code when we can know the result at code generation time. This would have the advantage that it would be a simple implementation and still get us a win when we do know the result while generating code.
Activity
jhawthorn commentedon Sep 28, 2021
I had a version of this in an old branch, but it definitely needs cleaning up (and I think the chaining behaviour probably isn't great when the argument is dynamic) https://github.com/jhawthorn/yjit/blob/e6d82f68a55f0c17dd79cb1009a5ad2cafaeaa5c/yjit_codegen.c#L2159-L2191
It would be really helpful if we had the ability to know when we had a constant value on the stack.
maximecb commentedon Sep 28, 2021
Do you mean constants like integers and true/false/nil or do you mean references to arrays and such?
jhawthorn commentedon Sep 28, 2021
I meant knowing that we're receiving
::Array, ie.rb_cArray, but just now realized that at least for theModule#===case we probably can find this from our receiver class beingrb_cArray's singleton class.If we want to implement the similar
is_a?on the other hand we probably need to add an extra guard on the argument.[-]Optimize `Module#===`[/-][+]YJIT: optimize `Module#===`[/+]jhawthorn commentedon Sep 19, 2022
Oh! I have work in progress for this and hope to submit a PR soon™
maximecb commentedon Sep 19, 2022
No problem @jhawthorn. I moved this PR to the shopify/ruby repo because I figured it's something we still cared about. Glad to hear you're planning to open a PR soon :)
maximecb commentedon Feb 13, 2023
We've just implemented fast paths for
Kernel#is_a?andObject#instance_of?: ruby#7297 (comment)I think we might be able to create a similar fast path for
Module#===that only generates code when we can know the result at code generation time. This would have the advantage that it would be a simple implementation and still get us a win when we do know the result while generating code.We could reuse code from John's PR for this: https://github.com/ruby/ruby/pull/6674/files
maximecb commentedon Feb 21, 2023
Completed in ruby#7351