Skip to content

Fix CALL_INDIRECT cross-module type index resolution (#88)#90

Merged
andreaTP merged 1 commit into
bytecodealliance:mainfrom
andreaTP:fix/call-indirect-cross-module-type-index
Jul 15, 2026
Merged

Fix CALL_INDIRECT cross-module type index resolution (#88)#90
andreaTP merged 1 commit into
bytecodealliance:mainfrom
andreaTP:fix/call-indirect-cross-module-type-index

Conversation

@andreaTP

Copy link
Copy Markdown
Contributor

Fix #88

Type indices are module-local, so CALL_INDIRECT must resolve the caller's type index against the caller's own type section — not the callee's. For same-module calls, nominal type-index comparison is preserved (required for GC subtyping). For cross-module calls, structural FunctionType comparison is used via a new FunctionType.matches() utility.

@andreaTP andreaTP force-pushed the fix/call-indirect-cross-module-type-index branch 2 times, most recently from 622659b to a130051 Compare July 14, 2026 14:38
…e#88)

Type indices are module-local, so CALL_INDIRECT must resolve the
caller's type index against the caller's own type section — not the
callee's. For same-module calls, nominal type-index comparison is
preserved (required for GC subtyping). For cross-module calls,
structural FunctionType comparison is used via a new
FunctionType.matches() utility.
@andreaTP andreaTP force-pushed the fix/call-indirect-cross-module-type-index branch from a130051 to 8cc4a64 Compare July 14, 2026 15:34
ILOAD 0
I2L
LASTORE
ALOAD 4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the compiler generates both branches (local lookupswitch + cross-module fallback) unconditionally now

@andreaTP andreaTP marked this pull request as ready for review July 14, 2026 18:18
@andreaTP andreaTP merged commit 7505798 into bytecodealliance:main Jul 15, 2026
25 checks passed
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.

CALL_INDIRECT resolves caller type indices against the referenced function's module

1 participant