Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Macro-generate most stack-switching `VM*` types (#14278)

Nick Fitzgeraldc518d90db4f6
diff --git a/crates/cranelift/src/alias_region.rs b/crates/cranelift/src/alias_region.rs
index 857a8c1376..2ced3eb928 100644
--- a/crates/cranelift/src/alias_region.rs
+++ b/crates/cranelift/src/alias_region.rs
@@ -1,3 +1,23 @@
+//! Alias regions for the memory that compiled Wasm code accesses.
+//!
+//! Every load and store Wasmtime emits carries a
+//! `cranelift_codegen::ir::AliasRegion` naming the memory it touches, so that
+//! Cranelift's alias analysis can better eliminate redundant loads, dead
+//! stores, etc. This module, and primarily its `AliasRegions` type, parcels
+//! those regions out.
+//!
+//! `AliasRegions` accessors come from two places:
+//!
+//! 1. Fields of the `VM*` types and of the vmctx types get one region per
+//! field, and an accessor per field is generated from our
+//! `for_each_vm[ctx]_type!` macros.
+//!
+//! 2. There are a handful of hand-written methods for memory regions that are
+//! not part of the vmctx or a `VM*` type at all (linear memories, the GC
+//! heap, stack slots, etc...).
+//!
+//! We strive to avoid adding new hand-written methods as much as possible.
+
use crate::translate::Load;
use core::fmt;
use cranelift_codegen::{
@@ -38,12 +58,15 @@ enum VmType {
VMCopyingHeapData,
VMNullHeapData,
VMDeferredThread,
+ VMStackLimits,
#[allow(
dead_code,
reason = "generated uniformly for all VM types via `for_each_vm_type!`"
)]
VMLazyThread,
VMContRef,
+ VMCommonStackInformation,
+ VMHostArray,
ContinuationStackMemory,
VMFunctionImport,
VMMemoryImport,
@@ -191,6 +214,9 @@ impl AliasRegionKey {
const VM_GLOBAL_DEFINITION_KIND: u32 = Self::new_kind(0b100001);
const VM_TAG_DEFINITION_KIND: u32 = Self::new_kind(0b100010);
const VM_LAZY_THREAD_KIND: u32 = Self::new_kind(0b100011);
+ const VM_STACK_LIMITS_KIND: u32 = Self::new_kind(0b100100);
+ const VM_COMMON_STACK_INFORMATION_KIND: u32 = Self::new_kind(0b100101);
+ const VM_HOST_ARRAY_KIND: u32 = Self::new_kind(0b100110);
/// Encode this key into a raw `u32` suitable for use as an
/// `AliasRegionData::user_id`.
@@ -210,8 +236,11 @@ impl AliasRegionKey {
VmType::VMCopyingHeapData => Self::VM_COPYING_HEAP_DATA_KIND,
VmType::VMNullHeapData => Self::VM_NULL_HEAP_DATA_KIND,
VmType::VMDeferredThread => Self::VM_DEFERRED_THREAD_KIND,
+ VmType::VMStackLimits => Self::VM_STACK_LIMITS_KIND,
VmType::VMLazyThread => Self::VM_LAZY_THREAD_KIND,
VmType::VMContRef => Self::VM_CONTREF_KIND,
+ VmType::VMCommonStackInformation => Self::VM_COMMON_STACK_INFORMATION_KIND,
+ VmType::VMHostArray => Self::VM_HOST_ARRAY_KIND,
VmType::ContinuationStackMemory => Self::CONTINUATION_STACK_MEMORY_KIND,
VmType::VMFunctionImport => Self::VM_FUNCTION_IMPORT_KIND,
VmType::VMMemoryImport => Self::VM_MEMORY_IMPORT_KIND,
@@ -600,6 +629,7 @@ macro_rules! define_vm_type_alias_region_helpers {
(@field_ty $pt:expr, Option < VmPtr < $g:ty >>) => { $pt };
(@field_ty $pt:expr, AtomicUsize) => { $pt };
(@field_ty $pt:expr, usize) => { $pt };
+ (@field_ty $pt:expr, * mut $g:ty) => { $pt };
(@field_ty $pt:expr, i64) => { ir::types::I64 };
(@field_ty $pt:expr, u64) => { ir::types::I64 };
(@field_ty $pt:expr, u32) => { ir::types::I32 };
@@ -614,6 +644,7 @@ macro_rules! define_vm_type_alias_region_helpers {
(@field_ty $pt:expr, DefinedMemoryIndex) => { ir::types::I32 };
(@field_ty $pt:expr, DefinedTagIndex) => { ir::types::I32 };
(@field_ty $pt:expr, VMGlobalKind) => { ir::types::I64 };
+ (@field_ty $pt:expr, VMStackState) => { ir::types::I32 };
// Classify an `#[indexed]` field's array type to
// `(element ir::Type, element size in bytes, element count)`.
@@ -1427,95 +1458,37 @@ impl<Offsets> AliasRegions<Offsets>
where
Offsets: GetPtrSize,
{
- /// Load `VMStackLimits::stack_limit`.
- pub fn stack_limit(
- &mut self,
- cursor: &mut FuncCursor<'_>,
- stack_limits: ir::Value,
- ) -> ir::Value {
- let offset = self.offsets.get_ptr_size().vmstack_limits_stack_limit();
- let region = self.vmcontref_region(cursor.func);
- cursor.ins().load(
- self.pointer_type,
- ir::MemFlagsData::trusted().with_alias_region(Some(region)),
- stack_limits,
- i32::from(offset),
- )
- }
-
- /// Load `VMStackLimits::last_wasm_entry_fp`.
- pub fn last_wasm_entry_fp(
- &mut self,
- cursor: &mut FuncCursor<'_>,
- stack_limits: ir::Value,
- ) -> ir::Value {
- let offset = self
- .offsets
- .get_ptr_size()
- .vmstack_limits_last_wasm_entry_fp();
- let region = self.vmcontref_region(cursor.func);
- cursor.ins().load(
- self.pointer_type,
- ir::MemFlagsData::trusted().with_alias_region(Some(region)),
- stack_limits,
- i32::from(offset),
- )
- }
-
- /// Load `VMStackLimits::last_wasm_entry_sp`.
- pub fn last_wasm_entry_sp(
- &mut self,
- cursor: &mut FuncCursor<'_>,
- stack_limits: ir::Value,
- ) -> ir::Value {
- let offset = self
- .offsets
- .get_ptr_size()
- .vmstack_limits_last_wasm_entry_sp();
- let region = self.vmcontref_region(cursor.func);
- cursor.ins().load(
- self.pointer_type,
- ir::MemFlagsData::trusted().with_alias_region(Some(region)),
- stack_limits,
- i32::from(offset),
- )
- }
-
- /// Load `VMStackLimits::last_wasm_entry_trap_handler`.
- pub fn last_wasm_entry_trap_handler(
- &mut self,
- cursor: &mut FuncCursor<'_>,
- stack_limits: ir::Value,
- ) -> ir::Value {
- let offset = self
- .offsets
- .get_ptr_size()
- .vmstack_limits_last_wasm_entry_trap_handler();
- let region = self.vmcontref_region(cursor.func);
- cursor.ins().load(
- self.pointer_type,
- ir::MemFlagsData::trusted().with_alias_region(Some(region)),
- stack_limits,
- i32::from(offset),
+ /// Get the alias region for the `VMContRef::parent_chain` field.
+ ///
+ /// Like `VMStoreContext::stack_chain`, this field is a two-pointer-wide
+ /// `VMStackChain`, which is not yet defined by `for_each_vm_type!` and so
+ /// has no alias region of its own. Its bytes are therefore mapped to the
+ /// containing `VMContRef`'s regions, keyed by the field's offset within it.
+ pub fn vm_cont_ref_parent_chain_region(&mut self, func: &mut ir::Function) -> ir::AliasRegion {
+ let offset = self.offsets.get_ptr_size().vm_cont_ref().parent_chain();
+ self.region(
+ func,
+ AliasRegionKey::Vm {
+ ty: VmType::VMContRef,
+ offset: offset.into(),
+ },
)
}
- /// Region for a continuation-reference object and its inline
- /// sub-structures.
+ /// Get the alias region for the top-of-stack pointer at the start of the
+ /// `VMContRef::stack` field.
///
- /// A `VMContRef` (and its inline `VMCommonStackInformation` /
- /// `VMStackLimits` / `VMHostArray` headers) is reached through a `*mut
- /// VMContRef`.
- ///
- /// A single region covers the whole object: this is coarse but sound, and
- /// keeps every field of the object disjoint from linear memory, the vmctx,
- /// the store context, etc...
- pub fn vmcontref_region(&mut self, func: &mut ir::Function) -> ir::AliasRegion {
+ /// `VMContinuationStack` is a platform-specific struct private to the
+ /// runtime, is not one of the types defined by `for_each_vm_type!`, and so
+ /// has no alias region of its own; as with `parent_chain` above, its bytes
+ /// are mapped to the containing `VMContRef`'s regions.
+ pub fn vm_cont_ref_top_of_stack_region(&mut self, func: &mut ir::Function) -> ir::AliasRegion {
+ let offset = self.offsets.get_ptr_size().vm_cont_ref().stack();
self.region(
func,
AliasRegionKey::Vm {
ty: VmType::VMContRef,
- offset: 0,
+ offset: offset.into(),
},
)
}
diff --git a/crates/cranelift/src/func_environ/stack_switching/instructions.rs b/crates/cranelift/src/func_environ/stack_switching/instructions.rs
index d263620b3c..0310f62bd1 100644
--- a/crates/cranelift/src/func_environ/stack_switching/instructions.rs
+++ b/crates/cranelift/src/func_environ/stack_switching/instructions.rs
@@ -103,7 +103,7 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> VMPayloads {
- let offset: i64 = env.offsets.ptr.vmcontref_args().into();
+ let offset: i64 = env.offsets.ptr.vm_cont_ref().args().into();
let address = builder.ins().iadd_imm_s(self.address, offset);
VMPayloads::new(address)
}
@@ -113,7 +113,7 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> VMPayloads {
- let offset: i64 = env.offsets.ptr.vmcontref_values().into();
+ let offset: i64 = env.offsets.ptr.vm_cont_ref().values().into();
let address = builder.ins().iadd_imm_s(self.address, offset);
VMPayloads::new(address)
}
@@ -123,7 +123,12 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> VMCommonStackInformation {
- let offset: i64 = env.offsets.ptr.vmcontref_common_stack_information().into();
+ let offset: i64 = env
+ .offsets
+ .ptr
+ .vm_cont_ref()
+ .common_stack_information()
+ .into();
let address = builder.ins().iadd_imm_s(self.address, offset);
VMCommonStackInformation { address }
}
@@ -137,8 +142,10 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
new_stack_chain: &VMStackChain,
) {
- let offset = env.offsets.ptr.vmcontref_parent_chain().into();
- let region = env.alias_regions.vmcontref_region(builder.func);
+ let offset = env.offsets.ptr.vm_cont_ref().parent_chain().into();
+ let region = env
+ .alias_regions
+ .vm_cont_ref_parent_chain_region(builder.func);
new_stack_chain.store(env, builder, self.address, offset, Some(region))
}
@@ -150,8 +157,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> VMStackChain {
- let offset = env.offsets.ptr.vmcontref_parent_chain().into();
- let region = env.alias_regions.vmcontref_region(builder.func);
+ let offset = env.offsets.ptr.vm_cont_ref().parent_chain().into();
+ let region = env
+ .alias_regions
+ .vm_cont_ref_parent_chain_region(builder.func);
VMStackChain::load(
env,
builder,
@@ -168,12 +177,11 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
last_ancestor: ir::Value,
) {
- let offset: i32 = env.offsets.ptr.vmcontref_last_ancestor().into();
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- builder
- .ins()
- .store(mem_flags, last_ancestor, self.address, offset);
+ env.alias_regions.vm_cont_ref().last_ancestor().store(
+ &mut builder.cursor(),
+ self.address,
+ last_ancestor,
+ );
}
pub fn get_last_ancestor<'a>(
@@ -181,12 +189,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let offset: i32 = env.offsets.ptr.vmcontref_last_ancestor().into();
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- builder
- .ins()
- .load(env.pointer_type(), mem_flags, self.address, offset)
+ env.alias_regions
+ .vm_cont_ref()
+ .last_ancestor()
+ .load(&mut builder.cursor(), self.address)
}
/// Gets the revision counter the a given continuation
@@ -196,11 +202,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let offset: i32 = env.offsets.ptr.vmcontref_revision().into();
- let revision = builder.ins().load(I64, mem_flags, self.address, offset);
- revision
+ env.alias_regions
+ .vm_cont_ref()
+ .revision()
+ .load(&mut builder.cursor(), self.address)
}
/// Sets the revision counter on the given continuation
@@ -212,13 +217,12 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
revision: ir::Value,
) -> ir::Value {
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let offset: i32 = env.offsets.ptr.vmcontref_revision().into();
let revision_plus1 = builder.ins().iadd_imm_s(revision, 1);
- builder
- .ins()
- .store(mem_flags, revision_plus1, self.address, offset);
+ env.alias_regions.vm_cont_ref().revision().store(
+ &mut builder.cursor(),
+ self.address,
+ revision_plus1,
+ );
revision_plus1
}
@@ -228,7 +232,7 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
) -> VMContinuationStack {
// The top of stack field is stored at offset 0 of the `FiberStack`.
- let offset: i64 = env.offsets.ptr.vmcontref_stack().into();
+ let offset: i64 = env.offsets.ptr.vm_cont_ref().stack().into();
let fiber_stack_top_of_stack_ptr = builder.ins().iadd_imm_s(self.address, offset);
VMContinuationStack::new(fiber_stack_top_of_stack_ptr)
}
@@ -242,43 +246,15 @@ pub(crate) mod stack_switching_helpers {
}
}
- fn get(
- &self,
- env: &mut crate::func_environ::FuncEnvironment<'_>,
- builder: &mut FunctionBuilder,
- ty: ir::Type,
- offset: i32,
- ) -> ir::Value {
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- builder.ins().load(ty, mem_flags, self.address, offset)
- }
-
- fn set<U>(
- &self,
- env: &mut crate::func_environ::FuncEnvironment<'_>,
- builder: &mut FunctionBuilder,
- offset: i32,
- value: ir::Value,
- ) {
- debug_assert_eq!(
- builder.func.dfg.value_type(value),
- Type::int_with_byte_size(u16::try_from(core::mem::size_of::<U>()).unwrap())
- .unwrap()
- );
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- builder.ins().store(mem_flags, value, self.address, offset);
- }
-
pub fn get_data<'a>(
&self,
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let offset = env.offsets.ptr.vmhostarray_data().into();
- let pointer_type = env.pointer_type();
- self.get(env, builder, pointer_type, offset)
+ env.alias_regions
+ .vm_host_array()
+ .data()
+ .load(&mut builder.cursor(), self.address)
}
pub fn get_length<'a>(
@@ -286,9 +262,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- // Array length is stored as u32.
- let offset = env.offsets.ptr.vmhostarray_length().into();
- self.get(env, builder, I32, offset)
+ env.alias_regions
+ .vm_host_array()
+ .length()
+ .load(&mut builder.cursor(), self.address)
}
fn set_length<'a>(
@@ -297,9 +274,11 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
length: ir::Value,
) {
- // Array length is stored as u32.
- let offset = env.offsets.ptr.vmhostarray_length().into();
- self.set::<u32>(env, builder, offset, length);
+ env.alias_regions.vm_host_array().length().store(
+ &mut builder.cursor(),
+ self.address,
+ length,
+ );
}
fn set_capacity<'a>(
@@ -308,9 +287,11 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
capacity: ir::Value,
) {
- // Array capacity is stored as u32.
- let offset = env.offsets.ptr.vmhostarray_capacity().into();
- self.set::<u32>(env, builder, offset, capacity);
+ env.alias_regions.vm_host_array().capacity().store(
+ &mut builder.cursor(),
+ self.address,
+ capacity,
+ );
}
fn set_data<'a>(
@@ -320,10 +301,11 @@ pub(crate) mod stack_switching_helpers {
data: ir::Value,
) {
debug_assert_eq!(builder.func.dfg.value_type(data), env.pointer_type());
- let offset: i32 = env.offsets.ptr.vmhostarray_data().into();
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- builder.ins().store(mem_flags, data, self.address, offset);
+ env.alias_regions.vm_host_array().data().store(
+ &mut builder.cursor(),
+ self.address,
+ data,
+ );
}
/// Returns pointer to next empty slot in data buffer and marks the
@@ -620,28 +602,23 @@ pub(crate) mod stack_switching_helpers {
// Since a `VMContRef` starts with an (inlined) CommonStackInformation
// object at offset 0, we actually have in both cases that `ptr` is
// now the address of the beginning of a VMStackLimits object.
- debug_assert_eq!(env.offsets.ptr.vmcontref_common_stack_information(), 0);
+ debug_assert_eq!(env.offsets.ptr.vm_cont_ref().common_stack_information(), 0);
VMCommonStackInformation { address }
}
}
impl VMCommonStackInformation {
- fn get_state_ptr<'a>(
- &self,
- env: &mut crate::func_environ::FuncEnvironment<'a>,
- builder: &mut FunctionBuilder,
- ) -> ir::Value {
- let offset: i64 = env.offsets.ptr.vmcommon_stack_information_state().into();
-
- builder.ins().iadd_imm_s(self.address, offset)
- }
-
fn get_stack_limits_ptr<'a>(
&self,
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let offset: i64 = env.offsets.ptr.vmcommon_stack_information_limits().into();
+ let offset: i64 = env
+ .offsets
+ .ptr
+ .vm_common_stack_information()
+ .limits()
+ .into();
builder.ins().iadd_imm_s(self.address, offset)
}
@@ -651,11 +628,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let state_ptr = self.get_state_ptr(env, builder);
-
- builder.ins().load(I32, mem_flags, state_ptr, 0)
+ env.alias_regions
+ .vm_common_stack_information()
+ .state()
+ .load(&mut builder.cursor(), self.address)
}
fn set_state_no_payload<'a>(
@@ -665,11 +641,10 @@ pub(crate) mod stack_switching_helpers {
discriminant: u32,
) {
let discriminant = builder.ins().iconst(I32, i64::from(discriminant));
- let region = env.alias_regions.vmcontref_region(builder.func);
- let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let state_ptr = self.get_state_ptr(env, builder);
-
- builder.ins().store(mem_flags, discriminant, state_ptr, 0);
+ env.alias_regions
+ .vm_common_stack_information()
+ .state()
+ .store(&mut builder.cursor(), self.address, discriminant);
}
pub fn set_state_running<'a>(
@@ -736,7 +711,12 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> VMHandlerList {
- let offset: i64 = env.offsets.ptr.vmcommon_stack_information_handlers().into();
+ let offset: i64 = env
+ .offsets
+ .ptr
+ .vm_common_stack_information()
+ .handlers()
+ .into();
let address = builder.ins().iadd_imm_s(self.address, offset);
VMHandlerList::new(address)
}
@@ -746,15 +726,10 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- // Field first_switch_handler_index has type u32
- let region = env.alias_regions.vmcontref_region(builder.func);
- let memflags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let offset: i32 = env
- .offsets
- .ptr
- .vmcommon_stack_information_first_switch_handler_index()
- .into();
- builder.ins().load(I32, memflags, self.address, offset)
+ env.alias_regions
+ .vm_common_stack_information()
+ .first_switch_handler_index()
+ .load(&mut builder.cursor(), self.address)
}
pub fn set_first_switch_handler_index<'a>(
@@ -763,15 +738,10 @@ pub(crate) mod stack_switching_helpers {
builder: &mut FunctionBuilder,
value: ir::Value,
) {
- // Field first_switch_handler_index has type u32
- let region = env.alias_regions.vmcontref_region(builder.func);
- let memflags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
- let offset: i32 = env
- .offsets
- .ptr
- .vmcommon_stack_information_first_switch_handler_index()
- .into();
- builder.ins().store(memflags, value, self.address, offset);
+ env.alias_regions
+ .vm_common_stack_information()
+ .first_switch_handler_index()
+ .store(&mut builder.cursor(), self.address, value);
}
/// Restores the stack limit and Wasm entry handler fields in
@@ -784,12 +754,13 @@ pub(crate) mod stack_switching_helpers {
) {
let stack_limits_ptr = self.get_stack_limits_ptr(env, builder);
- // The load side reads this continuation's inline `VMStackLimits`
- // (the `VMContRef` region); the store side targets the
- // `VMStoreContext`.
+ // The load side reads this continuation's inline `VMStackLimits`;
+ // the store side targets the `VMStoreContext`.
let stack_limit = env
.alias_regions
- .stack_limit(&mut builder.cursor(), stack_limits_ptr);
+ .vm_stack_limits()
+ .stack_limit()
+ .load(&mut builder.cursor(), stack_limits_ptr);
env.alias_regions.vm_store_context().stack_limit().store(
&mut builder.cursor(),
vmruntime_limits_ptr,
@@ -798,7 +769,9 @@ pub(crate) mod stack_switching_helpers {
let last_wasm_entry_fp = env
.alias_regions
- .last_wasm_entry_fp(&mut builder.cursor(), stack_limits_ptr);
+ .vm_stack_limits()
+ .last_wasm_entry_fp()
+ .load(&mut builder.cursor(), stack_limits_ptr);
env.alias_regions
.vm_store_context()
.last_wasm_entry_fp()
@@ -810,7 +783,9 @@ pub(crate) mod stack_switching_helpers {
let last_wasm_entry_sp = env
.alias_regions
- .last_wasm_entry_sp(&mut builder.cursor(), stack_limits_ptr);
+ .vm_stack_limits()
+ .last_wasm_entry_sp()
+ .load(&mut builder.cursor(), stack_limits_ptr);
env.alias_regions
.vm_store_context()
.last_wasm_entry_sp()
@@ -822,7 +797,9 @@ pub(crate) mod stack_switching_helpers {
let last_wasm_entry_trap_handler = env
.alias_regions
- .last_wasm_entry_trap_handler(&mut builder.cursor(), stack_limits_ptr);
+ .vm_stack_limits()
+ .last_wasm_entry_trap_handler()
+ .load(&mut builder.cursor(), stack_limits_ptr);
env.alias_regions
.vm_store_context()
.last_wasm_entry_trap_handler()
@@ -865,31 +842,22 @@ pub(crate) mod stack_switching_helpers {
.last_wasm_entry_trap_handler()
.load(&mut builder.cursor(), vmruntime_limits_ptr);
- let vmcontref_region = env.alias_regions.vmcontref_region(builder.func);
- let our_memflags =
- ir::MemFlagsData::trusted().with_alias_region(Some(vmcontref_region));
- builder.ins().store(
- our_memflags,
- last_wasm_entry_fp,
- stack_limits_ptr,
- i32::from(env.offsets.ptr.vmstack_limits_last_wasm_entry_fp()),
- );
- builder.ins().store(
- our_memflags,
- last_wasm_entry_sp,
- stack_limits_ptr,
- i32::from(env.offsets.ptr.vmstack_limits_last_wasm_entry_sp()),
- );
- builder.ins().store(
- our_memflags,
- last_wasm_entry_trap_handler,
- stack_limits_ptr,
- i32::from(
- env.offsets
- .ptr
- .vmstack_limits_last_wasm_entry_trap_handler(),
- ),
- );
+ env.alias_regions
+ .vm_stack_limits()
+ .last_wasm_entry_fp()
+ .store(&mut builder.cursor(), stack_limits_ptr, last_wasm_entry_fp);
+ env.alias_regions
+ .vm_stack_limits()
+ .last_wasm_entry_sp()
+ .store(&mut builder.cursor(), stack_limits_ptr, last_wasm_entry_sp);
+ env.alias_regions
+ .vm_stack_limits()
+ .last_wasm_entry_trap_handler()
+ .store(
+ &mut builder.cursor(),
+ stack_limits_ptr,
+ last_wasm_entry_trap_handler,
+ );
if load_stack_limit {
// Load from the `VMStoreContext`...
@@ -899,12 +867,10 @@ pub(crate) mod stack_switching_helpers {
.stack_limit()
.load(&mut builder.cursor(), vmruntime_limits_ptr);
// ...and store to this continuation's inline `VMStackLimits`.
- let stack_limit_offset = env.offsets.ptr.vmstack_limits_stack_limit();
- builder.ins().store(
- our_memflags,
- stack_limit,
+ env.alias_regions.vm_stack_limits().stack_limit().store(
+ &mut builder.cursor(),
stack_limits_ptr,
- i32::from(stack_limit_offset),
+ stack_limit,
);
}
}
@@ -923,7 +889,9 @@ pub(crate) mod stack_switching_helpers {
env: &mut crate::func_environ::FuncEnvironment<'a>,
builder: &mut FunctionBuilder,
) -> ir::Value {
- let region = env.alias_regions.vmcontref_region(builder.func);
+ let region = env
+ .alias_regions
+ .vm_cont_ref_top_of_stack_region(builder.func);
let mem_flags = ir::MemFlagsData::trusted().with_alias_region(Some(region));
builder
.ins()
diff --git a/crates/environ/src/vmoffsets.rs b/crates/environ/src/vmoffsets.rs
index 9c877d9526..139309f46d 100644
--- a/crates/environ/src/vmoffsets.rs
+++ b/crates/environ/src/vmoffsets.rs
@@ -48,6 +48,7 @@ macro_rules! define_vm_type_offsets {
(@size ($p:expr) Option < VmPtr < $g:ty >>) => { u32::from($p) };
(@size ($p:expr) AtomicUsize) => { u32::from($p) };
(@size ($p:expr) usize) => { u32::from($p) };
+ (@size ($p:expr) * mut $g:ty) => { u32::from($p) };
(@size ($p:expr) i64) => { 8u32 };
(@size ($p:expr) u64) => { 8u32 };
(@size ($p:expr) u32) => { 4u32 };
@@ -68,9 +69,20 @@ macro_rules! define_vm_type_offsets {
// this macro the single source of truth for their layout too.
(@size ($p:expr) VMMemoryDefinition) => { u32::from(($p).vm_memory_definition().size()) };
(@size ($p:expr) VMLazyThread) => { u32::from(($p).vm_lazy_thread().size()) };
+ (@size ($p:expr) VMStackLimits) => { u32::from(($p).vm_stack_limits().size()) };
+ (@size ($p:expr) VMHostArray) => { u32::from(($p).vm_host_array().size()) };
+ (@size ($p:expr) VMCommonStackInformation) => {
+ u32::from(($p).vm_common_stack_information().size())
+ };
// `VMStackChain` is a `repr(usize, C)` enum, and is not itself defined by
// `for_each_vm_type!`.
(@size ($p:expr) VMStackChain) => { u32::from(($p).size_of_vmstack_chain()) };
+ (@size ($p:expr) VMStackState) => { 4u32 };
+ // `VMContinuationStack` is a platform-specific `repr(C)` struct private to
+ // the runtime, but every implementation of it is a pointer, a `usize`, and a
+ // byte-sized tag.
+ (@size ($p:expr) VMContinuationStack) => { 3u32 * u32::from($p) };
+ (@size ($p:expr) PhantomPinned) => { 0u32 };
// As with `@size` above, `UnsafeCell<T>` has exactly `T`'s alignment.
(@align ($p:expr) UnsafeCell < $inner:tt >) => { define_vm_type_offsets!(@align ($p) $inner) };
@@ -86,6 +98,7 @@ macro_rules! define_vm_type_offsets {
(@align ($p:expr) Option < VmPtr < $g:ty >>) => { u32::from($p) };
(@align ($p:expr) AtomicUsize) => { u32::from($p) };
(@align ($p:expr) usize) => { u32::from($p) };
+ (@align ($p:expr) * mut $g:ty) => { u32::from($p) };
(@align ($p:expr) i64) => { 8u32 };
(@align ($p:expr) u64) => { 8u32 };
(@align ($p:expr) u32) => { 4u32 };
@@ -101,7 +114,15 @@ macro_rules! define_vm_type_offsets {
(@align ($p:expr) Range < *mut u8 >) => { u32::from($p) };
(@align ($p:expr) VMMemoryDefinition) => { u32::from(($p).vm_memory_definition().align()) };
(@align ($p:expr) VMLazyThread) => { u32::from(($p).vm_lazy_thread().align()) };
+ (@align ($p:expr) VMStackLimits) => { u32::from(($p).vm_stack_limits().align()) };
+ (@align ($p:expr) VMHostArray) => { u32::from(($p).vm_host_array().align()) };
+ (@align ($p:expr) VMCommonStackInformation) => {
+ u32::from(($p).vm_common_stack_information().align())
+ };
(@align ($p:expr) VMStackChain) => { u32::from($p) };
+ (@align ($p:expr) VMStackState) => { 4u32 };
+ (@align ($p:expr) VMContinuationStack) => { u32::from($p) };
+ (@align ($p:expr) PhantomPinned) => { 1u32 };
// Classify a `#[repr(...)]` to the minimum alignment it forces, as a `u32`.
(@repr_align C) => { 1u32 };
@@ -533,85 +554,6 @@ pub trait PtrSize {
2 * self.size()
}
- // Offsets within `VMStackLimits`
-
- /// Return the offset of `VMStackLimits::stack_limit`.
- fn vmstack_limits_stack_limit(&self) -> u8 {
- 0
- }
-
- /// Return the offset of `VMStackLimits::last_wasm_entry_fp`.
- fn vmstack_limits_last_wasm_entry_fp(&self) -> u8 {
- self.size()
- }
-
- /// Return the offset of `VMStackLimits::last_wasm_entry_sp`.
- fn vmstack_limits_last_wasm_entry_sp(&self) -> u8 {
- self.vmstack_limits_last_wasm_entry_fp() + self.size()
- }
-
- /// Return the offset of `VMStackLimits::last_wasm_entry_trap_handler`.
- fn vmstack_limits_last_wasm_entry_trap_handler(&self) -> u8 {
- self.vmstack_limits_last_wasm_entry_sp() + self.size()
- }
-
- // Offsets within `VMHostArray`
-
- /// Return the offset of `VMHostArray::length`.
- fn vmhostarray_length(&self) -> u8 {
- 0
- }
-
- /// Return the offset of `VMHostArray::capacity`.
- fn vmhostarray_capacity(&self) -> u8 {
- 4
- }
-
- /// Return the offset of `VMHostArray::data`.
- fn vmhostarray_data(&self) -> u8 {
- 8
- }
-
- /// Return the size of `VMHostArray`.
- fn size_of_vmhostarray(&self) -> u8 {
- 8 + self.size()
- }
-
- // Offsets within `VMCommonStackInformation`
-
- /// Return the offset of `VMCommonStackInformation::limits`.
- fn vmcommon_stack_information_limits(&self) -> u8 {
- 0 * self.size()
- }
-
- /// Return the offset of `VMCommonStackInformation::state`.
- fn vmcommon_stack_information_state(&self) -> u8 {
- 4 * self.size()
- }
-
- /// Return the offset of `VMCommonStackInformation::handlers`.
- fn vmcommon_stack_information_handlers(&self) -> u8 {
- u8::try_from(align(
- self.vmcommon_stack_information_state() as u32 + 4,
- u32::from(self.size()),
- ))
- .unwrap()
- }
-
- /// Return the offset of `VMCommonStackInformation::first_switch_handler_index`.
- fn vmcommon_stack_information_first_switch_handler_index(&self) -> u8 {
- self.vmcommon_stack_information_handlers() + self.size_of_vmhostarray()
- }
-
- /// Return the size of `VMCommonStackInformation`.
- fn size_of_vmcommon_stack_information(&self) -> u8 {
- u8::try_from(align(
- self.vmcommon_stack_information_first_switch_handler_index() as u32 + 4,
- u32::from(self.size()),
- ))
- .unwrap()
- }
-
// Offsets within `VMContObj`
/// Return the offset of `VMContObj::contref`
@@ -633,48 +575,6 @@ pub trait PtrSize {
))
.unwrap()
}
-
- // Offsets within `VMContRef`
-
- /// Return the offset of `VMContRef::common_stack_information`.
- fn vmcontref_common_stack_information(&self) -> u8 {
- 0 * self.size()
- }
-
- /// Return the offset of `VMContRef::parent_chain`.
- fn vmcontref_parent_chain(&self) -> u8 {
- u8::try_from(align(
- (self.vmcontref_common_stack_information() + self.size_of_vmcommon_stack_information())
- as u32,
- u32::from(self.size()),
- ))
- .unwrap()
- }
-
- /// Return the offset of `VMContRef::last_ancestor`.
- fn vmcontref_last_ancestor(&self) -> u8 {
- self.vmcontref_parent_chain() + 2 * self.size()
- }
-
- /// Return the offset of `VMContRef::revision`.
- fn vmcontref_revision(&self) -> u8 {
- self.vmcontref_last_ancestor() + self.size()
- }
-
- /// Return the offset of `VMContRef::stack`.
- fn vmcontref_stack(&self) -> u8 {
- self.vmcontref_revision() + self.size()
- }
-
- /// Return the offset of `VMContRef::args`.
- fn vmcontref_args(&self) -> u8 {
- self.vmcontref_stack() + 3 * self.size()
- }
-
- /// Return the offset of `VMContRef::values`.
- fn vmcontref_values(&self) -> u8 {
- self.vmcontref_args() + self.size_of_vmhostarray()
- }
}
/// A trait to abstract over various types that contain a `P: PtrSize`.
diff --git a/crates/environ/src/vmtypes.rs b/crates/environ/src/vmtypes.rs
index 71ba0f3691..a9b24f7722 100644
--- a/crates/environ/src/vmtypes.rs
+++ b/crates/environ/src/vmtypes.rs
@@ -561,6 +561,114 @@ macro_rules! for_each_vm_type {
pub saved_context: [u32; NUM_COMPONENT_CONTEXT_SLOTS],
}
+ /// This type is used to save (and subsequently restore) a subset of
+ /// the data in `VMStoreContext`.
+ ///
+ /// See documentation of `VMStackChain` for the exact uses.
+ #[derive(Debug, Default, Clone)]
+ #[repr(C)]
+ #[snake_name = vm_stack_limits]
+ pub struct VMStackLimits {
+ /// Saved version of the `stack_limit` field of `VMStoreContext`.
+ pub stack_limit: usize,
+ /// Saved version of the `last_wasm_entry_fp` field of
+ /// `VMStoreContext`.
+ pub last_wasm_entry_fp: usize,
+ /// Saved version of the `last_wasm_entry_sp` field of
+ /// `VMStoreContext`.
+ pub last_wasm_entry_sp: usize,
+ /// Saved version of the `last_wasm_entry_trap_handler` field of
+ /// `VMStoreContext`.
+ pub last_wasm_entry_trap_handler: usize,
+ }
+
+ /// A reference to a buffer ("array") allocated on a continuation's
+ /// stack.
+ ///
+ /// The elements are of whatever type the buffer's user expects;
+ /// `data` is an untyped pointer, and the runtime casts it at each
+ /// use site.
+ #[derive(Debug, Clone)]
+ #[repr(C)]
+ #[snake_name = vm_host_array]
+ pub struct VMHostArray {
+ /// Number of currently occupied slots.
+ pub length: u32,
+
+ /// Number of slots in the data buffer. Note that this is *not*
+ /// the size of the buffer in bytes!
+ pub capacity: u32,
+
+ /// The buffer itself, which lives on the continuation's stack
+ /// rather than in this object.
+ pub data: *mut u8,
+ }
+
+ /// The information saved for every stack, whether it is a
+ /// continuation's or the initial stack's.
+ #[derive(Debug, Clone)]
+ #[repr(C)]
+ #[snake_name = vm_common_stack_information]
+ pub struct VMCommonStackInformation {
+ /// The subset of `VMStoreContext` saved for this stack.
+ #[aggregate]
+ pub limits: VMStackLimits,
+
+ /// Where this stack is in its life cycle; a `VMStackState`
+ /// discriminant.
+ pub state: VMStackState,
+
+ /// The tags this stack handles, set while it is a `Parent`.
+ #[aggregate]
+ pub handlers: VMHostArray,
+
+ /// The index within `handlers` of the first `switch` handler.
+ pub first_switch_handler_index: u32,
+ }
+
+ /// A continuation.
+ #[repr(C)]
+ #[snake_name = vm_cont_ref]
+ pub struct VMContRef {
+ /// The information saved for this continuation's stack.
+ #[aggregate]
+ pub common_stack_information: VMCommonStackInformation,
+
+ /// This continuation's parent: another continuation, the
+ /// initial stack, or absent.
+ #[aggregate]
+ pub parent_chain: VMStackChain,
+
+ /// The end of this continuation's parent chain, used only while
+ /// it is `Suspended` or `Fresh`.
+ pub last_ancestor: *mut VMContRef,
+
+ /// Revision counter.
+ pub revision: usize,
+
+ /// The stack this continuation runs on.
+ #[aggregate]
+ pub stack: VMContinuationStack,
+
+ /// The arguments to, and return values of, the function passed
+ /// to `cont.new`.
+ #[aggregate]
+ pub args: VMHostArray,
+
+ /// The payloads passed to and from this continuation once it
+ /// has been suspended.
+ #[aggregate]
+ pub values: VMHostArray,
+
+ /// Tells the compiler that this structure has potential
+ /// self-references, through `last_ancestor`.
+ ///
+ /// This is a zero-sized type in final position, so it affects
+ /// neither this type's size nor its alignment.
+ #[aggregate]
+ pub _marker: PhantomPinned,
+ }
+
/// The deferred-reference-counting collector's JIT-accessible heap
/// data.
///
diff --git a/crates/wasmtime/src/runtime/vm.rs b/crates/wasmtime/src/runtime/vm.rs
index 5e77c7abd5..e7f0c94d93 100644
--- a/crates/wasmtime/src/runtime/vm.rs
+++ b/crates/wasmtime/src/runtime/vm.rs
@@ -135,9 +135,10 @@ pub use crate::runtime::vm::vmcontext::VMLazyThread;
#[cfg(feature = "gc-null")]
pub use crate::runtime::vm::vmcontext::VMNullHeapData;
pub use crate::runtime::vm::vmcontext::{
- VMArrayCallHostFuncContext, VMContext, VMFuncRef, VMFunctionImport, VMGlobalDefinition,
- VMGlobalImport, VMGlobalKind, VMMemoryDefinition, VMMemoryImport, VMOpaqueContext,
- VMStoreContext, VMTableImport, VMTagImport, VMWasmCallFunction, ValRaw,
+ VMArrayCallHostFuncContext, VMCommonStackInformation, VMContRef, VMContext, VMFuncRef,
+ VMFunctionImport, VMGlobalDefinition, VMGlobalImport, VMGlobalKind, VMHostArray,
+ VMMemoryDefinition, VMMemoryImport, VMOpaqueContext, VMStackLimits, VMStoreContext,
+ VMTableImport, VMTagImport, VMWasmCallFunction, ValRaw,
};
#[cfg(has_custom_sync)]
pub(crate) use sys::capi;
diff --git a/crates/wasmtime/src/runtime/vm/stack_switching.rs b/crates/wasmtime/src/runtime/vm/stack_switching.rs
index 29607771dd..8a71d52e7c 100644
--- a/crates/wasmtime/src/runtime/vm/stack_switching.rs
+++ b/crates/wasmtime/src/runtime/vm/stack_switching.rs
@@ -3,6 +3,7 @@
mod stack;
+use crate::vm::{VMCommonStackInformation, VMContRef, VMHostArray, VMStackLimits};
use core::{marker::PhantomPinned, ptr::NonNull};
pub use stack::*;
@@ -77,74 +78,13 @@ impl VMContObj {
unsafe impl Send for VMContObj {}
unsafe impl Sync for VMContObj {}
-/// This type is used to save (and subsequently restore) a subset of the data in
-/// `VMStoreContext`. See documentation of `VMStackChain` for the exact uses.
-#[repr(C)]
-#[derive(Debug, Default, Clone)]
-pub struct VMStackLimits {
- /// Saved version of `stack_limit` field of `VMStoreContext`
- pub stack_limit: usize,
- /// Saved version of `last_wasm_entry_fp` field of `VMStoreContext`
- pub last_wasm_entry_fp: usize,
- /// Saved version of `last_wasm_entry_sp` field of `VMStoreContext`
- pub last_wasm_entry_sp: usize,
- /// Saved version of `last_wasm_entry_trap_handler` field of `VMStoreContext`
- pub last_wasm_entry_trap_handler: usize,
-}
-
-/// This type represents "common" information that we need to save both for the
-/// initial stack and each continuation.
-#[repr(C)]
-#[derive(Debug, Clone)]
-pub struct VMCommonStackInformation {
- /// Saves subset of `VMStoreContext` for this stack. See documentation of
- /// `VMStackChain` for the exact uses.
- pub limits: VMStackLimits,
- /// For the initial stack, this field must only have one of the following values:
- /// - Running
- /// - Parent
- pub state: VMStackState,
-
- /// Only in use when state is `Parent`. Otherwise, the list must be empty.
- ///
- /// Represents the handlers that this stack installed when resume-ing a
- /// continuation.
- ///
- /// Note that for any resume instruction, we can re-order the handler
- /// clauses without changing behavior such that all the suspend handlers
- /// come first, followed by all the switch handler (while maintaining the
- /// original ordering within the two groups).
- /// Thus, we assume that the given resume instruction has the following
- /// shape:
- ///
- /// (resume $ct
- /// (on $tag_0 $block_0) ... (on $tag_{n-1} $block_{n-1})
- /// (on $tag_n switch) ... (on $tag_m switch)
- /// )
- ///
- /// On resume, the handler list is then filled with m + 1 (i.e., one per
- /// handler clause) entries such that the i-th entry, using 0-based
- /// indexing, is the identifier of $tag_i (represented as *mut
- /// VMTagDefinition).
- /// Further, `first_switch_handler_index` (see below) is set to n (i.e., the
- /// 0-based index of the first switch handler).
- ///
- /// Note that the actual data buffer (i.e., the one `handler.data` points
- /// to) is always allocated on the stack that this `CommonStackInformation`
- /// struct describes.
- pub handlers: VMHandlerList,
-
- /// Only used when state is `Parent`. See documentation of `handlers` above.
- pub first_switch_handler_index: u32,
-}
-
impl VMCommonStackInformation {
/// Default value with state set to `Running`
pub fn running_default() -> Self {
Self {
limits: VMStackLimits::default(),
state: VMStackState::Running,
- handlers: VMHandlerList::empty(),
+ handlers: VMHostArray::empty(),
first_switch_handler_index: 0,
}
}
@@ -160,22 +100,8 @@ impl VMStackLimits {
}
}
-#[repr(C)]
-#[derive(Debug, Clone)]
-/// Reference to a stack-allocated buffer ("array"), storing data of some type
-/// `T`.
-pub struct VMHostArray<T> {
- /// Number of currently occupied slots.
- pub length: u32,
- /// Number of slots in the data buffer. Note that this is *not* the size of
- /// the buffer in bytes!
- pub capacity: u32,
- /// The actual data buffer
- pub data: *mut T,
-}
-
-impl<T> VMHostArray<T> {
- /// Creates empty `Array`
+impl VMHostArray {
+ /// Creates an empty array.
pub fn empty() -> Self {
Self {
length: 0,
@@ -183,68 +109,6 @@ impl<T> VMHostArray<T> {
data: core::ptr::null_mut(),
}
}
-
- /// Makes `Array` empty.
- pub fn clear(&mut self) {
- *self = Self::empty();
- }
-}
-
-/// Type used for passing payloads to and from continuations. The actual type
-/// argument should be wasmtime::runtime::vm::vmcontext::ValRaw, but we don't
-/// have access to that here.
-pub type VMPayloads = VMHostArray<u128>;
-
-/// Type for a list of handlers, represented by the handled tag. Thus, the
-/// stored data is actually `*mut VMTagDefinition`, but we don't have access to
-/// that here.
-pub type VMHandlerList = VMHostArray<*mut u8>;
-
-/// The main type representing a continuation.
-#[repr(C)]
-pub struct VMContRef {
- /// The `CommonStackInformation` of this continuation's stack.
- pub common_stack_information: VMCommonStackInformation,
-
- /// The parent of this continuation, which may be another continuation, the
- /// initial stack, or absent (in case of a suspended continuation).
- pub parent_chain: VMStackChain,
-
- /// Only used if `common_stack_information.state` is `Suspended` or `Fresh`. In
- /// that case, this points to the end of the stack chain (i.e., the
- /// continuation in the parent chain whose own `parent_chain` field is
- /// `VMStackChain::Absent`).
- /// Note that this may be a pointer to itself (if the state is `Fresh`, this is always the case).
- pub last_ancestor: *mut VMContRef,
-
- /// Revision counter.
- pub revision: usize,
-
- /// The underlying stack.
- pub stack: VMContinuationStack,
-
- /// Used to store only
- /// 1. The arguments to the function passed to cont.new
- /// 2. The return values of that function
- ///
- /// Note that the actual data buffer (i.e., the one `args.data` points
- /// to) is always allocated on this continuation's stack.
- pub args: VMPayloads,
-
- /// Once a continuation has been suspended (using suspend or switch),
- /// this buffer is used to pass payloads to and from the continuation.
- /// More concretely, it is used to
- /// - Pass payloads from a suspend instruction to the corresponding handler.
- /// - Pass payloads to a continuation using cont.bind or resume
- /// - Pass payloads to the continuation being switched to when using switch.
- ///
- /// Note that the actual data buffer (i.e., the one `values.data` points
- /// to) is always allocated on this continuation's stack.
- pub values: VMPayloads,
-
- /// Tell the compiler that this structure has potential self-references
- /// through the `last_ancestor` pointer.
- _marker: core::marker::PhantomPinned,
}
impl VMContRef {
@@ -261,7 +125,7 @@ impl VMContRef {
pub fn empty() -> Self {
let limits = VMStackLimits::with_stack_limit(Default::default());
let state = VMStackState::Fresh;
- let handlers = VMHandlerList::empty();
+ let handlers = VMHostArray::empty();
let common_stack_information = VMCommonStackInformation {
limits,
state,
@@ -271,8 +135,8 @@ impl VMContRef {
let parent_chain = VMStackChain::Absent;
let last_ancestor = core::ptr::null_mut();
let stack = VMContinuationStack::unallocated();
- let args = VMPayloads::empty();
- let values = VMPayloads::empty();
+ let args = VMHostArray::empty();
+ let values = VMHostArray::empty();
let revision = 0;
let _marker = PhantomPinned;
@@ -333,7 +197,7 @@ pub fn cont_new(
// The initialization function will allocate the actual args/return value buffer and
// update this object (if needed).
- let contref_args_ptr = &mut contref.args as *mut _ as *mut VMHostArray<crate::ValRaw>;
+ let contref_args_ptr = &mut contref.args as *mut VMHostArray;
contref.stack.initialize(
func.cast::<crate::vm::VMFuncRef>(),
@@ -573,81 +437,6 @@ mod tests {
assert_eq!(size_of::<Option<VMContObj>>(), size_of::<VMContObj>());
}
- #[test]
- fn check_vm_stack_limits_offsets() {
- let module = Module::new(StaticModuleIndex::from_u32(0));
- let offsets = VMOffsets::new(HostPtr, &module);
- assert_eq!(
- offset_of!(VMStackLimits, stack_limit),
- usize::from(offsets.ptr.vmstack_limits_stack_limit())
- );
- assert_eq!(
- offset_of!(VMStackLimits, last_wasm_entry_fp),
- usize::from(offsets.ptr.vmstack_limits_last_wasm_entry_fp())
- );
- assert_eq!(
- offset_of!(VMStackLimits, last_wasm_entry_sp),
- usize::from(offsets.ptr.vmstack_limits_last_wasm_entry_sp())
- );
- assert_eq!(
- offset_of!(VMStackLimits, last_wasm_entry_trap_handler),
- usize::from(offsets.ptr.vmstack_limits_last_wasm_entry_trap_handler())
- );
- }
-
- #[test]
- fn check_vm_common_stack_information_offsets() {
- let module = Module::new(StaticModuleIndex::from_u32(0));
- let offsets = VMOffsets::new(HostPtr, &module);
- assert_eq!(
- size_of::<VMCommonStackInformation>(),
- usize::from(offsets.ptr.size_of_vmcommon_stack_information())
- );
- assert_eq!(
- offset_of!(VMCommonStackInformation, limits),
- usize::from(offsets.ptr.vmcommon_stack_information_limits())
- );
- assert_eq!(
- offset_of!(VMCommonStackInformation, state),
- usize::from(offsets.ptr.vmcommon_stack_information_state())
- );
- assert_eq!(
- offset_of!(VMCommonStackInformation, handlers),
- usize::from(offsets.ptr.vmcommon_stack_information_handlers())
- );
- assert_eq!(
- offset_of!(VMCommonStackInformation, first_switch_handler_index),
- usize::from(
- offsets
- .ptr
- .vmcommon_stack_information_first_switch_handler_index()
- )
- );
- }
-
- #[test]
- fn check_vm_array_offsets() {
- // Note that the type parameter has no influence on the size and offsets.
- let module = Module::new(StaticModuleIndex::from_u32(0));
- let offsets = VMOffsets::new(HostPtr, &module);
- assert_eq!(
- size_of::<VMHostArray<()>>(),
- usize::from(offsets.ptr.size_of_vmhostarray())
- );
- assert_eq!(
- offset_of!(VMHostArray<()>, length),
- usize::from(offsets.ptr.vmhostarray_length())
- );
- assert_eq!(
- offset_of!(VMHostArray<()>, capacity),
- usize::from(offsets.ptr.vmhostarray_capacity())
- );
- assert_eq!(
- offset_of!(VMHostArray<()>, data),
- usize::from(offsets.ptr.vmhostarray_data())
- );
- }
-
#[test]
fn check_vm_contobj_offsets() {
let module = Module::new(StaticModuleIndex::from_u32(0));
@@ -666,44 +455,6 @@ mod tests {
)
}
- #[test]
- fn check_vm_contref_offsets() {
- let module = Module::new(StaticModuleIndex::from_u32(0));
- let offsets = VMOffsets::new(HostPtr, &module);
- assert_eq!(
- offset_of!(VMContRef, common_stack_information),
- usize::from(offsets.ptr.vmcontref_common_stack_information())
- );
- assert_eq!(
- offset_of!(VMContRef, parent_chain),
- usize::from(offsets.ptr.vmcontref_parent_chain())
- );
- assert_eq!(
- offset_of!(VMContRef, last_ancestor),
- usize::from(offsets.ptr.vmcontref_last_ancestor())
- );
- // Some 32-bit platforms need this to be 8-byte aligned, some don't.
- // So we need to make sure it always is, without padding.
- assert_eq!(u8::vmcontref_revision(&4) % 8, 0);
- assert_eq!(u8::vmcontref_revision(&8) % 8, 0);
- assert_eq!(
- offset_of!(VMContRef, revision),
- usize::from(offsets.ptr.vmcontref_revision())
- );
- assert_eq!(
- offset_of!(VMContRef, stack),
- usize::from(offsets.ptr.vmcontref_stack())
- );
- assert_eq!(
- offset_of!(VMContRef, args),
- usize::from(offsets.ptr.vmcontref_args())
- );
- assert_eq!(
- offset_of!(VMContRef, values),
- usize::from(offsets.ptr.vmcontref_values())
- );
- }
-
#[test]
fn check_vm_stack_chain_offsets() {
let module = Module::new(StaticModuleIndex::from_u32(0));
diff --git a/crates/wasmtime/src/runtime/vm/stack_switching/stack.rs b/crates/wasmtime/src/runtime/vm/stack_switching/stack.rs
index 14984b30ed..fc24418c59 100644
--- a/crates/wasmtime/src/runtime/vm/stack_switching/stack.rs
+++ b/crates/wasmtime/src/runtime/vm/stack_switching/stack.rs
@@ -4,8 +4,8 @@
use crate::Result;
use core::ops::Range;
-use crate::runtime::vm::stack_switching::VMHostArray;
-use crate::runtime::vm::{VMContext, VMFuncRef, ValRaw};
+use crate::runtime::vm::VMHostArray;
+use crate::runtime::vm::{VMContext, VMFuncRef};
cfg_select! {
all(feature = "stack-switching", unix, target_arch = "x86_64") => {
@@ -103,7 +103,7 @@ impl VMContinuationStack {
&self,
func_ref: *const VMFuncRef,
caller_vmctx: *mut VMContext,
- args: *mut VMHostArray<ValRaw>,
+ args: *mut VMHostArray,
parameter_count: u32,
return_value_count: u32,
) -> Result<()> {
diff --git a/crates/wasmtime/src/runtime/vm/stack_switching/stack/dummy.rs b/crates/wasmtime/src/runtime/vm/stack_switching/stack/dummy.rs
index fdff618698..5c2cf049e4 100644
--- a/crates/wasmtime/src/runtime/vm/stack_switching/stack/dummy.rs
+++ b/crates/wasmtime/src/runtime/vm/stack_switching/stack/dummy.rs
@@ -1,8 +1,8 @@
use crate::Result;
use core::ops::Range;
-use crate::runtime::vm::stack_switching::VMHostArray;
-use crate::runtime::vm::{VMContext, VMFuncRef, ValRaw};
+use crate::runtime::vm::VMHostArray;
+use crate::runtime::vm::{VMContext, VMFuncRef};
/// Making sure that this has the same size as the non-dummy version, to
/// make some tests happy.
@@ -59,7 +59,7 @@ impl VMContinuationStack {
&self,
_func_ref: *const VMFuncRef,
_caller_vmctx: *mut VMContext,
- _args: *mut VMHostArray<ValRaw>,
+ _args: *mut VMHostArray,
_parameter_count: u32,
_return_value_count: u32,
) -> Result<()> {
diff --git a/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs b/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
index ee3152a499..247495a599 100644
--- a/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
+++ b/crates/wasmtime/src/runtime/vm/stack_switching/stack/unix.rs
@@ -64,7 +64,7 @@ use std::ops::Range;
use std::ptr;
use crate::prelude::*;
-use crate::runtime::vm::stack_switching::VMHostArray;
+use crate::runtime::vm::VMHostArray;
use crate::runtime::vm::{VMContext, VMFuncRef, ValRaw};
#[derive(Debug, PartialEq, Eq)]
@@ -228,7 +228,7 @@ impl VMContinuationStack {
&self,
func_ref: *const VMFuncRef,
caller_vmctx: *mut VMContext,
- args: *mut VMHostArray<ValRaw>,
+ args: *mut VMHostArray,
parameter_count: u32,
return_value_count: u32,
) -> Result<()> {
@@ -281,7 +281,7 @@ impl VMContinuationStack {
};
args_ref.capacity = args_capacity;
- args_ref.data = args_data_ptr.cast::<ValRaw>();
+ args_ref.data = args_data_ptr;
let to_store = [
// Data near top of stack:
@@ -324,7 +324,7 @@ impl Drop for VMContinuationStack {
unsafe extern "C" fn fiber_start(
func_ref: *mut VMFuncRef,
caller_vmctx: *mut VMContext,
- args: *mut VMHostArray<ValRaw>,
+ args: *mut VMHostArray,
return_value_count: u32,
) -> bool {
unsafe {
@@ -334,8 +334,11 @@ unsafe extern "C" fn fiber_start(
let params_and_returns: NonNull<[ValRaw]> = if args.capacity == 0 {
NonNull::from(&[])
} else {
- std::slice::from_raw_parts_mut(args.data, usize::try_from(args.capacity).unwrap())
- .into()
+ std::slice::from_raw_parts_mut(
+ args.data.cast::<ValRaw>(),
+ usize::try_from(args.capacity).unwrap(),
+ )
+ .into()
};
// NOTE(frank-emrich) The usage of the `caller_vmctx` is probably not
diff --git a/crates/wasmtime/src/runtime/vm/traphandlers/backtrace.rs b/crates/wasmtime/src/runtime/vm/traphandlers/backtrace.rs
index 0b40ebadf0..d2d530e2fb 100644
--- a/crates/wasmtime/src/runtime/vm/traphandlers/backtrace.rs
+++ b/crates/wasmtime/src/runtime/vm/traphandlers/backtrace.rs
@@ -29,7 +29,7 @@ use crate::runtime::vm::{
traphandlers::{CallThreadState, tls},
};
#[cfg(all(feature = "gc", feature = "stack-switching"))]
-use crate::vm::stack_switching::{VMContRef, VMStackState};
+use crate::vm::{VMContRef, stack_switching::VMStackState};
use core::ops::ControlFlow;
use wasmtime_unwinder::Frame;
#[cfg(feature = "debug")]
@@ -306,7 +306,7 @@ impl Backtrace {
entry_trampoline_fp: usize,
mut f: impl FnMut(Activation) -> ControlFlow<()>,
) -> ControlFlow<()> {
- use crate::runtime::vm::stack_switching::VMStackLimits;
+ use crate::runtime::vm::VMStackLimits;
// Handle the stack that is currently running (which may be a
// continuation or the initial stack).
diff --git a/crates/wasmtime/src/runtime/vm/vmcontext.rs b/crates/wasmtime/src/runtime/vm/vmcontext.rs
index 17afb693c1..f604f794bd 100644
--- a/crates/wasmtime/src/runtime/vm/vmcontext.rs
+++ b/crates/wasmtime/src/runtime/vm/vmcontext.rs
@@ -7,11 +7,11 @@ pub use self::vm_host_func_context::VMArrayCallHostFuncContext;
use crate::prelude::*;
use crate::runtime::vm::{InterpreterRef, VMGcRef, VmPtr, VmSafe, f32x4, f64x2, i8x16};
use crate::store::StoreOpaque;
-use crate::vm::stack_switching::VMStackChain;
+use crate::vm::stack_switching::{VMContinuationStack, VMStackChain, VMStackState};
use core::cell::UnsafeCell;
use core::ffi::c_void;
use core::fmt;
-use core::marker;
+use core::marker::{self, PhantomPinned};
use core::mem::{self, MaybeUninit};
#[cfg(feature = "gc-null")]
use core::num::NonZeroU32;
@@ -195,7 +195,56 @@ unsafe impl VmSafe for VMGlobalKind {}
unsafe impl VmSafe for VMTagImport {}
/// Define the runtime definitions of the shared `VM*` types.
+#[cfg_attr(
+ not(test),
+ allow(
+ unused_macro_rules,
+ reason = "the `@test` arms are only expanded inside the `#[cfg(test)]` \
+ layout-test module"
+ )
+)]
macro_rules! define_vm_types {
+ (@test [ $($cfg:tt)* ] $Name:ident $snake:ident [ $($fname:ident)* ]) => {
+ $($cfg)*
+ #[test]
+ fn $snake() {
+ use super::$Name;
+
+ let host = HostPtr;
+ let offsets = host.$snake();
+
+ let expected = usize::from(offsets.size());
+ let actual = size_of::<$Name>();
+ assert_eq!(
+ expected,
+ actual,
+ "size of {} failed: {expected} (expected) != {actual} (actual)",
+ stringify!($Name),
+ );
+
+ let expected = usize::from(offsets.align());
+ let actual = align_of::<$Name>();
+ assert_eq!(
+ expected,
+ actual,
+ "alignment of {} failed: {expected} (expected) != {actual} (actual)",
+ stringify!($Name),
+ );
+
+ $(
+ let expected = usize::from(offsets.$fname());
+ let actual = offset_of!($Name, $fname);
+ assert_eq!(
+ expected,
+ actual,
+ "offset of {}::{} failed: {expected} (expected) != {actual} (actual)",
+ stringify!($Name),
+ stringify!($fname),
+ );
+ )*
+ }
+ };
+
( $(
$(#[doc = $sdoc:literal])*
$(#[cfg($($scfg:tt)*)])?
@@ -209,7 +258,10 @@ macro_rules! define_vm_types {
$(#[indexed])?
$(#[readonly])?
$(#[can_move])?
- $fvis:vis $fname:ident : $fty:tt $(< $fgen:ty >)? ,
+ // Unlike the offsets and alias-region consumers, this one only
+ // ever re-emits a field's type verbatim, so it can capture the
+ // whole type as one fragment instead of taking it apart.
+ $fvis:vis $fname:ident : $fty:ty ,
)*
}
)* ) => {
@@ -221,7 +273,7 @@ macro_rules! define_vm_types {
$svis struct $Name {
$(
$(#[doc = $fdoc])*
- $fvis $fname: $fty $(< $fgen >)?,
+ $fvis $fname: $fty,
)*
}
)*
@@ -232,44 +284,12 @@ macro_rules! define_vm_types {
use wasmtime_environ::{HostPtr, PtrSize};
$(
- $(#[cfg($($scfg)*)])?
- #[test]
- fn $snake() {
- use super::$Name;
-
- let host = HostPtr;
- let offsets = host.$snake();
-
- let expected = usize::from(offsets.size());
- let actual = size_of::<$Name>();
- assert_eq!(
- expected,
- actual,
- "size of {} failed: {expected} (expected) != {actual} (actual)",
- stringify!($Name),
- );
-
- let expected = usize::from(offsets.align());
- let actual = align_of::<$Name>();
- assert_eq!(
- expected,
- actual,
- "alignment of {} failed: {expected} (expected) != {actual} (actual)",
- stringify!($Name),
- );
-
- $(
- let expected = usize::from(offsets.$fname());
- let actual = offset_of!($Name, $fname);
- assert_eq!(
- expected,
- actual,
- "offset of {}::{} failed: {expected} (expected) != {actual} (actual)",
- stringify!($Name),
- stringify!($fname),
- );
- )*
- }
+ define_vm_types!(
+ @test
+ [ $(#[cfg($($scfg)*)])? ]
+ $Name $snake
+ [ $($fname)* ]
+ );
)*
}
};
@@ -849,6 +869,26 @@ mod test_vmstore_context {
}
}
+#[cfg(test)]
+mod test_vm_cont_ref {
+ use wasmtime_environ::PtrSize;
+
+ /// Check the one `VMContRef` property that `for_each_vm_type!` does *not*
+ /// generate an assertion for: that `revision` lands at an eight-aligned
+ /// offset for every target pointer width, not just the host's.
+ ///
+ /// Some 32-bit platforms need it to be 8-byte aligned and some don't, so we
+ /// make sure that it always is, without padding to get there.
+ ///
+ /// Every field offset, plus the size and alignment of the type, is already
+ /// checked by the generated `test_vm_type_layouts::vm_cont_ref`.
+ #[test]
+ fn revision_is_eight_aligned() {
+ assert_eq!(4u8.vm_cont_ref().revision() % 8, 0);
+ assert_eq!(8u8.vm_cont_ref().revision() % 8, 0);
+ }
+}
+
impl VMLazyThread {
const _ASSERT_SIZE: () = assert!(
core::mem::size_of::<VMLazyThread>() == core::mem::size_of::<*mut VMDeferredThread>()
diff --git a/tests/disas/stack-switching/resume-suspend-data-passing.wat b/tests/disas/stack-switching/resume-suspend-data-passing.wat
index 4ca71c4234..340af188d2 100644
--- a/tests/disas/stack-switching/resume-suspend-data-passing.wat
+++ b/tests/disas/stack-switching/resume-suspend-data-passing.wat
@@ -42,8 +42,15 @@
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
;; region2 = 67108952 "VMStoreContext+0x58"
-;; region3 = 1073741824 "VMContRef+0x0"
-;; region4 = 1140850688 "ContinuationStackMemory+0x0"
+;; region3 = 1073741888 "VMContRef+0x40"
+;; region4 = 2550136840 "VMHostArray+0x8"
+;; region5 = 2483028024 "VMCommonStackInformation+0x38"
+;; region6 = 1140850688 "ContinuationStackMemory+0x0"
+;; region7 = 1073741904 "VMContRef+0x50"
+;; region8 = 2550136836 "VMHostArray+0x4"
+;; region9 = 2550136832 "VMHostArray+0x0"
+;; region10 = 2483028000 "VMCommonStackInformation+0x20"
+;; region11 = 1073741920 "VMContRef+0x60"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -56,12 +63,12 @@
;; @0044 v7 = load.i64 notrap aligned readonly can_move region0 v0+8
;; @0044 v31 = iconst.i64 136
;; @0044 v34 = stack_addr.i64 ss0
-;; @0044 v40 = iconst.i64 32
;; @0044 v37 = iconst.i64 0
-;; @0044 v49 = iconst.i64 96
-;; @0044 v52 = iconst.i64 -24
-;; v79 = iconst.i64 0x0002_0000_0000
-;; @0044 v57 = iconst.i64 5
+;; @0044 v47 = iconst.i64 96
+;; @0044 v50 = iconst.i64 -24
+;; v77 = iconst.i64 0x0002_0000_0000
+;; @0044 v43 = iconst.i64 32
+;; @0044 v55 = iconst.i64 5
;; @0040 jump block2(v3) ; v3 = 10
;;
;; block2(v4: i32):
@@ -72,95 +79,94 @@
;; @003a v2 = iconst.i32 0
;; @0044 jump block4(v8, v9, v4)
;;
-;; block4(v10: i64, v11: i64, v73: i32):
-;; v82 = iconst.i64 1
-;; v83 = icmp eq v10, v82 ; v82 = 1
-;; @0044 trapnz v83, user22
+;; block4(v10: i64, v11: i64, v71: i32):
+;; v80 = iconst.i64 1
+;; v81 = icmp eq v10, v80 ; v80 = 1
+;; @0044 trapnz v81, user22
;; @0044 jump block5
;;
;; block5:
;; @0044 v14 = load.i64 notrap aligned region3 v11+64
;; @0044 v15 = load.i64 notrap aligned region3 v11+72
-;; v84 = iconst.i64 40
-;; v85 = iadd v15, v84 ; v84 = 40
-;; @0044 v18 = load.i64 notrap aligned region3 v85+8
-;; @0044 v19 = load.i32 notrap aligned region3 v15+56
-;; v86 = iconst.i32 0
-;; v76 = iconst.i32 3
+;; v82 = iconst.i64 40
+;; v83 = iadd v15, v82 ; v82 = 40
+;; @0044 v18 = load.i64 notrap aligned region4 v83+8
+;; @0044 v19 = load.i32 notrap aligned region5 v15+56
+;; v84 = iconst.i32 0
+;; v74 = iconst.i32 3
;; @0044 v5 = iconst.i64 48
;; @0044 v6 = iadd.i64 v0, v5 ; v5 = 48
;; @0044 v29 = iconst.i32 1
-;; @0044 jump block6(v86) ; v86 = 0
+;; @0044 jump block6(v84) ; v84 = 0
;;
;; block6(v21: i32):
;; @0044 v22 = icmp ult v21, v19
-;; @0044 brif v22, block7, block4(v14, v15, v73)
+;; @0044 brif v22, block7, block4(v14, v15, v71)
;;
;; block7:
-;; v87 = iconst.i32 3
-;; v88 = ishl.i32 v21, v87 ; v87 = 3
-;; @0044 v25 = uextend.i64 v88
+;; v85 = iconst.i32 3
+;; v86 = ishl.i32 v21, v85 ; v85 = 3
+;; @0044 v25 = uextend.i64 v86
;; @0044 v26 = iadd.i64 v18, v25
-;; @0044 v27 = load.i64 notrap aligned region4 v26
-;; v89 = iadd.i64 v0, v5 ; v5 = 48
-;; v90 = icmp eq v27, v89
-;; v91 = iconst.i32 1
-;; v92 = iadd.i32 v21, v91 ; v91 = 1
-;; @0044 brif v90, block8, block6(v92)
+;; @0044 v27 = load.i64 notrap aligned region6 v26
+;; v87 = iadd.i64 v0, v5 ; v5 = 48
+;; v88 = icmp eq v27, v87
+;; v89 = iconst.i32 1
+;; v90 = iadd.i32 v21, v89 ; v89 = 1
+;; @0044 brif v88, block8, block6(v90)
;;
;; block8:
-;; @0044 store.i64 notrap aligned region3 v11, v9+80
-;; v93 = iconst.i32 1
-;; v94 = iconst.i64 136
-;; v95 = iadd.i64 v9, v94 ; v94 = 136
-;; @0044 store notrap aligned region3 v93, v95+4 ; v93 = 1
-;; @0044 store.i64 notrap aligned region3 v34, v95+8
-;; @0044 store.i32 notrap aligned region4 v4, v34
-;; @0044 store notrap aligned region3 v93, v95 ; v93 = 1
-;; v96 = iconst.i32 3
-;; v97 = iconst.i64 32
-;; v98 = iadd.i64 v9, v97 ; v97 = 32
-;; @0044 store notrap aligned region3 v96, v98 ; v96 = 3
-;; v99 = iconst.i64 0
-;; @0044 store notrap aligned region3 v99, v11+64 ; v99 = 0
-;; @0044 store notrap aligned region3 v99, v11+72 ; v99 = 0
-;; v100 = iconst.i64 96
-;; v101 = iadd.i64 v11, v100 ; v100 = 96
-;; @0044 v51 = load.i64 notrap aligned region3 v101
-;; v102 = iconst.i64 -24
-;; v103 = iadd v51, v102 ; v102 = -24
-;; @0044 v47 = uextend.i64 v21
-;; v104 = iconst.i64 0x0002_0000_0000
-;; v105 = bor v47, v104 ; v104 = 0x0002_0000_0000
-;; @0044 v54 = stack_switch v103, v103, v105
-;; v106 = ushr v54, v97 ; v97 = 32
-;; v107 = iconst.i64 5
-;; v108 = icmp eq v106, v107 ; v107 = 5
-;; @0044 brif v108, block10, block11
+;; @0044 store.i64 notrap aligned region7 v11, v9+80
+;; v91 = iconst.i32 1
+;; v92 = iconst.i64 136
+;; v93 = iadd.i64 v9, v92 ; v92 = 136
+;; @0044 store notrap aligned region8 v91, v93+4 ; v91 = 1
+;; @0044 store.i64 notrap aligned region4 v34, v93+8
+;; @0044 store.i32 notrap aligned region6 v4, v34
+;; @0044 store notrap aligned region9 v91, v93 ; v91 = 1
+;; v94 = iconst.i32 3
+;; @0044 store notrap aligned region10 v94, v9+32 ; v94 = 3
+;; v95 = iconst.i64 0
+;; @0044 store notrap aligned region3 v95, v11+64 ; v95 = 0
+;; @0044 store notrap aligned region3 v95, v11+72 ; v95 = 0
+;; v96 = iconst.i64 96
+;; v97 = iadd.i64 v11, v96 ; v96 = 96
+;; @0044 v49 = load.i64 notrap aligned region11 v97
+;; v98 = iconst.i64 -24
+;; v99 = iadd v49, v98 ; v98 = -24
+;; @0044 v45 = uextend.i64 v21
+;; v100 = iconst.i64 0x0002_0000_0000
+;; v101 = bor v45, v100 ; v100 = 0x0002_0000_0000
+;; @0044 v52 = stack_switch v99, v99, v101
+;; v102 = iconst.i64 32
+;; v103 = ushr v52, v102 ; v102 = 32
+;; v104 = iconst.i64 5
+;; v105 = icmp eq v103, v104 ; v104 = 5
+;; @0044 brif v105, block10, block11
;;
;; block10 cold:
-;; @0044 v61 = load.i64 notrap aligned region3 v95+8
-;; @0044 v62 = load.i32 notrap aligned region4 v61
-;; v113 = iconst.i32 0
-;; @0044 store notrap aligned region3 v113, v95 ; v113 = 0
-;; @0044 store notrap aligned region3 v113, v95+4 ; v113 = 0
-;; v114 = iconst.i64 0
-;; @0044 store notrap aligned region3 v114, v95+8 ; v114 = 0
-;; @0044 try_call fn0(v0, v62), sig0, block12, [ context v0 ]
+;; @0044 v59 = load.i64 notrap aligned region4 v93+8
+;; @0044 v60 = load.i32 notrap aligned region6 v59
+;; v110 = iconst.i32 0
+;; @0044 store notrap aligned region9 v110, v93 ; v110 = 0
+;; @0044 store notrap aligned region8 v110, v93+4 ; v110 = 0
+;; v111 = iconst.i64 0
+;; @0044 store notrap aligned region4 v111, v93+8 ; v111 = 0
+;; @0044 try_call fn0(v0, v60), sig0, block12, [ context v0 ]
;;
;; block12:
;; @0044 trap user12
;;
;; block11:
-;; @0044 v68 = load.i64 notrap aligned region3 v95+8
-;; v109 = iconst.i32 0
-;; @0044 store notrap aligned region3 v109, v95 ; v109 = 0
-;; @0044 store notrap aligned region3 v109, v95+4 ; v109 = 0
-;; v110 = iconst.i64 0
-;; @0044 store notrap aligned region3 v110, v95+8 ; v110 = 0
-;; v111 = iconst.i32 1
-;; v112 = isub.i32 v73, v111 ; v111 = 1
-;; @004d brif v112, block2(v112), block13
+;; @0044 v66 = load.i64 notrap aligned region4 v93+8
+;; v106 = iconst.i32 0
+;; @0044 store notrap aligned region9 v106, v93 ; v106 = 0
+;; @0044 store notrap aligned region8 v106, v93+4 ; v106 = 0
+;; v107 = iconst.i64 0
+;; @0044 store notrap aligned region4 v107, v93+8 ; v107 = 0
+;; v108 = iconst.i32 1
+;; v109 = isub.i32 v71, v108 ; v108 = 1
+;; @004d brif v109, block2(v109), block13
;;
;; block13:
;; @004f jump block3
@@ -176,12 +182,24 @@
;; ss0 = explicit_slot 8, align = 256
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
-;; region2 = 1073741824 "VMContRef+0x0"
-;; region3 = 67108952 "VMStoreContext+0x58"
-;; region4 = 67108936 "VMStoreContext+0x48"
-;; region5 = 67108928 "VMStoreContext+0x40"
-;; region6 = 67108944 "VMStoreContext+0x50"
-;; region7 = 1140850688 "ContinuationStackMemory+0x0"
+;; region2 = 1073741912 "VMContRef+0x58"
+;; region3 = 1073741904 "VMContRef+0x50"
+;; region4 = 67108952 "VMStoreContext+0x58"
+;; region5 = 1073741888 "VMContRef+0x40"
+;; region6 = 2483028000 "VMCommonStackInformation+0x20"
+;; region7 = 67108936 "VMStoreContext+0x48"
+;; region8 = 67108928 "VMStoreContext+0x40"
+;; region9 = 67108944 "VMStoreContext+0x50"
+;; region10 = 2415919112 "VMStackLimits+0x8"
+;; region11 = 2415919120 "VMStackLimits+0x10"
+;; region12 = 2415919128 "VMStackLimits+0x18"
+;; region13 = 2415919104 "VMStackLimits+0x0"
+;; region14 = 2550136836 "VMHostArray+0x4"
+;; region15 = 2550136840 "VMHostArray+0x8"
+;; region16 = 1140850688 "ContinuationStackMemory+0x0"
+;; region17 = 2550136832 "VMHostArray+0x0"
+;; region18 = 2483028024 "VMCommonStackInformation+0x38"
+;; region19 = 1073741920 "VMContRef+0x60"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -201,23 +219,22 @@
;; @0058 v7 = load.i64 notrap aligned region2 v6+88
;; @0058 v9 = uextend.i128 v7
;; @0058 v10 = iconst.i64 64
-;; v148 = ishl v9, v10 ; v10 = 64
+;; v138 = ishl v9, v10 ; v10 = 64
;; @0058 v8 = uextend.i128 v6
-;; @0058 v13 = bor v148, v8
+;; @0058 v13 = bor v138, v8
;; @0062 v22 = iconst.i64 1
;; @0062 v25 = load.i64 notrap aligned readonly can_move region0 v0+8
;; @0062 v28 = iconst.i64 0
;; @0062 v29 = iconst.i64 2
;; @0062 v33 = iconst.i32 1
-;; @0062 v34 = iconst.i64 32
-;; @0062 v36 = iconst.i32 2
-;; @0062 v52 = iconst.i64 40
-;; @0062 v55 = stack_addr.i64 ss0
-;; @0062 v56 = iconst.i64 48
-;; @0062 v57 = iadd v0, v56 ; v56 = 48
-;; @0062 v64 = iconst.i64 96
-;; @0062 v67 = iconst.i64 -24
-;; v152 = iconst.i64 0x0001_0000_0000
+;; @0062 v34 = iconst.i32 2
+;; @0062 v48 = iconst.i64 40
+;; @0062 v51 = stack_addr.i64 ss0
+;; @0062 v52 = iconst.i64 48
+;; @0062 v53 = iadd v0, v52 ; v52 = 48
+;; @0062 v60 = iconst.i64 96
+;; @0062 v63 = iconst.i64 -24
+;; v142 = iconst.i64 0x0001_0000_0000
;; @005c jump block2(v13)
;;
;; block2(v14: i128):
@@ -227,173 +244,166 @@
;; @0062 v15 = ireduce.i64 v14
;; @0062 trapz v15, user16
;; @0062 v20 = load.i64 notrap aligned region2 v15+88
-;; v155 = iconst.i64 64
-;; v156 = ushr.i128 v14, v155 ; v155 = 64
-;; @0062 v19 = ireduce.i64 v156
+;; v145 = iconst.i64 64
+;; v146 = ushr.i128 v14, v145 ; v145 = 64
+;; @0062 v19 = ireduce.i64 v146
;; @0062 v21 = icmp eq v20, v19
;; @0062 trapz v21, user23
-;; v157 = iconst.i64 1
-;; v158 = iadd v20, v157 ; v157 = 1
-;; @0062 store notrap aligned region2 v158, v15+88
-;; @0062 v24 = load.i64 notrap aligned region2 v15+80
-;; @0062 v26 = load.i64 notrap aligned region3 v25+88
-;; @0062 v27 = load.i64 notrap aligned region3 v25+96
-;; @0062 store notrap aligned region2 v26, v24+64
-;; @0062 store notrap aligned region2 v27, v24+72
-;; v159 = iconst.i64 0
-;; @0062 store notrap aligned region2 v159, v15+80 ; v159 = 0
-;; v160 = iconst.i64 2
-;; @0062 store notrap aligned region3 v160, v25+88 ; v160 = 2
-;; @0062 store notrap aligned region3 v15, v25+96
-;; v161 = iconst.i32 1
-;; v162 = iconst.i64 32
-;; v163 = iadd v15, v162 ; v162 = 32
-;; @0062 store notrap aligned region2 v161, v163 ; v161 = 1
-;; v164 = iconst.i32 2
-;; v165 = iadd v27, v162 ; v162 = 32
-;; @0062 store notrap aligned region2 v164, v165 ; v164 = 2
-;; @0062 v42 = load.i64 notrap aligned region4 v25+72
-;; @0062 v43 = load.i64 notrap aligned region5 v25+64
-;; @0062 v44 = load.i64 notrap aligned region6 v25+80
-;; @0062 store notrap aligned region2 v42, v27+8
-;; @0062 store notrap aligned region2 v43, v27+16
-;; @0062 store notrap aligned region2 v44, v27+24
-;; @0062 v45 = load.i64 notrap aligned region1 v25+24
-;; @0062 store notrap aligned region2 v45, v27
-;; @0062 v48 = load.i64 notrap aligned region2 v15
-;; @0062 store notrap aligned region1 v48, v25+24
-;; @0062 v49 = load.i64 notrap aligned region2 v15+8
-;; @0062 store notrap aligned region4 v49, v25+72
-;; @0062 v50 = load.i64 notrap aligned region2 v15+16
-;; @0062 store notrap aligned region5 v50, v25+64
-;; @0062 v51 = load.i64 notrap aligned region2 v15+24
-;; @0062 store notrap aligned region6 v51, v25+80
-;; v166 = iconst.i64 40
-;; v167 = iadd v27, v166 ; v166 = 40
-;; @0062 store notrap aligned region2 v161, v167+4 ; v161 = 1
-;; @0062 store.i64 notrap aligned region2 v55, v167+8
-;; v168 = iadd.i64 v0, v56 ; v56 = 48
-;; @0062 store notrap aligned region7 v168, v55
-;; @0062 store notrap aligned region2 v161, v167 ; v161 = 1
-;; @0062 store notrap aligned region2 v161, v27+56 ; v161 = 1
-;; v169 = iconst.i64 96
-;; v170 = iadd v24, v169 ; v169 = 96
-;; @0062 v66 = load.i64 notrap aligned region2 v170
-;; v171 = iconst.i64 -24
-;; v172 = iadd v66, v171 ; v171 = -24
-;; v173 = iconst.i64 0x0001_0000_0000
-;; @0062 v69 = stack_switch v172, v172, v173 ; v173 = 0x0001_0000_0000
-;; @0062 v71 = load.i64 notrap aligned region3 v25+88
-;; @0062 v72 = load.i64 notrap aligned region3 v25+96
-;; @0062 store notrap aligned region3 v26, v25+88
-;; @0062 store notrap aligned region3 v27, v25+96
-;; @0062 store notrap aligned region2 v161, v165 ; v161 = 1
-;; v174 = iconst.i32 0
-;; @0062 store notrap aligned region2 v174, v167 ; v174 = 0
-;; @0062 store notrap aligned region2 v174, v167+4 ; v174 = 0
-;; @0062 store notrap aligned region2 v159, v167+8 ; v159 = 0
-;; @0062 store notrap aligned region2 v159, v27+56 ; v159 = 0
-;; @0062 brif v69, block9, block6
+;; v147 = iconst.i64 1
+;; v148 = iadd v20, v147 ; v147 = 1
+;; @0062 store notrap aligned region2 v148, v15+88
+;; @0062 v24 = load.i64 notrap aligned region3 v15+80
+;; @0062 v26 = load.i64 notrap aligned region4 v25+88
+;; @0062 v27 = load.i64 notrap aligned region4 v25+96
+;; @0062 store notrap aligned region5 v26, v24+64
+;; @0062 store notrap aligned region5 v27, v24+72
+;; v149 = iconst.i64 0
+;; @0062 store notrap aligned region3 v149, v15+80 ; v149 = 0
+;; v150 = iconst.i64 2
+;; @0062 store notrap aligned region4 v150, v25+88 ; v150 = 2
+;; @0062 store notrap aligned region4 v15, v25+96
+;; v151 = iconst.i32 1
+;; @0062 store notrap aligned region6 v151, v15+32 ; v151 = 1
+;; v152 = iconst.i32 2
+;; @0062 store notrap aligned region6 v152, v27+32 ; v152 = 2
+;; @0062 v38 = load.i64 notrap aligned region7 v25+72
+;; @0062 v39 = load.i64 notrap aligned region8 v25+64
+;; @0062 v40 = load.i64 notrap aligned region9 v25+80
+;; @0062 store notrap aligned region10 v38, v27+8
+;; @0062 store notrap aligned region11 v39, v27+16
+;; @0062 store notrap aligned region12 v40, v27+24
+;; @0062 v41 = load.i64 notrap aligned region1 v25+24
+;; @0062 store notrap aligned region13 v41, v27
+;; @0062 v44 = load.i64 notrap aligned region13 v15
+;; @0062 store notrap aligned region1 v44, v25+24
+;; @0062 v45 = load.i64 notrap aligned region10 v15+8
+;; @0062 store notrap aligned region7 v45, v25+72
+;; @0062 v46 = load.i64 notrap aligned region11 v15+16
+;; @0062 store notrap aligned region8 v46, v25+64
+;; @0062 v47 = load.i64 notrap aligned region12 v15+24
+;; @0062 store notrap aligned region9 v47, v25+80
+;; v153 = iconst.i64 40
+;; v154 = iadd v27, v153 ; v153 = 40
+;; @0062 store notrap aligned region14 v151, v154+4 ; v151 = 1
+;; @0062 store.i64 notrap aligned region15 v51, v154+8
+;; v155 = iadd.i64 v0, v52 ; v52 = 48
+;; @0062 store notrap aligned region16 v155, v51
+;; @0062 store notrap aligned region17 v151, v154 ; v151 = 1
+;; @0062 store notrap aligned region18 v151, v27+56 ; v151 = 1
+;; v156 = iconst.i64 96
+;; v157 = iadd v24, v156 ; v156 = 96
+;; @0062 v62 = load.i64 notrap aligned region19 v157
+;; v158 = iconst.i64 -24
+;; v159 = iadd v62, v158 ; v158 = -24
+;; v160 = iconst.i64 0x0001_0000_0000
+;; @0062 v65 = stack_switch v159, v159, v160 ; v160 = 0x0001_0000_0000
+;; @0062 v67 = load.i64 notrap aligned region4 v25+88
+;; @0062 v68 = load.i64 notrap aligned region4 v25+96
+;; @0062 store notrap aligned region4 v26, v25+88
+;; @0062 store notrap aligned region4 v27, v25+96
+;; @0062 store notrap aligned region6 v151, v27+32 ; v151 = 1
+;; v161 = iconst.i32 0
+;; @0062 store notrap aligned region17 v161, v154 ; v161 = 0
+;; @0062 store notrap aligned region14 v161, v154+4 ; v161 = 0
+;; @0062 store notrap aligned region15 v149, v154+8 ; v149 = 0
+;; @0062 store notrap aligned region18 v149, v27+56 ; v149 = 0
+;; @0062 brif v65, block9, block6
;;
;; block9:
-;; v179 = iconst.i64 32
-;; v180 = ushr.i64 v69, v179 ; v179 = 32
-;; @0062 v82 = iconst.i64 4
-;; @0062 v83 = icmp eq v180, v82 ; v82 = 4
-;; @0062 brif v83, block8, block7
+;; @0062 v58 = iconst.i64 32
+;; @0062 v75 = ushr.i64 v65, v58 ; v58 = 32
+;; @0062 v76 = iconst.i64 4
+;; @0062 v77 = icmp eq v75, v76 ; v76 = 4
+;; @0062 brif v77, block8, block7
;;
;; block8 cold:
-;; @0062 v86 = iconst.i32 5
-;; v184 = iconst.i64 32
-;; v185 = iadd.i64 v72, v184 ; v184 = 32
-;; @0062 store notrap aligned region2 v86, v185 ; v86 = 5
-;; @0062 v91 = load.i64 notrap aligned region2 v27
-;; @0062 store notrap aligned region1 v91, v25+24
-;; @0062 v92 = load.i64 notrap aligned region2 v27+8
-;; @0062 store notrap aligned region4 v92, v25+72
-;; @0062 v93 = load.i64 notrap aligned region2 v27+16
-;; @0062 store notrap aligned region5 v93, v25+64
-;; @0062 v94 = load.i64 notrap aligned region2 v27+24
-;; @0062 store notrap aligned region6 v94, v25+80
-;; v186 = iconst.i32 0
-;; v187 = iconst.i64 120
-;; v188 = iadd.i64 v72, v187 ; v187 = 120
-;; @0062 store notrap aligned region2 v186, v188 ; v186 = 0
-;; @0062 store notrap aligned region2 v186, v188+4 ; v186 = 0
-;; v189 = iconst.i64 0
-;; @0062 store notrap aligned region2 v189, v188+8 ; v189 = 0
-;; v190 = iconst.i64 136
-;; v191 = iadd.i64 v72, v190 ; v190 = 136
-;; @0062 store notrap aligned region2 v186, v191 ; v186 = 0
-;; @0062 store notrap aligned region2 v186, v191+4 ; v186 = 0
-;; @0062 store notrap aligned region2 v189, v191+8 ; v189 = 0
+;; @0062 v80 = iconst.i32 5
+;; @0062 store notrap aligned region6 v80, v68+32 ; v80 = 5
+;; @0062 v83 = load.i64 notrap aligned region13 v27
+;; @0062 store notrap aligned region1 v83, v25+24
+;; @0062 v84 = load.i64 notrap aligned region10 v27+8
+;; @0062 store notrap aligned region7 v84, v25+72
+;; @0062 v85 = load.i64 notrap aligned region11 v27+16
+;; @0062 store notrap aligned region8 v85, v25+64
+;; @0062 v86 = load.i64 notrap aligned region12 v27+24
+;; @0062 store notrap aligned region9 v86, v25+80
+;; v167 = iconst.i32 0
+;; v168 = iconst.i64 120
+;; v169 = iadd.i64 v68, v168 ; v168 = 120
+;; @0062 store notrap aligned region17 v167, v169 ; v167 = 0
+;; @0062 store notrap aligned region14 v167, v169+4 ; v167 = 0
+;; v170 = iconst.i64 0
+;; @0062 store notrap aligned region15 v170, v169+8 ; v170 = 0
+;; v171 = iconst.i64 136
+;; v172 = iadd.i64 v68, v171 ; v171 = 136
+;; @0062 store notrap aligned region17 v167, v172 ; v167 = 0
+;; @0062 store notrap aligned region14 v167, v172+4 ; v167 = 0
+;; @0062 store notrap aligned region15 v170, v172+8 ; v170 = 0
;; @0062 try_call fn2(v0), sig2, block11, [ context v0 ]
;;
;; block11:
;; @0062 trap user12
;;
;; block7:
-;; @0062 v109 = load.i64 notrap aligned region4 v25+72
-;; @0062 v110 = load.i64 notrap aligned region5 v25+64
-;; @0062 v111 = load.i64 notrap aligned region6 v25+80
-;; @0062 store notrap aligned region2 v109, v72+8
-;; @0062 store notrap aligned region2 v110, v72+16
-;; @0062 store notrap aligned region2 v111, v72+24
-;; @0062 v114 = load.i64 notrap aligned region2 v27
-;; @0062 store notrap aligned region1 v114, v25+24
-;; @0062 v115 = load.i64 notrap aligned region2 v27+8
-;; @0062 store notrap aligned region4 v115, v25+72
-;; @0062 v116 = load.i64 notrap aligned region2 v27+16
-;; @0062 store notrap aligned region5 v116, v25+64
-;; @0062 v117 = load.i64 notrap aligned region2 v27+24
-;; @0062 store notrap aligned region6 v117, v25+80
-;; @0062 v119 = load.i64 notrap aligned region2 v72+88
+;; @0062 v101 = load.i64 notrap aligned region7 v25+72
+;; @0062 v102 = load.i64 notrap aligned region8 v25+64
+;; @0062 v103 = load.i64 notrap aligned region9 v25+80
+;; @0062 store notrap aligned region10 v101, v68+8
+;; @0062 store notrap aligned region11 v102, v68+16
+;; @0062 store notrap aligned region12 v103, v68+24
+;; @0062 v106 = load.i64 notrap aligned region13 v27
+;; @0062 store notrap aligned region1 v106, v25+24
+;; @0062 v107 = load.i64 notrap aligned region10 v27+8
+;; @0062 store notrap aligned region7 v107, v25+72
+;; @0062 v108 = load.i64 notrap aligned region11 v27+16
+;; @0062 store notrap aligned region8 v108, v25+64
+;; @0062 v109 = load.i64 notrap aligned region12 v27+24
+;; @0062 store notrap aligned region9 v109, v25+80
+;; @0062 v111 = load.i64 notrap aligned region2 v68+88
;; @0062 jump block10
;;
;; block12 cold:
;; @0062 trap user12
;;
;; block13:
-;; @0062 v126 = iconst.i64 136
-;; @0062 v127 = iadd.i64 v72, v126 ; v126 = 136
-;; @0062 v128 = load.i64 notrap aligned region2 v127+8
-;; @0062 v129 = load.i32 notrap aligned region7 v128
-;; v181 = iconst.i32 0
-;; @0062 store notrap aligned region2 v181, v127 ; v181 = 0
+;; @0062 v118 = iconst.i64 136
+;; @0062 v119 = iadd.i64 v68, v118 ; v118 = 136
+;; @0062 v120 = load.i64 notrap aligned region15 v119+8
+;; @0062 v121 = load.i32 notrap aligned region16 v120
+;; v164 = iconst.i32 0
+;; @0062 store notrap aligned region17 v164, v119 ; v164 = 0
;; @0062 jump block4
;;
;; block10:
-;; @0062 v118 = ireduce.i32 v69
-;; @0062 br_table v118, block12, [block13]
+;; @0062 v110 = ireduce.i32 v65
+;; @0062 br_table v110, block12, [block13]
;;
;; block6:
-;; @0062 v133 = load.i64 notrap aligned region2 v27
-;; @0062 store notrap aligned region1 v133, v25+24
-;; @0062 v134 = load.i64 notrap aligned region2 v27+8
-;; @0062 store notrap aligned region4 v134, v25+72
-;; @0062 v135 = load.i64 notrap aligned region2 v27+16
-;; @0062 store notrap aligned region5 v135, v25+64
-;; @0062 v136 = load.i64 notrap aligned region2 v27+24
-;; @0062 store notrap aligned region6 v136, v25+80
-;; @0062 v139 = iconst.i32 4
-;; v175 = iconst.i64 32
-;; v176 = iadd.i64 v72, v175 ; v175 = 32
-;; @0062 store notrap aligned region2 v139, v176 ; v139 = 4
-;; @0062 v142 = iconst.i64 120
-;; @0062 v143 = iadd.i64 v72, v142 ; v142 = 120
-;; @0062 v144 = load.i64 notrap aligned region2 v143+8
-;; v177 = iconst.i32 0
-;; @0062 store notrap aligned region2 v177, v143 ; v177 = 0
-;; @0062 store notrap aligned region2 v177, v143+4 ; v177 = 0
-;; v178 = iconst.i64 0
-;; @0062 store notrap aligned region2 v178, v143+8 ; v178 = 0
+;; @0062 v125 = load.i64 notrap aligned region13 v27
+;; @0062 store notrap aligned region1 v125, v25+24
+;; @0062 v126 = load.i64 notrap aligned region10 v27+8
+;; @0062 store notrap aligned region7 v126, v25+72
+;; @0062 v127 = load.i64 notrap aligned region11 v27+16
+;; @0062 store notrap aligned region8 v127, v25+64
+;; @0062 v128 = load.i64 notrap aligned region12 v27+24
+;; @0062 store notrap aligned region9 v128, v25+80
+;; @0062 v131 = iconst.i32 4
+;; @0062 store notrap aligned region6 v131, v68+32 ; v131 = 4
+;; @0062 v132 = iconst.i64 120
+;; @0062 v133 = iadd.i64 v68, v132 ; v132 = 120
+;; @0062 v134 = load.i64 notrap aligned region15 v133+8
+;; v162 = iconst.i32 0
+;; @0062 store notrap aligned region17 v162, v133 ; v162 = 0
+;; @0062 store notrap aligned region14 v162, v133+4 ; v162 = 0
+;; v163 = iconst.i64 0
+;; @0062 store notrap aligned region15 v163, v133+8 ; v163 = 0
;; @0068 return
;;
;; block4:
-;; @0062 v121 = uextend.i128 v119
-;; v182 = iconst.i64 64
-;; v183 = ishl v121, v182 ; v182 = 64
-;; @0062 v120 = uextend.i128 v72
-;; @0062 v125 = bor v183, v120
-;; @006d jump block2(v125)
+;; @0062 v113 = uextend.i128 v111
+;; v165 = iconst.i64 64
+;; v166 = ishl v113, v165 ; v165 = 64
+;; @0062 v112 = uextend.i128 v68
+;; @0062 v117 = bor v166, v112
+;; @006d jump block2(v117)
;; }
diff --git a/tests/disas/stack-switching/resume-suspend.wat b/tests/disas/stack-switching/resume-suspend.wat
index b4960b22ea..7f567d361b 100644
--- a/tests/disas/stack-switching/resume-suspend.wat
+++ b/tests/disas/stack-switching/resume-suspend.wat
@@ -27,8 +27,15 @@
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
;; region2 = 67108952 "VMStoreContext+0x58"
-;; region3 = 1073741824 "VMContRef+0x0"
-;; region4 = 1140850688 "ContinuationStackMemory+0x0"
+;; region3 = 1073741888 "VMContRef+0x40"
+;; region4 = 2550136840 "VMHostArray+0x8"
+;; region5 = 2483028024 "VMCommonStackInformation+0x38"
+;; region6 = 1140850688 "ContinuationStackMemory+0x0"
+;; region7 = 1073741904 "VMContRef+0x50"
+;; region8 = 2550136836 "VMHostArray+0x4"
+;; region9 = 2483028000 "VMCommonStackInformation+0x20"
+;; region10 = 1073741920 "VMContRef+0x60"
+;; region11 = 2550136832 "VMHostArray+0x0"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -46,92 +53,91 @@
;; @003b jump block2(v5, v6)
;;
;; block2(v7: i64, v8: i64):
-;; v73 = iconst.i64 1
-;; v74 = icmp eq v7, v73 ; v73 = 1
-;; @003b trapnz v74, user22
+;; v71 = iconst.i64 1
+;; v72 = icmp eq v7, v71 ; v71 = 1
+;; @003b trapnz v72, user22
;; @003b jump block3
;;
;; block3:
;; @003b v11 = load.i64 notrap aligned region3 v8+64
;; @003b v12 = load.i64 notrap aligned region3 v8+72
-;; v75 = iconst.i64 40
-;; v76 = iadd v12, v75 ; v75 = 40
-;; @003b v15 = load.i64 notrap aligned region3 v76+8
-;; @003b v16 = load.i32 notrap aligned region3 v12+56
-;; v77 = iconst.i32 0
-;; v67 = iconst.i32 3
+;; v73 = iconst.i64 40
+;; v74 = iadd v12, v73 ; v73 = 40
+;; @003b v15 = load.i64 notrap aligned region4 v74+8
+;; @003b v16 = load.i32 notrap aligned region5 v12+56
+;; v75 = iconst.i32 0
+;; v65 = iconst.i32 3
;; @003b v2 = iconst.i64 48
;; @003b v3 = iadd.i64 v0, v2 ; v2 = 48
;; @003b v26 = iconst.i32 1
-;; @003b jump block4(v77) ; v77 = 0
+;; @003b jump block4(v75) ; v75 = 0
;;
;; block4(v18: i32):
;; @003b v19 = icmp ult v18, v16
;; @003b brif v19, block5, block2(v11, v12)
;;
;; block5:
-;; v78 = iconst.i32 3
-;; v79 = ishl.i32 v18, v78 ; v78 = 3
-;; @003b v22 = uextend.i64 v79
+;; v76 = iconst.i32 3
+;; v77 = ishl.i32 v18, v76 ; v76 = 3
+;; @003b v22 = uextend.i64 v77
;; @003b v23 = iadd.i64 v15, v22
-;; @003b v24 = load.i64 notrap aligned region4 v23
-;; v80 = iadd.i64 v0, v2 ; v2 = 48
-;; v81 = icmp eq v24, v80
-;; v82 = iconst.i32 1
-;; v83 = iadd.i32 v18, v82 ; v82 = 1
-;; @003b brif v81, block6, block4(v83)
+;; @003b v24 = load.i64 notrap aligned region6 v23
+;; v78 = iadd.i64 v0, v2 ; v2 = 48
+;; v79 = icmp eq v24, v78
+;; v80 = iconst.i32 1
+;; v81 = iadd.i32 v18, v80 ; v80 = 1
+;; @003b brif v79, block6, block4(v81)
;;
;; block6:
-;; @003b store.i64 notrap aligned region3 v8, v6+80
-;; v84 = iconst.i32 1
+;; @003b store.i64 notrap aligned region7 v8, v6+80
+;; v82 = iconst.i32 1
;; @003b v28 = iconst.i64 136
;; @003b v29 = iadd.i64 v6, v28 ; v28 = 136
-;; @003b store notrap aligned region3 v84, v29+4 ; v84 = 1
+;; @003b store notrap aligned region8 v82, v29+4 ; v82 = 1
;; @003b v31 = stack_addr.i64 ss0
-;; @003b store notrap aligned region3 v31, v29+8
-;; v85 = iconst.i32 3
-;; @003b v35 = iconst.i64 32
-;; @003b v36 = iadd.i64 v6, v35 ; v35 = 32
-;; @003b store notrap aligned region3 v85, v36 ; v85 = 3
+;; @003b store notrap aligned region4 v31, v29+8
+;; v83 = iconst.i32 3
+;; @003b store notrap aligned region9 v83, v6+32 ; v83 = 3
;; @003b v32 = iconst.i64 0
;; @003b store notrap aligned region3 v32, v8+64 ; v32 = 0
;; @003b store notrap aligned region3 v32, v8+72 ; v32 = 0
-;; @003b v44 = iconst.i64 96
-;; @003b v45 = iadd.i64 v8, v44 ; v44 = 96
-;; @003b v46 = load.i64 notrap aligned region3 v45
-;; @003b v47 = iconst.i64 -24
-;; @003b v48 = iadd v46, v47 ; v47 = -24
-;; @003b v42 = uextend.i64 v18
-;; v70 = iconst.i64 0x0002_0000_0000
-;; v71 = bor v42, v70 ; v70 = 0x0002_0000_0000
-;; @003b v49 = stack_switch v48, v48, v71
-;; @003b v51 = ushr v49, v35 ; v35 = 32
-;; @003b v52 = iconst.i64 5
-;; @003b v53 = icmp eq v51, v52 ; v52 = 5
-;; @003b brif v53, block8, block9
+;; @003b v42 = iconst.i64 96
+;; @003b v43 = iadd.i64 v8, v42 ; v42 = 96
+;; @003b v44 = load.i64 notrap aligned region10 v43
+;; @003b v45 = iconst.i64 -24
+;; @003b v46 = iadd v44, v45 ; v45 = -24
+;; @003b v40 = uextend.i64 v18
+;; v68 = iconst.i64 0x0002_0000_0000
+;; v69 = bor v40, v68 ; v68 = 0x0002_0000_0000
+;; @003b v47 = stack_switch v46, v46, v69
+;; @003b v38 = iconst.i64 32
+;; @003b v49 = ushr v47, v38 ; v38 = 32
+;; @003b v50 = iconst.i64 5
+;; @003b v51 = icmp eq v49, v50 ; v50 = 5
+;; @003b brif v51, block8, block9
;;
;; block8 cold:
-;; v89 = iadd.i64 v6, v28 ; v28 = 136
-;; @003b v56 = load.i64 notrap aligned region3 v89+8
-;; @003b v57 = load.i32 notrap aligned region4 v56
-;; v90 = iconst.i32 0
-;; @003b store notrap aligned region3 v90, v89 ; v90 = 0
-;; @003b store notrap aligned region3 v90, v89+4 ; v90 = 0
-;; v91 = iconst.i64 0
-;; @003b store notrap aligned region3 v91, v89+8 ; v91 = 0
-;; @003b try_call fn0(v0, v57), sig0, block10, [ context v0 ]
+;; v87 = iadd.i64 v6, v28 ; v28 = 136
+;; @003b v54 = load.i64 notrap aligned region4 v87+8
+;; @003b v55 = load.i32 notrap aligned region6 v54
+;; v88 = iconst.i32 0
+;; @003b store notrap aligned region11 v88, v87 ; v88 = 0
+;; @003b store notrap aligned region8 v88, v87+4 ; v88 = 0
+;; v89 = iconst.i64 0
+;; @003b store notrap aligned region4 v89, v87+8 ; v89 = 0
+;; @003b try_call fn0(v0, v55), sig0, block10, [ context v0 ]
;;
;; block10:
;; @003b trap user12
;;
;; block9:
-;; v86 = iadd.i64 v6, v28 ; v28 = 136
-;; @003b v63 = load.i64 notrap aligned region3 v86+8
-;; v87 = iconst.i32 0
-;; @003b store notrap aligned region3 v87, v86 ; v87 = 0
-;; @003b store notrap aligned region3 v87, v86+4 ; v87 = 0
-;; v88 = iconst.i64 0
-;; @003b store notrap aligned region3 v88, v86+8 ; v88 = 0
+;; v84 = iadd.i64 v6, v28 ; v28 = 136
+;; @003b v61 = load.i64 notrap aligned region4 v84+8
+;; v85 = iconst.i32 0
+;; @003b store notrap aligned region11 v85, v84 ; v85 = 0
+;; @003b store notrap aligned region8 v85, v84+4 ; v85 = 0
+;; v86 = iconst.i64 0
+;; @003b store notrap aligned region4 v86, v84+8 ; v86 = 0
;; @003d jump block1
;;
;; block1:
@@ -142,12 +148,24 @@
;; ss0 = explicit_slot 8, align = 256
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
-;; region2 = 1073741824 "VMContRef+0x0"
-;; region3 = 67108952 "VMStoreContext+0x58"
-;; region4 = 67108936 "VMStoreContext+0x48"
-;; region5 = 67108928 "VMStoreContext+0x40"
-;; region6 = 67108944 "VMStoreContext+0x50"
-;; region7 = 1140850688 "ContinuationStackMemory+0x0"
+;; region2 = 1073741912 "VMContRef+0x58"
+;; region3 = 1073741904 "VMContRef+0x50"
+;; region4 = 67108952 "VMStoreContext+0x58"
+;; region5 = 1073741888 "VMContRef+0x40"
+;; region6 = 2483028000 "VMCommonStackInformation+0x20"
+;; region7 = 67108936 "VMStoreContext+0x48"
+;; region8 = 67108928 "VMStoreContext+0x40"
+;; region9 = 67108944 "VMStoreContext+0x50"
+;; region10 = 2415919112 "VMStackLimits+0x8"
+;; region11 = 2415919120 "VMStackLimits+0x10"
+;; region12 = 2415919128 "VMStackLimits+0x18"
+;; region13 = 2415919104 "VMStackLimits+0x0"
+;; region14 = 2550136836 "VMHostArray+0x4"
+;; region15 = 2550136840 "VMHostArray+0x8"
+;; region16 = 1140850688 "ContinuationStackMemory+0x0"
+;; region17 = 2550136832 "VMHostArray+0x0"
+;; region18 = 2483028024 "VMCommonStackInformation+0x38"
+;; region19 = 1073741920 "VMContRef+0x60"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -170,186 +188,179 @@
;; block3:
;; @0045 v16 = uextend.i128 v14
;; @0040 v5 = iconst.i64 64
-;; v163 = ishl v16, v5 ; v5 = 64
-;; v165 = ireduce.i64 v163
-;; v167 = bor v165, v13
-;; @004e trapz v167, user16
-;; @004e v26 = load.i64 notrap aligned region2 v167+88
+;; v153 = ishl v16, v5 ; v5 = 64
+;; v155 = ireduce.i64 v153
+;; v157 = bor v155, v13
+;; @004e trapz v157, user16
+;; @004e v26 = load.i64 notrap aligned region2 v157+88
;; @0045 v15 = uextend.i128 v13
-;; @0045 v20 = bor v163, v15
-;; v169 = ushr v20, v5 ; v5 = 64
-;; @004e v25 = ireduce.i64 v169
+;; @0045 v20 = bor v153, v15
+;; v159 = ushr v20, v5 ; v5 = 64
+;; @004e v25 = ireduce.i64 v159
;; @004e v27 = icmp eq v26, v25
;; @004e trapz v27, user23
;; @004e v28 = iconst.i64 1
;; @004e v29 = iadd v26, v28 ; v28 = 1
-;; @004e store notrap aligned region2 v29, v167+88
-;; @004e v30 = load.i64 notrap aligned region2 v167+80
+;; @004e store notrap aligned region2 v29, v157+88
+;; @004e v30 = load.i64 notrap aligned region3 v157+80
;; @004e v31 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004e v32 = load.i64 notrap aligned region3 v31+88
-;; @004e v33 = load.i64 notrap aligned region3 v31+96
-;; @004e store notrap aligned region2 v32, v30+64
-;; @004e store notrap aligned region2 v33, v30+72
+;; @004e v32 = load.i64 notrap aligned region4 v31+88
+;; @004e v33 = load.i64 notrap aligned region4 v31+96
+;; @004e store notrap aligned region5 v32, v30+64
+;; @004e store notrap aligned region5 v33, v30+72
;; @0040 v2 = iconst.i64 0
-;; @004e store notrap aligned region2 v2, v167+80 ; v2 = 0
+;; @004e store notrap aligned region3 v2, v157+80 ; v2 = 0
;; @004e v35 = iconst.i64 2
-;; @004e store notrap aligned region3 v35, v31+88 ; v35 = 2
-;; @004e store notrap aligned region3 v167, v31+96
+;; @004e store notrap aligned region4 v35, v31+88 ; v35 = 2
+;; @004e store notrap aligned region4 v157, v31+96
;; @004e v39 = iconst.i32 1
-;; @004e v40 = iconst.i64 32
-;; @004e v41 = iadd v167, v40 ; v40 = 32
-;; @004e store notrap aligned region2 v39, v41 ; v39 = 1
-;; @004e v42 = iconst.i32 2
-;; @004e v44 = iadd v33, v40 ; v40 = 32
-;; @004e store notrap aligned region2 v42, v44 ; v42 = 2
-;; @004e v48 = load.i64 notrap aligned region4 v31+72
-;; @004e v49 = load.i64 notrap aligned region5 v31+64
-;; @004e v50 = load.i64 notrap aligned region6 v31+80
-;; @004e store notrap aligned region2 v48, v33+8
-;; @004e store notrap aligned region2 v49, v33+16
-;; @004e store notrap aligned region2 v50, v33+24
-;; @004e v51 = load.i64 notrap aligned region1 v31+24
-;; @004e store notrap aligned region2 v51, v33
-;; @004e v54 = load.i64 notrap aligned region2 v167
-;; @004e store notrap aligned region1 v54, v31+24
-;; @004e v55 = load.i64 notrap aligned region2 v167+8
-;; @004e store notrap aligned region4 v55, v31+72
-;; @004e v56 = load.i64 notrap aligned region2 v167+16
-;; @004e store notrap aligned region5 v56, v31+64
-;; @004e v57 = load.i64 notrap aligned region2 v167+24
-;; @004e store notrap aligned region6 v57, v31+80
-;; @004e v58 = iconst.i64 40
-;; @004e v59 = iadd v33, v58 ; v58 = 40
-;; @004e store notrap aligned region2 v39, v59+4 ; v39 = 1
-;; @004e v61 = stack_addr.i64 ss0
-;; @004e store notrap aligned region2 v61, v59+8
-;; @004e v62 = iconst.i64 48
-;; @004e v63 = iadd.i64 v0, v62 ; v62 = 48
-;; @004e store notrap aligned region7 v63, v61
-;; @004e store notrap aligned region2 v39, v59 ; v39 = 1
-;; @004e store notrap aligned region2 v39, v33+56 ; v39 = 1
-;; @004e v70 = iconst.i64 96
-;; @004e v71 = iadd v30, v70 ; v70 = 96
-;; @004e v72 = load.i64 notrap aligned region2 v71
-;; @004e v73 = iconst.i64 -24
-;; @004e v74 = iadd v72, v73 ; v73 = -24
-;; v171 = iconst.i64 0x0001_0000_0000
-;; @004e v75 = stack_switch v74, v74, v171 ; v171 = 0x0001_0000_0000
-;; @004e v77 = load.i64 notrap aligned region3 v31+88
-;; @004e v78 = load.i64 notrap aligned region3 v31+96
-;; @004e store notrap aligned region3 v32, v31+88
-;; @004e store notrap aligned region3 v33, v31+96
-;; @004e store notrap aligned region2 v39, v44 ; v39 = 1
-;; v174 = iconst.i32 0
-;; @004e store notrap aligned region2 v174, v59 ; v174 = 0
-;; @004e store notrap aligned region2 v174, v59+4 ; v174 = 0
-;; @004e store notrap aligned region2 v2, v59+8 ; v2 = 0
-;; @004e store notrap aligned region2 v2, v33+56 ; v2 = 0
-;; @004e brif v75, block7, block4
+;; @004e store notrap aligned region6 v39, v157+32 ; v39 = 1
+;; @004e v40 = iconst.i32 2
+;; @004e store notrap aligned region6 v40, v33+32 ; v40 = 2
+;; @004e v44 = load.i64 notrap aligned region7 v31+72
+;; @004e v45 = load.i64 notrap aligned region8 v31+64
+;; @004e v46 = load.i64 notrap aligned region9 v31+80
+;; @004e store notrap aligned region10 v44, v33+8
+;; @004e store notrap aligned region11 v45, v33+16
+;; @004e store notrap aligned region12 v46, v33+24
+;; @004e v47 = load.i64 notrap aligned region1 v31+24
+;; @004e store notrap aligned region13 v47, v33
+;; @004e v50 = load.i64 notrap aligned region13 v157
+;; @004e store notrap aligned region1 v50, v31+24
+;; @004e v51 = load.i64 notrap aligned region10 v157+8
+;; @004e store notrap aligned region7 v51, v31+72
+;; @004e v52 = load.i64 notrap aligned region11 v157+16
+;; @004e store notrap aligned region8 v52, v31+64
+;; @004e v53 = load.i64 notrap aligned region12 v157+24
+;; @004e store notrap aligned region9 v53, v31+80
+;; @004e v54 = iconst.i64 40
+;; @004e v55 = iadd v33, v54 ; v54 = 40
+;; @004e store notrap aligned region14 v39, v55+4 ; v39 = 1
+;; @004e v57 = stack_addr.i64 ss0
+;; @004e store notrap aligned region15 v57, v55+8
+;; @004e v58 = iconst.i64 48
+;; @004e v59 = iadd.i64 v0, v58 ; v58 = 48
+;; @004e store notrap aligned region16 v59, v57
+;; @004e store notrap aligned region17 v39, v55 ; v39 = 1
+;; @004e store notrap aligned region18 v39, v33+56 ; v39 = 1
+;; @004e v66 = iconst.i64 96
+;; @004e v67 = iadd v30, v66 ; v66 = 96
+;; @004e v68 = load.i64 notrap aligned region19 v67
+;; @004e v69 = iconst.i64 -24
+;; @004e v70 = iadd v68, v69 ; v69 = -24
+;; v161 = iconst.i64 0x0001_0000_0000
+;; @004e v71 = stack_switch v70, v70, v161 ; v161 = 0x0001_0000_0000
+;; @004e v73 = load.i64 notrap aligned region4 v31+88
+;; @004e v74 = load.i64 notrap aligned region4 v31+96
+;; @004e store notrap aligned region4 v32, v31+88
+;; @004e store notrap aligned region4 v33, v31+96
+;; @004e store notrap aligned region6 v39, v33+32 ; v39 = 1
+;; v164 = iconst.i32 0
+;; @004e store notrap aligned region17 v164, v55 ; v164 = 0
+;; @004e store notrap aligned region14 v164, v55+4 ; v164 = 0
+;; @004e store notrap aligned region15 v2, v55+8 ; v2 = 0
+;; @004e store notrap aligned region18 v2, v33+56 ; v2 = 0
+;; @004e brif v71, block7, block4
;;
;; block7:
-;; v182 = iconst.i64 32
-;; v183 = ushr.i64 v75, v182 ; v182 = 32
-;; @004e v88 = iconst.i64 4
-;; @004e v89 = icmp eq v183, v88 ; v88 = 4
-;; @004e brif v89, block6, block5
+;; @004e v64 = iconst.i64 32
+;; @004e v81 = ushr.i64 v71, v64 ; v64 = 32
+;; @004e v82 = iconst.i64 4
+;; @004e v83 = icmp eq v81, v82 ; v82 = 4
+;; @004e brif v83, block6, block5
;;
;; block6 cold:
-;; @004e v92 = iconst.i32 5
-;; v187 = iconst.i64 32
-;; v188 = iadd.i64 v78, v187 ; v187 = 32
-;; @004e store notrap aligned region2 v92, v188 ; v92 = 5
-;; @004e v97 = load.i64 notrap aligned region2 v33
-;; @004e store notrap aligned region1 v97, v31+24
-;; @004e v98 = load.i64 notrap aligned region2 v33+8
-;; @004e store notrap aligned region4 v98, v31+72
-;; @004e v99 = load.i64 notrap aligned region2 v33+16
-;; @004e store notrap aligned region5 v99, v31+64
-;; @004e v100 = load.i64 notrap aligned region2 v33+24
-;; @004e store notrap aligned region6 v100, v31+80
-;; v189 = iconst.i32 0
-;; v190 = iconst.i64 120
-;; v191 = iadd.i64 v78, v190 ; v190 = 120
-;; @004e store notrap aligned region2 v189, v191 ; v189 = 0
-;; @004e store notrap aligned region2 v189, v191+4 ; v189 = 0
-;; v192 = iconst.i64 0
-;; @004e store notrap aligned region2 v192, v191+8 ; v192 = 0
-;; v193 = iconst.i64 136
-;; v194 = iadd.i64 v78, v193 ; v193 = 136
-;; @004e store notrap aligned region2 v189, v194 ; v189 = 0
-;; @004e store notrap aligned region2 v189, v194+4 ; v189 = 0
-;; @004e store notrap aligned region2 v192, v194+8 ; v192 = 0
+;; @004e v86 = iconst.i32 5
+;; @004e store notrap aligned region6 v86, v74+32 ; v86 = 5
+;; @004e v89 = load.i64 notrap aligned region13 v33
+;; @004e store notrap aligned region1 v89, v31+24
+;; @004e v90 = load.i64 notrap aligned region10 v33+8
+;; @004e store notrap aligned region7 v90, v31+72
+;; @004e v91 = load.i64 notrap aligned region11 v33+16
+;; @004e store notrap aligned region8 v91, v31+64
+;; @004e v92 = load.i64 notrap aligned region12 v33+24
+;; @004e store notrap aligned region9 v92, v31+80
+;; v173 = iconst.i32 0
+;; v174 = iconst.i64 120
+;; v175 = iadd.i64 v74, v174 ; v174 = 120
+;; @004e store notrap aligned region17 v173, v175 ; v173 = 0
+;; @004e store notrap aligned region14 v173, v175+4 ; v173 = 0
+;; v176 = iconst.i64 0
+;; @004e store notrap aligned region15 v176, v175+8 ; v176 = 0
+;; v177 = iconst.i64 136
+;; v178 = iadd.i64 v74, v177 ; v177 = 136
+;; @004e store notrap aligned region17 v173, v178 ; v173 = 0
+;; @004e store notrap aligned region14 v173, v178+4 ; v173 = 0
+;; @004e store notrap aligned region15 v176, v178+8 ; v176 = 0
;; @004e try_call fn2(v0), sig2, block9, [ context v0 ]
;;
;; block9:
;; @004e trap user12
;;
;; block5:
-;; @004e v115 = load.i64 notrap aligned region4 v31+72
-;; @004e v116 = load.i64 notrap aligned region5 v31+64
-;; @004e v117 = load.i64 notrap aligned region6 v31+80
-;; @004e store notrap aligned region2 v115, v78+8
-;; @004e store notrap aligned region2 v116, v78+16
-;; @004e store notrap aligned region2 v117, v78+24
-;; @004e v120 = load.i64 notrap aligned region2 v33
-;; @004e store notrap aligned region1 v120, v31+24
-;; @004e v121 = load.i64 notrap aligned region2 v33+8
-;; @004e store notrap aligned region4 v121, v31+72
-;; @004e v122 = load.i64 notrap aligned region2 v33+16
-;; @004e store notrap aligned region5 v122, v31+64
-;; @004e v123 = load.i64 notrap aligned region2 v33+24
-;; @004e store notrap aligned region6 v123, v31+80
-;; @004e v125 = load.i64 notrap aligned region2 v78+88
+;; @004e v107 = load.i64 notrap aligned region7 v31+72
+;; @004e v108 = load.i64 notrap aligned region8 v31+64
+;; @004e v109 = load.i64 notrap aligned region9 v31+80
+;; @004e store notrap aligned region10 v107, v74+8
+;; @004e store notrap aligned region11 v108, v74+16
+;; @004e store notrap aligned region12 v109, v74+24
+;; @004e v112 = load.i64 notrap aligned region13 v33
+;; @004e store notrap aligned region1 v112, v31+24
+;; @004e v113 = load.i64 notrap aligned region10 v33+8
+;; @004e store notrap aligned region7 v113, v31+72
+;; @004e v114 = load.i64 notrap aligned region11 v33+16
+;; @004e store notrap aligned region8 v114, v31+64
+;; @004e v115 = load.i64 notrap aligned region12 v33+24
+;; @004e store notrap aligned region9 v115, v31+80
+;; @004e v117 = load.i64 notrap aligned region2 v74+88
;; @004e jump block8
;;
;; block10 cold:
;; @004e trap user12
;;
;; block11:
-;; @004e v132 = iconst.i64 136
-;; @004e v133 = iadd.i64 v78, v132 ; v132 = 136
-;; @004e v134 = load.i64 notrap aligned region2 v133+8
-;; v184 = iconst.i32 0
-;; @004e store notrap aligned region2 v184, v133 ; v184 = 0
-;; @004e v127 = uextend.i128 v125
-;; v185 = iconst.i64 64
-;; v186 = ishl v127, v185 ; v185 = 64
-;; @004e v126 = uextend.i128 v78
-;; @004e v131 = bor v186, v126
-;; @004e jump block2(v131)
+;; @004e v124 = iconst.i64 136
+;; @004e v125 = iadd.i64 v74, v124 ; v124 = 136
+;; @004e v126 = load.i64 notrap aligned region15 v125+8
+;; v170 = iconst.i32 0
+;; @004e store notrap aligned region17 v170, v125 ; v170 = 0
+;; @004e v119 = uextend.i128 v117
+;; v171 = iconst.i64 64
+;; v172 = ishl v119, v171 ; v171 = 64
+;; @004e v118 = uextend.i128 v74
+;; @004e v123 = bor v172, v118
+;; @004e jump block2(v123)
;;
;; block8:
-;; @004e v124 = ireduce.i32 v75
-;; @004e br_table v124, block10, [block11]
+;; @004e v116 = ireduce.i32 v71
+;; @004e br_table v116, block10, [block11]
;;
;; block4:
-;; @004e v138 = load.i64 notrap aligned region2 v33
-;; @004e store notrap aligned region1 v138, v31+24
-;; @004e v139 = load.i64 notrap aligned region2 v33+8
-;; @004e store notrap aligned region4 v139, v31+72
-;; @004e v140 = load.i64 notrap aligned region2 v33+16
-;; @004e store notrap aligned region5 v140, v31+64
-;; @004e v141 = load.i64 notrap aligned region2 v33+24
-;; @004e store notrap aligned region6 v141, v31+80
-;; @004e v144 = iconst.i32 4
-;; v175 = iconst.i64 32
-;; v176 = iadd.i64 v78, v175 ; v175 = 32
-;; @004e store notrap aligned region2 v144, v176 ; v144 = 4
-;; @004e v147 = iconst.i64 120
-;; @004e v148 = iadd.i64 v78, v147 ; v147 = 120
-;; @004e v149 = load.i64 notrap aligned region2 v148+8
-;; v177 = iconst.i32 0
-;; @004e store notrap aligned region2 v177, v148 ; v177 = 0
-;; @004e store notrap aligned region2 v177, v148+4 ; v177 = 0
-;; v178 = iconst.i64 0
-;; @004e store notrap aligned region2 v178, v148+8 ; v178 = 0
-;; v179 = uextend.i128 v178 ; v178 = 0
-;; v180 = iconst.i64 64
-;; v181 = ishl v179, v180 ; v180 = 64
-;; @0040 v8 = bor v181, v179
+;; @004e v130 = load.i64 notrap aligned region13 v33
+;; @004e store notrap aligned region1 v130, v31+24
+;; @004e v131 = load.i64 notrap aligned region10 v33+8
+;; @004e store notrap aligned region7 v131, v31+72
+;; @004e v132 = load.i64 notrap aligned region11 v33+16
+;; @004e store notrap aligned region8 v132, v31+64
+;; @004e v133 = load.i64 notrap aligned region12 v33+24
+;; @004e store notrap aligned region9 v133, v31+80
+;; @004e v136 = iconst.i32 4
+;; @004e store notrap aligned region6 v136, v74+32 ; v136 = 4
+;; @004e v137 = iconst.i64 120
+;; @004e v138 = iadd.i64 v74, v137 ; v137 = 120
+;; @004e v139 = load.i64 notrap aligned region15 v138+8
+;; v165 = iconst.i32 0
+;; @004e store notrap aligned region17 v165, v138 ; v165 = 0
+;; @004e store notrap aligned region14 v165, v138+4 ; v165 = 0
+;; v166 = iconst.i64 0
+;; @004e store notrap aligned region15 v166, v138+8 ; v166 = 0
+;; v167 = uextend.i128 v166 ; v166 = 0
+;; v168 = iconst.i64 64
+;; v169 = ishl v167, v168 ; v168 = 64
+;; @0040 v8 = bor v169, v167
;; @0056 jump block2(v8)
;;
-;; block2(v160: i128):
+;; block2(v150: i128):
;; @0058 jump block1
;;
;; block1:
diff --git a/tests/disas/stack-switching/symmetric-switch.wat b/tests/disas/stack-switching/symmetric-switch.wat
index a88086bbc5..eac04c9a81 100644
--- a/tests/disas/stack-switching/symmetric-switch.wat
+++ b/tests/disas/stack-switching/symmetric-switch.wat
@@ -30,13 +30,25 @@
;; ss1 = explicit_slot 24, align = 256
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
-;; region2 = 1073741824 "VMContRef+0x0"
+;; region2 = 1073741912 "VMContRef+0x58"
;; region3 = 67108952 "VMStoreContext+0x58"
-;; region4 = 1140850688 "ContinuationStackMemory+0x0"
-;; region5 = 67108936 "VMStoreContext+0x48"
-;; region6 = 67108928 "VMStoreContext+0x40"
-;; region7 = 67108944 "VMStoreContext+0x50"
-;; region8 = 1543503873 "Stack(ss1)"
+;; region4 = 1073741888 "VMContRef+0x40"
+;; region5 = 2550136840 "VMHostArray+0x8"
+;; region6 = 2483028024 "VMCommonStackInformation+0x38"
+;; region7 = 2550136832 "VMHostArray+0x0"
+;; region8 = 1140850688 "ContinuationStackMemory+0x0"
+;; region9 = 1073741904 "VMContRef+0x50"
+;; region10 = 2550136836 "VMHostArray+0x4"
+;; region11 = 2483028000 "VMCommonStackInformation+0x20"
+;; region12 = 67108936 "VMStoreContext+0x48"
+;; region13 = 67108928 "VMStoreContext+0x40"
+;; region14 = 67108944 "VMStoreContext+0x50"
+;; region15 = 2415919112 "VMStackLimits+0x8"
+;; region16 = 2415919120 "VMStackLimits+0x10"
+;; region17 = 2415919128 "VMStackLimits+0x18"
+;; region18 = 2415919104 "VMStackLimits+0x0"
+;; region19 = 1073741920 "VMContRef+0x60"
+;; region20 = 1543503873 "Stack(ss1)"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -87,13 +99,13 @@
;; @003e brif v31, block7, block3
;;
;; block3:
-;; @003e v32 = load.i64 notrap aligned region2 v29+64
-;; @003e v33 = load.i64 notrap aligned region2 v29+72
+;; @003e v32 = load.i64 notrap aligned region4 v29+64
+;; @003e v33 = load.i64 notrap aligned region4 v29+72
;; @003e v34 = iconst.i64 40
;; @003e v35 = iadd v33, v34 ; v34 = 40
-;; @003e v36 = load.i64 notrap aligned region2 v35+8
-;; @003e v37 = load.i32 notrap aligned region2 v33+56
-;; @003e v38 = load.i32 notrap aligned region2 v35
+;; @003e v36 = load.i64 notrap aligned region5 v35+8
+;; @003e v37 = load.i32 notrap aligned region6 v33+56
+;; @003e v38 = load.i32 notrap aligned region7 v35
;; @003e jump block4(v37)
;;
;; block4(v39: i32):
@@ -105,7 +117,7 @@
;; @003e v42 = imul.i32 v39, v41 ; v41 = 8
;; @003e v43 = uextend.i64 v42
;; @003e v44 = iadd.i64 v36, v43
-;; @003e v45 = load.i64 notrap aligned region4 v44
+;; @003e v45 = load.i64 notrap aligned region8 v44
;; @003e v46 = icmp eq v45, v24
;; @003e v47 = iconst.i32 1
;; @003e v48 = iadd.i32 v39, v47 ; v47 = 1
@@ -115,160 +127,154 @@
;; @003e trap user22
;;
;; block6:
-;; @003e store.i64 notrap aligned region2 v29, v27+80
+;; @003e store.i64 notrap aligned region9 v29, v27+80
;; @003e v49 = iconst.i64 136
;; @003e v50 = iadd.i64 v27, v49 ; v49 = 136
;; @003e v51 = iconst.i32 1
;; @003e v52 = stack_addr.i64 ss0
-;; @003e store notrap aligned region2 v51, v50+4 ; v51 = 1
-;; @003e store notrap aligned region2 v52, v50+8
+;; @003e store notrap aligned region10 v51, v50+4 ; v51 = 1
+;; @003e store notrap aligned region5 v52, v50+8
;; @003e v53 = iconst.i64 0
;; @003e v54 = iadd.i64 v27, v53 ; v53 = 0
;; @003e v55 = iconst.i32 3
-;; @003e v56 = iconst.i64 32
-;; @003e v57 = iadd v54, v56 ; v56 = 32
-;; @003e store notrap aligned region2 v55, v57 ; v55 = 3
-;; @003e v58 = iconst.i64 0
+;; @003e store notrap aligned region11 v55, v54+32 ; v55 = 3
+;; @003e v56 = iconst.i64 0
+;; @003e v57 = iconst.i64 0
+;; @003e store notrap aligned region4 v56, v29+64 ; v56 = 0
+;; @003e store notrap aligned region4 v57, v29+72 ; v57 = 0
+;; @003e v58 = load.i64 notrap aligned readonly can_move region0 v0+8
;; @003e v59 = iconst.i64 0
-;; @003e store notrap aligned region2 v58, v29+64 ; v58 = 0
-;; @003e store notrap aligned region2 v59, v29+72 ; v59 = 0
-;; @003e v60 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @003e v61 = iconst.i64 0
-;; @003e v62 = iadd v54, v61 ; v61 = 0
-;; @003e v63 = load.i64 notrap aligned region5 v60+72
-;; @003e v64 = load.i64 notrap aligned region6 v60+64
-;; @003e v65 = load.i64 notrap aligned region7 v60+80
-;; @003e store notrap aligned region2 v63, v62+8
-;; @003e store notrap aligned region2 v64, v62+16
-;; @003e store notrap aligned region2 v65, v62+24
-;; @003e v66 = load.i64 notrap aligned region2 v27+88
-;; @003e v67 = uextend.i128 v27
-;; @003e v68 = uextend.i128 v66
-;; @003e v69 = iconst.i64 64
-;; @003e v70 = uextend.i128 v69 ; v69 = 64
-;; @003e v71 = ishl v68, v70
-;; @003e v72 = bor v71, v67
-;; @003e v74 = iconst.i64 0
-;; @003e v75 = iadd.i64 v14, v74 ; v74 = 0
-;; @003e v76 = iconst.i64 32
-;; @003e v77 = iadd v75, v76 ; v76 = 32
-;; @003e v78 = load.i32 notrap aligned region2 v77
-;; @003e v79 = iconst.i32 0
-;; @003e v80 = icmp ne v78, v79 ; v79 = 0
-;; @003e brif v80, block9, block8
+;; @003e v60 = iadd v54, v59 ; v59 = 0
+;; @003e v61 = load.i64 notrap aligned region12 v58+72
+;; @003e v62 = load.i64 notrap aligned region13 v58+64
+;; @003e v63 = load.i64 notrap aligned region14 v58+80
+;; @003e store notrap aligned region15 v61, v60+8
+;; @003e store notrap aligned region16 v62, v60+16
+;; @003e store notrap aligned region17 v63, v60+24
+;; @003e v64 = load.i64 notrap aligned region2 v27+88
+;; @003e v65 = uextend.i128 v27
+;; @003e v66 = uextend.i128 v64
+;; @003e v67 = iconst.i64 64
+;; @003e v68 = uextend.i128 v67 ; v67 = 64
+;; @003e v69 = ishl v66, v68
+;; @003e v70 = bor v69, v65
+;; @003e v72 = iconst.i64 0
+;; @003e v73 = iadd.i64 v14, v72 ; v72 = 0
+;; @003e v74 = load.i32 notrap aligned region11 v73+32
+;; @003e v75 = iconst.i32 0
+;; @003e v76 = icmp ne v74, v75 ; v75 = 0
+;; @003e brif v76, block9, block8
;;
;; block8:
-;; @003e v81 = iconst.i64 120
-;; @003e v82 = iadd.i64 v14, v81 ; v81 = 120
-;; @003e v83 = load.i64 notrap aligned region2 v82+8
-;; @003e v84 = load.i32 notrap aligned region2 v82
-;; @003e v85 = iconst.i32 1
-;; @003e v86 = iadd v84, v85 ; v85 = 1
-;; @003e store notrap aligned region2 v86, v82
-;; @003e v87 = uextend.i64 v84
-;; @003e v88 = iconst.i64 16
-;; @003e v89 = imul v87, v88 ; v88 = 16
-;; @003e v90 = iadd v83, v89
-;; @003e jump block10(v90)
+;; @003e v77 = iconst.i64 120
+;; @003e v78 = iadd.i64 v14, v77 ; v77 = 120
+;; @003e v79 = load.i64 notrap aligned region5 v78+8
+;; @003e v80 = load.i32 notrap aligned region7 v78
+;; @003e v81 = iconst.i32 1
+;; @003e v82 = iadd v80, v81 ; v81 = 1
+;; @003e store notrap aligned region7 v82, v78
+;; @003e v83 = uextend.i64 v80
+;; @003e v84 = iconst.i64 16
+;; @003e v85 = imul v83, v84 ; v84 = 16
+;; @003e v86 = iadd v79, v85
+;; @003e jump block10(v86)
;;
;; block9:
-;; @003e v91 = iconst.i64 136
-;; @003e v92 = iadd.i64 v14, v91 ; v91 = 136
-;; @003e v93 = load.i64 notrap aligned region2 v92+8
-;; @003e v94 = load.i32 notrap aligned region2 v92
-;; @003e v95 = iconst.i32 1
-;; @003e v96 = iadd v94, v95 ; v95 = 1
-;; @003e store notrap aligned region2 v96, v92
-;; @003e v97 = uextend.i64 v94
-;; @003e v98 = iconst.i64 16
-;; @003e v99 = imul v97, v98 ; v98 = 16
-;; @003e v100 = iadd v93, v99
-;; @003e jump block10(v100)
+;; @003e v87 = iconst.i64 136
+;; @003e v88 = iadd.i64 v14, v87 ; v87 = 136
+;; @003e v89 = load.i64 notrap aligned region5 v88+8
+;; @003e v90 = load.i32 notrap aligned region7 v88
+;; @003e v91 = iconst.i32 1
+;; @003e v92 = iadd v90, v91 ; v91 = 1
+;; @003e store notrap aligned region7 v92, v88
+;; @003e v93 = uextend.i64 v90
+;; @003e v94 = iconst.i64 16
+;; @003e v95 = imul v93, v94 ; v94 = 16
+;; @003e v96 = iadd v89, v95
+;; @003e jump block10(v96)
;;
-;; block10(v73: i64):
-;; @003e store.i128 notrap aligned region4 v72, v73
-;; @003e v101 = iconst.i64 0
-;; @003e v102 = iadd.i64 v14, v101 ; v101 = 0
-;; @003e v103 = iconst.i32 1
-;; @003e v104 = iconst.i64 32
-;; @003e v105 = iadd v102, v104 ; v104 = 32
-;; @003e store notrap aligned region2 v103, v105 ; v103 = 1
-;; @003e v106 = load.i64 notrap aligned region2 v14+80
-;; @003e store.i64 notrap aligned region2 v32, v106+64
-;; @003e store.i64 notrap aligned region2 v33, v106+72
-;; @003e v107 = iconst.i64 2
-;; @003e v108 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @003e store notrap aligned region3 v107, v108+88 ; v107 = 2
-;; @003e store.i64 notrap aligned region3 v14, v108+96
-;; @003e v109 = iconst.i64 0
-;; @003e v110 = iadd v102, v109 ; v109 = 0
-;; @003e v111 = load.i64 notrap aligned region2 v110
-;; @003e store notrap aligned region1 v111, v60+24
-;; @003e v112 = load.i64 notrap aligned region2 v110+8
-;; @003e store notrap aligned region5 v112, v60+72
-;; @003e v113 = load.i64 notrap aligned region2 v110+16
-;; @003e store notrap aligned region6 v113, v60+64
-;; @003e v114 = load.i64 notrap aligned region2 v110+24
-;; @003e store notrap aligned region7 v114, v60+80
-;; @003e v115 = iconst.i64 96
-;; @003e v116 = iadd.i64 v29, v115 ; v115 = 96
-;; @003e v117 = load.i64 notrap aligned region2 v116
-;; @003e v118 = iconst.i64 -24
-;; @003e v119 = iadd v117, v118 ; v118 = -24
-;; @003e v120 = iconst.i64 96
-;; @003e v121 = iadd v106, v120 ; v120 = 96
-;; @003e v122 = load.i64 notrap aligned region2 v121
-;; @003e v123 = iconst.i64 -24
-;; @003e v124 = iadd v122, v123 ; v123 = -24
-;; @003e v125 = stack_addr.i64 ss1
-;; @003e v126 = load.i64 notrap aligned region4 v124
-;; @003e store notrap aligned region8 v126, v125
-;; @003e v127 = load.i64 notrap aligned region4 v119
-;; @003e store notrap aligned region4 v127, v124
-;; @003e v128 = load.i64 notrap aligned region4 v124+8
-;; @003e store notrap aligned region8 v128, v125+8
-;; @003e v129 = load.i64 notrap aligned region4 v119+8
-;; @003e store notrap aligned region4 v129, v124+8
-;; @003e v130 = load.i64 notrap aligned region4 v124+16
-;; @003e store notrap aligned region8 v130, v125+16
-;; @003e v131 = load.i64 notrap aligned region4 v119+16
-;; @003e store notrap aligned region4 v131, v124+16
-;; @003e v132 = iconst.i64 3
-;; @003e v133 = iconst.i64 32
-;; @003e v134 = ishl v132, v133 ; v132 = 3, v133 = 32
-;; @003e v135 = stack_switch v119, v125, v134
-;; @003e v136 = iconst.i64 32
-;; @003e v137 = ushr v135, v136 ; v136 = 32
-;; @003e v138 = iconst.i64 5
-;; @003e v139 = icmp eq v137, v138 ; v138 = 5
-;; @003e brif v139, block11, block12
+;; block10(v71: i64):
+;; @003e store.i128 notrap aligned region8 v70, v71
+;; @003e v97 = iconst.i64 0
+;; @003e v98 = iadd.i64 v14, v97 ; v97 = 0
+;; @003e v99 = iconst.i32 1
+;; @003e store notrap aligned region11 v99, v98+32 ; v99 = 1
+;; @003e v100 = load.i64 notrap aligned region9 v14+80
+;; @003e store.i64 notrap aligned region4 v32, v100+64
+;; @003e store.i64 notrap aligned region4 v33, v100+72
+;; @003e v101 = iconst.i64 2
+;; @003e v102 = load.i64 notrap aligned readonly can_move region0 v0+8
+;; @003e store notrap aligned region3 v101, v102+88 ; v101 = 2
+;; @003e store.i64 notrap aligned region3 v14, v102+96
+;; @003e v103 = iconst.i64 0
+;; @003e v104 = iadd v98, v103 ; v103 = 0
+;; @003e v105 = load.i64 notrap aligned region18 v104
+;; @003e store notrap aligned region1 v105, v58+24
+;; @003e v106 = load.i64 notrap aligned region15 v104+8
+;; @003e store notrap aligned region12 v106, v58+72
+;; @003e v107 = load.i64 notrap aligned region16 v104+16
+;; @003e store notrap aligned region13 v107, v58+64
+;; @003e v108 = load.i64 notrap aligned region17 v104+24
+;; @003e store notrap aligned region14 v108, v58+80
+;; @003e v109 = iconst.i64 96
+;; @003e v110 = iadd.i64 v29, v109 ; v109 = 96
+;; @003e v111 = load.i64 notrap aligned region19 v110
+;; @003e v112 = iconst.i64 -24
+;; @003e v113 = iadd v111, v112 ; v112 = -24
+;; @003e v114 = iconst.i64 96
+;; @003e v115 = iadd v100, v114 ; v114 = 96
+;; @003e v116 = load.i64 notrap aligned region19 v115
+;; @003e v117 = iconst.i64 -24
+;; @003e v118 = iadd v116, v117 ; v117 = -24
+;; @003e v119 = stack_addr.i64 ss1
+;; @003e v120 = load.i64 notrap aligned region8 v118
+;; @003e store notrap aligned region20 v120, v119
+;; @003e v121 = load.i64 notrap aligned region8 v113
+;; @003e store notrap aligned region8 v121, v118
+;; @003e v122 = load.i64 notrap aligned region8 v118+8
+;; @003e store notrap aligned region20 v122, v119+8
+;; @003e v123 = load.i64 notrap aligned region8 v113+8
+;; @003e store notrap aligned region8 v123, v118+8
+;; @003e v124 = load.i64 notrap aligned region8 v118+16
+;; @003e store notrap aligned region20 v124, v119+16
+;; @003e v125 = load.i64 notrap aligned region8 v113+16
+;; @003e store notrap aligned region8 v125, v118+16
+;; @003e v126 = iconst.i64 3
+;; @003e v127 = iconst.i64 32
+;; @003e v128 = ishl v126, v127 ; v126 = 3, v127 = 32
+;; @003e v129 = stack_switch v113, v119, v128
+;; @003e v130 = iconst.i64 32
+;; @003e v131 = ushr v129, v130 ; v130 = 32
+;; @003e v132 = iconst.i64 5
+;; @003e v133 = icmp eq v131, v132 ; v132 = 5
+;; @003e brif v133, block11, block12
;;
;; block11 cold:
-;; @003e v140 = iconst.i64 136
-;; @003e v141 = iadd.i64 v27, v140 ; v140 = 136
-;; @003e v142 = load.i64 notrap aligned region2 v141+8
-;; @003e v143 = load.i32 notrap aligned region4 v142
-;; @003e v144 = iconst.i32 0
-;; @003e store notrap aligned region2 v144, v141 ; v144 = 0
-;; @003e v145 = iconst.i32 0
-;; @003e store notrap aligned region2 v145, v141+4 ; v145 = 0
-;; @003e v146 = iconst.i64 0
-;; @003e store notrap aligned region2 v146, v141+8 ; v146 = 0
-;; @003e try_call fn2(v0, v143), sig2, block13, [ context v0 ]
+;; @003e v134 = iconst.i64 136
+;; @003e v135 = iadd.i64 v27, v134 ; v134 = 136
+;; @003e v136 = load.i64 notrap aligned region5 v135+8
+;; @003e v137 = load.i32 notrap aligned region8 v136
+;; @003e v138 = iconst.i32 0
+;; @003e store notrap aligned region7 v138, v135 ; v138 = 0
+;; @003e v139 = iconst.i32 0
+;; @003e store notrap aligned region10 v139, v135+4 ; v139 = 0
+;; @003e v140 = iconst.i64 0
+;; @003e store notrap aligned region5 v140, v135+8 ; v140 = 0
+;; @003e try_call fn2(v0, v137), sig2, block13, [ context v0 ]
;;
;; block13:
;; @003e trap user12
;;
;; block12:
-;; @003e v147 = iconst.i64 136
-;; @003e v148 = iadd.i64 v27, v147 ; v147 = 136
-;; @003e v149 = load.i64 notrap aligned region2 v148+8
-;; @003e v150 = iconst.i32 0
-;; @003e store notrap aligned region2 v150, v148 ; v150 = 0
-;; @003e v151 = iconst.i32 0
-;; @003e store notrap aligned region2 v151, v148+4 ; v151 = 0
-;; @003e v152 = iconst.i64 0
-;; @003e store notrap aligned region2 v152, v148+8 ; v152 = 0
+;; @003e v141 = iconst.i64 136
+;; @003e v142 = iadd.i64 v27, v141 ; v141 = 136
+;; @003e v143 = load.i64 notrap aligned region5 v142+8
+;; @003e v144 = iconst.i32 0
+;; @003e store notrap aligned region7 v144, v142 ; v144 = 0
+;; @003e v145 = iconst.i32 0
+;; @003e store notrap aligned region10 v145, v142+4 ; v145 = 0
+;; @003e v146 = iconst.i64 0
+;; @003e store notrap aligned region5 v146, v142+8 ; v146 = 0
;; @0041 jump block1
;;
;; block1:
@@ -294,12 +300,24 @@
;; ss0 = explicit_slot 8, align = 256
;; region0 = 8 "VMContext+0x8"
;; region1 = 67108888 "VMStoreContext+0x18"
-;; region2 = 1073741824 "VMContRef+0x0"
-;; region3 = 67108952 "VMStoreContext+0x58"
-;; region4 = 67108936 "VMStoreContext+0x48"
-;; region5 = 67108928 "VMStoreContext+0x40"
-;; region6 = 67108944 "VMStoreContext+0x50"
-;; region7 = 1140850688 "ContinuationStackMemory+0x0"
+;; region2 = 1073741912 "VMContRef+0x58"
+;; region3 = 1073741904 "VMContRef+0x50"
+;; region4 = 67108952 "VMStoreContext+0x58"
+;; region5 = 1073741888 "VMContRef+0x40"
+;; region6 = 2483028000 "VMCommonStackInformation+0x20"
+;; region7 = 67108936 "VMStoreContext+0x48"
+;; region8 = 67108928 "VMStoreContext+0x40"
+;; region9 = 67108944 "VMStoreContext+0x50"
+;; region10 = 2415919112 "VMStackLimits+0x8"
+;; region11 = 2415919120 "VMStackLimits+0x10"
+;; region12 = 2415919128 "VMStackLimits+0x18"
+;; region13 = 2415919104 "VMStackLimits+0x0"
+;; region14 = 2550136836 "VMHostArray+0x4"
+;; region15 = 2550136840 "VMHostArray+0x8"
+;; region16 = 1140850688 "ContinuationStackMemory+0x0"
+;; region17 = 2550136832 "VMHostArray+0x0"
+;; region18 = 2483028024 "VMCommonStackInformation+0x38"
+;; region19 = 1073741920 "VMContRef+0x60"
;; gv0 = vmctx
;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8
;; gv2 = load.i64 notrap aligned region1 gv1+24
@@ -340,199 +358,189 @@
;; @004b v21 = iconst.i64 1
;; @004b v22 = iadd v19, v21 ; v21 = 1
;; @004b store notrap aligned region2 v22, v14+88
-;; @004b v23 = load.i64 notrap aligned region2 v14+80
+;; @004b v23 = load.i64 notrap aligned region3 v14+80
;; @004b v24 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004b v25 = load.i64 notrap aligned region3 v24+88
-;; @004b v26 = load.i64 notrap aligned region3 v24+96
-;; @004b store notrap aligned region2 v25, v23+64
-;; @004b store notrap aligned region2 v26, v23+72
+;; @004b v25 = load.i64 notrap aligned region4 v24+88
+;; @004b v26 = load.i64 notrap aligned region4 v24+96
+;; @004b store notrap aligned region5 v25, v23+64
+;; @004b store notrap aligned region5 v26, v23+72
;; @004b v27 = iconst.i64 0
-;; @004b store notrap aligned region2 v27, v14+80 ; v27 = 0
+;; @004b store notrap aligned region3 v27, v14+80 ; v27 = 0
;; @004b v28 = iconst.i64 2
;; @004b v29 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004b store notrap aligned region3 v28, v29+88 ; v28 = 2
-;; @004b store notrap aligned region3 v14, v29+96
+;; @004b store notrap aligned region4 v28, v29+88 ; v28 = 2
+;; @004b store notrap aligned region4 v14, v29+96
;; @004b v30 = iconst.i64 0
;; @004b v31 = iadd v14, v30 ; v30 = 0
;; @004b v32 = iconst.i32 1
-;; @004b v33 = iconst.i64 32
-;; @004b v34 = iadd v31, v33 ; v33 = 32
-;; @004b store notrap aligned region2 v32, v34 ; v32 = 1
-;; @004b v35 = iconst.i32 2
-;; @004b v36 = iconst.i64 32
-;; @004b v37 = iadd v26, v36 ; v36 = 32
-;; @004b store notrap aligned region2 v35, v37 ; v35 = 2
-;; @004b v38 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004b v39 = iconst.i64 0
-;; @004b v40 = iadd v26, v39 ; v39 = 0
-;; @004b v41 = load.i64 notrap aligned region4 v38+72
-;; @004b v42 = load.i64 notrap aligned region5 v38+64
-;; @004b v43 = load.i64 notrap aligned region6 v38+80
-;; @004b store notrap aligned region2 v41, v40+8
-;; @004b store notrap aligned region2 v42, v40+16
-;; @004b store notrap aligned region2 v43, v40+24
-;; @004b v44 = load.i64 notrap aligned region1 v38+24
-;; @004b store notrap aligned region2 v44, v40
-;; @004b v45 = iconst.i64 0
-;; @004b v46 = iadd v31, v45 ; v45 = 0
-;; @004b v47 = load.i64 notrap aligned region2 v46
-;; @004b store notrap aligned region1 v47, v38+24
-;; @004b v48 = load.i64 notrap aligned region2 v46+8
-;; @004b store notrap aligned region4 v48, v38+72
-;; @004b v49 = load.i64 notrap aligned region2 v46+16
-;; @004b store notrap aligned region5 v49, v38+64
-;; @004b v50 = load.i64 notrap aligned region2 v46+24
-;; @004b store notrap aligned region6 v50, v38+80
-;; @004b v51 = iconst.i64 40
-;; @004b v52 = iadd v26, v51 ; v51 = 40
+;; @004b store notrap aligned region6 v32, v31+32 ; v32 = 1
+;; @004b v33 = iconst.i32 2
+;; @004b store notrap aligned region6 v33, v26+32 ; v33 = 2
+;; @004b v34 = load.i64 notrap aligned readonly can_move region0 v0+8
+;; @004b v35 = iconst.i64 0
+;; @004b v36 = iadd v26, v35 ; v35 = 0
+;; @004b v37 = load.i64 notrap aligned region7 v34+72
+;; @004b v38 = load.i64 notrap aligned region8 v34+64
+;; @004b v39 = load.i64 notrap aligned region9 v34+80
+;; @004b store notrap aligned region10 v37, v36+8
+;; @004b store notrap aligned region11 v38, v36+16
+;; @004b store notrap aligned region12 v39, v36+24
+;; @004b v40 = load.i64 notrap aligned region1 v34+24
+;; @004b store notrap aligned region13 v40, v36
+;; @004b v41 = iconst.i64 0
+;; @004b v42 = iadd v31, v41 ; v41 = 0
+;; @004b v43 = load.i64 notrap aligned region13 v42
+;; @004b store notrap aligned region1 v43, v34+24
+;; @004b v44 = load.i64 notrap aligned region10 v42+8
+;; @004b store notrap aligned region7 v44, v34+72
+;; @004b v45 = load.i64 notrap aligned region11 v42+16
+;; @004b store notrap aligned region8 v45, v34+64
+;; @004b v46 = load.i64 notrap aligned region12 v42+24
+;; @004b store notrap aligned region9 v46, v34+80
+;; @004b v47 = iconst.i64 40
+;; @004b v48 = iadd v26, v47 ; v47 = 40
+;; @004b v49 = iconst.i32 1
+;; @004b v50 = stack_addr.i64 ss0
+;; @004b store notrap aligned region14 v49, v48+4 ; v49 = 1
+;; @004b store notrap aligned region15 v50, v48+8
+;; @004b v51 = iconst.i64 48
+;; @004b v52 = iadd.i64 v0, v51 ; v51 = 48
;; @004b v53 = iconst.i32 1
-;; @004b v54 = stack_addr.i64 ss0
-;; @004b store notrap aligned region2 v53, v52+4 ; v53 = 1
-;; @004b store notrap aligned region2 v54, v52+8
-;; @004b v55 = iconst.i64 48
-;; @004b v56 = iadd.i64 v0, v55 ; v55 = 48
-;; @004b v57 = iconst.i32 1
-;; @004b v58 = load.i64 notrap aligned region2 v52+8
-;; @004b store notrap aligned region7 v56, v58
-;; @004b store notrap aligned region2 v57, v52 ; v57 = 1
-;; @004b v59 = iconst.i32 0
-;; @004b store notrap aligned region2 v59, v26+56 ; v59 = 0
-;; @004b v60 = iconst.i64 1
-;; @004b v61 = iconst.i64 32
-;; @004b v62 = ishl v60, v61 ; v60 = 1, v61 = 32
-;; @004b v63 = iconst.i64 96
-;; @004b v64 = iadd v23, v63 ; v63 = 96
-;; @004b v65 = load.i64 notrap aligned region2 v64
-;; @004b v66 = iconst.i64 -24
-;; @004b v67 = iadd v65, v66 ; v66 = -24
-;; @004b v68 = stack_switch v67, v67, v62
-;; @004b v69 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004b v70 = load.i64 notrap aligned region3 v69+88
-;; @004b v71 = load.i64 notrap aligned region3 v69+96
-;; @004b v72 = load.i64 notrap aligned readonly can_move region0 v0+8
-;; @004b store notrap aligned region3 v25, v72+88
-;; @004b store notrap aligned region3 v26, v72+96
-;; @004b v73 = iconst.i32 1
-;; @004b v74 = iconst.i64 32
-;; @004b v75 = iadd v26, v74 ; v74 = 32
-;; @004b store notrap aligned region2 v73, v75 ; v73 = 1
-;; @004b v76 = iconst.i32 0
-;; @004b store notrap aligned region2 v76, v52 ; v76 = 0
-;; @004b v77 = iconst.i32 0
-;; @004b store notrap aligned region2 v77, v52+4 ; v77 = 0
-;; @004b v78 = iconst.i64 0
-;; @004b store notrap aligned region2 v78, v52+8 ; v78 = 0
-;; @004b store notrap aligned region2 v27, v26+56 ; v27 = 0
-;; @004b brif v68, block6, block3
+;; @004b v54 = load.i64 notrap aligned region15 v48+8
+;; @004b store notrap aligned region16 v52, v54
+;; @004b store notrap aligned region17 v53, v48 ; v53 = 1
+;; @004b v55 = iconst.i32 0
+;; @004b store notrap aligned region18 v55, v26+56 ; v55 = 0
+;; @004b v56 = iconst.i64 1
+;; @004b v57 = iconst.i64 32
+;; @004b v58 = ishl v56, v57 ; v56 = 1, v57 = 32
+;; @004b v59 = iconst.i64 96
+;; @004b v60 = iadd v23, v59 ; v59 = 96
+;; @004b v61 = load.i64 notrap aligned region19 v60
+;; @004b v62 = iconst.i64 -24
+;; @004b v63 = iadd v61, v62 ; v62 = -24
+;; @004b v64 = stack_switch v63, v63, v58
+;; @004b v65 = load.i64 notrap aligned readonly can_move region0 v0+8
+;; @004b v66 = load.i64 notrap aligned region4 v65+88
+;; @004b v67 = load.i64 notrap aligned region4 v65+96
+;; @004b v68 = load.i64 notrap aligned readonly can_move region0 v0+8
+;; @004b store notrap aligned region4 v25, v68+88
+;; @004b store notrap aligned region4 v26, v68+96
+;; @004b v69 = iconst.i32 1
+;; @004b store notrap aligned region6 v69, v26+32 ; v69 = 1
+;; @004b v70 = iconst.i32 0
+;; @004b store notrap aligned region17 v70, v48 ; v70 = 0
+;; @004b v71 = iconst.i32 0
+;; @004b store notrap aligned region14 v71, v48+4 ; v71 = 0
+;; @004b v72 = iconst.i64 0
+;; @004b store notrap aligned region15 v72, v48+8 ; v72 = 0
+;; @004b store notrap aligned region18 v27, v26+56 ; v27 = 0
+;; @004b brif v64, block6, block3
;;
;; block6:
-;; @004b v79 = iconst.i64 32
-;; @004b v80 = ushr.i64 v68, v79 ; v79 = 32
-;; @004b v81 = iconst.i64 4
-;; @004b v82 = icmp eq v80, v81 ; v81 = 4
-;; @004b brif v82, block5, block4
+;; @004b v73 = iconst.i64 32
+;; @004b v74 = ushr.i64 v64, v73 ; v73 = 32
+;; @004b v75 = iconst.i64 4
+;; @004b v76 = icmp eq v74, v75 ; v75 = 4
+;; @004b brif v76, block5, block4
;;
;; block5 cold:
-;; @004b v83 = iconst.i64 0
-;; @004b v84 = iadd.i64 v71, v83 ; v83 = 0
-;; @004b v85 = iconst.i32 5
-;; @004b v86 = iconst.i64 32
-;; @004b v87 = iadd v84, v86 ; v86 = 32
-;; @004b store notrap aligned region2 v85, v87 ; v85 = 5
-;; @004b v88 = iconst.i64 0
-;; @004b v89 = iadd.i64 v26, v88 ; v88 = 0
-;; @004b v90 = load.i64 notrap aligned region2 v89
-;; @004b store notrap aligned region1 v90, v38+24
-;; @004b v91 = load.i64 notrap aligned region2 v89+8
-;; @004b store notrap aligned region4 v91, v38+72
-;; @004b v92 = load.i64 notrap aligned region2 v89+16
-;; @004b store notrap aligned region5 v92, v38+64
-;; @004b v93 = load.i64 notrap aligned region2 v89+24
-;; @004b store notrap aligned region6 v93, v38+80
-;; @004b v94 = iconst.i64 120
-;; @004b v95 = iadd.i64 v71, v94 ; v94 = 120
-;; @004b v96 = iconst.i32 0
-;; @004b store notrap aligned region2 v96, v95 ; v96 = 0
-;; @004b v97 = iconst.i32 0
-;; @004b store notrap aligned region2 v97, v95+4 ; v97 = 0
-;; @004b v98 = iconst.i64 0
-;; @004b store notrap aligned region2 v98, v95+8 ; v98 = 0
-;; @004b v99 = iconst.i64 136
-;; @004b v100 = iadd.i64 v71, v99 ; v99 = 136
-;; @004b v101 = iconst.i32 0
-;; @004b store notrap aligned region2 v101, v100 ; v101 = 0
-;; @004b v102 = iconst.i32 0
-;; @004b store notrap aligned region2 v102, v100+4 ; v102 = 0
-;; @004b v103 = iconst.i64 0
-;; @004b store notrap aligned region2 v103, v100+8 ; v103 = 0
+;; @004b v77 = iconst.i64 0
+;; @004b v78 = iadd.i64 v67, v77 ; v77 = 0
+;; @004b v79 = iconst.i32 5
+;; @004b store notrap aligned region6 v79, v78+32 ; v79 = 5
+;; @004b v80 = iconst.i64 0
+;; @004b v81 = iadd.i64 v26, v80 ; v80 = 0
+;; @004b v82 = load.i64 notrap aligned region13 v81
+;; @004b store notrap aligned region1 v82, v34+24
+;; @004b v83 = load.i64 notrap aligned region10 v81+8
+;; @004b store notrap aligned region7 v83, v34+72
+;; @004b v84 = load.i64 notrap aligned region11 v81+16
+;; @004b store notrap aligned region8 v84, v34+64
+;; @004b v85 = load.i64 notrap aligned region12 v81+24
+;; @004b store notrap aligned region9 v85, v34+80
+;; @004b v86 = iconst.i64 120
+;; @004b v87 = iadd.i64 v67, v86 ; v86 = 120
+;; @004b v88 = iconst.i32 0
+;; @004b store notrap aligned region17 v88, v87 ; v88 = 0
+;; @004b v89 = iconst.i32 0
+;; @004b store notrap aligned region14 v89, v87+4 ; v89 = 0
+;; @004b v90 = iconst.i64 0
+;; @004b store notrap aligned region15 v90, v87+8 ; v90 = 0
+;; @004b v91 = iconst.i64 136
+;; @004b v92 = iadd.i64 v67, v91 ; v91 = 136
+;; @004b v93 = iconst.i32 0
+;; @004b store notrap aligned region17 v93, v92 ; v93 = 0
+;; @004b v94 = iconst.i32 0
+;; @004b store notrap aligned region14 v94, v92+4 ; v94 = 0
+;; @004b v95 = iconst.i64 0
+;; @004b store notrap aligned region15 v95, v92+8 ; v95 = 0
;; @004b try_call fn2(v0), sig2, block8, [ context v0 ]
;;
;; block8:
;; @004b trap user12
;;
;; block4:
-;; @004b v104 = iconst.i64 0
-;; @004b v105 = iadd.i64 v71, v104 ; v104 = 0
-;; @004b v106 = iconst.i64 0
-;; @004b v107 = iadd v105, v106 ; v106 = 0
-;; @004b v108 = load.i64 notrap aligned region4 v38+72
-;; @004b v109 = load.i64 notrap aligned region5 v38+64
-;; @004b v110 = load.i64 notrap aligned region6 v38+80
-;; @004b store notrap aligned region2 v108, v107+8
-;; @004b store notrap aligned region2 v109, v107+16
-;; @004b store notrap aligned region2 v110, v107+24
-;; @004b v111 = iconst.i64 0
-;; @004b v112 = iadd.i64 v26, v111 ; v111 = 0
-;; @004b v113 = load.i64 notrap aligned region2 v112
-;; @004b store notrap aligned region1 v113, v38+24
-;; @004b v114 = load.i64 notrap aligned region2 v112+8
-;; @004b store notrap aligned region4 v114, v38+72
-;; @004b v115 = load.i64 notrap aligned region2 v112+16
-;; @004b store notrap aligned region5 v115, v38+64
-;; @004b v116 = load.i64 notrap aligned region2 v112+24
-;; @004b store notrap aligned region6 v116, v38+80
-;; @004b v117 = ireduce.i32 v68
-;; @004b v118 = load.i64 notrap aligned region2 v71+88
-;; @004b v119 = uextend.i128 v71
-;; @004b v120 = uextend.i128 v118
-;; @004b v121 = iconst.i64 64
-;; @004b v122 = uextend.i128 v121 ; v121 = 64
-;; @004b v123 = ishl v120, v122
-;; @004b v124 = bor v123, v119
+;; @004b v96 = iconst.i64 0
+;; @004b v97 = iadd.i64 v67, v96 ; v96 = 0
+;; @004b v98 = iconst.i64 0
+;; @004b v99 = iadd v97, v98 ; v98 = 0
+;; @004b v100 = load.i64 notrap aligned region7 v34+72
+;; @004b v101 = load.i64 notrap aligned region8 v34+64
+;; @004b v102 = load.i64 notrap aligned region9 v34+80
+;; @004b store notrap aligned region10 v100, v99+8
+;; @004b store notrap aligned region11 v101, v99+16
+;; @004b store notrap aligned region12 v102, v99+24
+;; @004b v103 = iconst.i64 0
+;; @004b v104 = iadd.i64 v26, v103 ; v103 = 0
+;; @004b v105 = load.i64 notrap aligned region13 v104
+;; @004b store notrap aligned region1 v105, v34+24
+;; @004b v106 = load.i64 notrap aligned region10 v104+8
+;; @004b store notrap aligned region7 v106, v34+72
+;; @004b v107 = load.i64 notrap aligned region11 v104+16
+;; @004b store notrap aligned region8 v107, v34+64
+;; @004b v108 = load.i64 notrap aligned region12 v104+24
+;; @004b store notrap aligned region9 v108, v34+80
+;; @004b v109 = ireduce.i32 v64
+;; @004b v110 = load.i64 notrap aligned region2 v67+88
+;; @004b v111 = uextend.i128 v67
+;; @004b v112 = uextend.i128 v110
+;; @004b v113 = iconst.i64 64
+;; @004b v114 = uextend.i128 v113 ; v113 = 64
+;; @004b v115 = ishl v112, v114
+;; @004b v116 = bor v115, v111
;; @004b jump block7
;;
;; block9 cold:
;; @004b trap user12
;;
;; block7:
-;; @004b br_table v117, block9, []
+;; @004b br_table v109, block9, []
;;
;; block3:
-;; @004b v125 = iconst.i64 0
-;; @004b v126 = iadd.i64 v26, v125 ; v125 = 0
-;; @004b v127 = load.i64 notrap aligned region2 v126
-;; @004b store notrap aligned region1 v127, v38+24
-;; @004b v128 = load.i64 notrap aligned region2 v126+8
-;; @004b store notrap aligned region4 v128, v38+72
-;; @004b v129 = load.i64 notrap aligned region2 v126+16
-;; @004b store notrap aligned region5 v129, v38+64
-;; @004b v130 = load.i64 notrap aligned region2 v126+24
-;; @004b store notrap aligned region6 v130, v38+80
+;; @004b v117 = iconst.i64 0
+;; @004b v118 = iadd.i64 v26, v117 ; v117 = 0
+;; @004b v119 = load.i64 notrap aligned region13 v118
+;; @004b store notrap aligned region1 v119, v34+24
+;; @004b v120 = load.i64 notrap aligned region10 v118+8
+;; @004b store notrap aligned region7 v120, v34+72
+;; @004b v121 = load.i64 notrap aligned region11 v118+16
+;; @004b store notrap aligned region8 v121, v34+64
+;; @004b v122 = load.i64 notrap aligned region12 v118+24
+;; @004b store notrap aligned region9 v122, v34+80
+;; @004b v123 = iconst.i64 0
+;; @004b v124 = iadd.i64 v67, v123 ; v123 = 0
+;; @004b v125 = iconst.i32 4
+;; @004b store notrap aligned region6 v125, v124+32 ; v125 = 4
+;; @004b v126 = iconst.i64 120
+;; @004b v127 = iadd.i64 v67, v126 ; v126 = 120
+;; @004b v128 = load.i64 notrap aligned region15 v127+8
+;; @004b v129 = iconst.i32 0
+;; @004b store notrap aligned region17 v129, v127 ; v129 = 0
+;; @004b v130 = iconst.i32 0
+;; @004b store notrap aligned region14 v130, v127+4 ; v130 = 0
;; @004b v131 = iconst.i64 0
-;; @004b v132 = iadd.i64 v71, v131 ; v131 = 0
-;; @004b v133 = iconst.i32 4
-;; @004b v134 = iconst.i64 32
-;; @004b v135 = iadd v132, v134 ; v134 = 32
-;; @004b store notrap aligned region2 v133, v135 ; v133 = 4
-;; @004b v136 = iconst.i64 120
-;; @004b v137 = iadd.i64 v71, v136 ; v136 = 120
-;; @004b v138 = load.i64 notrap aligned region2 v137+8
-;; @004b v139 = iconst.i32 0
-;; @004b store notrap aligned region2 v139, v137 ; v139 = 0
-;; @004b v140 = iconst.i32 0
-;; @004b store notrap aligned region2 v140, v137+4 ; v140 = 0
-;; @004b v141 = iconst.i64 0
-;; @004b store notrap aligned region2 v141, v137+8 ; v141 = 0
+;; @004b store notrap aligned region15 v131, v127+8 ; v131 = 0
;; @0050 jump block1
;;
;; block1: