Stream: git-wasmtime

Topic: wasmtime / Issue #1815 Insert safepoints at loop headers


view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2020 at 23:02):

fitzgen opened Issue #1815:

Right now, we only insert them at (resumable) interrupt traps and calls:

https://github.com/bytecodealliance/wasmtime/blob/master/cranelift/codegen/src/regalloc/safepoint.rs#L54-L61

But long running wasm could be in a loop, and if this loop doesn't make any calls or have interrupt traps, there will be no safepoints inserted, which in turn means that GC cannot happen inside this long-running wasm loop.

We should fix this by inserting safepoints at loop headers.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2020 at 23:02):

fitzgen labeled Issue #1815:

Right now, we only insert them at (resumable) interrupt traps and calls:

https://github.com/bytecodealliance/wasmtime/blob/master/cranelift/codegen/src/regalloc/safepoint.rs#L54-L61

But long running wasm could be in a loop, and if this loop doesn't make any calls or have interrupt traps, there will be no safepoints inserted, which in turn means that GC cannot happen inside this long-running wasm loop.

We should fix this by inserting safepoints at loop headers.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2020 at 23:10):

fitzgen commented on Issue #1815:

Actually, now that I think about it, the loop header has to have some sort of check for whether the collector requested that the Wasm stop and synchronize for root marking or whatever. This synchronization will most likely will involve some kind of call, e.g

block0:
    gc_requested = i32.load <known offset from vmctx for the gc flag>
    brnz gc_requested, block2
    fallthrough block1

block1:
    ...

block2:
    call synchronize_with_gc
    jump block1

And in the case that a gc is requested, we call some synchronize_with_gc function, and this call will get a safepoint inserted. So maybe everything is ok here?

If we want to do the virtual memory tricks described in https://github.com/bytecodealliance/wasmtime/issues/1749 for gc synchronization, then we will need some extra work here though.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2020 at 23:11):

fitzgen closed Issue #1815:

Right now, we only insert them at (resumable) interrupt traps and calls:

https://github.com/bytecodealliance/wasmtime/blob/master/cranelift/codegen/src/regalloc/safepoint.rs#L54-L61

But long running wasm could be in a loop, and if this loop doesn't make any calls or have interrupt traps, there will be no safepoints inserted, which in turn means that GC cannot happen inside this long-running wasm loop.

We should fix this by inserting safepoints at loop headers.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 03 2020 at 23:16):

github-actions[bot] commented on Issue #1815:

Subscribe to Label Action

cc @bnjbvr

<details>
This issue or pull request has been labeled: "cranelift"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>


Last updated: Dec 23 2024 at 12:05 UTC