Skip to content

Handle more types exposed to JS in GTO#8454

Merged
tlively merged 2 commits intomainfrom
gto-jsinterop-subtypes-exports
Mar 12, 2026
Merged

Handle more types exposed to JS in GTO#8454
tlively merged 2 commits intomainfrom
gto-jsinterop-subtypes-exports

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Mar 11, 2026

GTO already handled keeping the prototype configuration fields on
descriptors of types that flowed out to JS via @binaryen.js.called
functions, but it did not handle propagating the information that a
type flows out to JS to that type's subtypes. It also did not consider
that types may flow out to JS via imports and exports. Fix these issues.

GTO already handled keeping the prototype configuration fields on
descriptors of types that flowed out to JS via @binaryen.js.called
functions, but it did not handle propagating the information that a
type flows out to JS to that type's subtypes. It also did not consider
that types may flow out to JS via imports and exports. Fix these issues.
@tlively tlively requested a review from kripken March 11, 2026 22:18
if (global->imported() && global->mutable_) {
flowOut(global->type);
}
}
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 if we can share this logic with your last PR? a general utility that finds the flow out/flow in JS stuff.

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.

Oh yes, that's a good idea. Do you mind if I do it as a follow-up?

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.

Followup sgtm

Comment thread test/lit/passes/gto-jsinterop.wast Outdated
(type $sub-desc (describes $sub) (struct (field externref i64)))
)

;; $super flows out, so $sub is exposed, so $sub-desc field is kept.
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.

Suggested change
;; $super flows out, so $sub is exposed, so $sub-desc field is kept.
;; $super flows out, so $sub is exposed, so $sub-desc's externref field is kept.

Comment thread test/lit/passes/gto-jsinterop.wast Outdated

(module
;; Same, but now the type is exact on the boundary, so it does not propagate
;; exposure to subtypes. We can optimize $sub-desc.
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.

Suggested change
;; exposure to subtypes. We can optimize $sub-desc.
;; exposure to subtypes. We can remove all $sub-desc's fields, unlike before.

Comment thread test/lit/passes/gto-jsinterop.wast Outdated

(module
;; Same, but now there is an abstract supertype on the boundary. We still
;; propagate expose and keep the externref field in $sub-desc.
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.

"propagate expose"?

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.

Will fix to "propagate the fact that the type flows out..."

@tlively tlively enabled auto-merge (squash) March 12, 2026 00:35
Comment thread test/lit/passes/gto-jsinterop.wast
)

(module
;; Now the supertype is a result of the imported function rather than a
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.

Suggested change
;; Now the supertype is a result of the imported function rather than a
;; Now the supertype is a result of the imported function's result rather than a

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 already said "result" earlier in the sentence. Leaving as-is.

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.

Ah, oops, I misread that...

Copy link
Copy Markdown
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm % comment fix

@tlively tlively disabled auto-merge March 12, 2026 15:20
@tlively tlively merged commit f1062b0 into main Mar 12, 2026
17 checks passed
@tlively tlively deleted the gto-jsinterop-subtypes-exports branch March 12, 2026 15:20
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