-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
Rewrite runtime, switch to tracing GC and bootstrap #1559
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like your implementation on the tri-color trace sweep algorithm.
Turns out that adding a shadow stack has one unfortunate consequence: It affects the |
Another: Putting incomplete objects onto the stack can break things if incremental GC just so happens to run in between allocating the object and properly initializing it. Looks like allocations need to zero memory to fix this, something we didn't do before to reduce overhead from zeroing memory we are going to initialize anyway. |
Meanwhile, the shadow stack thingy is getting together. Will prepare something for tomorrow, but for the time being, here's the bootstrap with incremental GC
|
To not inflict too much hope here: Adjusting the GC parameters can still lead to what seems to be memory corruption or bugs in the incremental mechanism at some places, and I have concerns with a few side products like that users again have to retain/release everything externally because GC may kick in at any time in an incremental GC. Feels a bit like we'll get the cons of both reference counting and tracing as soon as this gets incremental. Will have more details to report at today's meeting. |
Last commit makes it so that the GC can be invoked either to perform a full collection with |
Could you sync this PR with master? |
So, here's something cool: |
At this point it passes all the tests, generating the exact same code the compiler compiled to JS produces, except that if one runs multiple tests in sequence there's still something surprising going on. I'm surprised. |
One error is that in - f32.const -7.888609052210118e-31
f32.const -0
+ f32.const -0 f64.const -8.900295434028806e-308
- f64.const -8.900295434028806e-308
+ f64.const -0 f64.const 2.225073858507201e-308
- f64.const 2.225073858507201e-308
f64.const 0
+ f64.const 0 in certain test run situations. Wondering if that has something to do with float parsing, and not quite sure where these constants are in the |
This comment has been minimized.
This comment has been minimized.
Btw, using an optimized assemblyscript.wasm, I am seeing faster compile times compared to JS as expected.
Times for Wasm include a final full GC that's technically unnecessary when terminating right away, growing of memory that can be avoided by setting a reasonable initial memory size and overhead from interoping all the source texts into Wasm memory. |
FYI, Julia, the only language I know that allows triggering garbage collection manually, uses GC is a module (namespace) and gc is the function name. |
const _exports = {
rt: function () {
console.log("rt call");
}
}
_exports.rt.collect = function () {
console.log("__rt_collect call");
} usage: _exports.rt();
_exports.rt.collect(); |
Last commit revives the shadow stack pass and makes the
That's quite a price to pay for fully automatic GC, which was generally expected and has been extensively discussed in meetings, yet the significant code size hit is a bit surprising. From what I can tell so far:
Not much to do about that, but it's automatic. May be fine as long as it is not the default and users have options to do manual collect instead. Thoughts? |
Here's an unfortunate side effect. If one does for example assemblyscript.setGlobalAlias(compilerOptions,
__newString(alias),
__newString(name)
); one could expect that this just works with let aliasPtr = __pin(__newString(alias));
assemblyscript.setGlobalAlias(compilerOptions,
aliasPtr ,
__newString(name)
);
__unpin(aliasPtr); preventing premature collection through pinning, which is unfortunate. Currently evaluating how this situation can be avoided, as not having to pin arguments would be so much nicer. |
Last commit switches the default runtime to |
Removes the error-prone automatic reference counting implementation that has been haunting us for a long time and replaces it with a mark & sweep garbage collector. By doing so this PR also sets us up for initial experiments with Wasm GC due to introducing a very similar interface already.
__retain
/__release
mechanism has been removed and replaced with a new__pin
/__unpin
mechanism.incremental
(default),minimal
andstub
--exportRuntime
flag to achieve the effects of--runtime stub/full
with any runtime (i.e. exporting__new
,__pin
,__unpin
and__collect
).