Skip to content

Commit aace8ce

Browse files
committed
Move table export to the anyref pass
Turns out rustwasm#1704 was buggy and ended up never injecting initialization because the anyref table was never present! This fixes that issue and this should now be tested on CI to ensure this doesn't regress and future changes preserve correctness
1 parent ad34fa2 commit aace8ce

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,3 @@ wasm-bindgen = { path = '.' }
9292
wasm-bindgen-futures = { path = 'crates/futures' }
9393
js-sys = { path = 'crates/js-sys' }
9494
web-sys = { path = 'crates/web-sys' }
95-
wasm-webidl-bindings = { git = 'https://github.com/alexcrichton/wasm-webidl-bindings', branch = 'update-walrus' }

crates/anyref-xform/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ edition = '2018'
1313

1414
[dependencies]
1515
failure = "0.1"
16-
walrus = "0.10.0"
16+
walrus = "0.11.0"

crates/cli-support/src/anyref.rs

+15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ pub fn process(module: &mut Module) -> Result<(), Error> {
4444
}
4545

4646
cfg.run(module)?;
47+
48+
// Make sure to export the `anyref` table for the JS bindings since it
49+
// will need to be initialized. If it doesn't exist though then the
50+
// module must not use it, so we skip it.
51+
let table = module.tables.iter().find(|t| match t.kind {
52+
walrus::TableKind::Anyref(_) => true,
53+
_ => false,
54+
});
55+
let table = match table {
56+
Some(t) => t.id(),
57+
None => return Ok(()),
58+
};
59+
module.exports.add("__wbg_anyref_table", table);
60+
61+
// Clean up now-unused intrinsics and shims and such
4762
walrus::passes::gc::run(module);
4863

4964
// The GC pass above may end up removing some imported intrinsics. For

crates/cli-support/src/webidl/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,6 @@ impl<'a> Context<'a> {
624624
return Ok(());
625625
}
626626

627-
// Make sure to export the `anyref` table for the JS bindings since it
628-
// will need to be initialized. If it doesn't exist though then the
629-
// module must not use it, so we skip it.
630-
let table = self.module.tables.iter().find(|t| match t.kind {
631-
walrus::TableKind::Anyref(_) => true,
632-
_ => false,
633-
});
634-
let table = match table {
635-
Some(t) => t.id(),
636-
None => return Ok(()),
637-
};
638-
self.module.exports.add("__wbg_anyref_table", table);
639-
640627
let ty = self.module.types.add(&[], &[]);
641628
let (import, import_id) =
642629
self.module

crates/cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rouille = { version = "3.0.0", default-features = false }
2424
serde = { version = "1.0", features = ['derive'] }
2525
serde_derive = "1.0"
2626
serde_json = "1.0"
27-
walrus = { version = "0.10.0", features = ['parallel'] }
27+
walrus = { version = "0.11.0", features = ['parallel'] }
2828
wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.48" }
2929
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }
3030

crates/threads-xform/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ edition = "2018"
1313

1414
[dependencies]
1515
failure = "0.1"
16-
walrus = "0.10.0"
16+
walrus = "0.11.0"

crates/wasm-interpreter/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ edition = '2018'
1414
[dependencies]
1515
failure = "0.1"
1616
log = "0.4"
17-
walrus = "0.10.0"
17+
walrus = "0.11.0"
1818

1919
[dev-dependencies]
2020
tempfile = "3"

0 commit comments

Comments
 (0)