diff --git a/crates/js-component-bindgen-component/src/lib.rs b/crates/js-component-bindgen-component/src/lib.rs index ec60154e1..b7ce53f99 100644 --- a/crates/js-component-bindgen-component/src/lib.rs +++ b/crates/js-component-bindgen-component/src/lib.rs @@ -46,6 +46,17 @@ impl From for js_component_bindgen::InstantiationMode { } } +impl From for js_component_bindgen::BindingsMode { + fn from(value: BindingsMode) -> Self { + match value { + BindingsMode::Js => js_component_bindgen::BindingsMode::Js, + BindingsMode::DirectOptimized => js_component_bindgen::BindingsMode::DirectOptimized, + BindingsMode::Optimized => js_component_bindgen::BindingsMode::Optimized, + BindingsMode::Hybrid => js_component_bindgen::BindingsMode::Hybrid, + } + } +} + struct JsComponentBindgenComponent; export!(JsComponentBindgenComponent); @@ -67,6 +78,7 @@ impl Guest for JsComponentBindgenComponent { tracing: options.tracing.unwrap_or(false), no_namespaced_exports: options.no_namespaced_exports.unwrap_or(false), multi_memory: options.multi_memory.unwrap_or(false), + import_bindings: options.import_bindings.map(Into::into), }; let js_component_bindgen::Transpiled { @@ -134,6 +146,7 @@ impl Guest for JsComponentBindgenComponent { tracing: false, no_namespaced_exports: false, multi_memory: false, + import_bindings: None, }; let files = generate_types(name, resolve, world, opts).map_err(|e| e.to_string())?; diff --git a/crates/js-component-bindgen-component/wit/js-component-bindgen.wit b/crates/js-component-bindgen-component/wit/js-component-bindgen.wit index f9bfaa532..c0b19cde5 100644 --- a/crates/js-component-bindgen-component/wit/js-component-bindgen.wit +++ b/crates/js-component-bindgen-component/wit/js-component-bindgen.wit @@ -9,6 +9,13 @@ world js-component-bindgen { sync, } + variant bindings-mode { + js, + hybrid, + optimized, + direct-optimized, + } + record generate-options { /// Name to use for the generated component name: string, @@ -21,6 +28,9 @@ world js-component-bindgen { /// of the direct importable native ESM output. instantiation: option, + /// Import bindings generation mode + import-bindings: option, + /// Mappings of component import specifiers to JS import specifiers. map: option, diff --git a/crates/js-component-bindgen/src/function_bindgen.rs b/crates/js-component-bindgen/src/function_bindgen.rs index a88ca02c8..b62400635 100644 --- a/crates/js-component-bindgen/src/function_bindgen.rs +++ b/crates/js-component-bindgen/src/function_bindgen.rs @@ -45,8 +45,9 @@ pub enum ResourceData { /// /// For a given resource id {x}, the local variables are assumed: /// - handleTable{x} -/// - captureTable{x} (only for imported tables) -/// - captureCnt{x} (only for imported tables) +/// - captureTable{x} (rep to instance map for captured imported tables, only for JS import bindgen, +/// not hybrid) +/// - captureCnt{x} for assigning capture rep /// /// For component-defined resources: /// - finalizationRegistry{x} @@ -1045,17 +1046,6 @@ impl Bindgen for FunctionBindgen<'_> { self.bind_results(sig_results_length, results); uwriteln!(self.src, "{}({});", self.callee, operands.join(", ")); - if !self.cur_resource_borrows.is_empty() { - uwriteln!( - self.src, - "if ({}) {{ - throw new Error('Resource error: borrows were not dropped'); - }}", - self.cur_resource_borrows.join(" || ") - ); - self.cur_resource_borrows = Vec::new(); - } - if let Some(prefix) = self.tracing_prefix { let to_result_string = self.intrinsic(Intrinsic::ToResultString); uwriteln!( @@ -1196,16 +1186,16 @@ impl Bindgen for FunctionBindgen<'_> { let id = id.as_u32(); let symbol_dispose = self.intrinsic(Intrinsic::SymbolDispose); let rsc_table_remove = self.intrinsic(Intrinsic::ResourceTableRemove); + let rep = format!("rep{}", self.tmp()); if !imported { - let rep = format!("rep{}", self.tmp()); let symbol_resource_handle = self.intrinsic(Intrinsic::SymbolResourceHandle); - let rsc_table_get = self.intrinsic(Intrinsic::ResourceTableGet); + let rsc_flag = self.intrinsic(Intrinsic::ResourceTableFlag); uwrite!( self.src, "var {rsc} = new.target === {local_name} ? this : Object.create({local_name}.prototype); - var {rep} = {rsc_table_get}(handleTable{id}, {handle}).rep; - Object.defineProperty({rsc}, {symbol_resource_handle}, {{ writable: true, value: {rep} }}); + var {rep} = handleTable{id}[({handle} << 1) + 1] & ~{rsc_flag}; + Object.defineProperty({rsc}, {symbol_resource_handle}, {{ writable: true, value: {rep} }}); ", ); if is_own { @@ -1239,15 +1229,39 @@ impl Bindgen for FunctionBindgen<'_> { )); } } else { - // imported handles lift as instance capture from a previous lowering - let rsc_table_get = self.intrinsic(Intrinsic::ResourceTableGet); - uwriteln!(self.src, "var {rsc} = captureTable{id}.get({rsc_table_get}(handleTable{id}, {handle}).rep);"); - // an own lifting is a transfer to JS, so handle is implicitly dropped + // imported handles either lift as instance capture from a previous lowering, + // or we create a new JS class to represent it + let rsc_flag = self.intrinsic(Intrinsic::ResourceTableFlag); + let symbol_resource_rep = self.intrinsic(Intrinsic::SymbolResourceRep); + let symbol_resource_handle = + self.intrinsic(Intrinsic::SymbolResourceHandle); + uwriteln!( + self.src, + "var {rep} = handleTable{id}[({handle} << 1) + 1] & ~{rsc_flag};" + ); + uwriteln!(self.src, + "var {rsc} = captureTable{id}.get({rep}); + if (!{rsc}) {{ + {rsc} = Object.create({local_name}.prototype); + Object.defineProperty({rsc}, {symbol_resource_handle}, {{ writable: true, value: {handle} }}); + Object.defineProperty({rsc}, {symbol_resource_rep}, {{ writable: true, value: {rep} }}); + }}" + ); if is_own { + // an own lifting is a transfer to JS, so existing own handle is implicitly dropped uwriteln!( self.src, - "captureTable{id}.delete({rsc_table_remove}(handleTable{id}, {handle}).rep);" + "else {{ + captureTable{id}.delete({rep}); + }} + {rsc_table_remove}(handleTable{id}, {handle});" ); + } else { + // if lifting a borrow, that was not previously captured, create the class + self.cur_resource_borrows.push(format!( + "{}[{symbol_resource_handle}] = null;", + rsc.to_string() + )); } } } @@ -1318,78 +1332,72 @@ impl Bindgen for FunctionBindgen<'_> { ResourceData::Host { id, local_name, .. } => { let id = id.as_u32(); if !imported { - let rep = format!("rep{}", self.tmp()); - uwriteln!( self.src, - "var {rep} = {op}[{symbol_resource_handle}]; - if ({rep} === null) {{ - throw new Error('Resource error: \"{class_name}\" lifetime expired.'); - }} - if ({rep} === undefined) {{ + "var {handle} = {op}[{symbol_resource_handle}]; + if (!{handle}) {{ throw new Error('Resource error: Not a valid \"{class_name}\" resource.'); }} ", ); - // Own resources of own components lowered into the component - // still need handle table tracking of their rep value, by creating - // a new handle for this. - // The class representation of that own resource is still disposed - // though, and their finalizers deregistered as well. if is_own { let empty_func = self.intrinsic(Intrinsic::EmptyFunc); - let rsc_table_create_own = - self.intrinsic(Intrinsic::ResourceTableCreateOwn); uwriteln!( self.src, - "var {handle} = {rsc_table_create_own}(handleTable{id}, {rep}); - finalizationRegistry{id}.unregister({op}); + "finalizationRegistry{id}.unregister({op}); {op}[{symbol_dispose}] = {empty_func}; {op}[{symbol_resource_handle}] = null;" ); - } else { - // it is only in the local borrow case where we can simplify the handle - // to just be the original rep value and don't need to track an - // explicit handle lifetime. - uwriteln!(self.src, "var {handle} = {rep};"); } } else { - // imported resources are always given a unique handle + // imported resources may already have a handle if they were constructed + // by a component and then passed out uwriteln!( self.src, "if (!({op} instanceof {local_name})) {{ throw new Error('Resource error: Not a valid \"{class_name}\" resource.'); }} - captureTable{id}.set(++captureCnt{id}, {op});" + var {handle} = {op}[{symbol_resource_handle}]; + " ); + // otherwise, in hybrid bindgen we check for a Symbol.for('cabiRep') + // to get the resource rep + // fall back to assign a new rep in the capture table, when the imported + // resource was constructed externally if is_own { - let rsc_table_create_own = + let symbol_resource_rep = + self.intrinsic(Intrinsic::SymbolResourceRep); + let rsc_table_create = self.intrinsic(Intrinsic::ResourceTableCreateOwn); uwriteln!( self.src, - "var {handle} = {rsc_table_create_own}(handleTable{id}, captureCnt{id});", + "if (!{handle}) {{ + let rep = {op}[{symbol_resource_rep}]; + if (!rep) {{ + captureTable{id}.set(++captureCnt{id}, {op}); + rep = captureCnt{id}; + }} else {{ + {op}[{symbol_resource_rep}] = null; + }} + {handle} = {rsc_table_create}(handleTable{id}, rep); + }}" ); } else { - let rsc_table_create_borrow = + let symbol_resource_rep = + self.intrinsic(Intrinsic::SymbolResourceRep); + let rsc_table_create = self.intrinsic(Intrinsic::ResourceTableCreateBorrow); uwriteln!( self.src, - "var {handle} = {rsc_table_create_borrow}(handleTable{id}, captureCnt{id});", + "if (!{handle}) {{ + if (!{op}[{symbol_resource_rep}]) {{ + captureTable{id}.set(++captureCnt{id}, {op}); + }} + {handle} = {rsc_table_create}(handleTable{id}, {op}[{symbol_resource_rep}] || captureCnt{id}); + }}" ); - } - - // track lowered borrows to ensure they are dropped - // cur_resource_borrows can be reused because: - // - it is not possible to have a Wasm call that lifts a a borrow handle argument - // and wasm calls cannot return borrow handles for lifting - // - conversely, it is not possible to have a JS call that lowers a borrow handle argument - // and JS calls cannot return borrows for lowering - if !is_own && !self.valid_lifting_optimization { - let rsc_table_get = self.intrinsic(Intrinsic::ResourceTableGet); - self.cur_resource_borrows - .push(format!("{rsc_table_get}(handleTable{id}, {handle})")); - } + }; } } diff --git a/crates/js-component-bindgen/src/intrinsics.rs b/crates/js-component-bindgen/src/intrinsics.rs index 52ac7cfb7..70701f195 100644 --- a/crates/js-component-bindgen/src/intrinsics.rs +++ b/crates/js-component-bindgen/src/intrinsics.rs @@ -18,20 +18,24 @@ pub enum Intrinsic { HasOwnProperty, I32ToF32, I64ToF64, + ImportedResourceCnt, InstantiateCore, IsLE, ResourceTableFlag, ResourceTableCreateBorrow, ResourceTableCreateOwn, ResourceTableGet, - ResourceTableTryGet, + ResourceTableEnsureBorrowDrop, ResourceTableRemove, ResourceCallBorrows, ResourceTransferBorrow, ResourceTransferBorrowValidLifting, ResourceTransferOwn, ScopeId, + SymbolCabiDispose, + SymbolCabiLower, SymbolResourceHandle, + SymbolResourceRep, SymbolDispose, ThrowInvalidBool, ThrowUninitialized, @@ -169,7 +173,7 @@ pub fn render_intrinsics( }, Intrinsic::HandleTables => output.push_str(" - const handleTables = new Map(); + const handleTables = []; "), Intrinsic::HasOwnProperty => output.push_str(" @@ -186,6 +190,8 @@ pub fn render_intrinsics( const i64ToF64 = i => (i64ToF64I[0] = i, i64ToF64F[0]); "), + Intrinsic::ImportedResourceCnt => output.push_str("importedResourceCnt"), + Intrinsic::InstantiateCore => if !instantiation { output.push_str(" const instantiateCore = WebAssembly.instantiate; @@ -290,15 +296,10 @@ pub fn render_intrinsics( } "), - Intrinsic::ResourceTableTryGet => output.push_str(" - function rscTableTryGet (table, handle) { - const scope = table[handle << 1]; - const val = table[(handle << 1) + 1]; - const own = (val & T_FLAG) !== 0; - const rep = val & ~T_FLAG; - if (rep === 0 || (scope & T_FLAG) !== 0) - return; - return { rep, scope, own }; + Intrinsic::ResourceTableEnsureBorrowDrop => output.push_str(" + function rscTableEnsureBorrowDrop (table, handle, scope) { + if (table[handle << 1] === scope) + throw new Error('Resource borrow was not dropped at end of call'); } "), @@ -320,13 +321,12 @@ pub fn render_intrinsics( let resource_borrows = Intrinsic::ResourceCallBorrows.name(); let rsc_table_remove = Intrinsic::ResourceTableRemove.name(); let rsc_table_create_borrow = Intrinsic::ResourceTableCreateBorrow.name(); + let imported_rsc_cnt = Intrinsic::ImportedResourceCnt.name(); output.push_str(&format!(" function resourceTransferBorrow(handle, fromRid, toRid) {{ - const {{ t: fromTable, i: fromImport }} = {handle_tables}.get(fromRid); - const rep = fromImport ? {rsc_table_remove}(fromTable, handle) : handle; - const {{ t: toTable, i: toImport }} = {handle_tables}.get(toRid); - if (!toImport) return rep; - const newHandle = {rsc_table_create_borrow}(toTable, rep); + const rep = fromRid < {imported_rsc_cnt} ? {rsc_table_remove}({handle_tables}[fromRid], handle).rep : handle; + if (toRid >= {imported_rsc_cnt}) return rep; + const newHandle = {rsc_table_create_borrow}({handle_tables}[toRid], rep); {resource_borrows}.push({{ rid: toRid, handle: newHandle }}); return newHandle; }} @@ -337,13 +337,12 @@ pub fn render_intrinsics( let handle_tables = Intrinsic::HandleTables.name(); let rsc_table_remove = Intrinsic::ResourceTableRemove.name(); let rsc_table_create_borrow = Intrinsic::ResourceTableCreateBorrow.name(); + let imported_rsc_cnt = Intrinsic::ImportedResourceCnt.name(); output.push_str(&format!(" function resourceTransferBorrowValidLifting(handle, fromRid, toRid) {{ - const {{ t: fromTable, i: fromImport }} = {handle_tables}.get(fromRid); - const rep = fromImport ? {rsc_table_remove}(fromTable, handle) : handle; - const {{ t: toTable, i: toImport }} = {handle_tables}.get(toRid); - if (!toImport) return rep; - return {rsc_table_create_borrow}(toTable, rep); + const rep = fromRid < {imported_rsc_cnt} ? {rsc_table_remove}({handle_tables}[fromRid], handle).rep : handle; + if (toRid >= {imported_rsc_cnt}) return rep; + return {rsc_table_create_borrow}({handle_tables}[toRid], rep); }} ")); }, @@ -354,20 +353,30 @@ pub fn render_intrinsics( let rsc_table_create_own = Intrinsic::ResourceTableCreateOwn.name(); output.push_str(&format!(" function resourceTransferOwn(handle, fromRid, toRid) {{ - const {{ t: fromTable }} = {handle_tables}.get(fromRid); - const {{ rep }} = {rsc_table_remove}(fromTable, handle); - const {{ t: toTable }} = {handle_tables}.get(toRid); - return {rsc_table_create_own}(toTable, rep); + const {{ rep }} = {rsc_table_remove}({handle_tables}[fromRid], handle); + return {rsc_table_create_own}({handle_tables}[toRid], rep); }} ")); }, + Intrinsic::SymbolCabiDispose => output.push_str(" + const symbolCabiDispose = Symbol.for('cabiDispose'); + "), + + Intrinsic::SymbolCabiLower => output.push_str(" + const symbolCabiLower = Symbol.for('cabiLower'); + "), + Intrinsic::ScopeId => output.push_str(" let scopeId = 0; "), Intrinsic::SymbolResourceHandle => output.push_str(" - const resourceHandleSymbol = Symbol('resource'); + const symbolRscHandle = Symbol('handle'); + "), + + Intrinsic::SymbolResourceRep => output.push_str(" + const symbolRscRep = Symbol.for('cabiRep'); "), Intrinsic::SymbolDispose => output.push_str(" @@ -552,50 +561,51 @@ pub fn render_intrinsics( impl Intrinsic { pub fn get_global_names() -> &'static [&'static str] { &[ + // Intrinsic list exactly as below "base64Compile", - "BigInt", - "BigInt64Array", "clampGuest", "ComponentError", "dataView", - "DataView", - "dv", "emptyFunc", - "Error", - "E_OWN", - "E_FREE", "f32ToI32", "f64ToI64", - "fetch", "fetchCompile", - "Float32Array", - "Float64Array", "getErrorPayload", + "handleTables", "hasOwnProperty", "i32ToF32", "i64ToF64", + "importedResourceCnt", "instantiateCore", - "Int32Array", "isLE", - "Object", - "process", - "String", + "resourceCallBorrows", + "T_FLAG", + "rscTableCreateBorrow", + "rscTableCreateOwn", + "rscTableGet", + "rscTableTryGet", + "rscTableRemove", + "resourceTransferBorrow", + "resourceTransferBorrowValidLifting", + "resourceTransferOwn", + "scopeId", + "symbolCabiDispose", + "symbolCabiLower", "symbolDispose", + "symbolRscHandle", + "symbolRscRep", "throwInvalidBool", "throwUninitialized", + "toInt64", + "toUint64", "toInt16", "toInt32", - "toInt64", "toInt8", + "toResultString", "toString", "toUint16", "toUint32", - "toUint64", "toUint8", - "TypeError", - "Uint16Array", - "Uint8Array", - "URL", "utf16Decoder", "utf16Encode", "utf8Decoder", @@ -603,6 +613,25 @@ impl Intrinsic { "utf8EncodedLen", "validateGuestChar", "validateHostChar", + // JS Globals / non intrinsic names + "BigInt", + "BigInt64Array", + "DataView", + "dv", + "emptyFunc", + "Error", + "fetch", + "Float32Array", + "Float64Array", + "Int32Array", + "Object", + "process", + "String", + "toUint64", + "TypeError", + "Uint16Array", + "Uint8Array", + "URL", "WebAssembly", ] } @@ -622,6 +651,7 @@ impl Intrinsic { Intrinsic::HasOwnProperty => "hasOwnProperty", Intrinsic::I32ToF32 => "i32ToF32", Intrinsic::I64ToF64 => "i64ToF64", + Intrinsic::ImportedResourceCnt => "importedResourceCnt", Intrinsic::InstantiateCore => "instantiateCore", Intrinsic::IsLE => "isLE", Intrinsic::ResourceCallBorrows => "resourceCallBorrows", @@ -629,14 +659,17 @@ impl Intrinsic { Intrinsic::ResourceTableCreateBorrow => "rscTableCreateBorrow", Intrinsic::ResourceTableCreateOwn => "rscTableCreateOwn", Intrinsic::ResourceTableGet => "rscTableGet", - Intrinsic::ResourceTableTryGet => "rscTableTryGet", + Intrinsic::ResourceTableEnsureBorrowDrop => "rscTableTryGet", Intrinsic::ResourceTableRemove => "rscTableRemove", Intrinsic::ResourceTransferBorrow => "resourceTransferBorrow", Intrinsic::ResourceTransferBorrowValidLifting => "resourceTransferBorrowValidLifting", Intrinsic::ResourceTransferOwn => "resourceTransferOwn", Intrinsic::ScopeId => "scopeId", - Intrinsic::SymbolResourceHandle => "resourceHandleSymbol", + Intrinsic::SymbolCabiDispose => "symbolCabiDispose", + Intrinsic::SymbolCabiLower => "symbolCabiLower", Intrinsic::SymbolDispose => "symbolDispose", + Intrinsic::SymbolResourceHandle => "symbolRscHandle", + Intrinsic::SymbolResourceRep => "symbolRscRep", Intrinsic::ThrowInvalidBool => "throwInvalidBool", Intrinsic::ThrowUninitialized => "throwUninitialized", Intrinsic::ToBigInt64 => "toInt64", diff --git a/crates/js-component-bindgen/src/lib.rs b/crates/js-component-bindgen/src/lib.rs index c6173d0fd..ad5b403eb 100644 --- a/crates/js-component-bindgen/src/lib.rs +++ b/crates/js-component-bindgen/src/lib.rs @@ -8,7 +8,7 @@ pub mod function_bindgen; pub mod intrinsics; pub mod names; pub mod source; -pub use transpile_bindgen::{InstantiationMode, TranspileOpts}; +pub use transpile_bindgen::{BindingsMode, InstantiationMode, TranspileOpts}; use anyhow::Result; use transpile_bindgen::transpile_bindgen; diff --git a/crates/js-component-bindgen/src/names.rs b/crates/js-component-bindgen/src/names.rs index ab493ac13..10b5d875a 100644 --- a/crates/js-component-bindgen/src/names.rs +++ b/crates/js-component-bindgen/src/names.rs @@ -52,6 +52,16 @@ impl<'a> LocalNames { &self.local_name_ids[&hash] } + pub fn try_get(&'a self, unique_id: H) -> Option<&'a str> { + let mut new_s = self.random_state.build_hasher(); + unique_id.hash(&mut new_s); + let hash = new_s.finish(); + if !self.local_name_ids.contains_key(&hash) { + return None; + } + Some(&self.local_name_ids[&hash]) + } + /// get or create a unique identifier for a string while storing the lookup by unique id pub fn get_or_create(&'a mut self, unique_id: H, goal_name: &str) -> (&'a str, bool) { let mut new_s = self.random_state.build_hasher(); diff --git a/crates/js-component-bindgen/src/transpile_bindgen.rs b/crates/js-component-bindgen/src/transpile_bindgen.rs index cdd823b30..be4539537 100644 --- a/crates/js-component-bindgen/src/transpile_bindgen.rs +++ b/crates/js-component-bindgen/src/transpile_bindgen.rs @@ -37,12 +37,6 @@ use wit_parser::{ WorldItem, WorldKey, }; -#[derive(Hash)] -struct ResourceInstance<'a> { - resource_id: TypeId, - import: Option<&'a str>, -} - #[derive(Default, Clone)] pub struct TranspileOpts { pub name: String, @@ -52,6 +46,9 @@ pub struct TranspileOpts { /// Provide a custom JS instantiation API for the component instead /// of the direct importable native ESM output. pub instantiation: Option, + /// Configure how import bindings are provided, as high-level JS bindings, + /// or as hybrid optimized bindings. + pub import_bindings: Option, /// Comma-separated list of "from-specifier=./to-specifier.js" mappings of /// component import specifiers to JS import specifiers. pub map: Option>, @@ -93,6 +90,15 @@ enum CallType { CalleeResourceDispatch, } +#[derive(Default, Clone, Debug)] +pub enum BindingsMode { + Hybrid, + #[default] + Js, + Optimized, + DirectOptimized, +} + struct JsBindgen<'a> { local_names: LocalNames, @@ -523,7 +529,26 @@ impl<'a> Instantiator<'a, '_> { } } + // We push lower import initializers down to right before instantiate, so that the + // memory, realloc and postReturn functions are available to the import lowerings + // for optimized bindgen + let mut lower_import_initializers = Vec::new(); for init in self.component.initializers.iter() { + match init { + GlobalInitializer::InstantiateModule(_) => { + for init in lower_import_initializers.drain(..) { + self.instantiation_global_initializer(init); + } + } + GlobalInitializer::LowerImport { .. } => { + lower_import_initializers.push(init); + continue; + } + _ => {} + } + self.instantiation_global_initializer(init); + } + for init in lower_import_initializers.drain(..) { self.instantiation_global_initializer(init); } @@ -557,8 +582,23 @@ impl<'a> Instantiator<'a, '_> { for id in ids_to_ensure { self.ensure_resource_table(id); } + if self + .gen + .all_intrinsics + .contains(&Intrinsic::ResourceTransferBorrow) + || self + .gen + .all_intrinsics + .contains(&Intrinsic::ResourceTransferBorrowValidLifting) + { + let imported_resource_cnt = Intrinsic::ImportedResourceCnt.name(); + let val = self.component.imported_resources.len(); + uwrite!(self.src.js, "const {imported_resource_cnt} = {val};"); + } } + // instead of always outputting resource tables for all resources, only + // define resource tables that are explicitly used fn ensure_resource_table(&mut self, id: TypeResourceTableIndex) { let rid = id.as_u32(); if !self.resource_tables_initialized[rid as usize] { @@ -589,14 +629,11 @@ impl<'a> Instantiator<'a, '_> { let rsc_table_remove = self.gen.intrinsic(Intrinsic::ResourceTableRemove); if is_imported { - // imported resouces have both a rep table and a rep assignment - // for captured resource classes to assign them a rep numbering uwriteln!( self.src.js, "const handleTable{rid} = [{rsc_table_flag}, 0]; const captureTable{rid} = new Map(); - let captureCnt{rid} = 0; - {handle_tables}.set({rid}, {{ t: handleTable{rid}, i: captureTable{rid}.get.bind(captureTable{rid}) }});", + let captureCnt{rid} = 0;" ); } else { uwriteln!( @@ -605,10 +642,10 @@ impl<'a> Instantiator<'a, '_> { const finalizationRegistry{rid} = new FinalizationRegistry((handle) => {{ const {{ rep }} = {rsc_table_remove}(handleTable{rid}, handle);{maybe_dtor} }}); - {handle_tables}.set({rid}, {{ t: handleTable{rid}, i: null }}); ", ); } + uwriteln!(self.src.js, "{handle_tables}[{rid}] = handleTable{rid};"); self.resource_tables_initialized[rid as usize] = true; } } @@ -647,16 +684,16 @@ impl<'a> Instantiator<'a, '_> { // these are hoisted before initialization Trampoline::LowerImport { .. } => {} - // This is only used for a "degenerate component" which internally - // has a function that always traps. While this should be trivial to - // implement (generate a JS function that always throws) there's no - // way to test this at this time so leave this unimplemented. - Trampoline::AlwaysTrap => unimplemented!(), + Trampoline::AlwaysTrap => { + uwrite!( + self.src.js, + "function trampoline{i}(rep) {{ + throw new Error('AlwaysTrap'); + }} + " + ); + } - // This is required when strings pass between components within a - // component and may change encodings. This is left unimplemented - // for now since it can't be tested and additionally JS doesn't - // support multi-memory which transcoders rely on anyway. Trampoline::Transcoder { op, from, @@ -711,18 +748,20 @@ impl<'a> Instantiator<'a, '_> { Trampoline::ResourceRep(resource) => { self.ensure_resource_table(*resource); let rid = resource.as_u32(); - let rsc_table_get = self.gen.intrinsic(Intrinsic::ResourceTableGet); + let rsc_flag = self.gen.intrinsic(Intrinsic::ResourceTableFlag); uwriteln!( self.src.js, - "const trampoline{i} = {rsc_table_get}.bind(null, handleTable{rid});" + "function trampoline{i} (handle) {{ + return handleTable{rid}[(handle << 1) + 1] & ~{rsc_flag}; + }}" ); } Trampoline::ResourceDrop(resource) => { self.ensure_resource_table(*resource); let rid = resource.as_u32(); - let resource = &self.types[*resource]; + let resource_ty = &self.types[*resource]; let dtor = if let Some(resource_idx) = - self.component.defined_resource_index(resource.ty) + self.component.defined_resource_index(resource_ty.ty) { let resource_def = self .component @@ -735,28 +774,47 @@ impl<'a> Instantiator<'a, '_> { .unwrap(); if let Some(dtor) = &resource_def.dtor { - format!("{}(handleEntry.rep);", self.core_def(dtor)) + format!( + " + {}(handleEntry.rep);", + self.core_def(dtor) + ) } else { "".into() } } else { - // if there is a Symbol.dispose handler, call it explicitly for imported - // resources when the resource is dropped + // imported resource is one without a defined resource index + // if it is a captured instance (class instance was created externally so had to + // be assigned a rep), and there is a Symbol.dispose handler, call it explicitly + // for imported resources when the resource is dropped, otherwise + // if it is an instance without a captured class definition, then call the + // low-level bindgen destructor let symbol_dispose = self.gen.intrinsic(Intrinsic::SymbolDispose); + let symbol_cabi_dispose = self.gen.intrinsic(Intrinsic::SymbolCabiDispose); + + // previous imports walk should define all imported resources which are accessible + // if not, then capture / disposal paths are not possible + let imported_resource_local_name = self.gen.local_names.get(resource_ty.ty); format!( - "const rsc = captureTable{rid}.get(handleEntry.rep); - if (rsc[{symbol_dispose}]) rsc[{symbol_dispose}](); - captureTable{rid}.delete(handleEntry.rep);" + " + const rsc = captureTable{rid}.get(handleEntry.rep); + if (rsc) {{ + if (rsc[{symbol_dispose}]) rsc[{symbol_dispose}](); + captureTable{rid}.delete(handleEntry.rep); + }} else if ({imported_resource_local_name}[{symbol_cabi_dispose}]) {{ + {imported_resource_local_name}[{symbol_cabi_dispose}](handleEntry.rep); + }}" ) }; + // If the unexpected borrow handle case does ever happen in further testing, + // then we must handle this. let rsc_table_remove = self.gen.intrinsic(Intrinsic::ResourceTableRemove); uwrite!( self.src.js, "function trampoline{i}(handle) {{ const handleEntry = {rsc_table_remove}(handleTable{rid}, handle); - if (!handleEntry.own) throw new Error('Unexpected borrow handle'); - {dtor} + if (!handleEntry.own) throw new Error('Internal error: Unexpected borrow handle');{dtor} }} ", ); @@ -789,17 +847,18 @@ impl<'a> Instantiator<'a, '_> { let scope_id = self.gen.intrinsic(Intrinsic::ScopeId); let resource_borrows = self.gen.intrinsic(Intrinsic::ResourceCallBorrows); let handle_tables = self.gen.intrinsic(Intrinsic::HandleTables); - let rsc_table_try_get = self.gen.intrinsic(Intrinsic::ResourceTableCreateOwn); + // To verify that borrows are dropped, it is enough to verify that the handle + // either no longer exists (part of free list) or belongs to another scope, since + // the enter call closed off the ability to create new handles in the parent scope uwrite!( self.src.js, "function trampoline{i}() {{ - for (const {{ rid, handle, rep, scope }} of {resource_borrows}) {{ - const entry = {rsc_table_try_get}({handle_tables}.get(rid), handle); - if (entry && entry.rep === rep && entry.scope === scope) - throw new Error('borrow was not dropped for resource transfer call'); + {scope_id}--; + for (const {{ rid, handle }} of {resource_borrows}) {{ + if ({handle_tables}[rid][handle << 1] === {scope_id}) + throw new Error('borrows not dropped for resource call'); }} {resource_borrows} = []; - {scope_id}--; }} ", ); @@ -920,26 +979,37 @@ impl<'a> Instantiator<'a, '_> { let (options, trampoline, _) = self.lowering_options[index]; let (import_index, path) = &self.component.imports[import]; - let (import_name, _) = &self.component.import_types[*import_index]; + let (import_name, import_ty) = &self.component.import_types[*import_index]; let world_key = &self.imports[import_name]; // nested interfaces only currently possible through mapping let (import_specifier, maybe_iface_member) = map_import(&self.gen.opts.map, import_name); - let (func, func_name, iface_name) = + let (func, func_name, iface_name, func_ty) = match &self.resolve.worlds[self.world].imports[world_key] { WorldItem::Function(func) => { assert_eq!(path.len(), 0); - (func, import_name, None) + let TypeDef::ComponentFunc(func_ty) = import_ty else { + unreachable!() + }; + (func, import_name, None, func_ty) } WorldItem::Interface(i) => { assert_eq!(path.len(), 1); + let TypeDef::ComponentInstance(instance) = import_ty else { + unreachable!() + }; + let import_ty = &self.types[*instance]; let iface = &self.resolve.interfaces[*i]; let func = &iface.functions[&path[0]]; + let TypeDef::ComponentFunc(func_ty) = &import_ty.exports[&func.name] else { + unreachable!() + }; ( func, &path[0], Some(iface.name.as_deref().unwrap_or_else(|| import_name)), + func_ty, ) } WorldItem::Type(_) => unreachable!(), @@ -1000,24 +1070,113 @@ impl<'a> Instantiator<'a, '_> { .wasm_signature(AbiVariant::GuestImport, func) .params .len(); - - uwrite!(self.src.js, "\nfunction trampoline{}", trampoline.as_u32()); - self.bindgen( - nparams, - call_type, - if import_name.is_empty() { - None - } else { - Some(import_name) - }, - &callee_name, - options, - func, - AbiVariant::GuestImport, - false, - ); - uwriteln!(self.src.js, ""); - + match self.gen.opts.import_bindings { + None | Some(BindingsMode::Js) | Some(BindingsMode::Hybrid) => { + uwrite!(self.src.js, "\nfunction trampoline{}", trampoline.as_u32()); + self.bindgen( + nparams, + call_type, + if import_name.is_empty() { + None + } else { + Some(import_name) + }, + &callee_name, + options, + func, + AbiVariant::GuestImport, + false, + ); + uwriteln!(self.src.js, ""); + } + Some(BindingsMode::Optimized) | Some(BindingsMode::DirectOptimized) => { + uwriteln!(self.src.js, "let trampoline{};", trampoline.as_u32()); + } + }; + if !matches!(self.gen.opts.import_bindings, None | Some(BindingsMode::Js)) { + let memory = options + .memory + .map(|idx| format!(" memory: memory{},", idx.as_u32())) + .unwrap_or("".into()); + let realloc = options + .realloc + .map(|idx| format!(" realloc: realloc{},", idx.as_u32())) + .unwrap_or("".into()); + let post_return = options + .post_return + .map(|idx| format!(" postReturn: postReturn{},", idx.as_u32())) + .unwrap_or("".into()); + let string_encoding = match options.string_encoding { + component::StringEncoding::Utf8 => "", + component::StringEncoding::Utf16 => " stringEncoding: 'utf16',", + component::StringEncoding::CompactUtf16 => " stringEncoding: 'compact-utf16',", + }; + let callee_name = match func.kind { + FunctionKind::Static(_) | FunctionKind::Freestanding => callee_name.to_string(), + FunctionKind::Method(ty) => format!( + "{}.prototype.{}", + match &self.imports_resource_map[&ty].data { + ResourceData::Host { local_name, .. } => { + self.gen.esm_bindgen.ensure_import_binding(local_name); + local_name + } + ResourceData::Guest { .. } => unreachable!(), + }, + callee_name + ), + FunctionKind::Constructor(_) => callee_name[4..].to_string(), + }; + let resource_tables = { + let mut resource_tables: Vec = Vec::new(); + + let func_ty = &self.types[*func_ty]; + let params_ty = &self.types[func_ty.params]; + let results_ty = &self.types[func_ty.results]; + for iface_ty in params_ty.types.iter() { + self.collect_resource_types(iface_ty, &mut resource_tables); + } + for iface_ty in results_ty.types.iter() { + self.collect_resource_types(iface_ty, &mut resource_tables); + } + if resource_tables.len() == 0 { + "".to_string() + } else { + format!( + " resourceTables: [{}],", + resource_tables + .iter() + .map(|x| format!("handleTable{}", x.as_u32().to_string())) + .collect::>() + .join(", ") + ) + } + }; + match self.gen.opts.import_bindings { + Some(BindingsMode::Hybrid) => { + let symbol_cabi_lower = self.gen.intrinsic(Intrinsic::SymbolCabiLower); + uwriteln!(self.src.js_init, "if ({callee_name}[{symbol_cabi_lower}]) {{ + trampoline{} = {callee_name}[{symbol_cabi_lower}]({{{memory}{realloc}{post_return}{string_encoding}{resource_tables}}}); + }}", trampoline.as_u32()); + } + Some(BindingsMode::Optimized) => { + let symbol_cabi_lower = self.gen.intrinsic(Intrinsic::SymbolCabiLower); + if !self.gen.opts.valid_lifting_optimization { + uwriteln!(self.src.js_init, "if (!{callee_name}[{symbol_cabi_lower}]) {{ + throw new Error('import for \"{import_name}\" does not define a Symbol.for('cabiLower') optimized binding'); + }}"); + } + uwriteln!(self.src.js_init, "trampoline{} = {callee_name}[{symbol_cabi_lower}]({memory}{realloc}{post_return}{string_encoding}{resource_tables});", trampoline.as_u32()); + } + Some(BindingsMode::DirectOptimized) => { + uwriteln!( + self.src.js_init, + "trampoline{} = {callee_name}({memory}, {realloc}, {post_return}, {string_encoding});", + trampoline.as_u32() + ); + } + None | Some(BindingsMode::Js) => unreachable!(), + }; + } let (import_name, binding_name) = match func.kind { FunctionKind::Freestanding => (func_name.to_lower_camel_case(), callee_name), FunctionKind::Method(tid) @@ -1120,11 +1279,8 @@ impl<'a> Instantiator<'a, '_> { } let ty = &self.resolve.types[resource_id]; - let resource = ty.name.as_ref().unwrap(); + let resource_name = ty.name.as_ref().unwrap().to_upper_camel_case(); - let resource_name = resource.to_upper_camel_case(); - - // ensure imported resources are imported let local_name = if imported { let (world_key, iface_name) = match ty.owner { wit_parser::TypeOwner::World(world) => ( @@ -1156,13 +1312,7 @@ impl<'a> Instantiator<'a, '_> { }; let import_name = self.resolve.name_world_key(&world_key); - let (local_name, _) = self.gen.local_names.get_or_create( - ResourceInstance { - resource_id, - import: Some(&import_name), - }, - &resource_name, - ); + let (local_name, _) = self.gen.local_names.get_or_create(resource, &resource_name); let local_name_str = local_name.to_string(); @@ -1181,14 +1331,7 @@ impl<'a> Instantiator<'a, '_> { local_name_str } else { - let (local_name, _) = self.gen.local_names.get_or_create( - ResourceInstance { - resource_id, - import: None, - }, - &resource_name, - ); - + let (local_name, _) = self.gen.local_names.get_or_create(resource, &resource_name); local_name.to_string() }; @@ -1271,6 +1414,69 @@ impl<'a> Instantiator<'a, '_> { } } + fn collect_resource_types( + &mut self, + iface_ty: &InterfaceType, + resources: &mut Vec, + ) { + match iface_ty { + InterfaceType::Flags(_) | InterfaceType::Enum(_) => {} + InterfaceType::Record(t) => { + let t = &self.types[*t]; + for f in t.fields.iter() { + self.collect_resource_types(&f.ty, resources); + } + } + InterfaceType::Own(t) | InterfaceType::Borrow(t) => { + resources.push(*t); + } + InterfaceType::Tuple(t) => { + let t = &self.types[*t]; + for f in t.types.iter() { + self.collect_resource_types(f, resources); + } + } + InterfaceType::Variant(t) => { + let t = &self.types[*t]; + for f in t.cases.iter() { + if let Some(ty) = f.ty { + self.collect_resource_types(&ty, resources); + } + } + } + InterfaceType::Option(t) => { + let t = &self.types[*t]; + self.collect_resource_types(&t.ty, resources); + } + InterfaceType::Result(t) => { + let t = &self.types[*t]; + if let Some(ok) = &t.ok { + self.collect_resource_types(&ok, resources); + } + if let Some(err) = &t.err { + self.collect_resource_types(&err, resources); + } + } + InterfaceType::List(t) => { + let t = &self.types[*t]; + self.collect_resource_types(&t.element, resources); + } + InterfaceType::Bool + | InterfaceType::S8 + | InterfaceType::U8 + | InterfaceType::S16 + | InterfaceType::U16 + | InterfaceType::S32 + | InterfaceType::U32 + | InterfaceType::S64 + | InterfaceType::U64 + | InterfaceType::Float32 + | InterfaceType::Float64 + | InterfaceType::Char + | InterfaceType::String => {} + } + } + fn bindgen( &mut self, nparams: usize, @@ -1536,10 +1742,13 @@ impl<'a> Instantiator<'a, '_> { | FunctionKind::Method(resource_id) | FunctionKind::Static(resource_id) = func.kind { - self.gen.local_names.get(ResourceInstance { - resource_id, - import: None, - }) + let ResourceData::Host { id, .. } = + &self.exports_resource_map.get(&resource_id).unwrap().data + else { + unreachable!() + }; + let resource = self.types[*id].ty; + self.gen.local_names.get(resource) } else { self.gen.local_names.create_once(export_name) } @@ -1589,10 +1798,13 @@ impl<'a> Instantiator<'a, '_> { | FunctionKind::Method(resource_id) | FunctionKind::Static(resource_id) = func.kind { - self.gen.local_names.get(ResourceInstance { - resource_id, - import: None, - }) + let ResourceData::Host { id, .. } = + &self.exports_resource_map.get(&resource_id).unwrap().data + else { + unreachable!() + }; + let resource = self.types[*id].ty; + self.gen.local_names.get(resource) } else { self.gen.local_names.create_once(func_name) } diff --git a/docs/src/optimized-host-bindings.md b/docs/src/optimized-host-bindings.md new file mode 100644 index 000000000..a559610bb --- /dev/null +++ b/docs/src/optimized-host-bindings.md @@ -0,0 +1,134 @@ +# Host Bindings + +The default mode for host bindings in JS hosts in Jco is through the high-level JS-based bindgen. + +The benefit of this approach is that all host bindings are available as normal JS imports. For +example, JavaScript developers can directly import a function like +`import { getRandomBytes } from 'wasi:random/random'`, and directly interact with the bindings +at a high level. + +This also makes it easy to provide custom or virtual implementations for bindings using the same +host semantic conventions. + +But for performance-sensitive applications, host bindings still need to have a fast path for +optimized bindgen. + +## Using Native Host Bindings + +Given a JS host that implements such a binding, the `--import-bindings` flag may be used to customize +which host bindings mode to use: + +* The default bindgen mode is `--import-bindings=js` using high-level JS bindings for all imports. +* When generating `--import-bindings=hybrid`, Jco will still generate the high-level bindgen for all imports, but + check for a `Symbol.for('cabiLower')` and use this optimized bindgen when available on a function-by-function + basis. +* For `--import-bindings=optimized`, Jco will omit outputting the high-level JS bindgen for imports, and instead use + the low-level bindgen function directly, assuming `Symbol.for('cabiLower')` is defined on all imports. +* For `--import-bindings=direct-optimized`, instead of reading a `Symbol.for('cabiLower')`, Jco will assume that + imports are all these lower functions instead (useful in instantiatio mode). + +This scheme implies instantiation mode to provide the host bindings, or for the host to support +providing the imports as a host ESM import scheme such as `import { getRandomBytes } from 'wasi:random/random'`. + +## Optimized Host Bindings Spec + +### `fn[Symbol.for('cabiLower')](canonOpts) -> coreFn` + +A function that has a native optimized implementation, can expose its native optimized bindgen through +a `Symbol.for('cabiLower')` method, taking a `canonOpts` object. + +The following `canonOpts` fields may be defined as needed: + +* `memory`: The WebAssembly memory object for the component to which we are binding, if needed. +* `realloc`: The realloc function inside of the component we are binding, [per component model semantics](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Binary.md#canonical-definitions), if needed. +* `postReturn`: The post-return function for the call, if needed. +* `stringEncoding`: If needed, with `'utf8'` as the default. +* `resourceTables`: If needed, an ordered list of resource tables in which they uniquely appear in the +function parameters and results of type `ResourceTable[]`. + +The return value of this function is then a new function, `coreFn`, which represents an optimized +native function which can be provided as a direct core function import to the +`WebAssembly.instantiate` operation of the core binary for the component being linked, providing a +direct host-native binding to the inner core binary of the component without needing an intermediate +lowering operation in the component model semantics. + +### `ResourceTable: number[]` + +Resource handles are tracked in handle tables, a set of shared slab data structures primarily +relating handles to resource ids (reps) for the particular table. Each resource usually has a unique +handle table assign for every component it is used in. + +When handles are passed between component functions, resource state needs to be maintained between +these tables, therefore in optimized bindgen, this shared state needs to be operated on. For example, +resource creation creates an own handle in the table for that resource of the component caller, +requiring the creator to populate a table of the caller. + +In optimized bindgen, this is acheived by mutating the data structure accordingly. Great care needs +to be taken to ensure the full component model semantics are followed in this process. + +The implementation here is based on a JS array of integers. This is done instead of using typed +arrays because we need resizability without reserving a large buffer like resizable typed arrays +might for the same use case (and unless that changes in future). + +The number bits are the lowest 29 bits, while the flag bit for all data values is 1 << 30. We avoid +the use of the highest bit entirely to not trigger SMI deoptimization. + +Each entry consists of a pair of u32s, with each pair either a free list entry, or a data entry. + +#### Free List Entries: + + | index (x, u30) | ~unused~ | + |------ 32 bits ------|------ 32 bits ------| + | 01xxxxxxxxxxxxxxxxx | ################### | + +Free list entries use only the first value in the pair, with the high bit always set +to indicate that the pair is part of the free list. The first entry pair at indices +0 and 1 is the free list head, with the initial values of 1 << 30 and 0 respectively. +Removing the 1 << 30 flag gives 0, which indicates the end of the free list. + +#### Data Entries: + + | scope (x, u30) | own(o), rep(x, u30) | + |------ 32 bits ------|------ 32 bits ------| + | 00xxxxxxxxxxxxxxxxx | 0oxxxxxxxxxxxxxxxxx | + +Data entry pairs consist of a first u30 scope value and a second rep value. The field +is only called the scope for interface shape consistency, but is actually used for the +ref count for own handles and the scope id for borrow handles. The high bit is never +set for this first entry to distinguish the pair from the free list. The second value +in the pair is the rep for the resource, with the high bit in this entry indicating +if it is an own handle. + +The free list numbering and the handle numbering are the same, indexing by pair, so to +get from a handle or free list numbering to an index, we multiply by two. + +For example, to access a handle n, we read the pair of values n * 2 and n * 2 + 1 in +the array to get the context and rep respectively. If the high bit is set on the +context, we throw for an invalid handle. The rep value is masked out from the +ownership high bit, also throwing for an invalid zero rep. + +### `ResourceClass[Symbol.for('cabiDispose')](rep) -> void` + +Just like `Symbol.dispose` is used in high-level bindgen to provide a destructor for when an own +handle to a resource is dropped, low-level bindgen provides this hook through the `cabiDispose` +function. + +The `Symbol.for('cabiDispose')` function is an optional destructor which is available as a direct +static method on the imported resource class. + +Unlike the other low-level functions, this one does not need to be bound and is called directly, as +it takes the rep directly to handle internal destructor mechanisms. + +### `resourceInstance[Symbol.for('cabiRep')]` + +Normally imported resource classes do not have to define any special symbols, as they are assigned +rep numbers when passed in. + +When using hybrid or optimized bindgen, high-level functions may still return and take high-level +resource classes as parameters. For example, a resource type used optimized in import bindgen might +still be constructible elsewhere to be passed in as a parameter to an exported function of a +component attached to that optimized low-level import bindgen. + +As a result, when using low-level bindgen, any high-level resource instances MUST define a +`Symbol.for('cabiRep')` symbol in order for these resources to correctly interact with low-level +bindgen functions referring to those same resources. diff --git a/packages/preview2-shim/lib/io/calls.js b/packages/preview2-shim/lib/io/calls.js index d0e4df534..e1438cc7b 100644 --- a/packages/preview2-shim/lib/io/calls.js +++ b/packages/preview2-shim/lib/io/calls.js @@ -65,7 +65,6 @@ export const HTTP_SERVER_CLEAR_OUTGOING_RESPONSE = ++call_id << CALL_SHIFT; export const HTTP_OUTGOING_BODY_DISPOSE = ++call_id << CALL_SHIFT; // Clocks -export const CLOCKS_NOW = ++call_id << CALL_SHIFT; export const CLOCKS_DURATION_SUBSCRIBE = ++call_id << CALL_SHIFT; export const CLOCKS_INSTANT_SUBSCRIBE = ++call_id << CALL_SHIFT; diff --git a/packages/preview2-shim/lib/io/worker-io.js b/packages/preview2-shim/lib/io/worker-io.js index dace0c5b8..b886d1c7b 100644 --- a/packages/preview2-shim/lib/io/worker-io.js +++ b/packages/preview2-shim/lib/io/worker-io.js @@ -411,24 +411,19 @@ function pollableDispose(id) { ioCall(POLL_POLLABLE_DISPOSE, id); } +const rep = Symbol.for("cabiRep"); + class Pollable { - #id; #finalizer; ready() { - if (this.#id === 0) return true; - return ioCall(POLL_POLLABLE_READY, this.#id); + return ioCall(POLL_POLLABLE_READY, this[rep]); } block() { - if (this.#id !== 0) { - ioCall(POLL_POLLABLE_BLOCK, this.#id); - } - } - static _getId(pollable) { - return pollable.#id; + ioCall(POLL_POLLABLE_BLOCK, this[rep]); } static _create(id, parent) { const pollable = new Pollable(); - pollable.#id = id; + pollable[rep] = id; pollable.#finalizer = registerDispose( pollable, parent, @@ -438,26 +433,88 @@ class Pollable { return pollable; } [symbolDispose]() { - if (this.#finalizer) { + if (this.#finalizer && this[rep]) { earlyDispose(this.#finalizer); this.#finalizer = null; } } } +const cabiLowerSymbol = Symbol.for("cabiLower"); +const T_FLAG = 1 << 30; + +Pollable.prototype.ready[cabiLowerSymbol] = function ({ + resourceTables: [table], +}) { + return function pollableReady(handle) { + const rep = table[(handle << 1) + 1] & ~T_FLAG; + const ready = ioCall(POLL_POLLABLE_READY, rep); + return ready ? 1 : 0; + }; +}; + +Pollable.prototype.block[cabiLowerSymbol] = function ({ + resourceTables: [table], +}) { + return function pollableBlock(handle) { + const rep = table[(handle << 1) + 1] & ~T_FLAG; + ioCall(POLL_POLLABLE_BLOCK, rep); + }; +}; + +Pollable[Symbol.for("cabiDispose")] = function pollableDispose(rep) { + ioCall(POLL_POLLABLE_DISPOSE, rep); +}; + export const pollableCreate = Pollable._create; delete Pollable._create; -const pollableGetId = Pollable._getId; -delete Pollable._getId; - export const poll = { Pollable, poll(list) { - return ioCall(POLL_POLL_LIST, null, list.map(pollableGetId)); + return ioCall( + POLL_POLL_LIST, + null, + list.map((pollable) => pollable[rep]) + ); }, }; +poll.poll[cabiLowerSymbol] = function ({ memory, realloc, resourceTables: [table] }) { + return function pollPollList (listPtr, len, retptr) { + const handleList = new Uint32Array(memory.buffer, listPtr, len); + const repList = Array(len); + for (let i = 0; i < len; i++) { + const handle = handleList[i]; + repList[i] = table[(handle << 1) + 1] & ~T_FLAG; + } + const result = ioCall(POLL_POLL_LIST, null, repList); + const ptr = realloc(0, 0, 4, result.byteLength); + const out = new Uint32Array(memory.buffer, ptr, result.length); + out.set(result); + const ret = new Uint32Array(memory.buffer, retptr, 2); + ret[0] = ptr; + ret[1] = result.length; + return retptr; + }; +}; + export function createPoll(call, id, initPayload) { return pollableCreate(ioCall(call, id, initPayload)); } + +export function createPollLower(call, id, table) { + return function (initPayload) { + const rep = ioCall(call, id, initPayload); + const free = table[0] & ~T_FLAG; + if (free === 0) { + table.push(0); + table.push(rep | T_FLAG); + return (table.length >> 1) - 1; + } + table[0] = table[free << 1]; + table[free << 1] = 0; + table[(free << 1) + 1] = rep | T_FLAG; + return free; + }; +} diff --git a/packages/preview2-shim/lib/io/worker-thread.js b/packages/preview2-shim/lib/io/worker-thread.js index 80dc2e6a6..a736975b3 100644 --- a/packages/preview2-shim/lib/io/worker-thread.js +++ b/packages/preview2-shim/lib/io/worker-thread.js @@ -18,7 +18,6 @@ import { CALL_TYPE_MASK, CLOCKS_DURATION_SUBSCRIBE, CLOCKS_INSTANT_SUBSCRIBE, - CLOCKS_NOW, FILE, FUTURE_DISPOSE, FUTURE_SUBSCRIBE, @@ -537,8 +536,6 @@ function handle(call, id, payload) { } // Clocks - case CLOCKS_NOW: - return hrtime.bigint(); case CLOCKS_DURATION_SUBSCRIBE: payload = hrtime.bigint() + payload; // fallthrough @@ -776,7 +773,9 @@ function handle(call, id, payload) { pollStateCheck(pollState); if (pollState.ready) doneList.push(idx); } - if (doneList.length > 0) return new Uint32Array(doneList); + if (doneList.length > 0) { + return new Uint32Array(doneList); + } let readyPromiseResolve; const readyPromise = new Promise( (resolve) => void (readyPromiseResolve = resolve) diff --git a/packages/preview2-shim/lib/nodejs/clocks.js b/packages/preview2-shim/lib/nodejs/clocks.js index a676b2546..1aad968f1 100644 --- a/packages/preview2-shim/lib/nodejs/clocks.js +++ b/packages/preview2-shim/lib/nodejs/clocks.js @@ -1,16 +1,20 @@ -import { ioCall, createPoll } from "../io/worker-io.js"; +import { createPoll } from "../io/worker-io.js"; import { - CLOCKS_NOW, CLOCKS_INSTANT_SUBSCRIBE, CLOCKS_DURATION_SUBSCRIBE, } from "../io/calls.js"; +import { hrtime } from "node:process"; + +const symbolCabiLower = Symbol.for("cabiLower"); + +function resolution() { + return 1n; +} export const monotonicClock = { - resolution() { - return 1n; - }, + resolution, now() { - return ioCall(CLOCKS_NOW, null, null); + return hrtime.bigint(); }, subscribeInstant(instant) { return createPoll(CLOCKS_INSTANT_SUBSCRIBE, null, instant); @@ -22,12 +26,39 @@ export const monotonicClock = { }; export const wallClock = { + resolution() { + return { seconds: 0n, nanoseconds: 1e6 }; + }, now() { const seconds = BigInt(Math.floor(Date.now() / 1e3)); const nanoseconds = (Date.now() % 1e3) * 1e6; return { seconds, nanoseconds }; }, - resolution() { - return { seconds: 0n, nanoseconds: 1e6 }; - }, +}; + +monotonicClock.resolution[symbolCabiLower] = () => resolution; +monotonicClock.now[symbolCabiLower] = () => hrtime.bigint; +wallClock.resolution[symbolCabiLower] = (memory) => { + let buf32 = new Int32Array(memory.buffer); + return function now(retptr) { + if (memory.buffer !== buf32.buffer) buf32 = new Int32Array(memory.buffer); + if (retptr % 4) throw new Error('wasi-io trap: retptr not aligned'); + buf32[(retptr >> 2) + 0] = 0; + buf32[(retptr >> 2) + 4] = 0; + buf32[(retptr >> 2) + 8] = 1_000_000; + }; +}; + +wallClock.now[symbolCabiLower] = (memory) => { + let buf32 = new Int32Array(memory.buffer); + let buf64 = new BigInt64Array(memory.buffer); + return function now(retptr) { + if (memory.buffer !== buf32.buffer) { + buf32 = new Int32Array(memory.buffer); + buf64 = new BigInt64Array(memory.buffer); + } + if (retptr % 4) throw new Error('wasi-io trap: retptr not aligned'); + buf64[(retptr >> 2) + 0] = BigInt(Math.floor(Date.now() / 1e3)); + buf32[(retptr >> 2) + 8] = (Date.now() % 1e3) * 1e6; + }; }; diff --git a/packages/preview2-shim/lib/nodejs/filesystem.js b/packages/preview2-shim/lib/nodejs/filesystem.js index bf9004cb7..b52870561 100644 --- a/packages/preview2-shim/lib/nodejs/filesystem.js +++ b/packages/preview2-shim/lib/nodejs/filesystem.js @@ -152,6 +152,8 @@ class Descriptor { try { ftruncateSync(this.#fd, Number(size)); } catch (e) { + if (isWindows && e.code === 'EPERM') + throw 'access'; throw convertFsError(e); } } @@ -325,13 +327,14 @@ class Descriptor { } openAt(pathFlags, path, openFlags, descriptorFlags) { + if (preopenEntries.length === 0) + throw "access"; const fullPath = this.#getFullPath(path, pathFlags.symlinkFollow); let fsOpenFlags = 0x0; if (openFlags.create) fsOpenFlags |= constants.O_CREAT; if (openFlags.directory) fsOpenFlags |= constants.O_DIRECTORY; if (openFlags.exclusive) fsOpenFlags |= constants.O_EXCL; if (openFlags.truncate) fsOpenFlags |= constants.O_TRUNC; - if (descriptorFlags.read && descriptorFlags.write) fsOpenFlags |= constants.O_RDWR; else if (descriptorFlags.write) fsOpenFlags |= constants.O_WRONLY; diff --git a/packages/preview2-shim/lib/nodejs/http.js b/packages/preview2-shim/lib/nodejs/http.js index 5d24bc9ac..00344c4c5 100644 --- a/packages/preview2-shim/lib/nodejs/http.js +++ b/packages/preview2-shim/lib/nodejs/http.js @@ -27,7 +27,7 @@ import * as http from "node:http"; const { validateHeaderName = () => {}, validateHeaderValue = () => {} } = http; const symbolDispose = Symbol.dispose || Symbol.for("dispose"); -export const _forbiddenHeaders = new Set(["connection", "keep-alive"]); +export const _forbiddenHeaders = new Set(["connection", "keep-alive", "host"]); class IncomingBody { #finished = false; diff --git a/packages/preview2-shim/lib/nodejs/random.js b/packages/preview2-shim/lib/nodejs/random.js index 5a89452ac..b43f6e0cd 100644 --- a/packages/preview2-shim/lib/nodejs/random.js +++ b/packages/preview2-shim/lib/nodejs/random.js @@ -1,32 +1,45 @@ -import { randomBytes } from "node:crypto"; +import { randomBytes, randomFillSync } from "node:crypto"; export const insecure = { - getInsecureRandomBytes (len) { - return randomBytes(Number(len)); - }, - getInsecureRandomU64 () { + getInsecureRandomBytes: getRandomBytes, + getInsecureRandomU64() { return new BigUint64Array(randomBytes(8).buffer)[0]; - } + }, }; let insecureSeedValue1, insecureSeedValue2; export const insecureSeed = { - insecureSeed () { + insecureSeed() { if (insecureSeedValue1 === undefined) { insecureSeedValue1 = random.getRandomU64(); insecureSeedValue2 = random.getRandomU64(); } return [insecureSeedValue1, insecureSeedValue2]; - } + }, }; export const random = { - getRandomBytes(len) { - return randomBytes(Number(len)); - }, + getRandomBytes, - getRandomU64 () { + getRandomU64() { return new BigUint64Array(randomBytes(8).buffer)[0]; - } + }, +}; + +function getRandomBytes(len) { + return randomBytes(Number(len)); +} + +randomBytes[Symbol.for("cabiLower")] = ({ memory, realloc }) => { + let buf32 = new Uint32Array(memory.buffer); + return function randomBytes(len, retptr) { + len = Number(len); + const ptr = realloc(0, 0, 1, len); + randomFillSync(memory.buffer, ptr, len); + if (memory.buffer !== buf32.buffer) buf32 = new Uint32Array(memory.buffer); + if (retptr % 4) throw new Error('wasi-io trap: retptr not aligned'); + buf32[retptr >> 2] = ptr; + buf32[(retptr >> 2) + 1] = len; + }; }; diff --git a/src/cmd/run.js b/src/cmd/run.js index e571bfb4c..a6db7caee 100644 --- a/src/cmd/run.js +++ b/src/cmd/run.js @@ -75,7 +75,8 @@ async function runComponent (componentPath, args, opts, executor) { wasiShim: true, outDir, tracing: opts.jcoTrace, - map: opts.jcoMap + map: opts.jcoMap, + importBindings: opts.jcoImportBindings, }); } catch (e) { diff --git a/src/cmd/transpile.js b/src/cmd/transpile.js index 9a83a88ed..1cc9a3967 100644 --- a/src/cmd/transpile.js +++ b/src/cmd/transpile.js @@ -80,6 +80,7 @@ async function wasm2Js (source) { * @param {{ * name: string, * instantiation?: 'async' | 'sync', + * importBindings?: 'js' | 'optimized', 'hybrid', 'direct-optimized', * map?: Record, * validLiftingOptimization?: bool, * tracing?: bool, @@ -133,6 +134,7 @@ export async function transpileComponent (component, opts = {}) { name: opts.name ?? 'component', map: Object.entries(opts.map ?? {}), instantiation, + importBindings: opts.importBindings ? { tag: opts.importBindings } : null, validLiftingOptimization: opts.validLiftingOptimization ?? false, tracing: opts.tracing ?? false, noNodejsCompat: opts.nodejsCompat === false, diff --git a/src/jco.js b/src/jco.js index ee491d219..6633ec5fe 100755 --- a/src/jco.js +++ b/src/jco.js @@ -38,6 +38,7 @@ program.command('transpile') .option('-O, --optimize', 'optimize the component first') .option('--no-typescript', 'do not output TypeScript .d.ts types') .option('--valid-lifting-optimization', 'optimize component binary validations assuming all lifted values are valid') + .addOption(new Option('--import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js')) .option('--tracing', 'emit `tracing` calls on function entry/exit') .option('-b, --base64-cutoff ', 'set the byte size under which core Wasm binaries will be inlined as base64', myParseInt) .option('--tla-compat', 'enables compatibility for JS environments without top-level await support via an async $init promise export') @@ -64,6 +65,7 @@ program.command('run') .option('--jco-trace', 'Enable call tracing') .option('--jco-import ', 'Custom module to import before the run executes to support custom environment setup') .option('--jco-map ', 'specifier=./output custom mappings for the component imports') + .addOption(new Option('--jco-import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js')) .argument('[args...]', 'Any CLI arguments for the component') .action(asyncAction(async function run (cmd, args, opts, command) { // specially only allow help option in first position @@ -86,6 +88,7 @@ program.command('serve') .option('--jco-dir ', 'Instead of using a temporary dir, set the output directory for the transpiled code') .option('--jco-trace', 'Enable call tracing') .option('--jco-import ', 'Custom module to import before the server executes to support custom environment setup') + .addOption(new Option('--jco-import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js')) .option('--jco-map ', 'specifier=./output custom mappings for the component imports') .argument('[args...]', 'Any CLI arguments for the component') .action(asyncAction(async function serve (cmd, args, opts, command) { diff --git a/submodules/wasmtime b/submodules/wasmtime index b73b18caf..aa9e7f611 160000 --- a/submodules/wasmtime +++ b/submodules/wasmtime @@ -1 +1 @@ -Subproject commit b73b18caff267ab17b912f114278899cfa768f82 +Subproject commit aa9e7f611f7c8457996c566f42222fec763db315 diff --git a/tests/gen/api_proxy.component.wasm b/tests/gen/api_proxy.component.wasm index 0a98fd4c5..de38604d9 100644 Binary files a/tests/gen/api_proxy.component.wasm and b/tests/gen/api_proxy.component.wasm differ diff --git a/tests/gen/api_proxy_streaming.component.wasm b/tests/gen/api_proxy_streaming.component.wasm index 67054e452..7f3cf7e42 100644 Binary files a/tests/gen/api_proxy_streaming.component.wasm and b/tests/gen/api_proxy_streaming.component.wasm differ diff --git a/tests/gen/api_reactor.component.wasm b/tests/gen/api_reactor.component.wasm index 4bd4b6dae..a11d71a7a 100644 Binary files a/tests/gen/api_reactor.component.wasm and b/tests/gen/api_reactor.component.wasm differ diff --git a/tests/gen/api_reactor.rs b/tests/gen/api_reactor.rs index d6c31c6e4..8ef569480 100644 --- a/tests/gen/api_reactor.rs +++ b/tests/gen/api_reactor.rs @@ -16,6 +16,8 @@ fn api_reactor() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/api_reactor"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/api_read_only.component.wasm b/tests/gen/api_read_only.component.wasm index e87b5d646..f954dedb0 100644 Binary files a/tests/gen/api_read_only.component.wasm and b/tests/gen/api_read_only.component.wasm differ diff --git a/tests/gen/api_read_only.rs b/tests/gen/api_read_only.rs index 39a98ecc4..daecbe9ee 100644 --- a/tests/gen/api_read_only.rs +++ b/tests/gen/api_read_only.rs @@ -17,6 +17,8 @@ fn api_read_only() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/api_read_only"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/readonly.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/api_time.component.wasm b/tests/gen/api_time.component.wasm index 9be1f2332..9b1b52308 100644 Binary files a/tests/gen/api_time.component.wasm and b/tests/gen/api_time.component.wasm differ diff --git a/tests/gen/api_time.rs b/tests/gen/api_time.rs index bdd02e33e..bc0e2ff19 100644 --- a/tests/gen/api_time.rs +++ b/tests/gen/api_time.rs @@ -16,6 +16,8 @@ fn api_time() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/api_time"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/fakeclocks.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_args.component.wasm b/tests/gen/cli_args.component.wasm index 91a222bf3..4d52961fd 100644 Binary files a/tests/gen/cli_args.component.wasm and b/tests/gen/cli_args.component.wasm differ diff --git a/tests/gen/cli_args.rs b/tests/gen/cli_args.rs index 0125c00b9..dc6f91fde 100644 --- a/tests/gen/cli_args.rs +++ b/tests/gen/cli_args.rs @@ -16,6 +16,8 @@ fn cli_args() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_args"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_default_clocks.component.wasm b/tests/gen/cli_default_clocks.component.wasm index 6dc4f81f3..de47e266d 100644 Binary files a/tests/gen/cli_default_clocks.component.wasm and b/tests/gen/cli_default_clocks.component.wasm differ diff --git a/tests/gen/cli_default_clocks.rs b/tests/gen/cli_default_clocks.rs index 5f292ce1a..505af4a81 100644 --- a/tests/gen/cli_default_clocks.rs +++ b/tests/gen/cli_default_clocks.rs @@ -16,6 +16,8 @@ fn cli_default_clocks() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_default_clocks"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_directory_list.component.wasm b/tests/gen/cli_directory_list.component.wasm index ae837e833..7d38f7a9b 100644 Binary files a/tests/gen/cli_directory_list.component.wasm and b/tests/gen/cli_directory_list.component.wasm differ diff --git a/tests/gen/cli_directory_list.rs b/tests/gen/cli_directory_list.rs index 6405f2ac8..6b0a6b031 100644 --- a/tests/gen/cli_directory_list.rs +++ b/tests/gen/cli_directory_list.rs @@ -16,6 +16,8 @@ fn cli_directory_list() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_directory_list"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_env.component.wasm b/tests/gen/cli_env.component.wasm index cd6880900..96cdccb64 100644 Binary files a/tests/gen/cli_env.component.wasm and b/tests/gen/cli_env.component.wasm differ diff --git a/tests/gen/cli_env.rs b/tests/gen/cli_env.rs index aca8dff2c..cb1bf0d96 100644 --- a/tests/gen/cli_env.rs +++ b/tests/gen/cli_env.rs @@ -16,6 +16,8 @@ fn cli_env() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_env"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/envtest.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_exit_default.component.wasm b/tests/gen/cli_exit_default.component.wasm index 3adb5603b..ace217206 100644 Binary files a/tests/gen/cli_exit_default.component.wasm and b/tests/gen/cli_exit_default.component.wasm differ diff --git a/tests/gen/cli_exit_default.rs b/tests/gen/cli_exit_default.rs index 4e2b796ea..0d7717be0 100644 --- a/tests/gen/cli_exit_default.rs +++ b/tests/gen/cli_exit_default.rs @@ -16,6 +16,8 @@ fn cli_exit_default() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_exit_default"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_exit_failure.component.wasm b/tests/gen/cli_exit_failure.component.wasm index 6a7e7c3e9..515c387df 100644 Binary files a/tests/gen/cli_exit_failure.component.wasm and b/tests/gen/cli_exit_failure.component.wasm differ diff --git a/tests/gen/cli_exit_failure.rs b/tests/gen/cli_exit_failure.rs index 5594bc945..e5becb64e 100644 --- a/tests/gen/cli_exit_failure.rs +++ b/tests/gen/cli_exit_failure.rs @@ -16,6 +16,8 @@ fn cli_exit_failure() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_exit_failure"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_exit_panic.component.wasm b/tests/gen/cli_exit_panic.component.wasm index f2009c3eb..b26335a35 100644 Binary files a/tests/gen/cli_exit_panic.component.wasm and b/tests/gen/cli_exit_panic.component.wasm differ diff --git a/tests/gen/cli_exit_panic.rs b/tests/gen/cli_exit_panic.rs index 0aac8afbe..3289cef95 100644 --- a/tests/gen/cli_exit_panic.rs +++ b/tests/gen/cli_exit_panic.rs @@ -16,6 +16,8 @@ fn cli_exit_panic() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_exit_panic"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_exit_success.component.wasm b/tests/gen/cli_exit_success.component.wasm index 29b932956..59dc338ec 100644 Binary files a/tests/gen/cli_exit_success.component.wasm and b/tests/gen/cli_exit_success.component.wasm differ diff --git a/tests/gen/cli_exit_success.rs b/tests/gen/cli_exit_success.rs index 305019780..9252aeba7 100644 --- a/tests/gen/cli_exit_success.rs +++ b/tests/gen/cli_exit_success.rs @@ -16,6 +16,8 @@ fn cli_exit_success() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_exit_success"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_export_cabi_realloc.component.wasm b/tests/gen/cli_export_cabi_realloc.component.wasm index e8f53acf8..a189e7f23 100644 Binary files a/tests/gen/cli_export_cabi_realloc.component.wasm and b/tests/gen/cli_export_cabi_realloc.component.wasm differ diff --git a/tests/gen/cli_export_cabi_realloc.rs b/tests/gen/cli_export_cabi_realloc.rs index 6e939f1bf..b843edbd0 100644 --- a/tests/gen/cli_export_cabi_realloc.rs +++ b/tests/gen/cli_export_cabi_realloc.rs @@ -16,6 +16,8 @@ fn cli_export_cabi_realloc() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_export_cabi_realloc"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_file_append.component.wasm b/tests/gen/cli_file_append.component.wasm index 5a2793c90..5da3cc8a6 100644 Binary files a/tests/gen/cli_file_append.component.wasm and b/tests/gen/cli_file_append.component.wasm differ diff --git a/tests/gen/cli_file_append.rs b/tests/gen/cli_file_append.rs index a02f037d4..ae98768ea 100644 --- a/tests/gen/cli_file_append.rs +++ b/tests/gen/cli_file_append.rs @@ -16,6 +16,8 @@ fn cli_file_append() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_file_append"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/bar-jabberwock.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_file_dir_sync.component.wasm b/tests/gen/cli_file_dir_sync.component.wasm index 256357430..aadd78184 100644 Binary files a/tests/gen/cli_file_dir_sync.component.wasm and b/tests/gen/cli_file_dir_sync.component.wasm differ diff --git a/tests/gen/cli_file_dir_sync.rs b/tests/gen/cli_file_dir_sync.rs index a5613d4de..d025360a6 100644 --- a/tests/gen/cli_file_dir_sync.rs +++ b/tests/gen/cli_file_dir_sync.rs @@ -16,6 +16,8 @@ fn cli_file_dir_sync() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_file_dir_sync"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_file_read.component.wasm b/tests/gen/cli_file_read.component.wasm index 359430fcb..286bbdb9e 100644 Binary files a/tests/gen/cli_file_read.component.wasm and b/tests/gen/cli_file_read.component.wasm differ diff --git a/tests/gen/cli_file_read.rs b/tests/gen/cli_file_read.rs index acacc16a3..e30e718e1 100644 --- a/tests/gen/cli_file_read.rs +++ b/tests/gen/cli_file_read.rs @@ -16,6 +16,8 @@ fn cli_file_read() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_file_read"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_hello_stdout.component.wasm b/tests/gen/cli_hello_stdout.component.wasm index 4df114a16..62a6e7fb1 100644 Binary files a/tests/gen/cli_hello_stdout.component.wasm and b/tests/gen/cli_hello_stdout.component.wasm differ diff --git a/tests/gen/cli_hello_stdout.rs b/tests/gen/cli_hello_stdout.rs index 697f4830a..3506631bb 100644 --- a/tests/gen/cli_hello_stdout.rs +++ b/tests/gen/cli_hello_stdout.rs @@ -16,6 +16,8 @@ fn cli_hello_stdout() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_hello_stdout"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_no_ip_name_lookup.component.wasm b/tests/gen/cli_no_ip_name_lookup.component.wasm index 7f0e93246..2c590c6dc 100644 Binary files a/tests/gen/cli_no_ip_name_lookup.component.wasm and b/tests/gen/cli_no_ip_name_lookup.component.wasm differ diff --git a/tests/gen/cli_no_ip_name_lookup.rs b/tests/gen/cli_no_ip_name_lookup.rs index 2562f2bad..2b78d4baf 100644 --- a/tests/gen/cli_no_ip_name_lookup.rs +++ b/tests/gen/cli_no_ip_name_lookup.rs @@ -16,6 +16,8 @@ fn cli_no_ip_name_lookup() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_no_ip_name_lookup"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/deny-dns.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_no_tcp.component.wasm b/tests/gen/cli_no_tcp.component.wasm index 8bafe905a..9dacd3c79 100644 Binary files a/tests/gen/cli_no_tcp.component.wasm and b/tests/gen/cli_no_tcp.component.wasm differ diff --git a/tests/gen/cli_no_tcp.rs b/tests/gen/cli_no_tcp.rs index 4d5749670..daf80d8ee 100644 --- a/tests/gen/cli_no_tcp.rs +++ b/tests/gen/cli_no_tcp.rs @@ -16,6 +16,8 @@ fn cli_no_tcp() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_no_tcp"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/deny-tcp.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_no_udp.component.wasm b/tests/gen/cli_no_udp.component.wasm index 68b58c969..5b90a7e0a 100644 Binary files a/tests/gen/cli_no_udp.component.wasm and b/tests/gen/cli_no_udp.component.wasm differ diff --git a/tests/gen/cli_no_udp.rs b/tests/gen/cli_no_udp.rs index 74eeb9c60..b34f90a55 100644 --- a/tests/gen/cli_no_udp.rs +++ b/tests/gen/cli_no_udp.rs @@ -16,6 +16,8 @@ fn cli_no_udp() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_no_udp"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/deny-udp.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_splice_stdin.component.wasm b/tests/gen/cli_splice_stdin.component.wasm index a903b61c2..1648d4d0e 100644 Binary files a/tests/gen/cli_splice_stdin.component.wasm and b/tests/gen/cli_splice_stdin.component.wasm differ diff --git a/tests/gen/cli_splice_stdin.rs b/tests/gen/cli_splice_stdin.rs index 7b79b5ad9..d0ff01270 100644 --- a/tests/gen/cli_splice_stdin.rs +++ b/tests/gen/cli_splice_stdin.rs @@ -16,6 +16,8 @@ fn cli_splice_stdin() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_splice_stdin"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/cli_stdin.component.wasm b/tests/gen/cli_stdin.component.wasm index fe734d51e..c32c4a553 100644 Binary files a/tests/gen/cli_stdin.component.wasm and b/tests/gen/cli_stdin.component.wasm differ diff --git a/tests/gen/cli_stdin.rs b/tests/gen/cli_stdin.rs index 0e20d3359..7ef5a1dec 100644 --- a/tests/gen/cli_stdin.rs +++ b/tests/gen/cli_stdin.rs @@ -17,6 +17,8 @@ fn cli_stdin() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_stdin"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::piped()); diff --git a/tests/gen/cli_stdio_write_flushes.component.wasm b/tests/gen/cli_stdio_write_flushes.component.wasm index fe1d3c362..834c9c635 100644 Binary files a/tests/gen/cli_stdio_write_flushes.component.wasm and b/tests/gen/cli_stdio_write_flushes.component.wasm differ diff --git a/tests/gen/cli_stdio_write_flushes.rs b/tests/gen/cli_stdio_write_flushes.rs index b01dcdbb3..f8a5295cd 100644 --- a/tests/gen/cli_stdio_write_flushes.rs +++ b/tests/gen/cli_stdio_write_flushes.rs @@ -16,6 +16,8 @@ fn cli_stdio_write_flushes() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/cli_stdio_write_flushes"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_api_reactor.rs b/tests/gen/deno_api_reactor.rs index 01dbcd905..b502f0b85 100644 --- a/tests/gen/deno_api_reactor.rs +++ b/tests/gen/deno_api_reactor.rs @@ -18,6 +18,8 @@ fn api_reactor() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_api_reactor"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_api_time.rs b/tests/gen/deno_api_time.rs index b28190f44..6fbc7cf69 100644 --- a/tests/gen/deno_api_time.rs +++ b/tests/gen/deno_api_time.rs @@ -18,6 +18,8 @@ fn api_time() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_api_time"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/fakeclocks.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_cli_args.rs b/tests/gen/deno_cli_args.rs index 582927346..9c8afc621 100644 --- a/tests/gen/deno_cli_args.rs +++ b/tests/gen/deno_cli_args.rs @@ -18,6 +18,8 @@ fn cli_args() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_cli_args"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_cli_env.rs b/tests/gen/deno_cli_env.rs index de88fabc2..76555a2fd 100644 --- a/tests/gen/deno_cli_env.rs +++ b/tests/gen/deno_cli_env.rs @@ -18,6 +18,8 @@ fn cli_env() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_cli_env"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/envtest.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_cli_exit_default.rs b/tests/gen/deno_cli_exit_default.rs index d87c8a038..53e85bf7e 100644 --- a/tests/gen/deno_cli_exit_default.rs +++ b/tests/gen/deno_cli_exit_default.rs @@ -18,6 +18,8 @@ fn cli_exit_default() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_cli_exit_default"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_cli_exit_failure.rs b/tests/gen/deno_cli_exit_failure.rs index 7cc459a70..f85ef630b 100644 --- a/tests/gen/deno_cli_exit_failure.rs +++ b/tests/gen/deno_cli_exit_failure.rs @@ -18,6 +18,8 @@ fn cli_exit_failure() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_cli_exit_failure"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_cli_exit_success.rs b/tests/gen/deno_cli_exit_success.rs index 19f5e77d3..8c7256d6e 100644 --- a/tests/gen/deno_cli_exit_success.rs +++ b/tests/gen/deno_cli_exit_success.rs @@ -18,6 +18,8 @@ fn cli_exit_success() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_cli_exit_success"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_preview1_big_random_buf.rs b/tests/gen/deno_preview1_big_random_buf.rs index 1abc313d1..fce745f68 100644 --- a/tests/gen/deno_preview1_big_random_buf.rs +++ b/tests/gen/deno_preview1_big_random_buf.rs @@ -18,6 +18,8 @@ fn preview1_big_random_buf() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_preview1_big_random_buf"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/deno_preview2_random.rs b/tests/gen/deno_preview2_random.rs index c2c1ddb75..edace7b78 100644 --- a/tests/gen/deno_preview2_random.rs +++ b/tests/gen/deno_preview2_random.rs @@ -18,6 +18,8 @@ fn preview2_random() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/deno_preview2_random"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_content_length.component.wasm b/tests/gen/http_outbound_request_content_length.component.wasm index 8230b1126..795ceb387 100644 Binary files a/tests/gen/http_outbound_request_content_length.component.wasm and b/tests/gen/http_outbound_request_content_length.component.wasm differ diff --git a/tests/gen/http_outbound_request_content_length.rs b/tests/gen/http_outbound_request_content_length.rs index f6f4a40e7..4c47b3324 100644 --- a/tests/gen/http_outbound_request_content_length.rs +++ b/tests/gen/http_outbound_request_content_length.rs @@ -16,6 +16,8 @@ fn http_outbound_request_content_length() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_content_length"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_get.component.wasm b/tests/gen/http_outbound_request_get.component.wasm index 1146bdb85..43bbbba25 100644 Binary files a/tests/gen/http_outbound_request_get.component.wasm and b/tests/gen/http_outbound_request_get.component.wasm differ diff --git a/tests/gen/http_outbound_request_get.rs b/tests/gen/http_outbound_request_get.rs index d945eee27..281b0e268 100644 --- a/tests/gen/http_outbound_request_get.rs +++ b/tests/gen/http_outbound_request_get.rs @@ -16,6 +16,8 @@ fn http_outbound_request_get() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_get"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_invalid_dnsname.component.wasm b/tests/gen/http_outbound_request_invalid_dnsname.component.wasm index 80914663f..ccd3e46e3 100644 Binary files a/tests/gen/http_outbound_request_invalid_dnsname.component.wasm and b/tests/gen/http_outbound_request_invalid_dnsname.component.wasm differ diff --git a/tests/gen/http_outbound_request_invalid_dnsname.rs b/tests/gen/http_outbound_request_invalid_dnsname.rs index 18e6bbb74..96e4b0b8c 100644 --- a/tests/gen/http_outbound_request_invalid_dnsname.rs +++ b/tests/gen/http_outbound_request_invalid_dnsname.rs @@ -16,6 +16,8 @@ fn http_outbound_request_invalid_dnsname() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_invalid_dnsname"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_invalid_header.component.wasm b/tests/gen/http_outbound_request_invalid_header.component.wasm index afd86a033..560daa0de 100644 Binary files a/tests/gen/http_outbound_request_invalid_header.component.wasm and b/tests/gen/http_outbound_request_invalid_header.component.wasm differ diff --git a/tests/gen/http_outbound_request_invalid_header.rs b/tests/gen/http_outbound_request_invalid_header.rs index a8ff438fa..9d36add11 100644 --- a/tests/gen/http_outbound_request_invalid_header.rs +++ b/tests/gen/http_outbound_request_invalid_header.rs @@ -16,6 +16,8 @@ fn http_outbound_request_invalid_header() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_invalid_header"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_invalid_port.component.wasm b/tests/gen/http_outbound_request_invalid_port.component.wasm index 01888f80b..4771a274c 100644 Binary files a/tests/gen/http_outbound_request_invalid_port.component.wasm and b/tests/gen/http_outbound_request_invalid_port.component.wasm differ diff --git a/tests/gen/http_outbound_request_invalid_port.rs b/tests/gen/http_outbound_request_invalid_port.rs index 9dd4d63c6..ec99d348f 100644 --- a/tests/gen/http_outbound_request_invalid_port.rs +++ b/tests/gen/http_outbound_request_invalid_port.rs @@ -16,6 +16,8 @@ fn http_outbound_request_invalid_port() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_invalid_port"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_invalid_version.component.wasm b/tests/gen/http_outbound_request_invalid_version.component.wasm index 312ab0423..cd30ad714 100644 Binary files a/tests/gen/http_outbound_request_invalid_version.component.wasm and b/tests/gen/http_outbound_request_invalid_version.component.wasm differ diff --git a/tests/gen/http_outbound_request_invalid_version.rs b/tests/gen/http_outbound_request_invalid_version.rs index 2540cb15c..44746b267 100644 --- a/tests/gen/http_outbound_request_invalid_version.rs +++ b/tests/gen/http_outbound_request_invalid_version.rs @@ -16,6 +16,8 @@ fn http_outbound_request_invalid_version() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_invalid_version"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_large_post.component.wasm b/tests/gen/http_outbound_request_large_post.component.wasm index 2e5b7b675..bcda7b518 100644 Binary files a/tests/gen/http_outbound_request_large_post.component.wasm and b/tests/gen/http_outbound_request_large_post.component.wasm differ diff --git a/tests/gen/http_outbound_request_large_post.rs b/tests/gen/http_outbound_request_large_post.rs index 288f14d1d..d12498299 100644 --- a/tests/gen/http_outbound_request_large_post.rs +++ b/tests/gen/http_outbound_request_large_post.rs @@ -16,6 +16,8 @@ fn http_outbound_request_large_post() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_large_post"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_post.component.wasm b/tests/gen/http_outbound_request_post.component.wasm index 08f95520d..0fa18bb79 100644 Binary files a/tests/gen/http_outbound_request_post.component.wasm and b/tests/gen/http_outbound_request_post.component.wasm differ diff --git a/tests/gen/http_outbound_request_post.rs b/tests/gen/http_outbound_request_post.rs index aa68ecaa6..9d2f4cd0b 100644 --- a/tests/gen/http_outbound_request_post.rs +++ b/tests/gen/http_outbound_request_post.rs @@ -16,6 +16,8 @@ fn http_outbound_request_post() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_post"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_put.component.wasm b/tests/gen/http_outbound_request_put.component.wasm index 2c8a0c8fb..9e5f65644 100644 Binary files a/tests/gen/http_outbound_request_put.component.wasm and b/tests/gen/http_outbound_request_put.component.wasm differ diff --git a/tests/gen/http_outbound_request_put.rs b/tests/gen/http_outbound_request_put.rs index 3cb10a017..d5091b55a 100644 --- a/tests/gen/http_outbound_request_put.rs +++ b/tests/gen/http_outbound_request_put.rs @@ -16,6 +16,8 @@ fn http_outbound_request_put() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_put"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_response_build.component.wasm b/tests/gen/http_outbound_request_response_build.component.wasm index 9119ee36f..844a70799 100644 Binary files a/tests/gen/http_outbound_request_response_build.component.wasm and b/tests/gen/http_outbound_request_response_build.component.wasm differ diff --git a/tests/gen/http_outbound_request_response_build.rs b/tests/gen/http_outbound_request_response_build.rs index 023ba16fd..0b9087fcd 100644 --- a/tests/gen/http_outbound_request_response_build.rs +++ b/tests/gen/http_outbound_request_response_build.rs @@ -16,6 +16,8 @@ fn http_outbound_request_response_build() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_response_build"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_unknown_method.component.wasm b/tests/gen/http_outbound_request_unknown_method.component.wasm index 4ff20b502..ca0dfdbd4 100644 Binary files a/tests/gen/http_outbound_request_unknown_method.component.wasm and b/tests/gen/http_outbound_request_unknown_method.component.wasm differ diff --git a/tests/gen/http_outbound_request_unknown_method.rs b/tests/gen/http_outbound_request_unknown_method.rs index 285febfa1..b16e18dc1 100644 --- a/tests/gen/http_outbound_request_unknown_method.rs +++ b/tests/gen/http_outbound_request_unknown_method.rs @@ -16,6 +16,8 @@ fn http_outbound_request_unknown_method() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_unknown_method"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/http_outbound_request_unsupported_scheme.component.wasm b/tests/gen/http_outbound_request_unsupported_scheme.component.wasm index 0a8ee6885..e670b4149 100644 Binary files a/tests/gen/http_outbound_request_unsupported_scheme.component.wasm and b/tests/gen/http_outbound_request_unsupported_scheme.component.wasm differ diff --git a/tests/gen/http_outbound_request_unsupported_scheme.rs b/tests/gen/http_outbound_request_unsupported_scheme.rs index 230e165d2..17af97930 100644 --- a/tests/gen/http_outbound_request_unsupported_scheme.rs +++ b/tests/gen/http_outbound_request_unsupported_scheme.rs @@ -16,6 +16,8 @@ fn http_outbound_request_unsupported_scheme() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/http_outbound_request_unsupported_scheme"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/http.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/mod.rs b/tests/gen/mod.rs index 83f00a005..c8e540274 100644 --- a/tests/gen/mod.rs +++ b/tests/gen/mod.rs @@ -96,6 +96,8 @@ mod preview1_unicode_output; mod preview1_unlink_file_trailing_slashes; mod preview2_adapter_badfd; mod preview2_ip_name_lookup; +mod preview2_pollable_correct; +mod preview2_pollable_traps; mod preview2_random; mod preview2_sleep; mod preview2_stream_pollable_correct; diff --git a/tests/gen/piped_multiple.component.wasm b/tests/gen/piped_multiple.component.wasm index 2592779d4..4e75645d3 100644 Binary files a/tests/gen/piped_multiple.component.wasm and b/tests/gen/piped_multiple.component.wasm differ diff --git a/tests/gen/piped_multiple.rs b/tests/gen/piped_multiple.rs index afc87eb2b..e5a020718 100644 --- a/tests/gen/piped_multiple.rs +++ b/tests/gen/piped_multiple.rs @@ -16,6 +16,8 @@ fn piped_multiple() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/piped_multiple"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/piped.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); @@ -28,6 +30,8 @@ fn piped_multiple() -> anyhow::Result<()> { cmd2.arg("./tests/rundir/piped_multiple_consumer"); cmd2.arg("--jco-import"); cmd2.arg("./tests/virtualenvs/piped-consumer.js"); + cmd2.arg("--jco-import-bindings"); + cmd2.arg("hybrid"); cmd2.arg(wasi_file); cmd2.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd2.stdin(Stdio::null()); diff --git a/tests/gen/piped_polling.component.wasm b/tests/gen/piped_polling.component.wasm index cec14dfa8..4fc59fe05 100644 Binary files a/tests/gen/piped_polling.component.wasm and b/tests/gen/piped_polling.component.wasm differ diff --git a/tests/gen/piped_polling.rs b/tests/gen/piped_polling.rs index 7f8e81c98..72710a46c 100644 --- a/tests/gen/piped_polling.rs +++ b/tests/gen/piped_polling.rs @@ -16,6 +16,8 @@ fn piped_polling() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/piped_polling"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/piped.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); @@ -28,6 +30,8 @@ fn piped_polling() -> anyhow::Result<()> { cmd2.arg("./tests/rundir/piped_polling_consumer"); cmd2.arg("--jco-import"); cmd2.arg("./tests/virtualenvs/piped-consumer.js"); + cmd2.arg("--jco-import-bindings"); + cmd2.arg("hybrid"); cmd2.arg(wasi_file); cmd2.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd2.stdin(Stdio::null()); diff --git a/tests/gen/piped_simple.component.wasm b/tests/gen/piped_simple.component.wasm index 8067d0fe3..8922d2c71 100644 Binary files a/tests/gen/piped_simple.component.wasm and b/tests/gen/piped_simple.component.wasm differ diff --git a/tests/gen/piped_simple.rs b/tests/gen/piped_simple.rs index e68b1199b..eca712ce4 100644 --- a/tests/gen/piped_simple.rs +++ b/tests/gen/piped_simple.rs @@ -16,6 +16,8 @@ fn piped_simple() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/piped_simple"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/piped.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); @@ -28,6 +30,8 @@ fn piped_simple() -> anyhow::Result<()> { cmd2.arg("./tests/rundir/piped_simple_consumer"); cmd2.arg("--jco-import"); cmd2.arg("./tests/virtualenvs/piped-consumer.js"); + cmd2.arg("--jco-import-bindings"); + cmd2.arg("hybrid"); cmd2.arg(wasi_file); cmd2.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd2.stdin(Stdio::null()); diff --git a/tests/gen/preview1_big_random_buf.component.wasm b/tests/gen/preview1_big_random_buf.component.wasm index d3354bcca..299247e65 100644 Binary files a/tests/gen/preview1_big_random_buf.component.wasm and b/tests/gen/preview1_big_random_buf.component.wasm differ diff --git a/tests/gen/preview1_big_random_buf.rs b/tests/gen/preview1_big_random_buf.rs index d0553a164..dd9d9227f 100644 --- a/tests/gen/preview1_big_random_buf.rs +++ b/tests/gen/preview1_big_random_buf.rs @@ -16,6 +16,8 @@ fn preview1_big_random_buf() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_big_random_buf"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_clock_time_get.component.wasm b/tests/gen/preview1_clock_time_get.component.wasm index 6ae0ea18b..ebff3034b 100644 Binary files a/tests/gen/preview1_clock_time_get.component.wasm and b/tests/gen/preview1_clock_time_get.component.wasm differ diff --git a/tests/gen/preview1_clock_time_get.rs b/tests/gen/preview1_clock_time_get.rs index 357b11b1f..03b4d8bb1 100644 --- a/tests/gen/preview1_clock_time_get.rs +++ b/tests/gen/preview1_clock_time_get.rs @@ -16,6 +16,8 @@ fn preview1_clock_time_get() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_clock_time_get"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_close_preopen.component.wasm b/tests/gen/preview1_close_preopen.component.wasm index 828299b52..1d14f25be 100644 Binary files a/tests/gen/preview1_close_preopen.component.wasm and b/tests/gen/preview1_close_preopen.component.wasm differ diff --git a/tests/gen/preview1_close_preopen.rs b/tests/gen/preview1_close_preopen.rs index 791f2a9d9..dd6ab57b7 100644 --- a/tests/gen/preview1_close_preopen.rs +++ b/tests/gen/preview1_close_preopen.rs @@ -16,6 +16,8 @@ fn preview1_close_preopen() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_close_preopen"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_dangling_fd.component.wasm b/tests/gen/preview1_dangling_fd.component.wasm index c6577f51c..069439918 100644 Binary files a/tests/gen/preview1_dangling_fd.component.wasm and b/tests/gen/preview1_dangling_fd.component.wasm differ diff --git a/tests/gen/preview1_dangling_fd.rs b/tests/gen/preview1_dangling_fd.rs index e84a97522..ecada70f4 100644 --- a/tests/gen/preview1_dangling_fd.rs +++ b/tests/gen/preview1_dangling_fd.rs @@ -16,6 +16,8 @@ fn preview1_dangling_fd() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_dangling_fd"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_dangling_symlink.component.wasm b/tests/gen/preview1_dangling_symlink.component.wasm index af57db7ec..488759fd7 100644 Binary files a/tests/gen/preview1_dangling_symlink.component.wasm and b/tests/gen/preview1_dangling_symlink.component.wasm differ diff --git a/tests/gen/preview1_dangling_symlink.rs b/tests/gen/preview1_dangling_symlink.rs index 33fe6ece9..ae827dbbe 100644 --- a/tests/gen/preview1_dangling_symlink.rs +++ b/tests/gen/preview1_dangling_symlink.rs @@ -16,6 +16,8 @@ fn preview1_dangling_symlink() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_dangling_symlink"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_dir_fd_op_failures.component.wasm b/tests/gen/preview1_dir_fd_op_failures.component.wasm index 36a1a74f7..b883c9ca4 100644 Binary files a/tests/gen/preview1_dir_fd_op_failures.component.wasm and b/tests/gen/preview1_dir_fd_op_failures.component.wasm differ diff --git a/tests/gen/preview1_dir_fd_op_failures.rs b/tests/gen/preview1_dir_fd_op_failures.rs index b8f4e474a..cc5d0e540 100644 --- a/tests/gen/preview1_dir_fd_op_failures.rs +++ b/tests/gen/preview1_dir_fd_op_failures.rs @@ -16,6 +16,8 @@ fn preview1_dir_fd_op_failures() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_dir_fd_op_failures"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_directory_seek.component.wasm b/tests/gen/preview1_directory_seek.component.wasm index 45f7784df..627bd298f 100644 Binary files a/tests/gen/preview1_directory_seek.component.wasm and b/tests/gen/preview1_directory_seek.component.wasm differ diff --git a/tests/gen/preview1_directory_seek.rs b/tests/gen/preview1_directory_seek.rs index c1dc56bf9..3ad099241 100644 --- a/tests/gen/preview1_directory_seek.rs +++ b/tests/gen/preview1_directory_seek.rs @@ -16,6 +16,8 @@ fn preview1_directory_seek() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_directory_seek"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_fd_advise.component.wasm b/tests/gen/preview1_fd_advise.component.wasm index 6f1f0c9da..95f165cbd 100644 Binary files a/tests/gen/preview1_fd_advise.component.wasm and b/tests/gen/preview1_fd_advise.component.wasm differ diff --git a/tests/gen/preview1_fd_advise.rs b/tests/gen/preview1_fd_advise.rs index 4f5abe39a..840115ba9 100644 --- a/tests/gen/preview1_fd_advise.rs +++ b/tests/gen/preview1_fd_advise.rs @@ -16,6 +16,8 @@ fn preview1_fd_advise() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_fd_advise"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_fd_filestat_get.component.wasm b/tests/gen/preview1_fd_filestat_get.component.wasm index c237287d8..4e13ea54d 100644 Binary files a/tests/gen/preview1_fd_filestat_get.component.wasm and b/tests/gen/preview1_fd_filestat_get.component.wasm differ diff --git a/tests/gen/preview1_fd_filestat_get.rs b/tests/gen/preview1_fd_filestat_get.rs index 8836d5e2c..a969477a5 100644 --- a/tests/gen/preview1_fd_filestat_get.rs +++ b/tests/gen/preview1_fd_filestat_get.rs @@ -16,6 +16,8 @@ fn preview1_fd_filestat_get() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_fd_filestat_get"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_fd_filestat_set.component.wasm b/tests/gen/preview1_fd_filestat_set.component.wasm index 7a88f2047..20d652bba 100644 Binary files a/tests/gen/preview1_fd_filestat_set.component.wasm and b/tests/gen/preview1_fd_filestat_set.component.wasm differ diff --git a/tests/gen/preview1_fd_filestat_set.rs b/tests/gen/preview1_fd_filestat_set.rs index 85e56fe40..beeca60aa 100644 --- a/tests/gen/preview1_fd_filestat_set.rs +++ b/tests/gen/preview1_fd_filestat_set.rs @@ -16,6 +16,8 @@ fn preview1_fd_filestat_set() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_fd_filestat_set"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_fd_flags_set.component.wasm b/tests/gen/preview1_fd_flags_set.component.wasm index bad26b409..62c101ce2 100644 Binary files a/tests/gen/preview1_fd_flags_set.component.wasm and b/tests/gen/preview1_fd_flags_set.component.wasm differ diff --git a/tests/gen/preview1_fd_flags_set.rs b/tests/gen/preview1_fd_flags_set.rs index 929d98e34..975c97503 100644 --- a/tests/gen/preview1_fd_flags_set.rs +++ b/tests/gen/preview1_fd_flags_set.rs @@ -16,6 +16,8 @@ fn preview1_fd_flags_set() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_fd_flags_set"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_fd_readdir.component.wasm b/tests/gen/preview1_fd_readdir.component.wasm index 4b62b1d68..a9706563a 100644 Binary files a/tests/gen/preview1_fd_readdir.component.wasm and b/tests/gen/preview1_fd_readdir.component.wasm differ diff --git a/tests/gen/preview1_fd_readdir.rs b/tests/gen/preview1_fd_readdir.rs index 71bbcc04e..27408b7e4 100644 --- a/tests/gen/preview1_fd_readdir.rs +++ b/tests/gen/preview1_fd_readdir.rs @@ -16,6 +16,8 @@ fn preview1_fd_readdir() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_fd_readdir"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_allocate.component.wasm b/tests/gen/preview1_file_allocate.component.wasm index 93dfaf5e8..9e566d04f 100644 Binary files a/tests/gen/preview1_file_allocate.component.wasm and b/tests/gen/preview1_file_allocate.component.wasm differ diff --git a/tests/gen/preview1_file_allocate.rs b/tests/gen/preview1_file_allocate.rs index 304d38ec9..b56a1306b 100644 --- a/tests/gen/preview1_file_allocate.rs +++ b/tests/gen/preview1_file_allocate.rs @@ -16,6 +16,8 @@ fn preview1_file_allocate() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_allocate"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_pread_pwrite.component.wasm b/tests/gen/preview1_file_pread_pwrite.component.wasm index 91044ff00..892b49eed 100644 Binary files a/tests/gen/preview1_file_pread_pwrite.component.wasm and b/tests/gen/preview1_file_pread_pwrite.component.wasm differ diff --git a/tests/gen/preview1_file_pread_pwrite.rs b/tests/gen/preview1_file_pread_pwrite.rs index f95f54414..53198b910 100644 --- a/tests/gen/preview1_file_pread_pwrite.rs +++ b/tests/gen/preview1_file_pread_pwrite.rs @@ -16,6 +16,8 @@ fn preview1_file_pread_pwrite() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_pread_pwrite"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_seek_tell.component.wasm b/tests/gen/preview1_file_seek_tell.component.wasm index b37dcf233..0036bd57d 100644 Binary files a/tests/gen/preview1_file_seek_tell.component.wasm and b/tests/gen/preview1_file_seek_tell.component.wasm differ diff --git a/tests/gen/preview1_file_seek_tell.rs b/tests/gen/preview1_file_seek_tell.rs index f4943e4f9..e45495556 100644 --- a/tests/gen/preview1_file_seek_tell.rs +++ b/tests/gen/preview1_file_seek_tell.rs @@ -16,6 +16,8 @@ fn preview1_file_seek_tell() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_seek_tell"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_truncation.component.wasm b/tests/gen/preview1_file_truncation.component.wasm index daf5c5fbe..b4ef9c779 100644 Binary files a/tests/gen/preview1_file_truncation.component.wasm and b/tests/gen/preview1_file_truncation.component.wasm differ diff --git a/tests/gen/preview1_file_truncation.rs b/tests/gen/preview1_file_truncation.rs index 5c406a6c1..fd57b220b 100644 --- a/tests/gen/preview1_file_truncation.rs +++ b/tests/gen/preview1_file_truncation.rs @@ -16,6 +16,8 @@ fn preview1_file_truncation() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_truncation"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_unbuffered_write.component.wasm b/tests/gen/preview1_file_unbuffered_write.component.wasm index ada022e52..8ed5cbafb 100644 Binary files a/tests/gen/preview1_file_unbuffered_write.component.wasm and b/tests/gen/preview1_file_unbuffered_write.component.wasm differ diff --git a/tests/gen/preview1_file_unbuffered_write.rs b/tests/gen/preview1_file_unbuffered_write.rs index 393532eff..4650fcf51 100644 --- a/tests/gen/preview1_file_unbuffered_write.rs +++ b/tests/gen/preview1_file_unbuffered_write.rs @@ -16,6 +16,8 @@ fn preview1_file_unbuffered_write() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_unbuffered_write"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_file_write.component.wasm b/tests/gen/preview1_file_write.component.wasm index 477dd50a8..ec9ded7ab 100644 Binary files a/tests/gen/preview1_file_write.component.wasm and b/tests/gen/preview1_file_write.component.wasm differ diff --git a/tests/gen/preview1_file_write.rs b/tests/gen/preview1_file_write.rs index 6ac602a98..370abb052 100644 --- a/tests/gen/preview1_file_write.rs +++ b/tests/gen/preview1_file_write.rs @@ -16,6 +16,8 @@ fn preview1_file_write() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_file_write"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_interesting_paths.component.wasm b/tests/gen/preview1_interesting_paths.component.wasm index d4fec3d4e..dc737ee07 100644 Binary files a/tests/gen/preview1_interesting_paths.component.wasm and b/tests/gen/preview1_interesting_paths.component.wasm differ diff --git a/tests/gen/preview1_interesting_paths.rs b/tests/gen/preview1_interesting_paths.rs index 4be1aaec9..e1125726f 100644 --- a/tests/gen/preview1_interesting_paths.rs +++ b/tests/gen/preview1_interesting_paths.rs @@ -16,6 +16,8 @@ fn preview1_interesting_paths() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_interesting_paths"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_nofollow_errors.component.wasm b/tests/gen/preview1_nofollow_errors.component.wasm index d997fce46..435e72bbd 100644 Binary files a/tests/gen/preview1_nofollow_errors.component.wasm and b/tests/gen/preview1_nofollow_errors.component.wasm differ diff --git a/tests/gen/preview1_nofollow_errors.rs b/tests/gen/preview1_nofollow_errors.rs index c5ac13b78..021a9e79f 100644 --- a/tests/gen/preview1_nofollow_errors.rs +++ b/tests/gen/preview1_nofollow_errors.rs @@ -16,6 +16,8 @@ fn preview1_nofollow_errors() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_nofollow_errors"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_overwrite_preopen.component.wasm b/tests/gen/preview1_overwrite_preopen.component.wasm index eec57fe3a..2e24beb94 100644 Binary files a/tests/gen/preview1_overwrite_preopen.component.wasm and b/tests/gen/preview1_overwrite_preopen.component.wasm differ diff --git a/tests/gen/preview1_overwrite_preopen.rs b/tests/gen/preview1_overwrite_preopen.rs index 76509bb0b..99eac97a4 100644 --- a/tests/gen/preview1_overwrite_preopen.rs +++ b/tests/gen/preview1_overwrite_preopen.rs @@ -16,6 +16,8 @@ fn preview1_overwrite_preopen() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_overwrite_preopen"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_exists.component.wasm b/tests/gen/preview1_path_exists.component.wasm index cceb8efb8..ae32af4c1 100644 Binary files a/tests/gen/preview1_path_exists.component.wasm and b/tests/gen/preview1_path_exists.component.wasm differ diff --git a/tests/gen/preview1_path_exists.rs b/tests/gen/preview1_path_exists.rs index 81e874afc..c8153b06d 100644 --- a/tests/gen/preview1_path_exists.rs +++ b/tests/gen/preview1_path_exists.rs @@ -16,6 +16,8 @@ fn preview1_path_exists() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_exists"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_filestat.component.wasm b/tests/gen/preview1_path_filestat.component.wasm index 2ffd8a8f9..6467f3c20 100644 Binary files a/tests/gen/preview1_path_filestat.component.wasm and b/tests/gen/preview1_path_filestat.component.wasm differ diff --git a/tests/gen/preview1_path_filestat.rs b/tests/gen/preview1_path_filestat.rs index 44b6d7adb..571a1e25b 100644 --- a/tests/gen/preview1_path_filestat.rs +++ b/tests/gen/preview1_path_filestat.rs @@ -16,6 +16,8 @@ fn preview1_path_filestat() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_filestat"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_link.component.wasm b/tests/gen/preview1_path_link.component.wasm index c079a9cc8..1bb5436db 100644 Binary files a/tests/gen/preview1_path_link.component.wasm and b/tests/gen/preview1_path_link.component.wasm differ diff --git a/tests/gen/preview1_path_link.rs b/tests/gen/preview1_path_link.rs index 8524d4404..22947920c 100644 --- a/tests/gen/preview1_path_link.rs +++ b/tests/gen/preview1_path_link.rs @@ -16,6 +16,8 @@ fn preview1_path_link() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_link"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_create_existing.component.wasm b/tests/gen/preview1_path_open_create_existing.component.wasm index d56a10e8f..c0d80fa2d 100644 Binary files a/tests/gen/preview1_path_open_create_existing.component.wasm and b/tests/gen/preview1_path_open_create_existing.component.wasm differ diff --git a/tests/gen/preview1_path_open_create_existing.rs b/tests/gen/preview1_path_open_create_existing.rs index ee85679ad..3e07598a5 100644 --- a/tests/gen/preview1_path_open_create_existing.rs +++ b/tests/gen/preview1_path_open_create_existing.rs @@ -16,6 +16,8 @@ fn preview1_path_open_create_existing() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_create_existing"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_dirfd_not_dir.component.wasm b/tests/gen/preview1_path_open_dirfd_not_dir.component.wasm index 41743c7de..2a187d968 100644 Binary files a/tests/gen/preview1_path_open_dirfd_not_dir.component.wasm and b/tests/gen/preview1_path_open_dirfd_not_dir.component.wasm differ diff --git a/tests/gen/preview1_path_open_dirfd_not_dir.rs b/tests/gen/preview1_path_open_dirfd_not_dir.rs index 648564711..79193fdb0 100644 --- a/tests/gen/preview1_path_open_dirfd_not_dir.rs +++ b/tests/gen/preview1_path_open_dirfd_not_dir.rs @@ -16,6 +16,8 @@ fn preview1_path_open_dirfd_not_dir() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_dirfd_not_dir"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_lots.component.wasm b/tests/gen/preview1_path_open_lots.component.wasm index f1d6301cb..d6ee77a94 100644 Binary files a/tests/gen/preview1_path_open_lots.component.wasm and b/tests/gen/preview1_path_open_lots.component.wasm differ diff --git a/tests/gen/preview1_path_open_lots.rs b/tests/gen/preview1_path_open_lots.rs index 13662dbe2..6c8a3b63f 100644 --- a/tests/gen/preview1_path_open_lots.rs +++ b/tests/gen/preview1_path_open_lots.rs @@ -16,6 +16,8 @@ fn preview1_path_open_lots() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_lots"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_missing.component.wasm b/tests/gen/preview1_path_open_missing.component.wasm index a819fb2cd..f8fab25fd 100644 Binary files a/tests/gen/preview1_path_open_missing.component.wasm and b/tests/gen/preview1_path_open_missing.component.wasm differ diff --git a/tests/gen/preview1_path_open_missing.rs b/tests/gen/preview1_path_open_missing.rs index 8f0e2e187..124117c76 100644 --- a/tests/gen/preview1_path_open_missing.rs +++ b/tests/gen/preview1_path_open_missing.rs @@ -16,6 +16,8 @@ fn preview1_path_open_missing() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_missing"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_nonblock.component.wasm b/tests/gen/preview1_path_open_nonblock.component.wasm index 73dc746a8..144da630d 100644 Binary files a/tests/gen/preview1_path_open_nonblock.component.wasm and b/tests/gen/preview1_path_open_nonblock.component.wasm differ diff --git a/tests/gen/preview1_path_open_nonblock.rs b/tests/gen/preview1_path_open_nonblock.rs index 350a64cd3..3d05ea2b6 100644 --- a/tests/gen/preview1_path_open_nonblock.rs +++ b/tests/gen/preview1_path_open_nonblock.rs @@ -16,6 +16,8 @@ fn preview1_path_open_nonblock() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_nonblock"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_preopen.component.wasm b/tests/gen/preview1_path_open_preopen.component.wasm index 407d7051f..a7969c6e7 100644 Binary files a/tests/gen/preview1_path_open_preopen.component.wasm and b/tests/gen/preview1_path_open_preopen.component.wasm differ diff --git a/tests/gen/preview1_path_open_preopen.rs b/tests/gen/preview1_path_open_preopen.rs index 6e1d422d8..0263da754 100644 --- a/tests/gen/preview1_path_open_preopen.rs +++ b/tests/gen/preview1_path_open_preopen.rs @@ -16,6 +16,8 @@ fn preview1_path_open_preopen() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_preopen"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_open_read_write.component.wasm b/tests/gen/preview1_path_open_read_write.component.wasm index 4714425c1..74c9652d2 100644 Binary files a/tests/gen/preview1_path_open_read_write.component.wasm and b/tests/gen/preview1_path_open_read_write.component.wasm differ diff --git a/tests/gen/preview1_path_open_read_write.rs b/tests/gen/preview1_path_open_read_write.rs index d7ffd6182..10fb3bddd 100644 --- a/tests/gen/preview1_path_open_read_write.rs +++ b/tests/gen/preview1_path_open_read_write.rs @@ -16,6 +16,8 @@ fn preview1_path_open_read_write() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_open_read_write"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_rename.component.wasm b/tests/gen/preview1_path_rename.component.wasm index ff4dbfce3..44a776137 100644 Binary files a/tests/gen/preview1_path_rename.component.wasm and b/tests/gen/preview1_path_rename.component.wasm differ diff --git a/tests/gen/preview1_path_rename.rs b/tests/gen/preview1_path_rename.rs index f2a64f724..56da0c596 100644 --- a/tests/gen/preview1_path_rename.rs +++ b/tests/gen/preview1_path_rename.rs @@ -16,6 +16,8 @@ fn preview1_path_rename() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_rename"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_rename_dir_trailing_slashes.component.wasm b/tests/gen/preview1_path_rename_dir_trailing_slashes.component.wasm index 63c604120..3ece079dc 100644 Binary files a/tests/gen/preview1_path_rename_dir_trailing_slashes.component.wasm and b/tests/gen/preview1_path_rename_dir_trailing_slashes.component.wasm differ diff --git a/tests/gen/preview1_path_rename_dir_trailing_slashes.rs b/tests/gen/preview1_path_rename_dir_trailing_slashes.rs index ccaca468c..7a36a73a5 100644 --- a/tests/gen/preview1_path_rename_dir_trailing_slashes.rs +++ b/tests/gen/preview1_path_rename_dir_trailing_slashes.rs @@ -16,6 +16,8 @@ fn preview1_path_rename_dir_trailing_slashes() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_rename_dir_trailing_slashes"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_path_symlink_trailing_slashes.component.wasm b/tests/gen/preview1_path_symlink_trailing_slashes.component.wasm index 89e887027..3e8f16c52 100644 Binary files a/tests/gen/preview1_path_symlink_trailing_slashes.component.wasm and b/tests/gen/preview1_path_symlink_trailing_slashes.component.wasm differ diff --git a/tests/gen/preview1_path_symlink_trailing_slashes.rs b/tests/gen/preview1_path_symlink_trailing_slashes.rs index a3b41bf13..4a436d349 100644 --- a/tests/gen/preview1_path_symlink_trailing_slashes.rs +++ b/tests/gen/preview1_path_symlink_trailing_slashes.rs @@ -16,6 +16,8 @@ fn preview1_path_symlink_trailing_slashes() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_path_symlink_trailing_slashes"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_poll_oneoff_files.component.wasm b/tests/gen/preview1_poll_oneoff_files.component.wasm index 4c54e9eaa..01c88b3e6 100644 Binary files a/tests/gen/preview1_poll_oneoff_files.component.wasm and b/tests/gen/preview1_poll_oneoff_files.component.wasm differ diff --git a/tests/gen/preview1_poll_oneoff_files.rs b/tests/gen/preview1_poll_oneoff_files.rs index 874d94344..3c19a5132 100644 --- a/tests/gen/preview1_poll_oneoff_files.rs +++ b/tests/gen/preview1_poll_oneoff_files.rs @@ -16,6 +16,8 @@ fn preview1_poll_oneoff_files() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_poll_oneoff_files"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_poll_oneoff_stdio.component.wasm b/tests/gen/preview1_poll_oneoff_stdio.component.wasm index 638ac4d60..6cd4d6839 100644 Binary files a/tests/gen/preview1_poll_oneoff_stdio.component.wasm and b/tests/gen/preview1_poll_oneoff_stdio.component.wasm differ diff --git a/tests/gen/preview1_poll_oneoff_stdio.rs b/tests/gen/preview1_poll_oneoff_stdio.rs index b76030478..c3922e38e 100644 --- a/tests/gen/preview1_poll_oneoff_stdio.rs +++ b/tests/gen/preview1_poll_oneoff_stdio.rs @@ -16,6 +16,8 @@ fn preview1_poll_oneoff_stdio() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_poll_oneoff_stdio"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_readlink.component.wasm b/tests/gen/preview1_readlink.component.wasm index dcdd1bb8f..2af12a0dd 100644 Binary files a/tests/gen/preview1_readlink.component.wasm and b/tests/gen/preview1_readlink.component.wasm differ diff --git a/tests/gen/preview1_readlink.rs b/tests/gen/preview1_readlink.rs index ce5b4bb64..ce87a87db 100644 --- a/tests/gen/preview1_readlink.rs +++ b/tests/gen/preview1_readlink.rs @@ -16,6 +16,8 @@ fn preview1_readlink() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_readlink"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_regular_file_isatty.component.wasm b/tests/gen/preview1_regular_file_isatty.component.wasm index 544a498c0..343c52106 100644 Binary files a/tests/gen/preview1_regular_file_isatty.component.wasm and b/tests/gen/preview1_regular_file_isatty.component.wasm differ diff --git a/tests/gen/preview1_regular_file_isatty.rs b/tests/gen/preview1_regular_file_isatty.rs index 191d08759..2b2528af2 100644 --- a/tests/gen/preview1_regular_file_isatty.rs +++ b/tests/gen/preview1_regular_file_isatty.rs @@ -16,6 +16,8 @@ fn preview1_regular_file_isatty() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_regular_file_isatty"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_remove_directory.component.wasm b/tests/gen/preview1_remove_directory.component.wasm index 704ac910e..1580924fc 100644 Binary files a/tests/gen/preview1_remove_directory.component.wasm and b/tests/gen/preview1_remove_directory.component.wasm differ diff --git a/tests/gen/preview1_remove_directory.rs b/tests/gen/preview1_remove_directory.rs index 6568466e1..972371ac1 100644 --- a/tests/gen/preview1_remove_directory.rs +++ b/tests/gen/preview1_remove_directory.rs @@ -16,6 +16,8 @@ fn preview1_remove_directory() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_remove_directory"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_remove_nonempty_directory.component.wasm b/tests/gen/preview1_remove_nonempty_directory.component.wasm index 76e8f6cd6..5e855866f 100644 Binary files a/tests/gen/preview1_remove_nonempty_directory.component.wasm and b/tests/gen/preview1_remove_nonempty_directory.component.wasm differ diff --git a/tests/gen/preview1_remove_nonempty_directory.rs b/tests/gen/preview1_remove_nonempty_directory.rs index d72d4772b..37750031a 100644 --- a/tests/gen/preview1_remove_nonempty_directory.rs +++ b/tests/gen/preview1_remove_nonempty_directory.rs @@ -16,6 +16,8 @@ fn preview1_remove_nonempty_directory() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_remove_nonempty_directory"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_renumber.component.wasm b/tests/gen/preview1_renumber.component.wasm index 111b2ba67..659de54a0 100644 Binary files a/tests/gen/preview1_renumber.component.wasm and b/tests/gen/preview1_renumber.component.wasm differ diff --git a/tests/gen/preview1_renumber.rs b/tests/gen/preview1_renumber.rs index ccbf90584..f2ee3a32d 100644 --- a/tests/gen/preview1_renumber.rs +++ b/tests/gen/preview1_renumber.rs @@ -16,6 +16,8 @@ fn preview1_renumber() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_renumber"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_sched_yield.component.wasm b/tests/gen/preview1_sched_yield.component.wasm index 7b18b43f5..80e9f2132 100644 Binary files a/tests/gen/preview1_sched_yield.component.wasm and b/tests/gen/preview1_sched_yield.component.wasm differ diff --git a/tests/gen/preview1_sched_yield.rs b/tests/gen/preview1_sched_yield.rs index 967f33e6f..d6cd6079c 100644 --- a/tests/gen/preview1_sched_yield.rs +++ b/tests/gen/preview1_sched_yield.rs @@ -16,6 +16,8 @@ fn preview1_sched_yield() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_sched_yield"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_stdio.component.wasm b/tests/gen/preview1_stdio.component.wasm index 9820d9808..e1e8df408 100644 Binary files a/tests/gen/preview1_stdio.component.wasm and b/tests/gen/preview1_stdio.component.wasm differ diff --git a/tests/gen/preview1_stdio.rs b/tests/gen/preview1_stdio.rs index 8e7a1c94c..ebeb61f30 100644 --- a/tests/gen/preview1_stdio.rs +++ b/tests/gen/preview1_stdio.rs @@ -16,6 +16,8 @@ fn preview1_stdio() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_stdio"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_stdio_isatty.component.wasm b/tests/gen/preview1_stdio_isatty.component.wasm index a0cabfd1a..9bd1c8724 100644 Binary files a/tests/gen/preview1_stdio_isatty.component.wasm and b/tests/gen/preview1_stdio_isatty.component.wasm differ diff --git a/tests/gen/preview1_stdio_isatty.rs b/tests/gen/preview1_stdio_isatty.rs index d5e88cc28..547b42695 100644 --- a/tests/gen/preview1_stdio_isatty.rs +++ b/tests/gen/preview1_stdio_isatty.rs @@ -16,6 +16,8 @@ fn preview1_stdio_isatty() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_stdio_isatty"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_stdio_not_isatty.component.wasm b/tests/gen/preview1_stdio_not_isatty.component.wasm index a75e0c25e..ddecddc47 100644 Binary files a/tests/gen/preview1_stdio_not_isatty.component.wasm and b/tests/gen/preview1_stdio_not_isatty.component.wasm differ diff --git a/tests/gen/preview1_stdio_not_isatty.rs b/tests/gen/preview1_stdio_not_isatty.rs index 39ef2ab28..c9e3f6656 100644 --- a/tests/gen/preview1_stdio_not_isatty.rs +++ b/tests/gen/preview1_stdio_not_isatty.rs @@ -16,6 +16,8 @@ fn preview1_stdio_not_isatty() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_stdio_not_isatty"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/notty.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_symlink_create.component.wasm b/tests/gen/preview1_symlink_create.component.wasm index 6cf96dc50..ee02133af 100644 Binary files a/tests/gen/preview1_symlink_create.component.wasm and b/tests/gen/preview1_symlink_create.component.wasm differ diff --git a/tests/gen/preview1_symlink_create.rs b/tests/gen/preview1_symlink_create.rs index 95f4f68f8..4fc0db64c 100644 --- a/tests/gen/preview1_symlink_create.rs +++ b/tests/gen/preview1_symlink_create.rs @@ -16,6 +16,8 @@ fn preview1_symlink_create() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_symlink_create"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_symlink_filestat.component.wasm b/tests/gen/preview1_symlink_filestat.component.wasm index c99b0da4c..3e2b9c239 100644 Binary files a/tests/gen/preview1_symlink_filestat.component.wasm and b/tests/gen/preview1_symlink_filestat.component.wasm differ diff --git a/tests/gen/preview1_symlink_filestat.rs b/tests/gen/preview1_symlink_filestat.rs index d6207d124..f3dd44a8b 100644 --- a/tests/gen/preview1_symlink_filestat.rs +++ b/tests/gen/preview1_symlink_filestat.rs @@ -16,6 +16,8 @@ fn preview1_symlink_filestat() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_symlink_filestat"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_symlink_loop.component.wasm b/tests/gen/preview1_symlink_loop.component.wasm index b4bd42322..66f037e90 100644 Binary files a/tests/gen/preview1_symlink_loop.component.wasm and b/tests/gen/preview1_symlink_loop.component.wasm differ diff --git a/tests/gen/preview1_symlink_loop.rs b/tests/gen/preview1_symlink_loop.rs index 31719ec4f..e9af948cc 100644 --- a/tests/gen/preview1_symlink_loop.rs +++ b/tests/gen/preview1_symlink_loop.rs @@ -16,6 +16,8 @@ fn preview1_symlink_loop() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_symlink_loop"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_unicode_output.component.wasm b/tests/gen/preview1_unicode_output.component.wasm index 47ac8b026..e7978331b 100644 Binary files a/tests/gen/preview1_unicode_output.component.wasm and b/tests/gen/preview1_unicode_output.component.wasm differ diff --git a/tests/gen/preview1_unicode_output.rs b/tests/gen/preview1_unicode_output.rs index 0e0a2f16b..a5b46f075 100644 --- a/tests/gen/preview1_unicode_output.rs +++ b/tests/gen/preview1_unicode_output.rs @@ -16,6 +16,8 @@ fn preview1_unicode_output() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_unicode_output"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview1_unlink_file_trailing_slashes.component.wasm b/tests/gen/preview1_unlink_file_trailing_slashes.component.wasm index b328efa5d..48c07ff44 100644 Binary files a/tests/gen/preview1_unlink_file_trailing_slashes.component.wasm and b/tests/gen/preview1_unlink_file_trailing_slashes.component.wasm differ diff --git a/tests/gen/preview1_unlink_file_trailing_slashes.rs b/tests/gen/preview1_unlink_file_trailing_slashes.rs index 54340d54a..6cac7b7d7 100644 --- a/tests/gen/preview1_unlink_file_trailing_slashes.rs +++ b/tests/gen/preview1_unlink_file_trailing_slashes.rs @@ -16,6 +16,8 @@ fn preview1_unlink_file_trailing_slashes() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview1_unlink_file_trailing_slashes"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/scratch.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_adapter_badfd.component.wasm b/tests/gen/preview2_adapter_badfd.component.wasm index e4cb4f825..ad7130d8c 100644 Binary files a/tests/gen/preview2_adapter_badfd.component.wasm and b/tests/gen/preview2_adapter_badfd.component.wasm differ diff --git a/tests/gen/preview2_adapter_badfd.rs b/tests/gen/preview2_adapter_badfd.rs index bf1df2512..672f1dcaf 100644 --- a/tests/gen/preview2_adapter_badfd.rs +++ b/tests/gen/preview2_adapter_badfd.rs @@ -16,6 +16,8 @@ fn preview2_adapter_badfd() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_adapter_badfd"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_ip_name_lookup.component.wasm b/tests/gen/preview2_ip_name_lookup.component.wasm index 2f8688b49..5491b94bb 100644 Binary files a/tests/gen/preview2_ip_name_lookup.component.wasm and b/tests/gen/preview2_ip_name_lookup.component.wasm differ diff --git a/tests/gen/preview2_ip_name_lookup.rs b/tests/gen/preview2_ip_name_lookup.rs index 719452c2c..44b56a34d 100644 --- a/tests/gen/preview2_ip_name_lookup.rs +++ b/tests/gen/preview2_ip_name_lookup.rs @@ -16,6 +16,8 @@ fn preview2_ip_name_lookup() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_ip_name_lookup"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_pollable_correct.component.wasm b/tests/gen/preview2_pollable_correct.component.wasm new file mode 100644 index 000000000..b13cb0c69 Binary files /dev/null and b/tests/gen/preview2_pollable_correct.component.wasm differ diff --git a/tests/gen/preview2_pollable_correct.rs b/tests/gen/preview2_pollable_correct.rs new file mode 100644 index 000000000..1eb853d1c --- /dev/null +++ b/tests/gen/preview2_pollable_correct.rs @@ -0,0 +1,29 @@ +//! This file has been auto-generated, please do not modify manually +//! To regenerate this file re-run `cargo xtask generate tests` from the project root + +use std::fs; +use std::process::{Command, Stdio}; + +#[test] +fn preview2_pollable_correct() -> anyhow::Result<()> { + { + let wasi_file = "./tests/gen/preview2_pollable_correct.component.wasm"; + let _ = fs::remove_dir_all("./tests/rundir/preview2_pollable_correct"); + let mut cmd1 = Command::new("node"); + cmd1.arg("./src/jco.js"); + cmd1.arg("run"); + cmd1.arg("--jco-dir"); + cmd1.arg("./tests/rundir/preview2_pollable_correct"); + cmd1.arg("--jco-import"); + cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); + cmd1.arg(wasi_file); + cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); + cmd1.stdin(Stdio::null()); + let mut cmd1_child = cmd1.spawn().expect("failed to spawn test program"); + let status = cmd1_child.wait().expect("failed to wait on child"); + assert!(status.success(), "test execution failed"); + } + Ok(()) +} diff --git a/tests/gen/preview2_pollable_traps.component.wasm b/tests/gen/preview2_pollable_traps.component.wasm new file mode 100644 index 000000000..a85ea268a Binary files /dev/null and b/tests/gen/preview2_pollable_traps.component.wasm differ diff --git a/tests/gen/preview2_pollable_traps.rs b/tests/gen/preview2_pollable_traps.rs new file mode 100644 index 000000000..90e75d0e1 --- /dev/null +++ b/tests/gen/preview2_pollable_traps.rs @@ -0,0 +1,29 @@ +//! This file has been auto-generated, please do not modify manually +//! To regenerate this file re-run `cargo xtask generate tests` from the project root + +use std::fs; +use std::process::{Command, Stdio}; + +#[test] +fn preview2_pollable_traps() -> anyhow::Result<()> { + { + let wasi_file = "./tests/gen/preview2_pollable_traps.component.wasm"; + let _ = fs::remove_dir_all("./tests/rundir/preview2_pollable_traps"); + let mut cmd1 = Command::new("node"); + cmd1.arg("./src/jco.js"); + cmd1.arg("run"); + cmd1.arg("--jco-dir"); + cmd1.arg("./tests/rundir/preview2_pollable_traps"); + cmd1.arg("--jco-import"); + cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); + cmd1.arg(wasi_file); + cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); + cmd1.stdin(Stdio::null()); + let mut cmd1_child = cmd1.spawn().expect("failed to spawn test program"); + let status = cmd1_child.wait().expect("failed to wait on child"); + assert!(!status.success(), "test execution failed"); + } + Ok(()) +} diff --git a/tests/gen/preview2_random.component.wasm b/tests/gen/preview2_random.component.wasm index 84fc41d77..c310a537a 100644 Binary files a/tests/gen/preview2_random.component.wasm and b/tests/gen/preview2_random.component.wasm differ diff --git a/tests/gen/preview2_random.rs b/tests/gen/preview2_random.rs index bf0272045..2157e922f 100644 --- a/tests/gen/preview2_random.rs +++ b/tests/gen/preview2_random.rs @@ -16,6 +16,8 @@ fn preview2_random() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_random"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_sleep.component.wasm b/tests/gen/preview2_sleep.component.wasm index ee78fcb5f..d4dcbf0ad 100644 Binary files a/tests/gen/preview2_sleep.component.wasm and b/tests/gen/preview2_sleep.component.wasm differ diff --git a/tests/gen/preview2_sleep.rs b/tests/gen/preview2_sleep.rs index 7ca5e663a..3a2513c5a 100644 --- a/tests/gen/preview2_sleep.rs +++ b/tests/gen/preview2_sleep.rs @@ -16,6 +16,8 @@ fn preview2_sleep() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_sleep"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_stream_pollable_correct.component.wasm b/tests/gen/preview2_stream_pollable_correct.component.wasm index 6f72eb8be..7bed2f2dc 100644 Binary files a/tests/gen/preview2_stream_pollable_correct.component.wasm and b/tests/gen/preview2_stream_pollable_correct.component.wasm differ diff --git a/tests/gen/preview2_stream_pollable_correct.rs b/tests/gen/preview2_stream_pollable_correct.rs index 339e593db..c3c89b1dd 100644 --- a/tests/gen/preview2_stream_pollable_correct.rs +++ b/tests/gen/preview2_stream_pollable_correct.rs @@ -16,6 +16,8 @@ fn preview2_stream_pollable_correct() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_stream_pollable_correct"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_stream_pollable_traps.component.wasm b/tests/gen/preview2_stream_pollable_traps.component.wasm index fb04a8865..36e2db1ef 100644 Binary files a/tests/gen/preview2_stream_pollable_traps.component.wasm and b/tests/gen/preview2_stream_pollable_traps.component.wasm differ diff --git a/tests/gen/preview2_stream_pollable_traps.rs b/tests/gen/preview2_stream_pollable_traps.rs index 4bbc0efdc..17887581f 100644 --- a/tests/gen/preview2_stream_pollable_traps.rs +++ b/tests/gen/preview2_stream_pollable_traps.rs @@ -16,6 +16,8 @@ fn preview2_stream_pollable_traps() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_stream_pollable_traps"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_tcp_bind.component.wasm b/tests/gen/preview2_tcp_bind.component.wasm index dc8355067..ca4a6c0a8 100644 Binary files a/tests/gen/preview2_tcp_bind.component.wasm and b/tests/gen/preview2_tcp_bind.component.wasm differ diff --git a/tests/gen/preview2_tcp_bind.rs b/tests/gen/preview2_tcp_bind.rs index 3a7d8ef4d..e5be0fbd2 100644 --- a/tests/gen/preview2_tcp_bind.rs +++ b/tests/gen/preview2_tcp_bind.rs @@ -16,6 +16,8 @@ fn preview2_tcp_bind() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_tcp_bind"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_tcp_connect.component.wasm b/tests/gen/preview2_tcp_connect.component.wasm index 6ddb2f9a3..54c1bf621 100644 Binary files a/tests/gen/preview2_tcp_connect.component.wasm and b/tests/gen/preview2_tcp_connect.component.wasm differ diff --git a/tests/gen/preview2_tcp_connect.rs b/tests/gen/preview2_tcp_connect.rs index 31476ded4..6ddadaa21 100644 --- a/tests/gen/preview2_tcp_connect.rs +++ b/tests/gen/preview2_tcp_connect.rs @@ -16,6 +16,8 @@ fn preview2_tcp_connect() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_tcp_connect"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_tcp_sample_application.component.wasm b/tests/gen/preview2_tcp_sample_application.component.wasm index a5dd3e1ab..d4bd9cdc0 100644 Binary files a/tests/gen/preview2_tcp_sample_application.component.wasm and b/tests/gen/preview2_tcp_sample_application.component.wasm differ diff --git a/tests/gen/preview2_tcp_sample_application.rs b/tests/gen/preview2_tcp_sample_application.rs index 08355da93..45484bab3 100644 --- a/tests/gen/preview2_tcp_sample_application.rs +++ b/tests/gen/preview2_tcp_sample_application.rs @@ -16,6 +16,8 @@ fn preview2_tcp_sample_application() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_tcp_sample_application"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_tcp_sockopts.component.wasm b/tests/gen/preview2_tcp_sockopts.component.wasm index 2ab7805e0..2788366b2 100644 Binary files a/tests/gen/preview2_tcp_sockopts.component.wasm and b/tests/gen/preview2_tcp_sockopts.component.wasm differ diff --git a/tests/gen/preview2_tcp_sockopts.rs b/tests/gen/preview2_tcp_sockopts.rs index 097f363b2..ea7b79518 100644 --- a/tests/gen/preview2_tcp_sockopts.rs +++ b/tests/gen/preview2_tcp_sockopts.rs @@ -16,6 +16,8 @@ fn preview2_tcp_sockopts() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_tcp_sockopts"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_tcp_states.component.wasm b/tests/gen/preview2_tcp_states.component.wasm index f1543f5be..e90eb1337 100644 Binary files a/tests/gen/preview2_tcp_states.component.wasm and b/tests/gen/preview2_tcp_states.component.wasm differ diff --git a/tests/gen/preview2_tcp_states.rs b/tests/gen/preview2_tcp_states.rs index 2ea615c9d..9fca78e82 100644 --- a/tests/gen/preview2_tcp_states.rs +++ b/tests/gen/preview2_tcp_states.rs @@ -16,6 +16,8 @@ fn preview2_tcp_states() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_tcp_states"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_udp_bind.component.wasm b/tests/gen/preview2_udp_bind.component.wasm index c9868de15..453bd0727 100644 Binary files a/tests/gen/preview2_udp_bind.component.wasm and b/tests/gen/preview2_udp_bind.component.wasm differ diff --git a/tests/gen/preview2_udp_bind.rs b/tests/gen/preview2_udp_bind.rs index cbecb30cd..e53edebcc 100644 --- a/tests/gen/preview2_udp_bind.rs +++ b/tests/gen/preview2_udp_bind.rs @@ -16,6 +16,8 @@ fn preview2_udp_bind() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_udp_bind"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_udp_connect.component.wasm b/tests/gen/preview2_udp_connect.component.wasm index 3850dcb5f..5ee4a1d1f 100644 Binary files a/tests/gen/preview2_udp_connect.component.wasm and b/tests/gen/preview2_udp_connect.component.wasm differ diff --git a/tests/gen/preview2_udp_connect.rs b/tests/gen/preview2_udp_connect.rs index f24142871..c8242eb16 100644 --- a/tests/gen/preview2_udp_connect.rs +++ b/tests/gen/preview2_udp_connect.rs @@ -16,6 +16,8 @@ fn preview2_udp_connect() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_udp_connect"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_udp_sample_application.component.wasm b/tests/gen/preview2_udp_sample_application.component.wasm index 050d6137e..116aa25b0 100644 Binary files a/tests/gen/preview2_udp_sample_application.component.wasm and b/tests/gen/preview2_udp_sample_application.component.wasm differ diff --git a/tests/gen/preview2_udp_sample_application.rs b/tests/gen/preview2_udp_sample_application.rs index f2defb9c3..6af24a0aa 100644 --- a/tests/gen/preview2_udp_sample_application.rs +++ b/tests/gen/preview2_udp_sample_application.rs @@ -16,6 +16,8 @@ fn preview2_udp_sample_application() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_udp_sample_application"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_udp_sockopts.component.wasm b/tests/gen/preview2_udp_sockopts.component.wasm index d5772b08d..aeae597d1 100644 Binary files a/tests/gen/preview2_udp_sockopts.component.wasm and b/tests/gen/preview2_udp_sockopts.component.wasm differ diff --git a/tests/gen/preview2_udp_sockopts.rs b/tests/gen/preview2_udp_sockopts.rs index ecd0d2ec9..aca487a70 100644 --- a/tests/gen/preview2_udp_sockopts.rs +++ b/tests/gen/preview2_udp_sockopts.rs @@ -16,6 +16,8 @@ fn preview2_udp_sockopts() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_udp_sockopts"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/preview2_udp_states.component.wasm b/tests/gen/preview2_udp_states.component.wasm index c870055d9..98a2a14a1 100644 Binary files a/tests/gen/preview2_udp_states.component.wasm and b/tests/gen/preview2_udp_states.component.wasm differ diff --git a/tests/gen/preview2_udp_states.rs b/tests/gen/preview2_udp_states.rs index e40b5f2d8..3d23c70cd 100644 --- a/tests/gen/preview2_udp_states.rs +++ b/tests/gen/preview2_udp_states.rs @@ -16,6 +16,8 @@ fn preview2_udp_states() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/preview2_udp_states"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/base.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/proxy_echo.component.wasm b/tests/gen/proxy_echo.component.wasm index 08687c75c..e3c94d0e1 100644 Binary files a/tests/gen/proxy_echo.component.wasm and b/tests/gen/proxy_echo.component.wasm differ diff --git a/tests/gen/proxy_echo.rs b/tests/gen/proxy_echo.rs index 3f021e71b..66b5a8536 100644 --- a/tests/gen/proxy_echo.rs +++ b/tests/gen/proxy_echo.rs @@ -16,6 +16,8 @@ fn proxy_echo() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/proxy_echo"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/server-api-proxy-streaming.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/proxy_handler.component.wasm b/tests/gen/proxy_handler.component.wasm index c215f84c6..136da8854 100644 Binary files a/tests/gen/proxy_handler.component.wasm and b/tests/gen/proxy_handler.component.wasm differ diff --git a/tests/gen/proxy_handler.rs b/tests/gen/proxy_handler.rs index 460bceb45..e28342170 100644 --- a/tests/gen/proxy_handler.rs +++ b/tests/gen/proxy_handler.rs @@ -16,6 +16,8 @@ fn proxy_handler() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/proxy_handler"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/server-api-proxy.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/gen/proxy_hash.component.wasm b/tests/gen/proxy_hash.component.wasm index 67e3064c0..87fdf3925 100644 Binary files a/tests/gen/proxy_hash.component.wasm and b/tests/gen/proxy_hash.component.wasm differ diff --git a/tests/gen/proxy_hash.rs b/tests/gen/proxy_hash.rs index 59a6227bd..893eb3a09 100644 --- a/tests/gen/proxy_hash.rs +++ b/tests/gen/proxy_hash.rs @@ -16,6 +16,8 @@ fn proxy_hash() -> anyhow::Result<()> { cmd1.arg("./tests/rundir/proxy_hash"); cmd1.arg("--jco-import"); cmd1.arg("./tests/virtualenvs/server-api-proxy-streaming.js"); + cmd1.arg("--jco-import-bindings"); + cmd1.arg("hybrid"); cmd1.arg(wasi_file); cmd1.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); cmd1.stdin(Stdio::null()); diff --git a/tests/server/http-server.js b/tests/server/http-server.js index 979a4f7e5..b0fd9a1fd 100644 --- a/tests/server/http-server.js +++ b/tests/server/http-server.js @@ -1,7 +1,12 @@ import { _forbiddenHeaders, HTTPServer } from '@bytecodealliance/preview2-shim/http'; +import { _setPreopens } from "@bytecodealliance/preview2-shim/filesystem"; +import process from "node:process"; _forbiddenHeaders.add('custom-forbidden-header'); +if (process.env.FS === "0") + _setPreopens({}); + let server; process.on('message', async msg => { // null message = exit @@ -37,6 +42,7 @@ process.on('message', async msg => { }); } catch (e) { + process._rawDebug(e); console.error(`Error updating server handler to ${msg}`); console.error(e); process.exit(1); diff --git a/tests/server/index.js b/tests/server/index.js index 1e0bc8154..7d7daa2a7 100644 --- a/tests/server/index.js +++ b/tests/server/index.js @@ -33,7 +33,7 @@ export async function createIncomingServer(serverName) { fileURLToPath(import.meta.url.split("/").slice(0, -1).join("/")) + "/http-server.js", { - env: Object.assign(process.env, { PREVIEW2_SHIM_DEBUG: "0" }), + env: Object.assign(process.env, { PREVIEW2_SHIM_DEBUG: "0", FS: "0" }), } ); servers.push(serverProcess); @@ -52,6 +52,7 @@ export async function createIncomingServer(serverName) { const { files } = generate(component, { name: "component", noTypescript: true, + importBindings: { tag: 'hybrid' }, map: Object.entries({ "wasi:cli/*": "@bytecodealliance/preview2-shim/cli#*", "wasi:clocks/*": "@bytecodealliance/preview2-shim/clocks#*", diff --git a/xtask/src/build/jco.rs b/xtask/src/build/jco.rs index 0f240cbf3..2fe6953a4 100644 --- a/xtask/src/build/jco.rs +++ b/xtask/src/build/jco.rs @@ -1,4 +1,5 @@ use anyhow::{Context, Result}; +use js_component_bindgen::BindingsMode; use std::{collections::HashMap, fs, io::Write, path::PathBuf}; use wit_component::ComponentEncoder; @@ -68,6 +69,7 @@ fn transpile(component_path: &str, name: String) -> Result<()> { tracing: false, no_namespaced_exports: true, multi_memory: true, + import_bindings: Some(BindingsMode::Js), }; let transpiled = js_component_bindgen::transpile(&adapted_component, opts)?; diff --git a/xtask/src/generate/tests.rs b/xtask/src/generate/tests.rs index a989ca862..5aba78e7e 100644 --- a/xtask/src/generate/tests.rs +++ b/xtask/src/generate/tests.rs @@ -91,6 +91,8 @@ const DENO_IGNORE: &[&str] = &[ "preview1_unlink_file_trailing_slashes", "preview2_adapter_badfd", "preview2_ip_name_lookup", + "preview2_pollable_correct", + "preview2_pollable_traps", "preview2_sleep", "preview2_stream_pollable_correct", "preview2_stream_pollable_traps", @@ -235,7 +237,10 @@ fn generate_test(test_name: &str, windows_skip: bool, deno: bool) -> String { }; let should_error = match test_name { - "cli_exit_failure" | "cli_exit_panic" | "preview2_stream_pollable_traps" => true, + "cli_exit_failure" + | "cli_exit_panic" + | "preview2_stream_pollable_traps" + | "preview2_pollable_traps" => true, _ => false, }; @@ -342,6 +347,8 @@ fn generate_command_invocation( {cmd_name}.arg("./tests/rundir/{run_dir}"); {cmd_name}.arg("--jco-import"); {cmd_name}.arg("./tests/virtualenvs/{virtual_env}.js"); + {cmd_name}.arg("--jco-import-bindings"); + {cmd_name}.arg("hybrid"); {cmd_name}.arg(wasi_file); {cmd_name}.args(&["hello", "this", "", "is an argument", "with 🚩 emoji"]); {cmd_name}.stdin({});"##, diff --git a/xtask/src/generate/wasi_types.rs b/xtask/src/generate/wasi_types.rs index f70237802..f4942d06c 100644 --- a/xtask/src/generate/wasi_types.rs +++ b/xtask/src/generate/wasi_types.rs @@ -3,7 +3,7 @@ use std::fs; use std::io::Write; use std::path::PathBuf; -use js_component_bindgen::{generate_types, source::wit_parser::Resolve}; +use js_component_bindgen::{generate_types, source::wit_parser::Resolve, BindingsMode}; pub(crate) fn run() -> Result<()> { for world in ["wasi:http/proxy", "wasi:cli/command"] { @@ -37,6 +37,7 @@ pub(crate) fn run() -> Result<()> { tracing: false, no_namespaced_exports: true, multi_memory: false, + import_bindings: Some(BindingsMode::Js), }; let files = generate_types(name, resolve, world, opts)?;