Skip to content

Commit 3f4a619

Browse files
chore: update wirm to 5.0.0
This updates wirm to 5.0.0 to re-enable the custom section deleting functionality
1 parent 84f00ed commit 3f4a619

6 files changed

Lines changed: 34 additions & 24 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ anyhow = { version = "1.0.95", default-features = false }
1515
heck = { version = "0.5", default-features = false }
1616
rand = { version = "0.8", default-features = false }
1717
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
18-
wirm = { version = "4.0.6", default-features = false }
18+
wirm = { version = "5.0.0", default-features = false }
1919

2020
wasm-encoder = { version = "0.245.1", features = ["component-model", "std"] }
2121
wasmparser = { version = "0.245.1", features = [

crates/spidermonkey-embedding-splicer/src/bindgen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use wit_bindgen_core::wit_parser::{
1717
WorldId, WorldItem,
1818
};
1919
use wit_component::StringEncoding;
20+
use wit_parser::Param;
2021
use wit_parser::abi::WasmType;
2122
use wit_parser::abi::{AbiVariant, WasmSignature};
2223

@@ -771,7 +772,7 @@ impl JsBindgen<'_> {
771772

772773
fn create_resource_map(&self, func: &Function) -> ResourceMap {
773774
let mut resource_map = BTreeMap::new();
774-
for wit_parser::Param { ty, .. } in func.params.iter() {
775+
for Param { ty, .. } in func.params.iter() {
775776
self.iter_resources(ty, &mut resource_map);
776777
}
777778
if let Some(ty) = func.result {

crates/spidermonkey-embedding-splicer/src/splice.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ pub fn splice(
356356
);
357357
}
358358

359+
// we reencode the WASI world component data, so strip it out from the
360+
// custom section
361+
let maybe_component_section_id = module
362+
.custom_sections
363+
.get_id("component-type:bindings".to_string());
364+
if let Some(component_section_id) = maybe_component_section_id {
365+
module.delete_custom_section(component_section_id);
366+
}
367+
359368
// Extract the native instructions from sample functions
360369
// then inline the imported functions and main import gating function
361370
// (erasing sample functions in the process)
@@ -472,7 +481,7 @@ fn synthesize_import_functions(
472481
.unwrap();
473482

474483
// Sets the return value on args from the stack
475-
let args_ret_i32: Vec<wirm::wasmparser::Operator> = vec![
484+
let args_ret_i32: Vec<Operator> = vec![
476485
Operator::I64ExtendI32U,
477486
Operator::I64Const {
478487
value: -545460846592,
@@ -776,7 +785,7 @@ fn synthesize_import_functions(
776785
builder.inject_at(
777786
0,
778787
InstrumentationMode::Before,
779-
wirm::wasmparser::Operator::LocalSet {
788+
Operator::LocalSet {
780789
local_index: *idx_local,
781790
},
782791
);
@@ -789,7 +798,7 @@ fn synthesize_import_functions(
789798
{
790799
let ops_ro = builder.body.instructions.get_ops();
791800
for (idx, op) in ops_ro.iter().enumerate() {
792-
if let wirm::wasmparser::Operator::I32Const { value } = op {
801+
if let Operator::I32Const { value } = op {
793802
// we specifically need the const "around" 3393
794803
// which is the coreabi_sample_i32 table offset
795804
if *value < 1000 || *value > 5000 {
@@ -800,8 +809,7 @@ fn synthesize_import_functions(
800809
// in the base computation.
801810
let mut base = *value;
802811
if idx > 0
803-
&& let wirm::wasmparser::Operator::GlobalGet { global_index } =
804-
&ops_ro[idx - 1]
812+
&& let Operator::GlobalGet { global_index } = &ops_ro[idx - 1]
805813
&& let GlobalKind::Local(local_global) =
806814
module.globals.get_kind(GlobalID(*global_index))
807815
&& let [InitInstr::Value(Value::I32(v))] =
@@ -819,25 +827,25 @@ fn synthesize_import_functions(
819827
builder.inject_at(
820828
table_instr_idx,
821829
InstrumentationMode::Before,
822-
wirm::wasmparser::Operator::LocalGet {
830+
Operator::LocalGet {
823831
local_index: *idx_local,
824832
},
825833
);
826834
builder.inject_at(
827835
table_instr_idx + 1,
828836
InstrumentationMode::Before,
829-
wirm::wasmparser::Operator::I32Add,
837+
Operator::I32Add,
830838
);
831839

832840
if delta != 0 {
833-
builder.body.instructions.add_instr(
834-
table_instr_idx,
835-
wirm::wasmparser::Operator::I32Const { value: delta },
836-
);
837841
builder
838842
.body
839843
.instructions
840-
.add_instr(table_instr_idx, wirm::wasmparser::Operator::I32Add);
844+
.add_instr(table_instr_idx, Operator::I32Const { value: delta });
845+
builder
846+
.body
847+
.instructions
848+
.add_instr(table_instr_idx, Operator::I32Add);
841849
}
842850
}
843851

crates/spidermonkey-embedding-splicer/src/stub_wasi.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use wirm::ir::id::{FunctionID, LocalID};
88
use wirm::ir::module::module_functions::FuncKind;
99
use wirm::ir::types::{BlockType, InitExpr, Value};
1010
use wirm::module_builder::AddLocal;
11+
use wirm::wasmparser::{MemArg, TypeRef};
1112
use wirm::{DataType, InitInstr, Module, Opcode};
1213
use wit_parser::Resolve;
1314

@@ -31,7 +32,7 @@ where
3132
continue;
3233
};
3334

34-
let wirm::wasmparser::TypeRef::Func(_) = module.imports.get(iid).ty else {
35+
let TypeRef::Func(_) = module.imports.get(iid).ty else {
3536
bail!("'{full_import}#{name}' is not a function.")
3637
};
3738
let fid: FunctionID = FunctionID(*iid);
@@ -74,7 +75,7 @@ where
7475
return Ok(None);
7576
};
7677

77-
let wirm::wasmparser::TypeRef::Func(_) = module.imports.get(iid).ty else {
78+
let TypeRef::Func(_) = module.imports.get(iid).ty else {
7879
bail!("'{import}#{name}' is not a function.")
7980
};
8081
let fid: FunctionID = FunctionID(*iid);
@@ -269,7 +270,7 @@ fn stub_random(module: &mut Module) -> Result<()> {
269270

270271
// *retptr = outptr
271272
// *retptr + 1 = len
272-
body.i32_store(wirm::wasmparser::MemArg {
273+
body.i32_store(MemArg {
273274
align: 2,
274275
max_align: 0,
275276
offset: 0,
@@ -279,7 +280,7 @@ fn stub_random(module: &mut Module) -> Result<()> {
279280
body.local_get(retptr);
280281
body.local_get(num_bytes);
281282
body.i32_wrap_i64();
282-
body.i32_store(wirm::wasmparser::MemArg {
283+
body.i32_store(MemArg {
283284
align: 2,
284285
max_align: 0,
285286
offset: 4,
@@ -294,7 +295,7 @@ fn stub_random(module: &mut Module) -> Result<()> {
294295
body.loop_stmt(BlockType::Empty);
295296
body.local_get(curptr);
296297
body.call(random_u64);
297-
body.i64_store(wirm::wasmparser::MemArg {
298+
body.i64_store(MemArg {
298299
align: 3,
299300
max_align: 0,
300301
offset: 0,
@@ -351,7 +352,7 @@ fn stub_clocks(module: &mut Module) -> Result<()> {
351352
body.local_get(time_ptr);
352353
body.local_get(time_ptr);
353354
body.i64_const(i64::try_from(unix_time.as_nanos())?);
354-
body.i64_store(wirm::wasmparser::MemArg {
355+
body.i64_store(MemArg {
355356
align: 3,
356357
offset: 0,
357358
max_align: 0,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)