Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -791,3 +791,18 @@ fpr = "fpr"

[workspace.metadata.typos.files]
extend-exclude = [ "docs/js/mermaid*.js", "crates/wasi-nn/**/*.txt", "*.isle" ]

[patch.crates-io]
wasmparser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wat = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wast = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasmprinter = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-encoder = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-smith = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-mutate = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wit-parser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wit-component = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-wave = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-compose = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
wasm-metadata = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
json-from-wast = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "a7a7254c359e82c7a55b9827ddca30a42eecb1e9" }
24 changes: 24 additions & 0 deletions crates/cranelift/src/compiler/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,17 @@ impl<'a> TrampolineCompiler<'a> {
);
}
}
Trampoline::StreamForward { instance, ty } => {
self.translate_libcall(
host::stream_forward,
TrapSentinel::Falsy,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(me.index_value(*ty));
},
);
}
Trampoline::StreamCancelRead {
instance,
ty,
Expand Down Expand Up @@ -498,6 +509,17 @@ impl<'a> TrampolineCompiler<'a> {
},
);
}
Trampoline::FutureForward { instance, ty } => {
self.translate_libcall(
host::future_forward,
TrapSentinel::Falsy,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(me.index_value(*ty));
},
);
}
Trampoline::FutureCancelRead {
instance,
ty,
Expand Down Expand Up @@ -1551,13 +1573,15 @@ impl<'a> TrampolineCompiler<'a> {
| Trampoline::StreamNew { instance, .. }
| Trampoline::StreamRead { instance, .. }
| Trampoline::StreamWrite { instance, .. }
| Trampoline::StreamForward { instance, .. }
| Trampoline::StreamCancelRead { instance, .. }
| Trampoline::StreamCancelWrite { instance, .. }
| Trampoline::StreamDropReadable { instance, .. }
| Trampoline::StreamDropWritable { instance, .. }
| Trampoline::FutureNew { instance, .. }
| Trampoline::FutureRead { instance, .. }
| Trampoline::FutureWrite { instance, .. }
| Trampoline::FutureForward { instance, .. }
| Trampoline::FutureCancelRead { instance, .. }
| Trampoline::FutureCancelWrite { instance, .. }
| Trampoline::FutureDropReadable { instance, .. }
Expand Down
4 changes: 4 additions & 0 deletions crates/environ/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ macro_rules! foreach_builtin_component_function {
#[cfg(feature = "component-model-async")]
future_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, future: u32, address: u32) -> u64;
#[cfg(feature = "component-model-async")]
future_forward(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32, writer: u32) -> bool;
#[cfg(feature = "component-model-async")]
future_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
#[cfg(feature = "component-model-async")]
future_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
Expand All @@ -160,6 +162,8 @@ macro_rules! foreach_builtin_component_function {
#[cfg(feature = "component-model-async")]
stream_read(vmctx: vmctx, caller_instance: u32, ty: u32, options: u32, stream: u32, address: u32, count: u32) -> u64;
#[cfg(feature = "component-model-async")]
stream_forward(vmctx: vmctx, caller_instance: u32, ty: u32, reader: u32, writer: u32) -> bool;
#[cfg(feature = "component-model-async")]
stream_cancel_write(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, writer: u32) -> u64;
#[cfg(feature = "component-model-async")]
stream_cancel_read(vmctx: vmctx, caller_instance: u32, ty: u32, async_: u8, reader: u32) -> u64;
Expand Down
16 changes: 16 additions & 0 deletions crates/environ/src/component/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ pub enum Trampoline {
ty: TypeStreamTableIndex,
options: OptionsId,
},
StreamForward {
instance: RuntimeComponentInstanceIndex,
ty: TypeStreamTableIndex,
},
StreamCancelRead {
instance: RuntimeComponentInstanceIndex,
ty: TypeStreamTableIndex,
Expand Down Expand Up @@ -422,6 +426,10 @@ pub enum Trampoline {
ty: TypeFutureTableIndex,
options: OptionsId,
},
FutureForward {
instance: RuntimeComponentInstanceIndex,
ty: TypeFutureTableIndex,
},
FutureCancelRead {
instance: RuntimeComponentInstanceIndex,
ty: TypeFutureTableIndex,
Expand Down Expand Up @@ -1033,6 +1041,10 @@ impl LinearizeDfg<'_> {
ty: *ty,
options: self.options(*options),
},
Trampoline::StreamForward { instance, ty } => info::Trampoline::StreamForward {
instance: *instance,
ty: *ty,
},
Trampoline::StreamCancelRead {
instance,
ty,
Expand Down Expand Up @@ -1085,6 +1097,10 @@ impl LinearizeDfg<'_> {
ty: *ty,
options: self.options(*options),
},
Trampoline::FutureForward { instance, ty } => info::Trampoline::FutureForward {
instance: *instance,
ty: *ty,
},
Trampoline::FutureCancelRead {
instance,
ty,
Expand Down
22 changes: 22 additions & 0 deletions crates/environ/src/component/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,16 @@ pub enum Trampoline {
options: OptionsIndex,
},

/// A `stream.forward` intrinsic to forward all remaining elements from the
/// readable end of one `stream` into the writable end of another `stream`
/// of the specified type.
StreamForward {
/// The specific component instance which is calling the intrinsic.
instance: RuntimeComponentInstanceIndex,
/// The table index for the specific `stream` type and caller instance.
ty: TypeStreamTableIndex,
},

/// A `stream.cancel-read` intrinsic to cancel an in-progress read from a
/// `stream` of the specified type.
StreamCancelRead {
Expand Down Expand Up @@ -960,6 +970,16 @@ pub enum Trampoline {
options: OptionsIndex,
},

/// A `future.forward` intrinsic to forward the value of the `future` with
/// the specified readable end into the `future` with the specified
/// writable end.
FutureForward {
/// The specific component instance which is calling the intrinsic.
instance: RuntimeComponentInstanceIndex,
/// The table index for the specific `future` type and caller instance.
ty: TypeFutureTableIndex,
},

/// A `future.cancel-read` intrinsic to cancel an in-progress read from a
/// `future` of the specified type.
FutureCancelRead {
Expand Down Expand Up @@ -1225,13 +1245,15 @@ impl Trampoline {
StreamNew { .. } => format!("stream-new"),
StreamRead { .. } => format!("stream-read"),
StreamWrite { .. } => format!("stream-write"),
StreamForward { .. } => format!("stream-forward"),
StreamCancelRead { .. } => format!("stream-cancel-read"),
StreamCancelWrite { .. } => format!("stream-cancel-write"),
StreamDropReadable { .. } => format!("stream-drop-readable"),
StreamDropWritable { .. } => format!("stream-drop-writable"),
FutureNew { .. } => format!("future-new"),
FutureRead { .. } => format!("future-read"),
FutureWrite { .. } => format!("future-write"),
FutureForward { .. } => format!("future-forward"),
FutureCancelRead { .. } => format!("future-cancel-read"),
FutureCancelWrite { .. } => format!("future-cancel-write"),
FutureDropReadable { .. } => format!("future-drop-readable"),
Expand Down
28 changes: 28 additions & 0 deletions crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ enum LocalInitializer<'data> {
ty: ComponentDefinedTypeId,
options: LocalCanonicalOptions,
},
StreamForward {
ty: ComponentDefinedTypeId,
func: ModuleInternedTypeIndex,
},
StreamCancelRead {
ty: ComponentDefinedTypeId,
func: ModuleInternedTypeIndex,
Expand Down Expand Up @@ -272,6 +276,10 @@ enum LocalInitializer<'data> {
ty: ComponentDefinedTypeId,
options: LocalCanonicalOptions,
},
FutureForward {
ty: ComponentDefinedTypeId,
func: ModuleInternedTypeIndex,
},
FutureCancelRead {
ty: ComponentDefinedTypeId,
func: ModuleInternedTypeIndex,
Expand Down Expand Up @@ -1145,6 +1153,16 @@ impl<'a, 'data> Translator<'a, 'data> {
core_func_index += 1;
LocalInitializer::StreamWrite { ty, options }
}
wasmparser::CanonicalFunction::StreamForward { ty } => {
let ty = self
.validator
.types(0)
.unwrap()
.component_defined_type_at(ty);
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
LocalInitializer::StreamForward { ty, func }
}
wasmparser::CanonicalFunction::StreamCancelRead { ty, async_ } => {
let ty = self
.validator
Expand Down Expand Up @@ -1215,6 +1233,16 @@ impl<'a, 'data> Translator<'a, 'data> {
core_func_index += 1;
LocalInitializer::FutureWrite { ty, options }
}
wasmparser::CanonicalFunction::FutureForward { ty } => {
let ty = self
.validator
.types(0)
.unwrap()
.component_defined_type_at(ty);
let func = self.core_func_signature(core_func_index)?;
core_func_index += 1;
LocalInitializer::FutureForward { ty, func }
}
wasmparser::CanonicalFunction::FutureCancelRead { ty, async_ } => {
let ty = self
.validator
Expand Down
Loading
Loading