Skip to content

PrintBoundary pass, emitting a JSON summary of the API boundary of the module#8703

Merged
kripken merged 33 commits into
WebAssembly:mainfrom
kripken:print-boundary
May 15, 2026
Merged

PrintBoundary pass, emitting a JSON summary of the API boundary of the module#8703
kripken merged 33 commits into
WebAssembly:mainfrom
kripken:print-boundary

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented May 14, 2026

cc @tlively @rmahdav @Liedtke - does this look like what we want? (see test for concrete example)

@kripken kripken requested a review from a team as a code owner May 14, 2026 20:17
@kripken kripken requested review from tlively and removed request for a team May 14, 2026 20:17
item["name"] = json::Value::make(exp->name.view());
item["kind"] = getKindName(exp->kind);
item["type"] =
getExternalType(exp->kind, *exp->getInternalName(), *module);
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.

It looks like this won't work for exported heap types... but I don't remember why Export even supports holding a HeapType given that we have no ExternalKind for heap types. Do you remember the context around #7335?

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.

Wasn't the context, as mentioned there, preparation for type exports..? I feel I am not understanding your question, sorry.

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, but why were we preparing for type exports? It doesn't look like anything else has changed to support them since then.

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.

Looks like it's at stage 1 still, I guess nothing changed because it isn't urgent for anything?

Comment on lines +56 to +63
;; CHECK-NEXT: "params": [
;; CHECK-NEXT: "(ref $struct.0)"
;; CHECK-NEXT: ],
;; CHECK-NEXT: "results": [
;; CHECK-NEXT: "i32",
;; CHECK-NEXT: "i32",
;; CHECK-NEXT: "i32"
;; CHECK-NEXT: ]
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.

Maybe we should just print the number of params and results instead of their types, since non-abstract reference types will not be meaningful to consumers of this json. It sounds like Fuzzilli will not use more than the arity anyway.

An alternative that doesn't go so far would be to print the top reference type so the consumer can at least determine what reference type hierarchy the parameter or result is in.

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 would like Fuzzilli to do more than the arity, though (eventually). It would make sense to send references to reference params, for example, reducing the odds of immediate traps that make testcases useless. More specifically, even, when Fuzzilli sees a ref $A is sent out one place, then it could send it back in to another that receives ref $A.

Comment thread test/lit/passes/print-boundary.wast Outdated
Comment on lines +69 to +71
;; CHECK-NEXT: "type": [
;; CHECK-NEXT: "i32"
;; CHECK-NEXT: ]
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 wonder what happens if you try to emit a binary with an imported or exported tuple global. That shouldn't work because such globals do not exist in WebAssembly, so there should be no situations in which the consumer of this information can actually observe multiple values here. We can probably just emit a single type here instead of a list.

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 disallow exporting/importing multivalue globals (validation fails).

I agree it is nicer to not emit a list when not needed, done.

Copy link
Copy Markdown
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.

LGTM, but @rmahdav PTAL.

@rmahdav
Copy link
Copy Markdown

rmahdav commented May 15, 2026

Looks great! The json files looks exactly like what we need on Fuzzilli part. Thanks Alon for quickly adding this functionality.

@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 15, 2026

Great! Landing.

@kripken kripken merged commit 332a49f into WebAssembly:main May 15, 2026
16 checks passed
@kripken kripken deleted the print-boundary branch May 15, 2026 20:01
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.

3 participants