Skip to content

Commit 6c9cc04

Browse files
chore(deps): update upstream wasm deps to *.227.1
Signed-off-by: Victor Adossi <[email protected]>
1 parent 7f17009 commit 6c9cc04

File tree

3 files changed

+88
-36
lines changed

3 files changed

+88
-36
lines changed

Cargo.toml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,28 @@ edition = "2021"
88
version = "0.1.0"
99

1010
[workspace.dependencies]
11-
anyhow = "1.0.95"
12-
heck = "0.5"
13-
js-component-bindgen = "1.10.0"
14-
wasm-encoder = "0.225.0"
15-
wasmparser = "0.224.0"
16-
wit-bindgen = "0.39.0"
17-
wit-bindgen-core = "0.39.0"
18-
wit-component = { version = "0.225.0", features = ["dummy-module"] }
19-
wit-parser = "0.225.0"
20-
orca-wasm = "0.9.0"
11+
anyhow = { version = "1.0.95", default-features = false }
12+
heck = { version = "0.5", default-features = false }
13+
#js-component-bindgen = { version = "1.10.0", default-features = false }
14+
#orca-wasm = { version = "0.9.0", default-features = false }
15+
rand = { version = "0.8", default-features = false }
16+
#wasm-encoder = { version = "0.225.0", default-features = false }
17+
#wasmparser = { version = "0.224.0", features = ["features"] }
18+
#wit-bindgen = { version = "0.39.0", features = [ "macros" ] }
19+
#wit-bindgen-core = { version = "0.39.0", default-features = false }
20+
#wit-component = { version = "0.225.0", features = ["dummy-module"] }
21+
#wit-parser = { version = "0.225.0", default-features = false }
22+
23+
# TODO: remove once js-component-bindgen with newer upstream versions is released
24+
js-component-bindgen = { path = "../jco/crates/js-component-bindgen", default-features = false }
25+
26+
# TODO: remove once orca PR has merged
27+
# see: https://github.com/thesuhas/orca/pull/241
28+
orca-wasm = { path = "../orca" }
29+
30+
wasm-encoder = { version = "0.227.1", default-features = false }
31+
wasmparser = { version = "0.227.1", features = ["features"] }
32+
wit-bindgen = { version = "0.41.0", features = [ "macros" ] }
33+
wit-bindgen-core = { version = "0.41.0", default-features = false }
34+
wit-component = { version = "0.227.1", features = ["dummy-module"] }
35+
wit-parser = { version = "0.227.1", default-features = false }

crates/spidermonkey-embedding-splicer/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ edition.workspace = true
1010

1111
[dependencies]
1212
anyhow = { workspace = true }
13+
clap = { version = "4.5.31", features = ["suggestions", "color", "derive"] }
1314
heck = { workspace = true }
1415
js-component-bindgen = { workspace = true }
15-
wasmparser = { workspace = true }
16+
orca-wasm = { workspace = true }
17+
rand = { workspace = true }
1618
wasm-encoder = { workspace = true }
19+
wasmparser = { workspace = true }
20+
wit-bindgen = { workspace = true }
21+
wit-bindgen-core = { workspace = true }
1722
wit-component = { workspace = true }
1823
wit-parser = { workspace = true }
19-
wit-bindgen-core = { workspace = true }
20-
wit-bindgen = { workspace = true }
21-
orca-wasm.workspace = true
22-
clap = { version = "4.5.31", features = ["suggestions", "color", "derive"] }

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

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use crate::{uwrite, uwriteln};
2-
use anyhow::Result;
1+
use std::collections::{BTreeMap, BTreeSet, HashMap};
2+
use std::fmt::Write;
3+
4+
use anyhow::{bail, Result};
35
use heck::*;
46
use js_component_bindgen::function_bindgen::{
57
ErrHandling, FunctionBindgen, ResourceData, ResourceMap, ResourceTable,
68
};
79
use js_component_bindgen::intrinsics::{render_intrinsics, Intrinsic};
810
use js_component_bindgen::names::LocalNames;
911
use js_component_bindgen::source::Source;
10-
use std::collections::{BTreeMap, BTreeSet, HashMap};
11-
use std::fmt::Write;
1212
use wit_bindgen_core::abi::{self, LiftLower};
1313
use wit_bindgen_core::wit_parser::Resolve;
1414
use wit_bindgen_core::wit_parser::{
@@ -19,6 +19,8 @@ use wit_component::StringEncoding;
1919
use wit_parser::abi::WasmType;
2020
use wit_parser::abi::{AbiVariant, WasmSignature};
2121

22+
use crate::{uwrite, uwriteln, Features};
23+
2224
#[derive(Debug)]
2325
pub enum Resource {
2426
None,
@@ -521,6 +523,9 @@ impl JsBindgen<'_> {
521523
resource_name,
522524
);
523525
}
526+
FunctionKind::AsyncFreestanding => todo!(),
527+
FunctionKind::AsyncMethod(_id) => todo!(),
528+
FunctionKind::AsyncStatic(_id) => todo!(),
524529
};
525530
}
526531
}
@@ -610,10 +615,14 @@ impl JsBindgen<'_> {
610615
BTreeMap::<_, Vec<_>>::new(),
611616
|mut map, (name, func)| {
612617
map.entry(match &func.kind {
613-
FunctionKind::Freestanding => None,
618+
FunctionKind::Freestanding | FunctionKind::AsyncFreestanding => {
619+
None
620+
}
614621
FunctionKind::Method(ty)
615622
| FunctionKind::Static(ty)
616-
| FunctionKind::Constructor(ty) => Some(*ty),
623+
| FunctionKind::Constructor(ty)
624+
| FunctionKind::AsyncMethod(ty)
625+
| FunctionKind::AsyncStatic(ty) => Some(*ty),
617626
})
618627
.or_default()
619628
.push((name.as_str(), func));
@@ -731,6 +740,9 @@ impl JsBindgen<'_> {
731740
Resource::Constructor(self.resolve.types[*ty].name.clone().unwrap()),
732741
)
733742
}
743+
FunctionKind::AsyncFreestanding => todo!(),
744+
FunctionKind::AsyncMethod(_id) => todo!(),
745+
FunctionKind::AsyncStatic(_id) => todo!(),
734746
};
735747

736748
// imports are canonicalized as exports because
@@ -786,8 +798,8 @@ impl JsBindgen<'_> {
786798
for (_, ty) in func.params.iter() {
787799
self.iter_resources(ty, &mut resource_map);
788800
}
789-
for ty in func.results.iter_types() {
790-
self.iter_resources(ty, &mut resource_map);
801+
if let Some(ty) = func.result {
802+
self.iter_resources(&ty, &mut resource_map);
791803
}
792804
resource_map
793805
}
@@ -896,23 +908,27 @@ impl JsBindgen<'_> {
896908
}
897909
}
898910

911+
let err = if get_thrown_type(self.resolve, func.result)
912+
.is_some_and(|(_, err_ty)| err_ty.is_some())
913+
{
914+
match abi {
915+
AbiVariant::GuestExport => ErrHandling::ThrowResultErr,
916+
AbiVariant::GuestImport => ErrHandling::ResultCatchHandler,
917+
AbiVariant::GuestImportAsync => todo!(),
918+
AbiVariant::GuestExportAsync => todo!(),
919+
AbiVariant::GuestExportAsyncStackful => todo!(),
920+
}
921+
} else {
922+
ErrHandling::None
923+
};
924+
899925
let mut f = FunctionBindgen {
900926
is_async: false,
901927
tracing_prefix: None,
902928
intrinsics: &mut self.all_intrinsics,
903929
valid_lifting_optimization: true,
904930
sizes: &self.sizes,
905-
err: if func.results.throws(self.resolve).is_some() {
906-
match abi {
907-
AbiVariant::GuestExport => ErrHandling::ThrowResultErr,
908-
AbiVariant::GuestImport => ErrHandling::ResultCatchHandler,
909-
AbiVariant::GuestImportAsync => todo!(),
910-
AbiVariant::GuestExportAsync => todo!(),
911-
AbiVariant::GuestExportAsyncStackful => todo!(),
912-
}
913-
} else {
914-
ErrHandling::None
915-
},
931+
err,
916932
block_storage: Vec::new(),
917933
blocks: Vec::new(),
918934
callee,
@@ -976,6 +992,9 @@ impl JsBindgen<'_> {
976992
Resource::Constructor(self.resolve.types[*ty].name.clone().unwrap()),
977993
format!("new {callee}"),
978994
),
995+
FunctionKind::AsyncFreestanding => todo!(),
996+
FunctionKind::AsyncMethod(_id) => todo!(),
997+
FunctionKind::AsyncStatic(_id) => todo!(),
979998
};
980999

9811000
let binding_name = format!(
@@ -1020,8 +1039,8 @@ impl JsBindgen<'_> {
10201039
CoreFn {
10211040
retsize: if sig.retptr {
10221041
let mut retsize: u32 = 0;
1023-
for ret_ty in func.results.iter_types() {
1024-
retsize += self.sizes.size(ret_ty).size_wasm32() as u32;
1042+
if let Some(ret_ty) = func.result {
1043+
retsize += self.sizes.size(&ret_ty).size_wasm32() as u32;
10251044
}
10261045
retsize
10271046
} else {
@@ -1330,3 +1349,20 @@ fn binding_name(func_name: &str, iface_name: &Option<String>) -> String {
13301349
None => format!("{func_name}"),
13311350
}
13321351
}
1352+
1353+
/// Utility function for deducing whether a type can throw
1354+
pub fn get_thrown_type<'a>(
1355+
resolve: &'a Resolve,
1356+
return_type: Option<Type>,
1357+
) -> Option<(Option<&'a Type>, Option<&'a Type>)> {
1358+
match return_type {
1359+
None => None,
1360+
Some(ty) => match ty {
1361+
Type::Id(id) => match &resolve.types[id].kind {
1362+
TypeDefKind::Result(r) => Some((r.ok.as_ref(), r.err.as_ref())),
1363+
_ => None,
1364+
},
1365+
_ => None,
1366+
},
1367+
}
1368+
}

0 commit comments

Comments
 (0)