diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rs index bfabe07a0213..f4c9f788d0d8 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.rs index d60f35b64199..1c7961323aed 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.rs index 244ab92e3910..5f9602c44536 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.rs index 9c665e084b44..ceaa88cbb383 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