-
-
Notifications
You must be signed in to change notification settings - Fork 670
GC experimentation #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
Comments
One question I have about this, for @dcodeIO: perhaps you can give an overview of what the GC plans are here? (Sorry if this is on the wiki, I couldn't see it.) Specifically, how do you intend to use GC - is it for external JS things, or also for AssemblyScript objects themselves, or something else? And will it be an optional flag that any AssemblyScript code can use, or will source code be written somewhat differently for it? |
Plan so far was to implement a makeshift GC as a placeholder while the GC spec is still in the works, but given that there is something we can test with on the horizon, I am considering skipping a custom GC and instead focusing on integrating with WASM GC right away, eventually making it the primary implementation in AssemblyScript (for internal and external objects).
There is already a mechanism for retaining the non-GC behavior with Maybe a little shopping list for what would be necessary on the Binaryen side to be utilized by the AssemblyScript compiler: Classes
Arrays
With the above in place it should be possible to implement managed classes and arrays by throwing away unnecessary parts of the standard library (currently has code to do indexed access through operator overloads for example) and re-implement on top of GC in the compiler, i.e. indexed array access, property accesses on class instances and changing linear allocation to I hope I didn't miss something obvious here, but if I did or failed to clarify some parts, feel free to mention it :) P.S: Only prequesite to get started here on my side is to finish this PR. Nothing specific on the roadmap after that. |
Thanks @dcodeIO ! From talking with @lukewagner (Luke, correct me if I got something wrong), the first step here for VMs is to implement the "reference types proposal", which define some new types and new instructions. This may already be ready for experimentation? However, it is not enough for the AssemblyScript stuff described above like creating a new object and getting and setting fields, instead, if I understand the spec it just adds
In other words this is a small step towards full GC support, but only provides table and related operations. Would reference types be interesting to experiment with in AssemblyScript? Should be quick to add to Binaryen if so. Or would we need to wait for full GC support? |
I see, thanks. From my point of view, reference types seem like something that might be good to implement as a new basic type, Regarding the table instructions I don't yet see an immediate use case in the language, but there's always the option to add temporary builtins emitting the operations we'd like to test, here |
Yeah, I don't really see the table instruction use case either. Overall, it doesn't seem like that much is possible with just the reference-types proposal, and we need to wait for full GC. @lukewagner, am I missing something? |
Hmm, @dcodeIO you want use wasm GC for external and internal purposes? Is it mean all internal refs should be stored in table? Sorry, if I misunderstood something, I'm not deeply familiar with GC spec =) |
The use case for tables-of-refs is when you want to logically store a reference in linear memory. Then you stick it into a table and store its For AssemblyScript, since the goal (I assume?) is for all objects to be allocated in the GC heap (not linear memory), there wouldn't be any need for this rooting so I agree there wouldn't be any need. So yeah, I'd start with an
This impl strategy will actually be somewhat slow (compared to native JS property access), but we can optimize it in various ways over time (both in engines, and possibly in the standard via a special get-prop Host Binding). |
@MaxGraey I think that spec'ed-features should become the default (best interoperability between different languages, smallest binaries), but we can of course just rename the current native implementation of arrays to @lukewagner Thanks for the clarification, makes sense. So tables will actually be important to make structures that live in linear memory interoperable with references that don't. Here, for example, a (*) Now I wonder if |
FYI: There is now support for sign-extension-ops and mutable-global behind feature flags. With this mechanism present, the same can be done for reference-types without the need to keep it in its own branch :) |
What is current status of this? Are there any VMs already implementing GC spec? Is there any roadmap on when spec will be finalized? |
Maybe a quick update on this for everyone stumbling upon this issue: From what I can tell, there is no sign of WASM GC on the horizon yet. However, recent commits to master implement a custom MM/GC combination based on reference counting for the time being, as described here. |
Just leave this paper which describe how we could further improve Reference Counting |
Paper investigated Immix approach for RC: |
Another paper about RC Immix |
With the GC subgroup having regular meetings meanwhile and initial prototype implementations being pursued in WABT and V8, I've created a follow-up for the necessary Binaryen support here: WebAssembly/binaryen#2935 It's likely that it's still a bit too early, so don't hold your breath. |
If anyone from the AssemblyScript community would be interested in working to implement experimental GC support in Binaryen, I would be happy to help out with guidance and code reviews. |
I guess we could close this. Or keep open until Wasm GC? |
Yes, this work is well under way in Binaryen and supported in V8. I think this general issue can probably be closed. |
The wasm GC spec is making progress, initial experimental implementations are starting to be worked on in VMs, and there is experimentation in AssemblyScript too. It would be great to be able to connect all these things! That is, to know what the earliest testable GC things in VMs are going to be, so that we can emit them from AssemblyScript and then see that code running in a VM. Then we'd be testing the whole
toolchain->VM
pipeline.A possible vague plan:
(Personally I'd love to help out with this, on the Binaryen parts.)
The text was updated successfully, but these errors were encountered: