Skip to content

Commit

Permalink
Use a dedicated heap type for the JS Tag
Browse files Browse the repository at this point in the history
Binaryen started preserving the specific heap types used by  tags rather than generating new heap types for them based on their signatures when writing binaries. As a result, the imported JS tag started using whatever function type happened to be the first to be declared to take a single externref parameter and return no results. In general, this type is not the expected type when importing the JS exception tag. To fix the issue, declare and use the precise expected function type in the WAT output.

PiperOrigin-RevId: 717026300
  • Loading branch information
Googler authored and copybara-github committed Jan 18, 2025
1 parent 4cec33e commit adfda33
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ public void emitExceptionTag() {
// with the type $java.lang.Throwable.
// TODO(b/277970998): Decide how to handle this hard coded import w.r.t. import generation.
builder.newLine();
builder.append("(import \"WebAssembly\" \"JSTag\" (tag $exception.event (param externref)))");
builder.append("(type $_js_tag_type (func (param externref)))");
builder.newLine();
builder.append(
"(import \"WebAssembly\" \"JSTag\" (tag $exception.event (type $_js_tag_type) (param"
+ " externref)))");
}

private void renderMonolithicTypeStructs(Type type) {
Expand Down

0 comments on commit adfda33

Please sign in to comment.