mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
Move table export to the anyref pass
Turns out #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
This commit is contained in:
parent
ad34fa29d8
commit
aace8cedee
@ -92,4 +92,3 @@ wasm-bindgen = { path = '.' }
|
||||
wasm-bindgen-futures = { path = 'crates/futures' }
|
||||
js-sys = { path = 'crates/js-sys' }
|
||||
web-sys = { path = 'crates/web-sys' }
|
||||
wasm-webidl-bindings = { git = 'https://github.com/alexcrichton/wasm-webidl-bindings', branch = 'update-walrus' }
|
||||
|
@ -13,4 +13,4 @@ edition = '2018'
|
||||
|
||||
[dependencies]
|
||||
failure = "0.1"
|
||||
walrus = "0.10.0"
|
||||
walrus = "0.11.0"
|
||||
|
@ -44,6 +44,21 @@ pub fn process(module: &mut Module) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
cfg.run(module)?;
|
||||
|
||||
// Make sure to export the `anyref` table for the JS bindings since it
|
||||
// will need to be initialized. If it doesn't exist though then the
|
||||
// module must not use it, so we skip it.
|
||||
let table = module.tables.iter().find(|t| match t.kind {
|
||||
walrus::TableKind::Anyref(_) => true,
|
||||
_ => false,
|
||||
});
|
||||
let table = match table {
|
||||
Some(t) => t.id(),
|
||||
None => return Ok(()),
|
||||
};
|
||||
module.exports.add("__wbg_anyref_table", table);
|
||||
|
||||
// Clean up now-unused intrinsics and shims and such
|
||||
walrus::passes::gc::run(module);
|
||||
|
||||
// The GC pass above may end up removing some imported intrinsics. For
|
||||
|
@ -624,19 +624,6 @@ impl<'a> Context<'a> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Make sure to export the `anyref` table for the JS bindings since it
|
||||
// will need to be initialized. If it doesn't exist though then the
|
||||
// module must not use it, so we skip it.
|
||||
let table = self.module.tables.iter().find(|t| match t.kind {
|
||||
walrus::TableKind::Anyref(_) => true,
|
||||
_ => false,
|
||||
});
|
||||
let table = match table {
|
||||
Some(t) => t.id(),
|
||||
None => return Ok(()),
|
||||
};
|
||||
self.module.exports.add("__wbg_anyref_table", table);
|
||||
|
||||
let ty = self.module.types.add(&[], &[]);
|
||||
let (import, import_id) =
|
||||
self.module
|
||||
|
@ -24,7 +24,7 @@ rouille = { version = "3.0.0", default-features = false }
|
||||
serde = { version = "1.0", features = ['derive'] }
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
walrus = { version = "0.10.0", features = ['parallel'] }
|
||||
walrus = { version = "0.11.0", features = ['parallel'] }
|
||||
wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.48" }
|
||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }
|
||||
|
||||
|
@ -13,4 +13,4 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
failure = "0.1"
|
||||
walrus = "0.10.0"
|
||||
walrus = "0.11.0"
|
||||
|
@ -14,7 +14,7 @@ edition = '2018'
|
||||
[dependencies]
|
||||
failure = "0.1"
|
||||
log = "0.4"
|
||||
walrus = "0.10.0"
|
||||
walrus = "0.11.0"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
Loading…
x
Reference in New Issue
Block a user