-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ZJIT: Split Send into Lookup+Call #13400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I will absolutely be cleaning up the commits in this PR for rebasing |
Also, I need to figure out some stuff before landing like a codegen implementation of |
Is it intentional that the ZJIT CI is failing at the moment? |
Well it's not exactly intentional but I don't have codegen for CallMethod because I can't figure out a way to do it yet :( It's currently crashing/assert failing/... |
But if you have feedback on the rest of the (admittedly big, kind of disorganized) PR separate from that, I would be interested. The CallMethod codegen is hopefully separate/isolated enough |
❌ Tests Failed✖️no tests failed ✔️61990 tests passed(1 flake) |
This helps method lookups get resolved.
9974149
to
9e4b269
Compare
* Need to spill receiver and arguments to the VM stack as arguments * Don't use cpush; cpush always pushes two words * Save SP * Align stack
Should we just set up a frame and shell out to |
That sounds as tricky as what you're doing right now, since we still need to switch on the CME type in static code, set up parameters and all that. Basically vm_call0_cme(). |
Short of just breaking codegen for now, just debugging all the failures seems like the way to go. We can set up pairing sessions and whatnot. (BTW, CI isn't running now because of merge conflict) |
I wonder if you could have just split the HIR instruction in one PR and then worked on changing the generated code in another PR. You seem to have introduced |
I could split up the HIR in one PR, yes, but then I want to actually generate those HIR instructions. And if I generate the HIR, we have to compile it (in the current set of tests) :/ So in that sense they kind of have to be together |
Maybe I can have CallMethod behave as thought it were a full Send, including (re-)doing the lookup, for now, and therefore re-use existing codegen for Send |
Oh, I thought you're splitting both It seems important to optimize Generally, if you want to optimize a method call, you should generate an optimized method call instruction like
Yeah, I think we should do that. |
The motivation to split SendWithoutBlock is that there are two separate components that happen in a send: a lookup and a call. Since there are N different kinds of calls (though we only support positional and positional with block right now) but more or less only one kind of lookup, we should split those so they can be optimized separately. CallIseq replaces SendWithoutBlockDirect, CallCFunc is a more general (can side-effect/reenter) version of CCall, and then we can start attaching HIR fast-paths to those later in a separate PR. |
I think we should have a pairing session as Alan suggested 🙂 I have some more details I want to share/discuss with you, but it takes a lot of effort to do that in texts, and it has not been as effective as I wanted for this issue so far. |
Split
SendWithoutBlock{,Direct}
intoLookupMethod
andCallMethod
. From there,centralize the profile- and type-driven rewrites to one function:
optimize_lookup_method
. This determines if we know the call target at compiletime.
Then, we can rewrite
CallMethod
to do something with a known-constant target.If we know it at compile-time, we can specialize to
CallCFunc
orCallIseq
(or more, like a hypothetical
GetInstanceVariable
, in the future).Also,
Fixes Shopify#577
Co-authored-by: Aaron Patterson [email protected]