Stream: general

Topic: About C API finalizers in RFC 11


view this post on Zulip Cheng Shao (May 13 2021 at 14:14):

After https://github.com/bytecodealliance/wasmtime/pull/2897 is merged, in the C API, the only finalizers that need to be called are finalizers for engine/store, right? I checked the examples and there are still calls to other finalizers present (e.g. linker) though

This PR is an implementation of RFC 11 which is a redesign of Wasmtime's APIs. Note: The RFC is not merged at this time, so this PR is purely meant for informational purposes and review. This ...

view this post on Zulip Till Schneidereit (May 13 2021 at 14:23):

CC @Alex Crichton

view this post on Zulip Alex Crichton (May 13 2021 at 14:24):

@Cheng Shao mostly, yeah. Finalizers for func/table/instance/memory/global are all being removed since they no longer need to be finalized

view this post on Zulip Alex Crichton (May 13 2021 at 14:24):

modules/config/linker all still need finalization though

view this post on Zulip Cheng Shao (May 13 2021 at 14:27):

@Alex Crichton Thanks for answering! Also, is there still constraint that the finalizers must be run on the same system thread where they are created?

view this post on Zulip Alex Crichton (May 13 2021 at 14:27):

that constraint has been lifted! (one of the major goals of the RFC) -- all finalizers can be run concurrently on any thread

view this post on Zulip Alex Crichton (May 13 2021 at 14:28):

the main reason for that is that finalizers never finalize aliasing data, everything is entirely separately owned (e.g. a linker is entirely disconnected from a store)

view this post on Zulip Alex Crichton (May 13 2021 at 14:28):

(my intention is to cover all this in the documentation, which is yet-to-be-written at this point still)

view this post on Zulip Cheng Shao (May 13 2021 at 14:29):

Excellent news to hear! Thanks for all the hard work. Not before looking at the PR did I realize that there used to be such a constraint

view this post on Zulip Alex Crichton (May 13 2021 at 14:31):

It's not technically so restrictive that it has to be run from the original thread, only that store-related objects (e.g. stores, funcs, globals, memories, etc) must all be dropped on the same thread. They can all migrate somewhere else but it has to be all at once. This is such a fine point though that it's basically technically infeasible

view this post on Zulip Cheng Shao (May 13 2021 at 14:35):

So wasmtime doesn't actually use thread local storage, and as long as there are no concurrent usages from different threads, it doesn't matter where the methods are called?

view this post on Zulip Alex Crichton (May 13 2021 at 14:37):

more-or-less

view this post on Zulip Alex Crichton (May 13 2021 at 14:37):

nonatomic reference counting is used for Store objects today, which is basically the constraint

view this post on Zulip Alex Crichton (May 13 2021 at 14:38):

(but with the new API there's no reference counting at all, everything is separately owned, including the Store)


Last updated: Nov 22 2024 at 17:03 UTC