Skip to content

Comments

Do not merge functions differing in semantics-altering annotations#8361

Merged
kripken merged 43 commits intoWebAssembly:mainfrom
kripken:no.jscall.merge
Feb 24, 2026
Merged

Do not merge functions differing in semantics-altering annotations#8361
kripken merged 43 commits intoWebAssembly:mainfrom
kripken:no.jscall.merge

Conversation

@kripken
Copy link
Member

@kripken kripken commented Feb 23, 2026

If function A is js.called and B is not, do not merge them, as the result
would have to either have the annotation or not, and neither is necessarily
what the user wanted.

@kripken kripken requested a review from tlively February 23, 2026 21:13
Comment on lines 50 to 51
if (leftAnnotations.jsCalled != rightAnnotations.jsCalled ||
leftAnnotations.removableIfUnused != rightAnnotations.removableIfUnused) {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than checking inequality of the semantics-affecting annotations, can we instead check equality of the known-non-functional annotations? Then when we add new annotations, they will be conservatively prevent merging.

Copy link
Member

Choose a reason for hiding this comment

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

OTOH doing the current "unsafe" thing allows the fuzzer tell us when we forgot to update this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is tricky. The fuzzer doesn't normally run on this code - fuzzing semantic-altering hints is hard, look at the work it took to fuzz js.called - but there is at least a chance of it telling us of mistakes. While erroring the other way means not merging code that could be, and losing on code size, silently... not sure what's best.

I did refactor wasm.h now to add functions with explicit comparison of semantics changing/preserving, so when adding a new one, you have to at least decide on that, in the most central place. wdyt?

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Nice solution!

@kripken kripken merged commit 4f3f48d into WebAssembly:main Feb 24, 2026
17 checks passed
@kripken kripken deleted the no.jscall.merge branch February 24, 2026 00:16
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