cfallin opened PR #14690 from cfallin:no-global-code-registry to bytecodealliance:main:
In some high-performance embeddings of Wasmtime, the embedder may try to avoid all inter-thread synchronization for deterministic-latency reasons, and may use an
Engineper thread. Such embedders may also avoid using signal handlers altogether.In a no-signals-based-traps, no-std build, Wasmtime shouldn't need the global code registry. This registry exists only to allow signal handlers for signals raised by the effects of trapping Wasm actions to find the appropriate module and trap code and take the appropriate action. When running without signals-based traps, the trap is instead implemented as a libcall, with the full
Storeaccessible via an ordinary parameter passed to that libcall.Hence, we should be able to remove usage of the registry.
This PR does so. There are some slight complications related to Pulley: Pulley always uses "signal"-based traps, where the signal is instead a software implementation of trapping behavior directly in the interpreter loop. For Pulley's case, this PR also adds a raw
Storepointer to theCallThreadState. If that's not palatable, then I'm happy to figure out either how to exclude Pulley altogether from this "registry exemption", or refactor ownership/pointer linkages some other way.This PR also carries some changes to the
min-platformexample, using it as an integration-test for this functionality. We now do an additional kind of smoke-test with separate pthreads (spawned from the host side) that invoke a "load and instantiate this module a bunch of times" entry point in the no-std Wasmtime library payload, with this build using the no-contention-only locking stubs, ensuring that we would have discovered locking contention if any locking/shared registry access actually occurred.The
min-platformexample also needed some updating. Apparently it was silently failing module loads because, without virtual memory support, it could not make pages executable; it now does so with a custom code publisher. There was also a typo in an env var set from CI.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested wasmtime-core-reviewers for a review on PR #14690.
cfallin requested fitzgen for a review on PR #14690.
cfallin requested wasmtime-default-reviewers for a review on PR #14690.
cfallin requested dicej for a review on PR #14690.
:memo: alexcrichton submitted PR review:
Sounds reasonable to me! One minor coment in
registry.rs-- perhaps a#[cfg(...)] mod global;to avoid too much#[cfg]within the file itself?For a broader comment about Pulley, I'd ideally like to keep the Pulley-related bits in interpreter-style modules as opposed to handling it too differently throughout the runtime. Reading over things again though I think it might be possible to avoid the use of
test_if_trapentirely here on Pulley. TheInterpreterRef::trapmethod is only called fromInterpreterRef::calland that's already got acallerargument which should be a validVMContextthrough which the store can be loaded (e.g.Instance::enter_host_from_wasm) and from there I think what you've got in this PR would suffice (look at the store'smodules().store_code_by_pc(..)and such). That'd have a nice benefit where Pulley's behavior would be independent of#[cfg]and Pulley wouldn't actually need the global handler at all either.
github-actions[bot] added the label wasmtime:api on PR #14690.
cfallin updated PR #14690.
cfallin updated PR #14690.
cfallin commented on PR #14690:
Ah, good ideas, thanks -- both implemented (coarse cfg-gating and making Pulley go through explicit VMContext/Store accesses)!
:thumbs_up: alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #14690.
alexcrichton added PR #14690 runtime: eliminate the shared global code registry altogether in no-signals-based-traps builds. to the merge queue
:check: alexcrichton merged PR #14690.
alexcrichton removed PR #14690 runtime: eliminate the shared global code registry altogether in no-signals-based-traps builds. from the merge queue
Last updated: Oct 31 2026 at 23:03 UTC