Skip to content

Commit 39e6972

Browse files
chore(bindgen): update wasm/wit deps to 0.245.1
1 parent d1d3086 commit 39e6972

5 files changed

Lines changed: 87 additions & 134 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ webidl2wit = { version = "0.1.0", default-features = false }
4646
xshell = { version = "0.2.7", default-features = false }
4747

4848
wasmtime = { version = "43.0.0", default-features = false }
49-
wasm-encoder = { version = "0.246.1", default-features = false }
50-
wasm-metadata = { version = "0.246.1", default-features = false }
51-
wasmparser = { version = "0.246.1", default-features = false }
52-
wasmprinter = { version = "0.246.1", default-features = false }
49+
wasm-encoder = { version = "0.245.1", default-features = false }
50+
wasm-metadata = { version = "0.245.1", default-features = false }
51+
wasmparser = { version = "0.245.1", default-features = false }
52+
wasmprinter = { version = "0.245.1", default-features = false }
5353
wasmtime-environ = { version = "43.0.0", features= [ "component-model", "compile" ] }
54-
wat = { version = "1.246.1", default-features = false }
54+
wat = { version = "1.245.1", default-features = false }
5555
wit-bindgen = { version = "0.54.0", default-features = false }
5656
wit-bindgen-core = { version = "0.54.0", default-features = false }
57-
wit-component = { version = "0.246.1", features = ["dummy-module"] }
58-
wit-parser = { version = "0.246.1", default-features = false }
57+
wit-component = { version = "0.245.1", features = ["dummy-module"] }
58+
wit-parser = { version = "0.245.1", default-features = false }
5959

6060
js-component-bindgen = { version = "1.16.5", path = "./crates/js-component-bindgen" }
6161

6262
[patch.crates-io]
63-
weedle = { git = "https://github.com/wasm-bindgen/weedle", ref = "v0.13.0" }
63+
# NOTE: weedle added a breaking change which gets pulled in by webidl2wit
64+
# see: https://github.com/wasi-gfx/webidl2wit/pull/56
65+
weedle = { git = "https://github.com/wasm-bindgen/weedle", rev = "33f52628f699502c8c9ec49a18adc53af6c4a846" }

crates/js-component-bindgen/src/core.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,18 @@ impl<'a> Translation<'a> {
201201

202202
/// Returns the exports of this module, which are not modified by
203203
/// augmentation.
204-
pub fn exports(
205-
&self,
206-
) -> &wasmtime_environ::wasmparser::collections::IndexMap<String, EntityIndex> {
207-
match self {
208-
Translation::Normal(translation) => &translation.module.exports,
209-
Translation::Augmented { original, .. } => &original.module.exports,
210-
}
204+
pub fn exports(&self) -> HashMap<String, EntityIndex> {
205+
let (translation, exports) = match self {
206+
Translation::Normal(translation) => (translation, &translation.module.exports),
207+
Translation::Augmented { original, .. } => (original, &original.module.exports),
208+
};
209+
210+
exports
211+
.iter()
212+
.map(|(atom, entity_idx)| {
213+
(String::from(&translation.module.strings[atom]), *entity_idx)
214+
})
215+
.collect()
211216
}
212217
}
213218

crates/js-component-bindgen/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn transpile(component: &[u8], opts: TranspileOpts) -> Result<Transpiled> {
135135
| WasmFeatures::CM_ASYNC_BUILTINS
136136
| WasmFeatures::CM_ASYNC_STACKFUL
137137
| WasmFeatures::CM_ERROR_CONTEXT
138-
| WasmFeatures::CM_FIXED_SIZE_LIST,
138+
| WasmFeatures::CM_FIXED_LENGTH_LISTS,
139139
);
140140

141141
let mut types = ComponentTypesBuilder::new(&validator);

crates/js-component-bindgen/src/transpile_bindgen.rs

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,36 +2316,38 @@ impl<'a> Instantiator<'a, '_> {
23162316
uwriteln!(self.src.js, "const trampoline{i} = {resource_transfer};");
23172317
}
23182318

2319-
Trampoline::ResourceEnterCall => {
2320-
let scope_id = self.bindgen.intrinsic(Intrinsic::ScopeId);
2321-
uwrite!(self.src.js, "function trampoline{i}() {{ {scope_id}++; }}");
2322-
}
2323-
2324-
Trampoline::ResourceExitCall => {
2325-
let scope_id = self.bindgen.intrinsic(Intrinsic::ScopeId);
2326-
let resource_borrows = self
2327-
.bindgen
2328-
.intrinsic(Intrinsic::Resource(ResourceIntrinsic::ResourceCallBorrows));
2329-
let handle_tables = self.bindgen.intrinsic(Intrinsic::HandleTables);
2330-
// To verify that borrows are dropped, it is enough to verify that the handle
2331-
// either no longer exists (part of free list) or belongs to another scope, since
2332-
// the enter call closed off the ability to create new handles in the parent scope
2333-
uwrite!(
2334-
self.src.js,
2335-
r#"function trampoline{i}() {{
2336-
{scope_id}--;
2337-
for (const {{ rid, handle }} of {resource_borrows}) {{
2338-
const storedScopeId = {handle_tables}[rid][handle << 1]
2339-
if (storedScopeId === {scope_id}) {{
2340-
throw new TypeError('borrows not dropped for resource call');
2341-
}}
2342-
}}
2343-
{resource_borrows} = [];
2344-
}}
2345-
"#,
2346-
);
2347-
}
2348-
2319+
// TODO: we need to do this? does this mean we need to start keeping track of when we
2320+
// enter a call on a resource explicitly?
2321+
2322+
// Trampoline::ResourceEnterCall => {
2323+
// let scope_id = self.bindgen.intrinsic(Intrinsic::ScopeId);
2324+
// uwrite!(self.src.js, "function trampoline{i}() {{ {scope_id}++; }}");
2325+
// }
2326+
2327+
// Trampoline::ResourceExitCall => {
2328+
// let scope_id = self.bindgen.intrinsic(Intrinsic::ScopeId);
2329+
// let resource_borrows = self
2330+
// .bindgen
2331+
// .intrinsic(Intrinsic::Resource(ResourceIntrinsic::ResourceCallBorrows));
2332+
// let handle_tables = self.bindgen.intrinsic(Intrinsic::HandleTables);
2333+
// // To verify that borrows are dropped, it is enough to verify that the handle
2334+
// // either no longer exists (part of free list) or belongs to another scope, since
2335+
// // the enter call closed off the ability to create new handles in the parent scope
2336+
// uwrite!(
2337+
// self.src.js,
2338+
// r#"function trampoline{i}() {{
2339+
// {scope_id}--;
2340+
// for (const {{ rid, handle }} of {resource_borrows}) {{
2341+
// const storedScopeId = {handle_tables}[rid][handle << 1]
2342+
// if (storedScopeId === {scope_id}) {{
2343+
// throw new TypeError('borrows not dropped for resource call');
2344+
// }}
2345+
// }}
2346+
// {resource_borrows} = [];
2347+
// }}
2348+
// "#,
2349+
// );
2350+
// }
23492351
Trampoline::ContextSet { instance, slot, .. } => {
23502352
let context_set_fn = self
23512353
.bindgen
@@ -2532,10 +2534,15 @@ impl<'a> Instantiator<'a, '_> {
25322534
}
25332535
Trampoline::ThreadIndex => todo!("Trampoline::ThreadIndex"),
25342536
Trampoline::ThreadNewIndirect { .. } => todo!("Trampoline::ThreadNewIndirect"),
2535-
Trampoline::ThreadSwitchTo { .. } => todo!("Trampoline::ThreadSwitchTo"),
25362537
Trampoline::ThreadSuspend { .. } => todo!("Trampoline::ThreadSuspend"),
2537-
Trampoline::ThreadResumeLater { .. } => todo!("Trampoline::ThreadResumeLater"),
2538-
Trampoline::ThreadYieldTo { .. } => todo!("Trampoline::ThreadYieldTo"),
2538+
Trampoline::ThreadSuspendTo { .. } => todo!("Trampoline::ThreadSuspendTo"),
2539+
Trampoline::ThreadUnsuspend { .. } => todo!("Trampoline::ThreadUnsuspend"),
2540+
Trampoline::ThreadYieldToSuspended { .. } => {
2541+
todo!("Trampoline::ThreadYieldToSuspended")
2542+
}
2543+
Trampoline::ThreadSuspendToSuspended { .. } => {
2544+
todo!("Trampoline::ThreadYieldToSuspended")
2545+
}
25392546

25402547
Trampoline::Trap => {
25412548
uwriteln!(
@@ -3947,11 +3954,12 @@ impl<'a> Instantiator<'a, '_> {
39473954
.iter()
39483955
.find_map(|(name, i)| if *i == idx { Some(name) } else { None })
39493956
.unwrap()
3957+
.to_string()
39503958
}
3951-
ExportItem::Name(s) => s,
3959+
ExportItem::Name(s) => s.to_string(),
39523960
};
39533961
let i = export.instance.as_u32() as usize;
3954-
let quoted = maybe_quote_member(name);
3962+
let quoted = maybe_quote_member(&name);
39553963
format!("exports{i}{quoted}")
39563964
}
39573965

0 commit comments

Comments
 (0)