Skip to content

feat: memory64 support#305

Merged
guybedford merged 5 commits intomainfrom
memory64
Mar 25, 2026
Merged

feat: memory64 support#305
guybedford merged 5 commits intomainfrom
memory64

Conversation

@logan-gatlin
Copy link
Copy Markdown
Contributor

Two small changes:

  • Stop truncating MemArg offsets to 32 bits
  • Allow ConstExpr::Extended when accessing data segments and tables. This is not strictly memory64 related, but the memory64 spec-tests require it, and its a trivial change.

This change is not backwards compatible, MemArg.offset has changed from a u32 to a u64.

logan-gatlin and others added 2 commits March 13, 2026 12:16
Data segment offsets, element segment offsets, and element expression
items were only matching ConstExpr::Global and ConstExpr::RefFunc when
building the GC root set. If any of these used a ConstExpr::Extended
containing GlobalGet or RefFunc operations, those references would not
be marked as used, causing the GC pass to potentially remove globals
or functions that are still referenced.

Extract a push_const_expr_refs helper that handles all ConstExpr
variants (including Extended) and use it uniformly for globals, data
segment offsets, element offsets, and element expression items.
@guybedford
Copy link
Copy Markdown
Contributor

Added a commit to fix a pre-existing bug in src/passes/used.rs that becomes more relevant with this PR's acceptance of ConstExpr::Extended in data/element validation.

Problem: The GC used-set pass only matched ConstExpr::Global and ConstExpr::RefFunc when tracking references in:

  • Data segment offsets (line ~238)
  • Element segment offsets (line ~268)
  • Element expression items (lines ~251-264)

If any of these used a ConstExpr::Extended containing GlobalGet or RefFunc operations, those references would not be marked as used, potentially causing the GC pass to incorrectly remove globals or functions that are still referenced.

Fix: Extracted a push_const_expr_refs helper that exhaustively handles all ConstExpr variants (including Extended) and applied it uniformly across globals, data segment offsets, element offsets, and element expression items. This also simplifies the existing globals handling as a nice side effect.

@guybedford guybedford merged commit 90d8de7 into main Mar 25, 2026
18 checks passed
@guybedford guybedford deleted the memory64 branch March 25, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants