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

Use table.fill in externref-xform (TODO) #3446

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions crates/externref-xform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,19 +652,12 @@ impl Transform<'_> {
// Note that we pave over all our stack slots with `ref.null` to ensure
// that the table doesn't accidentally hold a strong reference to items
// no longer in use by our wasm instance.
//
// TODO: use `table.fill` once that's spec'd
if externref_stack > 0 {
for i in 0..externref_stack {
body.local_get(fp);
if i > 0 {
body.i32_const(i).binop(BinaryOp::I32Add);
}
body.ref_null(ValType::Externref);
body.table_set(self.table);
}

body.local_get(fp)
.ref_null(ValType::Externref)
.i32_const(externref_stack)
.table_fill(self.table)
.local_get(fp)
.i32_const(externref_stack)
.binop(BinaryOp::I32Add)
.global_set(self.stack_pointer);
Expand Down
3 changes: 2 additions & 1 deletion crates/externref-xform/tests/anyref-param.wat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
call $foo
local.get 1
ref.null extern
table.set 0
i32.const 1
table.fill 0
local.get 1
i32.const 1
i32.add
Expand Down
3 changes: 2 additions & 1 deletion crates/externref-xform/tests/mixed-export.wat
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
call $a
local.get 5
ref.null extern
table.set 0
i32.const 1
table.fill 0
local.get 5
i32.const 1
i32.add
Expand Down