-
Notifications
You must be signed in to change notification settings - Fork 89
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
proposal: improve CALL support #144
Comments
FWIW here's the full text of the go asm implementation I have so far:
Which, of course, is completely broken. I'm still learning the details of when PCDATA needs to be called and how to handle the closure's stack frame. |
Thanks for this detailed issue, and sorry for my slow reply. I do think this would be a nice feature for Just a quick note on the technical details, the argument passing part would be fairly easy since that part is already implemented in the |
I totally understand this being low priority. Thanks for keeping it open as a proposal! Unfortunately I have no idea about the stability of PCDATA/FUNCDATA. I know that the Go team has previously looked at using Avo for the generation of some of their own library code (crypto package I think?). I don't know where they landed on that, but perhaps there's some room for cooperation here - no one wants to manually insert those pseudo calls, and closures aren't the only place where it'd be useful to do so. There's a somewhat infamous blog post where Filippo Valsorda explored fast FFI that bypasses cgo by using go assembly, but his approach shares this same problem as what I've run into: the resulting code isn't sound because it doesn't work with the runtime. Avo could potentially unlock what he was digging at in a sound manner. I think there's a lot of potential utility in code-generated CALL functionality. |
It seems like avo could do a lot more to support the CALL instruction, including helpers and documentation. I'll give a simplified example of a function I had hoped avo would help me write.
The goal I'll present is to do a pure asm implementation of
runtime.Callers()
, but instead with a callback signalling to continue unwinding the stack.In my terrible psuedo-assembly, that would look something like this:
Writing this code in go asm is perilous for several reasons:
It seems like this would be a perfect use case for avo: those are all considerations that can be handled via code generation.
What I found while attempting to implement this routine was that avo seems to lack any special magic around
CALL
. Some of the things I had hoped avo could help with:FUNCDATA
andPCDATA
instructions to play nicely with the runtime.Today, writing go asm functions which call into go is widely avoided. To quote Ian Lance Taylor:
He explains how PCDATA calls are required, and then goes on to say:
I think avo is in a unique position to open up this class of assembly routines.
The text was updated successfully, but these errors were encountered: