Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require RefFunc to have the proper type #7376

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tlively
Copy link
Member

@tlively tlively commented Mar 14, 2025

As a holdout from before GC was implemented, we previously allowed
RefFunc expressions to have type funcref rather than a specific
signature type matching that of the referenced function. Remove this
allowance and start requiring the types to be correct and precise to
eliminate the possibility of stale types inhibiting (or invalidating!)
optimizations.

Update various older passes to update the types of RefFuncs, including
those in tables, to keep their output passing validation. Also update
the kitchen sink example test to construct RefFunc expressions with the
correct type via the C API.

As a holdout from before GC was implemented, we previously allowed
RefFunc expressions to have type `funcref` rather than a specific
signature type matching that of the referenced function. Remove this
allowance and start requiring the types to be correct and precise to
eliminate the possibility of stale types inhibiting (or invalidating!)
optimizations.

Update various older passes to update the types of RefFuncs, including
those in tables, to keep their output passing validation. Also update
the kitchen sink example test to construct RefFunc expressions with the
correct type via the C API.
@tlively tlively requested a review from kripken March 14, 2025 22:40
Copy link
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.

Do we have ref.func-using tests for FuncCastEmulation, I64ToI32Lowering, and LegalizeJSInterface?

@@ -18,6 +18,8 @@ Current Trunk
- Add an option to preserve imports and exports in the fuzzer (for fuzzer
harnesses where they only want Binaryen to modify their given testcases, not
generate new things in them).
- Require the type of RefFunc expressions to match the type of the referenced
function. It is no longer valid to type them as anyref in the IR.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function. It is no longer valid to type them as anyref in the IR.
function. It is no longer valid to type them as funcref in the IR.

@tlively
Copy link
Member Author

tlively commented Mar 17, 2025

Do we have ref.func-using tests for FuncCastEmulation, I64ToI32Lowering, and LegalizeJSInterface?

Yes, via indirect call tables.

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