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
2 changes: 2 additions & 0 deletions Cargo.lock

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

99 changes: 76 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ wasmtime-cranelift = { workspace = true, optional = true }
wasmtime-environ = { workspace = true }
wasmtime-explorer = { workspace = true, optional = true }
wasmtime-wast = { workspace = true, optional = true }
wasi-common = { workspace = true, default-features = true, features = ["exit", "tokio"], optional = true }
wasi-common = { workspace = true, default-features = true, features = [
"exit",
"tokio",
], optional = true }
wasmtime-wasi = { workspace = true, default-features = true, optional = true }
wasmtime-wasi-nn = { workspace = true, optional = true }
wasmtime-wasi-config = { workspace = true, optional = true }
Expand Down Expand Up @@ -82,22 +85,36 @@ pulley-interpreter = { workspace = true, optional = true }
async-trait = { workspace = true }
bytes = { workspace = true }
cfg-if = { workspace = true }
tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] }
tokio = { workspace = true, optional = true, features = ["signal", "macros"] }
hyper = { workspace = true, optional = true }
http = { workspace = true, optional = true }
http-body-util = { workspace = true, optional = true }
tracing-subscriber.workspace = true

[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["mm", "process"] }

[dev-dependencies]
# depend again on wasmtime to activate its default features for tests
wasmtime = { workspace = true, features = ['default', 'winch', 'pulley', 'all-arch', 'call-hook', 'memory-protection-keys', 'component-model-async'] }
wasmtime = { workspace = true, features = [
'default',
'winch',
'pulley',
'all-arch',
'call-hook',
'memory-protection-keys',
'component-model-async',
] }
env_logger = { workspace = true }
log = { workspace = true }
filecheck = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["rt", "time", "macros", "rt-multi-thread"] }
tokio = { workspace = true, features = [
"rt",
"time",
"macros",
"rt-multi-thread",
] }
wast = { workspace = true }
criterion = { workspace = true }
num_cpus = "1.13.0"
Expand All @@ -107,7 +124,10 @@ wat = { workspace = true }
rayon = "1.5.0"
wasmtime-wast = { workspace = true, features = ['component-model'] }
wasmtime-component-util = { workspace = true }
wasmtime-test-util = { workspace = true, features = ['wasmtime-wast', 'component'] }
wasmtime-test-util = { workspace = true, features = [
'wasmtime-wast',
'component',
] }
bstr = "1.6.0"
libc = { workspace = true }
serde = { workspace = true }
Expand All @@ -117,7 +137,11 @@ test-programs-artifacts = { workspace = true }
bytesize = "2.0.1"
wit-component = { workspace = true }
cranelift-filetests = { workspace = true }
cranelift-codegen = { workspace = true, features = ["disas", "trace-log", "timing"] }
cranelift-codegen = { workspace = true, features = [
"disas",
"trace-log",
"timing",
] }
cranelift-reader = { workspace = true }
toml = { workspace = true }
similar = { workspace = true }
Expand Down Expand Up @@ -170,9 +194,7 @@ members = [
"fuzz",
"winch/codegen",
]
exclude = [
'docs/rust_wasi_markdown_parser',
]
exclude = ['docs/rust_wasi_markdown_parser']

[workspace.package]
version = "38.0.0"
Expand Down Expand Up @@ -253,8 +275,8 @@ wasmtime-wmemcheck = { path = "crates/wmemcheck", version = "=38.0.0", package =
wasmtime-c-api-macros = { path = "crates/c-api-macros", version = "=38.0.0", package = 'wasmtime-internal-c-api-macros' }
wasmtime-cache = { path = "crates/cache", version = "=38.0.0", package = 'wasmtime-internal-cache' }
wasmtime-cranelift = { path = "crates/cranelift", version = "=38.0.0", package = 'wasmtime-internal-cranelift' }
wasmtime-winch = { path = "crates/winch", version = "=38.0.0", package = 'wasmtime-internal-winch' }
wasmtime-explorer = { path = "crates/explorer", version = "=38.0.0", package = 'wasmtime-internal-explorer' }
wasmtime-winch = { path = "crates/winch", version = "=38.0.0", package = 'wasmtime-internal-winch' }
wasmtime-explorer = { path = "crates/explorer", version = "=38.0.0", package = 'wasmtime-internal-explorer' }
wasmtime-fiber = { path = "crates/fiber", version = "=38.0.0", package = 'wasmtime-internal-fiber' }
wasmtime-jit-debug = { path = "crates/jit-debug", version = "=38.0.0", package = 'wasmtime-internal-jit-debug' }
wasmtime-component-util = { path = "crates/component-util", version = "=38.0.0", package = 'wasmtime-internal-component-util' }
Expand All @@ -263,7 +285,7 @@ wasmtime-versioned-export-macros = { path = "crates/versioned-export-macros", ve
wasmtime-slab = { path = "crates/slab", version = "=38.0.0", package = 'wasmtime-internal-slab' }
wasmtime-jit-icache-coherence = { path = "crates/jit-icache-coherence", version = "=38.0.0", package = 'wasmtime-internal-jit-icache-coherence' }
wasmtime-wit-bindgen = { path = "crates/wit-bindgen", version = "=38.0.0", package = 'wasmtime-internal-wit-bindgen' }
wasmtime-math = { path = "crates/math", version = "=38.0.0", package = 'wasmtime-internal-math' }
wasmtime-math = { path = "crates/math", version = "=38.0.0", package = 'wasmtime-internal-math' }
wasmtime-unwinder = { path = "crates/unwinder", version = "=38.0.0", package = 'wasmtime-internal-unwinder' }

# Miscellaneous crates without a `wasmtime-*` prefix in their name but still
Expand All @@ -277,7 +299,10 @@ pulley-macros = { path = 'pulley/macros', version = "=38.0.0" }

# Cranelift crates in this workspace
cranelift-assembler-x64 = { path = "cranelift/assembler-x64", version = "0.125.0" }
cranelift-codegen = { path = "cranelift/codegen", version = "0.125.0", default-features = false, features = ["std", "unwind"] }
cranelift-codegen = { path = "cranelift/codegen", version = "0.125.0", default-features = false, features = [
"std",
"unwind",
] }
cranelift-frontend = { path = "cranelift/frontend", version = "0.125.0" }
cranelift-entity = { path = "cranelift/entity", version = "0.125.0" }
cranelift-native = { path = "cranelift/native", version = "0.125.0" }
Expand Down Expand Up @@ -328,7 +353,9 @@ wit-bindgen = { version = "0.46.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.46.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.239.0", default-features = false, features = ['simd'] }
wasmparser = { version = "0.239.0", default-features = false, features = [
'simd',
] }
wat = "1.239.0"
wast = "239.0.0"
wasmprinter = "0.239.0"
Expand All @@ -346,14 +373,20 @@ json-from-wast = "0.239.0"
arbitrary = "1.4.0"
mutatis = "0.3.2"
cc = "1.0"
object = { version = "0.37.3", default-features = false, features = ['read_core', 'elf'] }
object = { version = "0.37.3", default-features = false, features = [
'read_core',
'elf',
] }
gimli = { version = "0.32.0", default-features = false, features = ['read'] }
addr2line = { version = "0.25.0", default-features = false }
anyhow = { version = "1.0.93", default-features = false }
windows-sys = "0.60.0"
env_logger = "0.11.5"
log = { version = "0.4.27", default-features = false }
clap = { version = "4.5.17", default-features = false, features = ["std", "derive"] }
clap = { version = "4.5.17", default-features = false, features = [
"std",
"derive",
] }
clap_complete = "4.4.7"
hashbrown = { version = "0.15", default-features = false }
capstone = "0.13.0"
Expand Down Expand Up @@ -382,7 +415,7 @@ tempfile = "3.21.0"
filecheck = "0.5.0"
libc = { version = "0.2.112", default-features = true }
file-per-thread-logger = "0.2.0"
tokio = { version = "1.43.0", features = [ "rt", "time" ] }
tokio = { version = "1.43.0", features = ["rt", "time"] }
hyper = "1.0.1"
http = "1.0.0"
http-body = "1.0.0"
Expand All @@ -394,10 +427,18 @@ syn = "2.0.25"
quote = "1.0"
proc-macro2 = "1.0"
test-log = { version = "0.2", default-features = false, features = ["trace"] }
tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt', 'env-filter', 'ansi', 'tracing-log'] }
tracing-subscriber = { version = "0.3.1", default-features = false, features = [
'fmt',
'env-filter',
'ansi',
'tracing-log',
] }
url = "2.3.1"
postcard = { version = "1.0.8", default-features = false, features = ['alloc'] }
criterion = { version = "0.6.0", default-features = false, features = ["html_reports", "rayon"] }
criterion = { version = "0.6.0", default-features = false, features = [
"html_reports",
"rayon",
] }
rustc-hash = "2.0.0"
libtest-mimic = "0.8.1"
semver = { version = "1.0.17", default-features = false }
Expand Down Expand Up @@ -505,14 +546,23 @@ disable-logging = ["log/max_level_off", "tracing/max_level_off"]
wasi-nn = ["dep:wasmtime-wasi-nn"]
wasi-tls = ["dep:wasmtime-wasi-tls"]
wasi-threads = ["dep:wasmtime-wasi-threads", "threads"]
wasi-http = ["component-model", "dep:wasmtime-wasi-http", "dep:tokio", "dep:hyper", "wasmtime-wasi-http/default-send-request"]
wasi-http = [
"component-model",
"dep:wasmtime-wasi-http",
"dep:tokio",
"dep:hyper",
"wasmtime-wasi-http/default-send-request",
]
wasi-config = ["dep:wasmtime-wasi-config"]
wasi-keyvalue = ["dep:wasmtime-wasi-keyvalue"]
pooling-allocator = ["wasmtime/pooling-allocator", "wasmtime-cli-flags/pooling-allocator"]
pooling-allocator = [
"wasmtime/pooling-allocator",
"wasmtime-cli-flags/pooling-allocator",
]
component-model = [
"wasmtime/component-model",
"wasmtime-wast?/component-model",
"wasmtime-cli-flags/component-model"
"wasmtime-cli-flags/component-model",
]
wat = ["dep:wat", "wasmtime/wat"]
cache = ["dep:wasmtime-cache", "wasmtime-cli-flags/cache"]
Expand All @@ -529,7 +579,10 @@ gc = ["wasmtime-cli-flags/gc", "wasmtime/gc"]
gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"]
gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"]
pulley = ["wasmtime-cli-flags/pulley"]
stack-switching = ["wasmtime/stack-switching", "wasmtime-cli-flags/stack-switching"]
stack-switching = [
"wasmtime/stack-switching",
"wasmtime-cli-flags/stack-switching",
]

# CLI subcommands for the `wasmtime` executable. See `wasmtime $cmd --help`
# for more information on each subcommand.
Expand Down
4 changes: 4 additions & 0 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ wasmtime_option_group! {
/// Component model support for async lifting/lowering: this corresponds
/// to the 🚟 emoji in the component model specification.
pub component_model_async_stackful: Option<bool>,
/// Component model support for threading: this corresponds
/// to the 🧵 emoji in the component model specification.
pub component_model_threading: Option<bool>,
/// Component model support for `error-context`: this corresponds
/// to the 📝 emoji in the component model specification.
pub component_model_error_context: Option<bool>,
Expand Down Expand Up @@ -1052,6 +1055,7 @@ impl CommonOptions {
("component-model-async", component_model_async, wasm_component_model_async)
("component-model-async", component_model_async_builtins, wasm_component_model_async_builtins)
("component-model-async", component_model_async_stackful, wasm_component_model_async_stackful)
("component-model-async", component_model_threading, wasm_component_model_threading)
("component-model", component_model_error_context, wasm_component_model_error_context)
("threads", threads, wasm_threads)
("gc", gc, wasm_gc)
Expand Down
86 changes: 86 additions & 0 deletions crates/cranelift/src/compiler/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,92 @@ impl<'a> TrampolineCompiler<'a> {
},
);
}
Trampoline::ThreadIndex => {
self.translate_libcall(
host::thread_index,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|_, _| {},
);
}
Trampoline::ThreadNewIndirect {
instance,
start_func_table_idx,
start_func_ty_idx,
} => {
self.translate_libcall(
host::thread_new_indirect,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(me.index_value(*start_func_table_idx));
params.push(me.index_value(*start_func_ty_idx));
},
);
}
Trampoline::ThreadSwitchTo {
instance,
cancellable,
} => {
self.translate_libcall(
host::thread_switch_to,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(
me.builder
.ins()
.iconst(ir::types::I8, i64::from(*cancellable)),
);
},
);
}
Trampoline::ThreadSuspend {
instance,
cancellable,
} => {
self.translate_libcall(
host::thread_suspend,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(
me.builder
.ins()
.iconst(ir::types::I8, i64::from(*cancellable)),
);
},
);
}
Trampoline::ThreadResumeLater => {
self.translate_libcall(
host::thread_resume_later,
TrapSentinel::Falsy,
WasmArgs::InRegisters,
|_, _| {},
);
}
Trampoline::ThreadYieldTo {
instance,
cancellable,
} => {
self.translate_libcall(
host::thread_yield_to,
TrapSentinel::NegativeOne,
WasmArgs::InRegisters,
|me, params| {
params.push(me.index_value(*instance));
params.push(
me.builder
.ins()
.iconst(ir::types::I8, i64::from(*cancellable)),
);
},
);
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions crates/environ/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ macro_rules! foreach_builtin_component_function {
context_get(vmctx: vmctx, caller_instance: u32, slot: u32) -> u64;
#[cfg(feature = "component-model-async")]
context_set(vmctx: vmctx, caller_instance: u32, slot: u32, val: u32) -> bool;
#[cfg(feature = "component-model-async")]
thread_index(vmctx: vmctx) -> u64;
#[cfg(feature = "component-model-async")]
thread_new_indirect(vmctx: vmctx, caller_instance: u32, func_ty_id: u32, func_table_idx: u32, func_idx: u32, context: u32) -> u64;
#[cfg(feature = "component-model-async")]
thread_switch_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
#[cfg(feature = "component-model-async")]
thread_suspend(vmctx: vmctx, caller_instance: u32, cancellable: u8) -> u32;
#[cfg(feature = "component-model-async")]
thread_resume_later(vmctx: vmctx, thread_idx: u32) -> bool;
#[cfg(feature = "component-model-async")]
thread_yield_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;

trap(vmctx: vmctx, code: u8) -> bool;

Expand Down
Loading
Loading