Skip to content

Commit 0daa290

Browse files
committed
Update to walrus 0.9.0
This commit updates the `walrus` dependency with recent upstream API changes in `walrus` itself, namely updates to passive segements and how memory data segments are handled
1 parent 68a1519 commit 0daa290

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

crates/anyref-xform/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ edition = '2018'
1313

1414
[dependencies]
1515
failure = "0.1"
16-
walrus = "0.8.0"
16+
walrus = "0.9.0"

crates/anyref-xform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl Transform<'_> {
676676
// initialized correctly.
677677
fn inject_initialization(&mut self, module: &mut Module) {
678678
let ty = module.types.add(&[], &[]);
679-
let import = module.add_import_func(
679+
let (import, _) = module.add_import_func(
680680
"__wbindgen_placeholder__",
681681
"__wbindgen_init_anyref_table",
682682
ty,

crates/cli-support/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ log = "0.4"
1818
rustc-demangle = "0.1.13"
1919
serde_json = "1.0"
2020
tempfile = "3.0"
21-
walrus = "0.8.0"
21+
walrus = "0.9.0"
2222
wasm-bindgen-anyref-xform = { path = '../anyref-xform', version = '=0.2.48' }
2323
wasm-bindgen-shared = { path = "../shared", version = '=0.2.48' }
2424
wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.48' }
2525
wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.48' }
26-
wasm-webidl-bindings = "0.1.2"
26+
wasm-webidl-bindings = "0.2.0"

crates/cli-support/src/descriptors.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,8 @@ impl WasmBindgenDescriptorsSection {
152152
let ty = module.funcs.get(wbindgen_describe_closure).ty();
153153
for (func, (call_instr, descriptor)) in func_to_descriptor {
154154
let import_name = format!("__wbindgen_closure_wrapper{}", func.index());
155-
let id = module.add_import_func("__wbindgen_placeholder__", &import_name, ty);
156-
let import_id = module
157-
.imports
158-
.iter()
159-
.find(|i| i.name == import_name)
160-
.unwrap()
161-
.id();
155+
let (id, import_id) =
156+
module.add_import_func("__wbindgen_placeholder__", &import_name, ty);
162157
module.funcs.get_mut(id).name = Some(import_name);
163158

164159
let local = match &mut module.funcs.get_mut(func).kind {

crates/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
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 = "0.8.0"
27+
walrus = "0.9.0"
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ edition = "2018"
1313

1414
[dependencies]
1515
failure = "0.1"
16-
walrus = "0.8.0"
16+
walrus = "0.9.0"

crates/threads-xform/src/lib.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Config {
101101
let prev_max = mem.maximum.unwrap();
102102
assert!(mem.import.is_some());
103103
mem.maximum = Some(cmp::max(self.maximum_memory / PAGE_SIZE, prev_max));
104-
assert!(mem.data.is_empty());
104+
assert!(mem.data_segments.is_empty());
105105

106106
let init_memory = module
107107
.exports
@@ -146,11 +146,24 @@ fn switch_data_segments_to_passive(
146146
) -> Result<Vec<PassiveSegment>, Error> {
147147
let mut ret = Vec::new();
148148
let memory = module.memories.get_mut(memory);
149-
let data = mem::replace(&mut memory.data, Default::default());
150-
for (offset, value) in data.into_iter() {
151-
let len = value.len() as u32;
152-
let id = module.data.add(value);
153-
ret.push(PassiveSegment { id, offset, len });
149+
for id in mem::replace(&mut memory.data_segments, Default::default()) {
150+
let data = module.data.get_mut(id);
151+
let kind = match &data.kind {
152+
walrus::DataKind::Active(kind) => kind,
153+
walrus::DataKind::Passive => continue,
154+
};
155+
let offset = match kind.location {
156+
walrus::ActiveDataLocation::Absolute(n) => {
157+
walrus::InitExpr::Value(walrus::ir::Value::I32(n as i32))
158+
}
159+
walrus::ActiveDataLocation::Relative(global) => walrus::InitExpr::Global(global),
160+
};
161+
data.kind = walrus::DataKind::Passive;
162+
ret.push(PassiveSegment {
163+
id,
164+
offset,
165+
len: data.value.len() as u32,
166+
});
154167
}
155168

156169
Ok(ret)

crates/wasm-interpreter/Cargo.toml

Lines changed: 1 addition & 1 deletion
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.8.0"
17+
walrus = "0.9.0"
1818

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

0 commit comments

Comments
 (0)