Skip to content

[JSInterop] Be aware of configureAll#8046

Merged
kripken merged 17 commits into
WebAssembly:mainfrom
kripken:configureAll
Nov 14, 2025
Merged

[JSInterop] Be aware of configureAll#8046
kripken merged 17 commits into
WebAssembly:mainfrom
kripken:configureAll

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Nov 13, 2025

This magic import refers to functions, which we must handle, and not
modify their signature or contents.

This fixes things optimally for RUME, but for all the passes that look
at public/private heap types, it just marks those functions as public,
which inhibits optimizations. This unblocks work on JS Interop for now
(and maybe those optimizations are not necessary, but if we do want
them, it would mean changes to each such pass).

Spec:

https://github.com/WebAssembly/custom-descriptors/blob/main/proposals/custom-descriptors/Overview.md#configuration-api

@kripken kripken requested a review from tlively November 13, 2025 17:54
@tlively
Copy link
Copy Markdown
Member

tlively commented Nov 13, 2025

What is RUME???

@kripken
Copy link
Copy Markdown
Member Author

kripken commented Nov 13, 2025

RemoveUnusedModuleElements

Comment thread src/ir/intrinsics.cpp
return nullptr;
}

bool Intrinsics::isConfigureAll(Function* func) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check the type as well so all users can be guaranteed that the parameters have the correct types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't do that for the intrinsic above. Do you think it is worth the effort? I'm not sure what it would catch in practice that would be useful. (If the user has this wrong, the VM will error anyhow?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe it's not worth it. configureAll has a single type whereas call.without.effects is overloaded for an infinite set of types, so at least we could check its type rather than letting the user find out about the problem at runtime.

Comment thread src/ir/intrinsics.cpp Outdated
Comment thread src/ir/module-utils.cpp
// several passes.
// TODO Specific fixes in those passes could replace this, and allow better
// optimization.
if (wasm.start) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine that eventually we'll need to handle this in places other than the start function, but starting with this is probably sufficient.

Comment thread test/lit/passes/remove-unused-module-elements-configureAll.wast
Co-authored-by: Thomas Lively <tlively123@gmail.com>
Comment thread src/ir/intrinsics.cpp
return nullptr;
}

bool Intrinsics::isConfigureAll(Function* func) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe it's not worth it. configureAll has a single type whereas call.without.effects is overloaded for an infinite set of types, so at least we could check its type rather than letting the user find out about the problem at runtime.

Comment thread src/ir/intrinsics.cpp
Comment on lines +67 to +69
auto error = [&](const char* msg) {
Fatal() << "Invalid configureAll( " << msg << "): " << *call;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely avoid erroring out on unrecognized configureAll patterns, since they would still be perfectly valid. Maybe we can print a warning and return an empty list if we see some other pattern.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to error for now? A warning might be missed, and make things harder to debug. (We can always reduce an error to a warning later if it feels annoying in practice.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, if a warning is missed, and configureAll is not noticed, we'd end up optimizing away code in ways that might be confusing, like we've seen already.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok fair enough.

@kripken kripken merged commit f70c5cf into WebAssembly:main Nov 14, 2025
16 checks passed
@kripken kripken deleted the configureAll branch November 14, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants