A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Little follow ups to #13695 (#13755)
Nick Fitzgerald1faf78359920
diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rsindex bfabe07a02..f4c9f788d0 100644--- a/crates/cranelift/src/compiler.rs+++ b/crates/cranelift/src/compiler.rs@@ -1530,7 +1530,10 @@ impl Compiler {// `VMDeferredThread` inside an old, since-unwound stack// frame. Therefore, we must reset `current_thread` to avoid// potential use-after-free bugs.- let forced = builder.ins().iconst(pointer_type, 1);+ let forced = builder.ins().iconst(+ pointer_type,+ i64::try_from(wasmtime_environ::VM_LAZY_THREAD_FORCED).unwrap(),+ );alias_regions.store_vmstore_context_current_thread(&mut builder.cursor(),vm_store_ctx,diff --git a/crates/environ/src/compile/module_environ.rs b/crates/environ/src/compile/module_environ.rsindex d60f35b641..1c7961323a 100644--- a/crates/environ/src/compile/module_environ.rs+++ b/crates/environ/src/compile/module_environ.rs@@ -49,12 +49,12 @@ pub enum FactInlineIntrinsic {ExitSyncCall,}-/// TODO FITZGEN+/// A statically-known function import.#[derive(Clone, Debug)]pub enum KnownFunc {- /// TODO FITZGEN+ /// A function described by the given key.FuncKey(FuncKey),- /// TODO FITZGEN+ /// An always-inlined FACT intrinsic.FactIntrinsic(FactInlineIntrinsic),}diff --git a/crates/environ/src/vmoffsets.rs b/crates/environ/src/vmoffsets.rsindex 244ab92e39..5f9602c445 100644--- a/crates/environ/src/vmoffsets.rs+++ b/crates/environ/src/vmoffsets.rs@@ -1411,3 +1411,6 @@ mod tests {assert!(is_aligned(align(31, 16)));}}++/// The bit pattern of `VMLazyThread::forced()`.+pub const VM_LAZY_THREAD_FORCED: u64 = 1;diff --git a/crates/wasmtime/src/runtime/vm/vmcontext.rs b/crates/wasmtime/src/runtime/vm/vmcontext.rsindex 9c665e084b..ceaa88cbb3 100644--- a/crates/wasmtime/src/runtime/vm/vmcontext.rs+++ b/crates/wasmtime/src/runtime/vm/vmcontext.rs@@ -1515,6 +1515,19 @@ impl VMLazyThread {}}+#[cfg(test)]+mod test_vmlazy_thread {+ use super::*;++ #[test]+ fn vmlazy_thread_forced() {+ assert_eq!(+ VMLazyThread::forced().0.unwrap().addr().get(),+ usize::try_from(wasmtime_environ::VM_LAZY_THREAD_FORCED).unwrap()+ );+ }+}+/// A deferred component-model thread.////// This is an on-stack record pushed by a fused sync-to-sync adapter's fast