Skip to content

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

Optimize `array.fill` and `array.copy` (#13382)

Alex Crichton2b7c8549912a
diff --git a/crates/cranelift/src/func_environ.rs b/crates/cranelift/src/func_environ.rs
index 259dc8d34d..ea6bbf7039 100644
--- a/crates/cranelift/src/func_environ.rs
+++ b/crates/cranelift/src/func_environ.rs
@@ -35,7 +35,7 @@ use wasmtime_environ::{
};
use wasmtime_environ::{FUNCREF_INIT_BIT, FUNCREF_MASK};
-#[derive(Debug)]
+#[derive(Copy, Clone, Debug)]
pub(crate) enum Extension {
Sign,
Zero,
@@ -583,6 +583,25 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
builder.switch_to_block(continuation_block);
}
+ /// Manually insert a fuel check, as opposed to what already happens around
+ /// normal loops headers and function entries.
+ ///
+ /// This can be used for expensive opcodes, such as `array.copy`, where the
+ /// operation's runtime is a function of the runtime state.
+ #[cfg(feature = "gc")]
+ fn manual_fuel_check(&mut self, builder: &mut FunctionBuilder<'_>, fuel_to_consume: ir::Value) {
+ if !self.tunables.consume_fuel {
+ return;
+ }
+ self.fuel_increment_var(builder);
+
+ let fuel = builder.use_var(self.fuel_var);
+ let fuel = builder.ins().iadd(fuel, fuel_to_consume);
+ builder.def_var(self.fuel_var, fuel);
+
+ self.fuel_check(builder);
+ }
+
fn epoch_function_entry(&mut self, builder: &mut FunctionBuilder<'_>) {
debug_assert!(self.epoch_deadline_var.is_reserved_value());
self.epoch_deadline_var = builder.declare_var(ir::types::I64);
@@ -2824,44 +2843,22 @@ impl FuncEnvironment<'_> {
dst_array_type_index: TypeIndex,
dst_array: ir::Value,
dst_index: ir::Value,
- _src_array_type_index: TypeIndex,
+ src_array_type_index: TypeIndex,
src_array: ir::Value,
src_index: ir::Value,
len: ir::Value,
) -> WasmResult<()> {
- let interned_type_index =
- self.module.types[dst_array_type_index].unwrap_module_type_index();
- let array_ty = self.types.unwrap_array(interned_type_index)?;
- let elem_ty = array_ty.0.element_type;
-
- let vmctx = self.vmctx_val(&mut builder.cursor());
-
- if elem_ty.is_vmgcref_type_and_not_i31() {
- let libcall = gc::builtins::array_copy_gc_ref_elems(self, builder.func)?;
- builder.ins().call(
- libcall,
- &[vmctx, dst_array, dst_index, src_array, src_index, len],
- );
- } else {
- let libcall = gc::builtins::array_copy_non_gc_ref_elems(self, builder.func)?;
- let interned_type_index = builder
- .ins()
- .iconst(I32, i64::from(interned_type_index.as_u32()));
- builder.ins().call(
- libcall,
- &[
- vmctx,
- interned_type_index,
- dst_array,
- dst_index,
- src_array,
- src_index,
- len,
- ],
- );
- }
-
- Ok(())
+ gc::translate_array_copy(
+ self,
+ builder,
+ dst_array_type_index,
+ dst_array,
+ dst_index,
+ src_array_type_index,
+ src_array,
+ src_index,
+ len,
+ )
}
pub fn translate_array_fill(
diff --git a/crates/cranelift/src/func_environ/gc.rs b/crates/cranelift/src/func_environ/gc.rs
index f1079a2fbd..a445699d5a 100644
--- a/crates/cranelift/src/func_environ/gc.rs
+++ b/crates/cranelift/src/func_environ/gc.rs
@@ -210,8 +210,6 @@ pub mod builtins {
table_fill_gc_ref,
array_new_data,
array_new_elem,
- array_copy_gc_ref_elems,
- array_copy_non_gc_ref_elems,
array_init_data,
array_init_elem,
}
diff --git a/crates/cranelift/src/func_environ/gc/disabled.rs b/crates/cranelift/src/func_environ/gc/disabled.rs
index 13c41f27a1..8ae38e4faf 100644
--- a/crates/cranelift/src/func_environ/gc/disabled.rs
+++ b/crates/cranelift/src/func_environ/gc/disabled.rs
@@ -163,3 +163,17 @@ pub fn translate_ref_test(
) -> WasmResult<ir::Value> {
disabled()
}
+
+pub fn translate_array_copy(
+ _func_env: &mut FuncEnvironment<'_>,
+ _builder: &mut FunctionBuilder<'_>,
+ _dst_array_type_index: TypeIndex,
+ _dst_array: ir::Value,
+ _dst_index: ir::Value,
+ _src_array_type_index: TypeIndex,
+ _src_array: ir::Value,
+ _src_index: ir::Value,
+ _len: ir::Value,
+) -> WasmResult<()> {
+ disabled()
+}
diff --git a/crates/cranelift/src/func_environ/gc/enabled.rs b/crates/cranelift/src/func_environ/gc/enabled.rs
index 24dd6c3bb9..26a56feb34 100644
--- a/crates/cranelift/src/func_environ/gc/enabled.rs
+++ b/crates/cranelift/src/func_environ/gc/enabled.rs
@@ -747,10 +747,12 @@ impl ArrayInit<'_> {
emit_array_fill_impl(
func_env,
builder,
+ elem_ty,
elems_addr,
elem_size,
elems_end,
- |func_env, builder, elem_addr| {
+ elem,
+ |func_env, builder, elem_addr, elem| {
init_field(func_env, builder, elem_ty, elem_addr, elem)
},
)?;
@@ -764,13 +766,16 @@ impl ArrayInit<'_> {
fn emit_array_fill_impl(
func_env: &mut FuncEnvironment<'_>,
builder: &mut FunctionBuilder<'_>,
+ elem_ty: WasmStorageType,
elem_addr: ir::Value,
elem_size: ir::Value,
fill_end: ir::Value,
+ value: ir::Value,
mut emit_elem_write: impl FnMut(
&mut FuncEnvironment<'_>,
&mut FunctionBuilder<'_>,
ir::Value,
+ ir::Value,
) -> WasmResult<()>,
) -> WasmResult<()> {
log::trace!(
@@ -783,6 +788,43 @@ fn emit_array_fill_impl(
assert_eq!(builder.func.dfg.value_type(elem_size), pointer_ty);
assert_eq!(builder.func.dfg.value_type(fill_end), pointer_ty);
+ // If this is a byte array then specialize its fill to use the same libcall
+ // as `memory.fill`. This gets us to `memset` on the host which for larger
+ // arrays can be a big boost due to the vectorized implementation. Note
+ // though that this explicitly checks to make sure that the final address
+ // being written is in-bounds in the GC heap to detect corruption and traps
+ // here in-wasm. Once we're in the host GC heap corruption can't be caught,
+ // so it needs to be an up-front check here.
+ if let Some(value) = array_fill_value_as_memset(builder, elem_ty, value) {
+ let base = func_env.get_gc_heap_base(builder);
+ let bound = func_env.get_gc_heap_bound(builder);
+ let heap_end = builder.ins().iadd(base, bound);
+ let corrupt = builder
+ .ins()
+ .icmp(IntCC::UnsignedGreaterThan, fill_end, heap_end);
+ func_env.trapnz(builder, corrupt, TRAP_GC_HEAP_CORRUPT);
+
+ let memory_fill = func_env.builtin_functions.memory_fill(&mut builder.func);
+ let mut pos = builder.cursor();
+ let vmctx = func_env.vmctx_val(&mut pos);
+ let len = builder.ins().isub(fill_end, elem_addr);
+
+ // Manually consume fuel for this operation because arrays can be large.
+ // This is a noop if fuel is disabled. Note that fuel is always a 64-bit
+ // counter.
+ let fuel_consumed = match func_env.pointer_type() {
+ ir::types::I32 => builder.ins().uextend(ir::types::I64, len),
+ ir::types::I64 => len,
+ _ => unreachable!(),
+ };
+ func_env.manual_fuel_check(builder, fuel_consumed);
+
+ builder
+ .ins()
+ .call(memory_fill, &[vmctx, elem_addr, value, len]);
+ return Ok(());
+ }
+
// Loop to fill the elements, emitting the equivalent of the following
// pseudo-CLIF:
//
@@ -832,7 +874,7 @@ fn emit_array_fill_impl(
// element's address, and then jump back to the loop header block.
builder.switch_to_block(loop_body_block);
log::trace!("emit_array_fill_impl: loop body");
- emit_elem_write(func_env, builder, elem_addr)?;
+ emit_elem_write(func_env, builder, elem_addr, value)?;
let next_elem_addr = builder.ins().iadd(elem_addr, elem_size);
builder
.ins()
@@ -847,6 +889,280 @@ fn emit_array_fill_impl(
Ok(())
}
+/// Tests to seew hether `value`, stored as `ty`, can be extracted to a single
+/// byte which can be passed to `memset`, or the host's `memory.fill`, to
+/// satisfy this array initialization request.
+fn array_fill_value_as_memset(
+ builder: &mut FunctionBuilder<'_>,
+ ty: WasmStorageType,
+ value: ir::Value,
+) -> Option<ir::Value> {
+ // If the storage type is `i8`, then no matter the value we can always use
+ // `memset` regardless of the upper bits.
+ let value_ty = builder.func.dfg.value_type(value);
+ if let WasmStorageType::I8 = ty {
+ assert_eq!(value_ty, ir::types::I32);
+ return Some(value);
+ }
+
+ // Otherwise check to see if `value` is a constant whose value we can
+ // inspect here.
+ let inst = builder.func.dfg.value_def(value).inst()?;
+ let bits = match builder.func.dfg.insts[inst] {
+ ir::InstructionData::UnaryImm {
+ opcode: ir::Opcode::Iconst,
+ imm,
+ } => imm.bits(),
+ ir::InstructionData::UnaryIeee32 {
+ opcode: ir::Opcode::F32const,
+ imm,
+ } => i64::from(imm.bits()),
+ ir::InstructionData::UnaryIeee64 {
+ opcode: ir::Opcode::F64const,
+ imm,
+ } => imm.bits().cast_signed(),
+
+ // For other initialization we don't know what the value is, so we
+ // can't check if a byte-set is valid, so bail out which will fall back
+ // to an element-by-element loop.
+ _ => return None,
+ };
+
+ let width = match ty {
+ // Handled above
+ WasmStorageType::I8 => unreachable!(),
+ // These are initialized with CLIF-level `i32` values, but we only want
+ // to check the lower 2 bytes.
+ WasmStorageType::I16 => 2,
+ // For everything else the natural CLIF value is what's written so
+ // that's the byte width to check.
+ WasmStorageType::Val(_) => value_ty.bytes() as usize,
+ };
+ let bytes = bits.to_le_bytes();
+ if bytes[1..width].iter().any(|b| *b != bytes[0]) {
+ return None;
+ }
+ Some(builder.ins().iconst(ir::types::I32, bits & 0xff))
+}
+
+pub fn translate_array_copy(
+ func_env: &mut FuncEnvironment<'_>,
+ builder: &mut FunctionBuilder<'_>,
+ dst_array_type_index: TypeIndex,
+ dst_array: ir::Value,
+ dst_index: ir::Value,
+ _src_array_type_index: TypeIndex,
+ src_array: ir::Value,
+ src_index: ir::Value,
+ copy_len: ir::Value,
+) -> WasmResult<()> {
+ let interned_type_index =
+ func_env.module.types[dst_array_type_index].unwrap_module_type_index();
+ let array_ty = func_env.types[interned_type_index]
+ .composite_type
+ .inner
+ .unwrap_array();
+ let elem_ty = array_ty.0.element_type;
+
+ // Helper closure to return `(start,end)` as the native-memory-address
+ // bounds of the copy that is being done.
+ let mut array_bounds = |array: ir::Value, index: ir::Value| -> WasmResult<_> {
+ let array_len = translate_array_len(func_env, builder, array)?;
+
+ // Check that the full range of elements we want to write is in bounds.
+ let end_index =
+ func_env.uadd_overflow_trap(builder, index, copy_len, crate::TRAP_ARRAY_OUT_OF_BOUNDS);
+ let out_of_bounds = builder
+ .ins()
+ .icmp(IntCC::UnsignedGreaterThan, end_index, array_len);
+ func_env.trapnz(builder, out_of_bounds, crate::TRAP_ARRAY_OUT_OF_BOUNDS);
+
+ // Calculate the address of the first element in the array.
+ let ArraySizeInfo {
+ obj_size,
+ one_elem_size,
+ base_size,
+ } = emit_array_size_info(func_env, builder, interned_type_index, array_len);
+ let offset_in_elems = builder.ins().imul(index, one_elem_size);
+ let obj_offset = builder.ins().iadd(base_size, offset_in_elems);
+ let elem_addr = func_env.prepare_gc_ref_access(
+ builder,
+ array,
+ BoundsCheck::DynamicObjectField {
+ offset: obj_offset,
+ object_size: obj_size,
+ },
+ );
+
+ Ok((elem_addr, one_elem_size))
+ };
+
+ // Calculate the heap-start address of both copies. This'll ensure
+ // everything is in-bounds as well.
+ let (src_elem_addr, one_elem_size) = array_bounds(src_array, src_index)?;
+ let (dst_elem_addr, _one_elem_size) = array_bounds(dst_array, dst_index)?;
+
+ // Also calculate the heap-end address of both copies. Note that with
+ // everything being in-bounds this multiplication won't overflow.
+ let copy_byte_size = builder.ins().imul(copy_len, one_elem_size);
+ let copy_byte_size =
+ uextend_i32_to_pointer_type(builder, func_env.pointer_type(), copy_byte_size);
+ let src_end_addr = builder.ins().iadd(src_elem_addr, copy_byte_size);
+ let dst_end_addr = builder.ins().iadd(dst_elem_addr, copy_byte_size);
+
+ // If the element of this array isn't a GC reference, or if it's an i31ref,
+ // then there's no need for the barrier-using loops below. Instead use the
+ // `memory.copy` intrinsic to do a raw `memcpy` from one array to another.
+ //
+ // Note that like `memory.fill` this is preceded with a defensive check
+ // against heap corruption to ensure that, even in the face of heap
+ // corruption, the `memory.copy` call on the host should not ever fault.
+ if !elem_ty.is_vmgcref_type_and_not_i31() {
+ let base = func_env.get_gc_heap_base(builder);
+ let bound = func_env.get_gc_heap_bound(builder);
+ let heap_end = builder.ins().iadd(base, bound);
+ let corrupt = builder
+ .ins()
+ .icmp(IntCC::UnsignedGreaterThan, src_end_addr, heap_end);
+ func_env.trapnz(builder, corrupt, TRAP_GC_HEAP_CORRUPT);
+ let corrupt = builder
+ .ins()
+ .icmp(IntCC::UnsignedGreaterThan, dst_end_addr, heap_end);
+ func_env.trapnz(builder, corrupt, TRAP_GC_HEAP_CORRUPT);
+
+ let memory_copy = func_env.builtin_functions.memory_copy(&mut builder.func);
+ let mut pos = builder.cursor();
+ let vmctx = func_env.vmctx_val(&mut pos);
+
+ // Manually consume fuel for this operation because arrays can be large.
+ // This is a noop if fuel is disabled.
+ func_env.manual_fuel_check(builder, copy_byte_size);
+
+ builder.ins().call(
+ memory_copy,
+ &[vmctx, dst_elem_addr, src_elem_addr, copy_byte_size],
+ );
+ return Ok(());
+ }
+
+ // For GC references, inline the copy loop here with barriers. This is
+ // either a forwards copy or a backwards copy depending on the src/dst
+ // pointers. The loop here looks like:
+ //
+ // current_block:
+ // ...
+ // brif len, nonempty_block, done_block
+ //
+ // nonempty_block:
+ // forward = icmp ult dst_elem_addr, src_elem_addr
+ // brif forward,
+ // forward_block(dst_elem_addr, src_elem_addr),
+ // backwards_block(dst_end_addr, src_end_addr)
+ //
+ // forward_block(dst, src):
+ // *dst = *src
+ // dst += elem_size
+ // src += elem_size
+ // done = icmp eq src, src_end_addr
+ // brif done, done_block, forward_block(dst, src)
+ //
+ // backwards_block(dst, src):
+ // dst -= elem_size
+ // src -= elem_size
+ // *dst = *src
+ // done = icmp eq src, src_elem_addr
+ // brif done, done_block, backwards_block(dst, src)
+ //
+ // done_block:
+ // ...
+ let current_block = builder.current_block().unwrap();
+ let nonempty_block = builder.create_block();
+ let forward_block = builder.create_block();
+ let backwards_block = builder.create_block();
+ let done_block = builder.create_block();
+
+ builder.ensure_inserted_block();
+ builder.insert_block_after(nonempty_block, current_block);
+ builder.insert_block_after(forward_block, nonempty_block);
+ builder.insert_block_after(backwards_block, forward_block);
+ builder.insert_block_after(done_block, backwards_block);
+
+ let ext = match elem_ty {
+ WasmStorageType::I8 => Some(Extension::Zero),
+ WasmStorageType::I16 => Some(Extension::Zero),
+ _ => None,
+ };
+
+ // Terminate `current_block` by testing to see if we're copying any
+ // elements at all.
+ builder
+ .ins()
+ .brif(copy_len, nonempty_block, &[], done_block, &[]);
+
+ // In the nonempty_block test to see if this is a forward or backwards
+ // copy.
+ builder.switch_to_block(nonempty_block);
+ let one_elem_size =
+ uextend_i32_to_pointer_type(builder, func_env.pointer_type(), one_elem_size);
+ let dst_first = builder
+ .ins()
+ .icmp(IntCC::UnsignedLessThan, dst_elem_addr, src_elem_addr);
+ builder.ins().brif(
+ dst_first,
+ forward_block,
+ &[dst_elem_addr.into(), src_elem_addr.into()],
+ backwards_block,
+ &[dst_end_addr.into(), src_end_addr.into()],
+ );
+
+ // Forward copy -- copy one field, then mutate the current pointers, then
+ // check to see if we're done.
+ builder.switch_to_block(forward_block);
+ func_env.translate_loop_header(builder)?;
+ let dst_cur = builder.append_block_param(forward_block, func_env.pointer_type());
+ let src_cur = builder.append_block_param(forward_block, func_env.pointer_type());
+ let value = read_field_at_addr(func_env, builder, elem_ty, src_cur, ext)?;
+ write_field_at_addr(func_env, builder, elem_ty, dst_cur, value)?;
+ let dst_next = builder.ins().iadd(dst_cur, one_elem_size);
+ let src_next = builder.ins().iadd(src_cur, one_elem_size);
+ let done = builder.ins().icmp(IntCC::Equal, src_next, src_end_addr);
+ builder.ins().brif(
+ done,
+ done_block,
+ &[],
+ forward_block,
+ &[dst_next.into(), src_next.into()],
+ );
+
+ // Backwards copy -- update the pointers, then perform a copy, then check
+ // to see if we're done.
+ builder.switch_to_block(backwards_block);
+ func_env.translate_loop_header(builder)?;
+ let dst_cur = builder.append_block_param(backwards_block, func_env.pointer_type());
+ let src_cur = builder.append_block_param(backwards_block, func_env.pointer_type());
+ let dst_cur = builder.ins().isub(dst_cur, one_elem_size);
+ let src_cur = builder.ins().isub(src_cur, one_elem_size);
+ let value = read_field_at_addr(func_env, builder, elem_ty, src_cur, ext)?;
+ write_field_at_addr(func_env, builder, elem_ty, dst_cur, value)?;
+ let done = builder.ins().icmp(IntCC::Equal, src_cur, src_elem_addr);
+ builder.ins().brif(
+ done,
+ done_block,
+ &[],
+ backwards_block,
+ &[dst_cur.into(), src_cur.into()],
+ );
+
+ builder.switch_to_block(done_block);
+
+ builder.seal_block(nonempty_block);
+ builder.seal_block(forward_block);
+ builder.seal_block(backwards_block);
+ builder.seal_block(done_block);
+
+ Ok(())
+}
+
pub fn translate_array_fill(
func_env: &mut FuncEnvironment<'_>,
builder: &mut FunctionBuilder<'_>,
@@ -871,6 +1187,8 @@ pub fn translate_array_fill(
// Get the address of the first element we want to fill.
let interned_type_index = func_env.module.types[array_type_index].unwrap_module_type_index();
+ let array_ty = func_env.types.unwrap_array(interned_type_index)?;
+ let elem_ty = array_ty.0.element_type;
let ArraySizeInfo {
obj_size,
one_elem_size,
@@ -898,15 +1216,12 @@ pub fn translate_array_fill(
let result = emit_array_fill_impl(
func_env,
builder,
+ elem_ty,
elem_addr,
one_elem_size,
fill_end,
- |func_env, builder, elem_addr| {
- let elem_ty = func_env
- .types
- .unwrap_array(interned_type_index)?
- .0
- .element_type;
+ value,
+ |func_env, builder, elem_addr, value| {
write_field_at_addr(func_env, builder, elem_ty, elem_addr, value)
},
);
@@ -1513,7 +1828,6 @@ impl FuncEnvironment<'_> {
}
/// Get the GC heap's base.
- #[cfg(any(feature = "gc-null", feature = "gc-drc", feature = "gc-copying"))]
fn get_gc_heap_base(&mut self, builder: &mut FunctionBuilder) -> ir::Value {
let global = self.get_gc_heap_base_global(&mut builder.func);
builder.ins().global_value(self.pointer_type(), global)
@@ -1536,7 +1850,6 @@ impl FuncEnvironment<'_> {
}
/// Get the GC heap's bound.
- #[cfg(feature = "gc-null")]
fn get_gc_heap_bound(&mut self, builder: &mut FunctionBuilder) -> ir::Value {
let global = self.get_gc_heap_bound_global(&mut builder.func);
builder.ins().global_value(self.pointer_type(), global)
diff --git a/crates/environ/src/builtin.rs b/crates/environ/src/builtin.rs
index 8d4906657c..6fe53515b1 100644
--- a/crates/environ/src/builtin.rs
+++ b/crates/environ/src/builtin.rs
@@ -145,31 +145,6 @@ macro_rules! foreach_builtin_function {
len: u32
) -> u32;
- // Builtin implementation of `array.copy` for arrays whose
- // elements are GC references.
- #[cfg(feature = "gc")]
- array_copy_gc_ref_elems(
- vmctx: vmctx,
- dst_array: u32,
- dst_index: u32,
- src_array: u32,
- src_index: u32,
- len: u32
- ) -> bool;
-
- // Builtin implementation of `array.copy` for arrays whose
- // elements are not GC references.
- #[cfg(feature = "gc")]
- array_copy_non_gc_ref_elems(
- vmctx: vmctx,
- array_interned_type_index: u32,
- dst_array: u32,
- dst_index: u32,
- src_array: u32,
- src_index: u32,
- len: u32
- ) -> bool;
-
// Builtin implementation of the `array.init_data` instruction.
#[cfg(feature = "gc")]
array_init_data(
diff --git a/crates/wasmtime/src/runtime/vm/gc.rs b/crates/wasmtime/src/runtime/vm/gc.rs
index ea4d197eca..a4501f675b 100644
--- a/crates/wasmtime/src/runtime/vm/gc.rs
+++ b/crates/wasmtime/src/runtime/vm/gc.rs
@@ -324,18 +324,6 @@ impl GcStore {
self.gc_heap.gc_object_data_mut(gc_ref)
}
- /// Get the object datas for the given pair of object references.
- ///
- /// Panics if `a` and `b` are the same reference or either is out of bounds.
- pub fn gc_object_data_pair(
- &mut self,
- a: &VMGcRef,
- b: &VMGcRef,
- ) -> (&mut VMGcObjectData, &mut VMGcObjectData) {
- assert_ne!(a, b);
- self.gc_heap.gc_object_data_pair(a, b)
- }
-
/// Allocate an uninitialized array with the given type index.
///
/// This does NOT check that the index is currently allocated in the types
diff --git a/crates/wasmtime/src/runtime/vm/gc/gc_runtime.rs b/crates/wasmtime/src/runtime/vm/gc/gc_runtime.rs
index 8eab8d3fbf..6bad5b45cd 100644
--- a/crates/wasmtime/src/runtime/vm/gc/gc_runtime.rs
+++ b/crates/wasmtime/src/runtime/vm/gc/gc_runtime.rs
@@ -531,40 +531,6 @@ pub unsafe trait GcHeap: 'static + Send + Sync {
let data = &mut self.heap_slice_mut()[range];
data.into()
}
-
- /// Get a pair of mutable borrows of the given objects' data.
- ///
- /// # Panics
- ///
- /// Panics if `a == b` or on out-of-bounds accesses or if either GC ref is
- /// an `i31ref`.
- fn gc_object_data_pair(
- &mut self,
- a: &VMGcRef,
- b: &VMGcRef,
- ) -> (&mut VMGcObjectData, &mut VMGcObjectData) {
- assert_ne!(a, b);
-
- let a_range = self.object_range(a);
- let b_range = self.object_range(b);
-
- // Assert that the two objects do not overlap.
- assert!(a_range.start <= a_range.end);
- assert!(b_range.start <= b_range.end);
- assert!(a_range.end <= b_range.start || b_range.end <= a_range.start);
-
- let (a_data, b_data) = if a_range.start < b_range.start {
- let (a_half, b_half) = self.heap_slice_mut().split_at_mut(b_range.start);
- let b_len = b_range.end - b_range.start;
- (&mut a_half[a_range], &mut b_half[..b_len])
- } else {
- let (b_half, a_half) = self.heap_slice_mut().split_at_mut(a_range.start);
- let a_len = a_range.end - a_range.start;
- (&mut a_half[..a_len], &mut b_half[b_range])
- };
-
- (a_data.into(), b_data.into())
- }
}
/// A list of GC roots.
diff --git a/crates/wasmtime/src/runtime/vm/libcalls.rs b/crates/wasmtime/src/runtime/vm/libcalls.rs
index ff75e49f6e..7681aaef2a 100644
--- a/crates/wasmtime/src/runtime/vm/libcalls.rs
+++ b/crates/wasmtime/src/runtime/vm/libcalls.rs
@@ -1104,154 +1104,6 @@ fn array_init_elem(
Ok(())
}
-#[cfg(feature = "gc")]
-fn array_copy_gc_ref_elems(
- store: &mut dyn VMStore,
- _instance: InstanceId,
- dst_array: u32,
- dst: u32,
- src_array: u32,
- src: u32,
- len: u32,
-) -> Result<()> {
- use crate::{ArrayRef, OpaqueRootScope, store::AutoAssertNoGc};
-
- log::trace!(
- "array.copy(dst_array={dst_array:#x}, dst_index={dst}, src_array={src_array:#x}, src_index={src}, len={len})",
- );
-
- let mut store = OpaqueRootScope::new(store.store_opaque_mut());
- let mut store = AutoAssertNoGc::new(&mut store);
-
- // Convert the raw GC refs into `Rooted<ArrayRef>`s.
- let dst_array = VMGcRef::from_raw_u32(dst_array).ok_or_else(|| Trap::NullReference)?;
- let dst_array = store.unwrap_gc_store_mut().clone_gc_ref(&dst_array);
- let dst_array = ArrayRef::from_cloned_gc_ref(&mut store, dst_array);
- let src_array = VMGcRef::from_raw_u32(src_array).ok_or_else(|| Trap::NullReference)?;
- let src_array = store.unwrap_gc_store_mut().clone_gc_ref(&src_array);
- let src_array = ArrayRef::from_cloned_gc_ref(&mut store, src_array);
-
- debug_assert!(dst_array.layout(&store).unwrap().elems_are_gc_refs);
-
- // Bounds check the destination array's elements.
- let dst_array_len = dst_array._len(&store)?;
- if dst.checked_add(len).ok_or_else(|| Trap::ArrayOutOfBounds)? > dst_array_len {
- return Err(Trap::ArrayOutOfBounds.into());
- }
-
- // Bounds check the source array's elements.
- let src_array_len = src_array._len(&store)?;
- if src.checked_add(len).ok_or_else(|| Trap::ArrayOutOfBounds)? > src_array_len {
- return Err(Trap::ArrayOutOfBounds.into());
- }
-
- let mut store = AutoAssertNoGc::new(&mut store);
- // If `src_array` and `dst_array` are the same array, then we are
- // potentially doing an overlapping copy, so make sure to copy elements in
- // the order that doesn't clobber the source elements before they are
- // copied. If they are different arrays, the order doesn't matter, but we
- // simply don't bother checking.
- if src > dst {
- for i in 0..len {
- let src_elem = src_array._get(&mut store, src + i)?;
- let dst_i = dst + i;
- dst_array._set(&mut store, dst_i, src_elem)?;
- }
- } else {
- for i in (0..len).rev() {
- let src_elem = src_array._get(&mut store, src + i)?;
- let dst_i = dst + i;
- dst_array._set(&mut store, dst_i, src_elem)?;
- }
- }
- Ok(())
-}
-
-#[cfg(feature = "gc")]
-fn array_copy_non_gc_ref_elems(
- store: &mut dyn VMStore,
- instance_id: InstanceId,
- array_type_index: u32,
- dst_array: u32,
- dst: u32,
- src_array: u32,
- src: u32,
- len: u32,
-) -> Result<()> {
- use wasmtime_environ::ModuleInternedTypeIndex;
-
- log::trace!(
- "array.copy non-gc-refs(dst_array={dst_array:#x}, dst_index={dst}, src_array={src_array:#x}, src_index={src}, len={len})",
- );
-
- let array_type_index = ModuleInternedTypeIndex::from_u32(array_type_index);
-
- let same_array = dst_array == src_array;
-
- // Null checks and conversion to `VMArrayRef`.
- let dst_gc_ref = VMGcRef::from_raw_u32(dst_array).ok_or_else(|| Trap::NullReference)?;
- let dst_arr = dst_gc_ref
- .into_arrayref(&*store.unwrap_gc_store().gc_heap)
- .expect("gc ref should be an array");
- let src_gc_ref = VMGcRef::from_raw_u32(src_array).ok_or_else(|| Trap::NullReference)?;
- let src_arr = src_gc_ref
- .into_arrayref(&*store.unwrap_gc_store().gc_heap)
- .expect("gc ref should be an array");
-
- // Bounds check the destination array's elements.
- let dst_len = dst_arr.len(store.store_opaque());
- let dst_end = dst.checked_add(len).ok_or_else(|| Trap::ArrayOutOfBounds)?;
- if dst_end > dst_len {
- return Err(Trap::ArrayOutOfBounds.into());
- }
-
- // Bounds check the source array's elements.
- let src_len = src_arr.len(store.store_opaque());
- let src_end = src.checked_add(len).ok_or_else(|| Trap::ArrayOutOfBounds)?;
- if src_end > src_len {
- return Err(Trap::ArrayOutOfBounds.into());
- }
-
- // Get the array layout to compute byte offsets.
- let instance = store.instance(instance_id);
- let shared_ty = instance.engine_type_index(array_type_index);
- let gc_layout = store
- .engine()
- .signatures()
- .layout(shared_ty)
- .expect("array types have GC layouts");
- let array_layout = gc_layout.unwrap_array();
- debug_assert!(!array_layout.elems_are_gc_refs);
-
- let byte_len = len
- .checked_mul(array_layout.elem_size)
- .expect("already checked bounds");
-
- let src_byte_start = array_layout.elem_offset(src).unwrap();
- let dst_byte_start = array_layout.elem_offset(dst).unwrap();
-
- // Use `core::ptr::copy` to do a bulk copy of the element data.
- let gc_store = store.unwrap_gc_store_mut();
- if same_array {
- // Same array: potentially overlapping.
- let src_byte_end = src_byte_start
- .checked_add(byte_len)
- .expect("already checked bounds");
- gc_store
- .gc_object_data(dst_arr.as_gc_ref())
- .copy_within(src_byte_start..src_byte_end, dst_byte_start);
- } else {
- // Different arrays: non-overlapping.
- let (src_data, dst_data) =
- gc_store.gc_object_data_pair(src_arr.as_gc_ref(), dst_arr.as_gc_ref());
- let src_slice = src_data.slice(src_byte_start, byte_len);
- let dst_slice = dst_data.slice_mut(dst_byte_start, byte_len);
- dst_slice.copy_from_slice(src_slice);
- }
-
- Ok(())
-}
-
#[cfg(feature = "gc")]
fn is_subtype(
store: &mut dyn VMStore,
diff --git a/tests/disas/array-copy-anyref.wat b/tests/disas/array-copy-anyref.wat
new file mode 100644
index 0000000000..14c8df1052
--- /dev/null
+++ b/tests/disas/array-copy-anyref.wat
@@ -0,0 +1,113 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc -Ccollector=copying'
+
+(module
+ (type $a (array (mut anyref)))
+
+ (func $copy (param (ref $a) i32 (ref $a) i32 i32)
+ (array.copy $a $a (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
+;; @002b trapz v4, user16
+;; @002b v83 = load.i64 notrap aligned readonly can_move v0+8
+;; @002b v8 = load.i64 notrap aligned readonly can_move v83+32
+;; @002b v7 = uextend.i64 v4
+;; @002b v9 = iadd v8, v7
+;; @002b v10 = iconst.i64 16
+;; @002b v11 = iadd v9, v10 ; v10 = 16
+;; @002b v12 = load.i32 user2 readonly v11
+;; @002b v13 = uadd_overflow_trap v5, v6, user17
+;; @002b v14 = icmp ugt v13, v12
+;; @002b trapnz v14, user17
+;; @002b v16 = uextend.i64 v12
+;; v85 = iconst.i64 2
+;; v86 = ishl v16, v85 ; v85 = 2
+;; v82 = iconst.i64 32
+;; @002b v18 = ushr v86, v82 ; v82 = 32
+;; @002b trapnz v18, user2
+;; v95 = iconst.i32 2
+;; v96 = ishl v12, v95 ; v95 = 2
+;; @002b v20 = iconst.i32 20
+;; @002b v21 = uadd_overflow_trap v96, v20, user2 ; v20 = 20
+;; @002b v25 = uadd_overflow_trap v4, v21, user2
+;; @002b trapz v2, user16
+;; @002b v32 = uextend.i64 v2
+;; @002b v34 = iadd v8, v32
+;; @002b v36 = iadd v34, v10 ; v10 = 16
+;; @002b v37 = load.i32 user2 readonly v36
+;; @002b v38 = uadd_overflow_trap v3, v6, user17
+;; @002b v39 = icmp ugt v38, v37
+;; @002b trapnz v39, user17
+;; @002b v41 = uextend.i64 v37
+;; v106 = ishl v41, v85 ; v85 = 2
+;; @002b v43 = ushr v106, v82 ; v82 = 32
+;; @002b trapnz v43, user2
+;; v113 = ishl v37, v95 ; v95 = 2
+;; @002b v46 = uadd_overflow_trap v113, v20, user2 ; v20 = 20
+;; @002b v50 = uadd_overflow_trap v2, v46, user2
+;; @002b brif v6, block2, block5
+;;
+;; block2:
+;; @002b v51 = uextend.i64 v50
+;; @002b v53 = iadd.i64 v8, v51
+;; v129 = iconst.i32 2
+;; v130 = ishl.i32 v3, v129 ; v129 = 2
+;; v131 = iconst.i32 20
+;; v132 = iadd v130, v131 ; v131 = 20
+;; @002b v54 = isub.i32 v46, v132
+;; @002b v55 = uextend.i64 v54
+;; @002b v56 = isub v53, v55
+;; @002b v26 = uextend.i64 v25
+;; @002b v28 = iadd.i64 v8, v26
+;; v133 = ishl.i32 v5, v129 ; v129 = 2
+;; v134 = iadd v133, v131 ; v131 = 20
+;; @002b v29 = isub.i32 v21, v134
+;; @002b v30 = uextend.i64 v29
+;; @002b v31 = isub v28, v30
+;; @002b v62 = icmp ult v56, v31
+;; v135 = ishl.i32 v6, v129 ; v129 = 2
+;; @002b v58 = uextend.i64 v135
+;; @002b v60 = iadd v56, v58
+;; @002b v59 = iadd v31, v58
+;; @002b v15 = iconst.i64 4
+;; v126 = iadd v28, v15 ; v15 = 4
+;; @002b brif v62, block3(v56, v31), block4(v60, v59)
+;;
+;; block3(v63: i64, v64: i64):
+;; @002b v65 = load.i32 user2 little v64
+;; @002b store user2 little v65, v63
+;; v141 = iconst.i64 4
+;; v142 = iadd v64, v141 ; v141 = 4
+;; @002b v68 = icmp eq v142, v59
+;; v143 = iadd v63, v141 ; v141 = 4
+;; @002b brif v68, block5, block3(v143, v142)
+;;
+;; block4(v69: i64, v70: i64):
+;; v136 = iconst.i64 4
+;; v137 = isub v70, v136 ; v136 = 4
+;; @002b v73 = load.i32 user2 little v137
+;; v138 = isub v69, v136 ; v136 = 4
+;; @002b store user2 little v73, v138
+;; v125 = iadd v70, v30
+;; v139 = iadd.i64 v28, v15 ; v15 = 4
+;; v140 = icmp eq v125, v139
+;; @002b brif v140, block5, block4(v138, v137)
+;;
+;; block5:
+;; @002f jump block1
+;;
+;; block1:
+;; @002f return
+;; }
diff --git a/tests/disas/array-copy-i64.wat b/tests/disas/array-copy-i64.wat
new file mode 100644
index 0000000000..5f7991b27f
--- /dev/null
+++ b/tests/disas/array-copy-i64.wat
@@ -0,0 +1,91 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i64)))
+
+ (func $copy (param (ref $a) i32 (ref $a) i32 i32)
+ (array.copy $a $a (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i64, i64) tail
+;; fn0 = colocated u805306368:4 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
+;; @002b trapz v4, user16
+;; @002b v79 = load.i64 notrap aligned readonly can_move v0+8
+;; @002b v8 = load.i64 notrap aligned readonly can_move v79+32
+;; @002b v7 = uextend.i64 v4
+;; @002b v9 = iadd v8, v7
+;; @002b v10 = iconst.i64 24
+;; @002b v11 = iadd v9, v10 ; v10 = 24
+;; @002b v12 = load.i32 user2 readonly v11
+;; @002b v13 = uadd_overflow_trap v5, v6, user17
+;; @002b v14 = icmp ugt v13, v12
+;; @002b trapnz v14, user17
+;; @002b v16 = uextend.i64 v12
+;; v81 = iconst.i64 3
+;; v82 = ishl v16, v81 ; v81 = 3
+;; v78 = iconst.i64 32
+;; @002b v18 = ushr v82, v78 ; v78 = 32
+;; @002b trapnz v18, user2
+;; v91 = iconst.i32 3
+;; v92 = ishl v12, v91 ; v91 = 3
+;; @002b v20 = iconst.i32 32
+;; @002b v21 = uadd_overflow_trap v92, v20, user2 ; v20 = 32
+;; @002b v25 = uadd_overflow_trap v4, v21, user2
+;; @002b trapz v2, user16
+;; @002b v32 = uextend.i64 v2
+;; @002b v34 = iadd v8, v32
+;; @002b v36 = iadd v34, v10 ; v10 = 24
+;; @002b v37 = load.i32 user2 readonly v36
+;; @002b v38 = uadd_overflow_trap v3, v6, user17
+;; @002b v39 = icmp ugt v38, v37
+;; @002b trapnz v39, user17
+;; @002b v41 = uextend.i64 v37
+;; v102 = ishl v41, v81 ; v81 = 3
+;; @002b v43 = ushr v102, v78 ; v78 = 32
+;; @002b trapnz v43, user2
+;; v109 = ishl v37, v91 ; v91 = 3
+;; @002b v46 = uadd_overflow_trap v109, v20, user2 ; v20 = 32
+;; @002b v50 = uadd_overflow_trap v2, v46, user2
+;; @002b v62 = load.i64 notrap aligned v79+40
+;; @002b v26 = uextend.i64 v25
+;; @002b v28 = iadd v8, v26
+;; v98 = ishl v5, v91 ; v91 = 3
+;; v100 = iadd v98, v20 ; v20 = 32
+;; @002b v29 = isub v21, v100
+;; @002b v30 = uextend.i64 v29
+;; @002b v31 = isub v28, v30
+;; v119 = ishl v6, v91 ; v91 = 3
+;; @002b v58 = uextend.i64 v119
+;; @002b v59 = iadd v31, v58
+;; @002b v63 = iadd v8, v62
+;; @002b v64 = icmp ugt v59, v63
+;; @002b trapnz v64, user2
+;; @002b v51 = uextend.i64 v50
+;; @002b v53 = iadd v8, v51
+;; v115 = ishl v3, v91 ; v91 = 3
+;; v117 = iadd v115, v20 ; v20 = 32
+;; @002b v54 = isub v46, v117
+;; @002b v55 = uextend.i64 v54
+;; @002b v56 = isub v53, v55
+;; @002b v60 = iadd v56, v58
+;; @002b v65 = icmp ugt v60, v63
+;; @002b trapnz v65, user2
+;; @002b call fn0(v0, v56, v31, v58)
+;; @002f jump block1
+;;
+;; block1:
+;; @002f return
+;; }
diff --git a/tests/disas/array-copy-i8.wat b/tests/disas/array-copy-i8.wat
new file mode 100644
index 0000000000..01369435fe
--- /dev/null
+++ b/tests/disas/array-copy-i8.wat
@@ -0,0 +1,82 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i8)))
+
+ (func $copy (param (ref $a) i32 (ref $a) i32 i32)
+ (array.copy $a $a (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i64, i64) tail
+;; fn0 = colocated u805306368:4 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
+;; @002b trapz v4, user16
+;; @002b v79 = load.i64 notrap aligned readonly can_move v0+8
+;; @002b v8 = load.i64 notrap aligned readonly can_move v79+32
+;; @002b v7 = uextend.i64 v4
+;; @002b v9 = iadd v8, v7
+;; @002b v10 = iconst.i64 24
+;; @002b v11 = iadd v9, v10 ; v10 = 24
+;; @002b v12 = load.i32 user2 readonly v11
+;; @002b v13 = uadd_overflow_trap v5, v6, user17
+;; @002b v14 = icmp ugt v13, v12
+;; @002b trapnz v14, user17
+;; @002b v16 = uextend.i64 v12
+;; v78 = iconst.i64 32
+;; @002b v18 = ushr v16, v78 ; v78 = 32
+;; @002b trapnz v18, user2
+;; @002b v20 = iconst.i32 28
+;; @002b v21 = uadd_overflow_trap v12, v20, user2 ; v20 = 28
+;; @002b v25 = uadd_overflow_trap v4, v21, user2
+;; @002b trapz v2, user16
+;; @002b v32 = uextend.i64 v2
+;; @002b v34 = iadd v8, v32
+;; @002b v36 = iadd v34, v10 ; v10 = 24
+;; @002b v37 = load.i32 user2 readonly v36
+;; @002b v38 = uadd_overflow_trap v3, v6, user17
+;; @002b v39 = icmp ugt v38, v37
+;; @002b trapnz v39, user17
+;; @002b v41 = uextend.i64 v37
+;; @002b v43 = ushr v41, v78 ; v78 = 32
+;; @002b trapnz v43, user2
+;; @002b v46 = uadd_overflow_trap v37, v20, user2 ; v20 = 28
+;; @002b v50 = uadd_overflow_trap v2, v46, user2
+;; @002b v62 = load.i64 notrap aligned v79+40
+;; @002b v26 = uextend.i64 v25
+;; @002b v28 = iadd v8, v26
+;; v87 = iadd v5, v20 ; v20 = 28
+;; @002b v29 = isub v21, v87
+;; @002b v30 = uextend.i64 v29
+;; @002b v31 = isub v28, v30
+;; @002b v58 = uextend.i64 v6
+;; @002b v59 = iadd v31, v58
+;; @002b v63 = iadd v8, v62
+;; @002b v64 = icmp ugt v59, v63
+;; @002b trapnz v64, user2
+;; @002b v51 = uextend.i64 v50
+;; @002b v53 = iadd v8, v51
+;; v92 = iadd v3, v20 ; v20 = 28
+;; @002b v54 = isub v46, v92
+;; @002b v55 = uextend.i64 v54
+;; @002b v56 = isub v53, v55
+;; @002b v60 = iadd v56, v58
+;; @002b v65 = icmp ugt v60, v63
+;; @002b trapnz v65, user2
+;; @002b call fn0(v0, v56, v31, v58)
+;; @002f jump block1
+;;
+;; block1:
+;; @002f return
+;; }
diff --git a/tests/disas/array-fill-anyref.wat b/tests/disas/array-fill-anyref.wat
new file mode 100644
index 0000000000..0be3d6d30b
--- /dev/null
+++ b/tests/disas/array-fill-anyref.wat
@@ -0,0 +1,203 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc -Ccollector=copying'
+
+(module
+ (type $a (array (mut anyref)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v anyref) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.null any) (local.get $len))
+ )
+
+ (func $fill-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.i31 (i32.const -1)) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @0030 trapz v2, user16
+;; @0030 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0030 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0030 v6 = uextend.i64 v2
+;; @0030 v8 = iadd v7, v6
+;; @0030 v9 = iconst.i64 16
+;; @0030 v10 = iadd v8, v9 ; v9 = 16
+;; @0030 v11 = load.i32 user2 readonly v10
+;; @0030 v12 = uadd_overflow_trap v3, v5, user17
+;; @0030 v13 = icmp ugt v12, v11
+;; @0030 trapnz v13, user17
+;; @0030 v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @0030 v17 = ushr v44, v40 ; v40 = 32
+;; @0030 trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @0030 v19 = iconst.i32 20
+;; @0030 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 20
+;; @0030 v24 = uadd_overflow_trap v2, v20, user2
+;; @0030 v25 = uextend.i64 v24
+;; @0030 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 20
+;; @0030 v28 = isub v20, v62
+;; @0030 v29 = uextend.i64 v28
+;; @0030 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 2
+;; @0030 v32 = uextend.i64 v64
+;; @0030 v33 = iadd v30, v32
+;; @0030 v14 = iconst.i64 4
+;; @0030 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0030 v36 = icmp eq v35, v33
+;; @0030 brif v36, block4, block3
+;;
+;; block3:
+;; @0030 store.i32 user2 little v4, v35
+;; v66 = iconst.i64 4
+;; v67 = iadd.i64 v35, v66 ; v66 = 4
+;; @0030 jump block2(v67)
+;;
+;; block4:
+;; @0033 jump block1
+;;
+;; block1:
+;; @0033 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003e trapz v2, user16
+;; @003e v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003e v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003e v6 = uextend.i64 v2
+;; @003e v8 = iadd v7, v6
+;; @003e v9 = iconst.i64 16
+;; @003e v10 = iadd v8, v9 ; v9 = 16
+;; @003e v11 = load.i32 user2 readonly v10
+;; @003e v12 = uadd_overflow_trap v3, v4, user17
+;; @003e v13 = icmp ugt v12, v11
+;; @003e trapnz v13, user17
+;; @003e v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @003e v17 = ushr v52, v48 ; v48 = 32
+;; @003e trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @003e v19 = iconst.i32 20
+;; @003e v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 20
+;; @003e v24 = uadd_overflow_trap v2, v20, user2
+;; @003e v37 = load.i64 notrap aligned v49+40
+;; @003e v25 = uextend.i64 v24
+;; @003e v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 20
+;; @003e v28 = isub v20, v70
+;; @003e v29 = uextend.i64 v28
+;; @003e v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @003e v32 = uextend.i64 v72
+;; @003e v33 = iadd v30, v32
+;; @003e v38 = iadd v7, v37
+;; @003e v39 = icmp ugt v33, v38
+;; @003e trapnz v39, user2
+;; @003a v5 = iconst.i32 0
+;; @003e call fn0(v0, v30, v5, v32) ; v5 = 0
+;; @0041 jump block1
+;;
+;; block1:
+;; @0041 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @004e trapz v2, user16
+;; @004e v43 = load.i64 notrap aligned readonly can_move v0+8
+;; @004e v9 = load.i64 notrap aligned readonly can_move v43+32
+;; @004e v8 = uextend.i64 v2
+;; @004e v10 = iadd v9, v8
+;; @004e v11 = iconst.i64 16
+;; @004e v12 = iadd v10, v11 ; v11 = 16
+;; @004e v13 = load.i32 user2 readonly v12
+;; @004e v14 = uadd_overflow_trap v3, v4, user17
+;; @004e v15 = icmp ugt v14, v13
+;; @004e trapnz v15, user17
+;; @004e v17 = uextend.i64 v13
+;; v53 = iconst.i64 2
+;; v54 = ishl v17, v53 ; v53 = 2
+;; v42 = iconst.i64 32
+;; @004e v19 = ushr v54, v42 ; v42 = 32
+;; @004e trapnz v19, user2
+;; v63 = iconst.i32 2
+;; v64 = ishl v13, v63 ; v63 = 2
+;; @004e v21 = iconst.i32 20
+;; @004e v22 = uadd_overflow_trap v64, v21, user2 ; v21 = 20
+;; @004e v26 = uadd_overflow_trap v2, v22, user2
+;; @004e v27 = uextend.i64 v26
+;; @004e v29 = iadd v9, v27
+;; v70 = ishl v3, v63 ; v63 = 2
+;; v72 = iadd v70, v21 ; v21 = 20
+;; @004e v30 = isub v22, v72
+;; @004e v31 = uextend.i64 v30
+;; @004e v32 = isub v29, v31
+;; v74 = ishl v4, v63 ; v63 = 2
+;; @004e v34 = uextend.i64 v74
+;; @004e v35 = iadd v32, v34
+;; @0048 v5 = iconst.i32 -1
+;; @004e v16 = iconst.i64 4
+;; @004e jump block2(v32)
+;;
+;; block2(v37: i64):
+;; @004e v38 = icmp eq v37, v35
+;; @004e brif v38, block4, block3
+;;
+;; block3:
+;; v76 = iconst.i32 -1
+;; @004e store user2 little v76, v37 ; v76 = -1
+;; v77 = iconst.i64 4
+;; v78 = iadd.i64 v37, v77 ; v77 = 4
+;; @004e jump block2(v78)
+;;
+;; block4:
+;; @0051 jump block1
+;;
+;; block1:
+;; @0051 return
+;; }
diff --git a/tests/disas/array-fill-externref.wat b/tests/disas/array-fill-externref.wat
new file mode 100644
index 0000000000..96a424bb64
--- /dev/null
+++ b/tests/disas/array-fill-externref.wat
@@ -0,0 +1,134 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc -Ccollector=copying'
+
+(module
+ (type $a (array (mut externref)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v externref) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.null extern) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @002f trapz v2, user16
+;; @002f v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @002f v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @002f v6 = uextend.i64 v2
+;; @002f v8 = iadd v7, v6
+;; @002f v9 = iconst.i64 16
+;; @002f v10 = iadd v8, v9 ; v9 = 16
+;; @002f v11 = load.i32 user2 readonly v10
+;; @002f v12 = uadd_overflow_trap v3, v5, user17
+;; @002f v13 = icmp ugt v12, v11
+;; @002f trapnz v13, user17
+;; @002f v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @002f v17 = ushr v44, v40 ; v40 = 32
+;; @002f trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @002f v19 = iconst.i32 20
+;; @002f v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 20
+;; @002f v24 = uadd_overflow_trap v2, v20, user2
+;; @002f v25 = uextend.i64 v24
+;; @002f v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 20
+;; @002f v28 = isub v20, v62
+;; @002f v29 = uextend.i64 v28
+;; @002f v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 2
+;; @002f v32 = uextend.i64 v64
+;; @002f v33 = iadd v30, v32
+;; @002f v14 = iconst.i64 4
+;; @002f jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @002f v36 = icmp eq v35, v33
+;; @002f brif v36, block4, block3
+;;
+;; block3:
+;; @002f store.i32 user2 little v4, v35
+;; v66 = iconst.i64 4
+;; v67 = iadd.i64 v35, v66 ; v66 = 4
+;; @002f jump block2(v67)
+;;
+;; block4:
+;; @0032 jump block1
+;;
+;; block1:
+;; @0032 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003d trapz v2, user16
+;; @003d v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003d v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003d v6 = uextend.i64 v2
+;; @003d v8 = iadd v7, v6
+;; @003d v9 = iconst.i64 16
+;; @003d v10 = iadd v8, v9 ; v9 = 16
+;; @003d v11 = load.i32 user2 readonly v10
+;; @003d v12 = uadd_overflow_trap v3, v4, user17
+;; @003d v13 = icmp ugt v12, v11
+;; @003d trapnz v13, user17
+;; @003d v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @003d v17 = ushr v52, v48 ; v48 = 32
+;; @003d trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @003d v19 = iconst.i32 20
+;; @003d v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 20
+;; @003d v24 = uadd_overflow_trap v2, v20, user2
+;; @003d v37 = load.i64 notrap aligned v49+40
+;; @003d v25 = uextend.i64 v24
+;; @003d v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 20
+;; @003d v28 = isub v20, v70
+;; @003d v29 = uextend.i64 v28
+;; @003d v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @003d v32 = uextend.i64 v72
+;; @003d v33 = iadd v30, v32
+;; @003d v38 = iadd v7, v37
+;; @003d v39 = icmp ugt v33, v38
+;; @003d trapnz v39, user2
+;; @0039 v5 = iconst.i32 0
+;; @003d call fn0(v0, v30, v5, v32) ; v5 = 0
+;; @0040 jump block1
+;;
+;; block1:
+;; @0040 return
+;; }
diff --git a/tests/disas/array-fill-f32.wat b/tests/disas/array-fill-f32.wat
new file mode 100644
index 0000000000..cf4edbd950
--- /dev/null
+++ b/tests/disas/array-fill-f32.wat
@@ -0,0 +1,203 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut f32)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v f32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (f32.const 0) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (f32.const 1) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, f32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: f32, v5: i32):
+;; @0030 trapz v2, user16
+;; @0030 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0030 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0030 v6 = uextend.i64 v2
+;; @0030 v8 = iadd v7, v6
+;; @0030 v9 = iconst.i64 24
+;; @0030 v10 = iadd v8, v9 ; v9 = 24
+;; @0030 v11 = load.i32 user2 readonly v10
+;; @0030 v12 = uadd_overflow_trap v3, v5, user17
+;; @0030 v13 = icmp ugt v12, v11
+;; @0030 trapnz v13, user17
+;; @0030 v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @0030 v17 = ushr v44, v40 ; v40 = 32
+;; @0030 trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @0030 v19 = iconst.i32 28
+;; @0030 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 28
+;; @0030 v24 = uadd_overflow_trap v2, v20, user2
+;; @0030 v25 = uextend.i64 v24
+;; @0030 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 28
+;; @0030 v28 = isub v20, v62
+;; @0030 v29 = uextend.i64 v28
+;; @0030 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 2
+;; @0030 v32 = uextend.i64 v64
+;; @0030 v33 = iadd v30, v32
+;; @0030 v14 = iconst.i64 4
+;; @0030 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0030 v36 = icmp eq v35, v33
+;; @0030 brif v36, block4, block3
+;;
+;; block3:
+;; @0030 store.f32 user2 little v4, v35
+;; v66 = iconst.i64 4
+;; v67 = iadd.i64 v35, v66 ; v66 = 4
+;; @0030 jump block2(v67)
+;;
+;; block4:
+;; @0033 jump block1
+;;
+;; block1:
+;; @0033 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @0041 trapz v2, user16
+;; @0041 v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @0041 v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @0041 v6 = uextend.i64 v2
+;; @0041 v8 = iadd v7, v6
+;; @0041 v9 = iconst.i64 24
+;; @0041 v10 = iadd v8, v9 ; v9 = 24
+;; @0041 v11 = load.i32 user2 readonly v10
+;; @0041 v12 = uadd_overflow_trap v3, v4, user17
+;; @0041 v13 = icmp ugt v12, v11
+;; @0041 trapnz v13, user17
+;; @0041 v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @0041 v17 = ushr v52, v48 ; v48 = 32
+;; @0041 trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @0041 v19 = iconst.i32 28
+;; @0041 v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 28
+;; @0041 v24 = uadd_overflow_trap v2, v20, user2
+;; @0041 v37 = load.i64 notrap aligned v49+40
+;; @0041 v25 = uextend.i64 v24
+;; @0041 v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 28
+;; @0041 v28 = isub v20, v70
+;; @0041 v29 = uextend.i64 v28
+;; @0041 v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @0041 v32 = uextend.i64 v72
+;; @0041 v33 = iadd v30, v32
+;; @0041 v38 = iadd v7, v37
+;; @0041 v39 = icmp ugt v33, v38
+;; @0041 trapnz v39, user2
+;; @0041 v35 = iconst.i32 0
+;; @0041 call fn0(v0, v30, v35, v32) ; v35 = 0
+;; @0044 jump block1
+;;
+;; block1:
+;; @0044 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @0052 trapz v2, user16
+;; @0052 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0052 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0052 v6 = uextend.i64 v2
+;; @0052 v8 = iadd v7, v6
+;; @0052 v9 = iconst.i64 24
+;; @0052 v10 = iadd v8, v9 ; v9 = 24
+;; @0052 v11 = load.i32 user2 readonly v10
+;; @0052 v12 = uadd_overflow_trap v3, v4, user17
+;; @0052 v13 = icmp ugt v12, v11
+;; @0052 trapnz v13, user17
+;; @0052 v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @0052 v17 = ushr v44, v40 ; v40 = 32
+;; @0052 trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @0052 v19 = iconst.i32 28
+;; @0052 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 28
+;; @0052 v24 = uadd_overflow_trap v2, v20, user2
+;; @0052 v25 = uextend.i64 v24
+;; @0052 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 28
+;; @0052 v28 = isub v20, v62
+;; @0052 v29 = uextend.i64 v28
+;; @0052 v30 = isub v27, v29
+;; v64 = ishl v4, v53 ; v53 = 2
+;; @0052 v32 = uextend.i64 v64
+;; @0052 v33 = iadd v30, v32
+;; @004b v5 = f32const 0x1.000000p0
+;; @0052 v14 = iconst.i64 4
+;; @0052 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0052 v36 = icmp eq v35, v33
+;; @0052 brif v36, block4, block3
+;;
+;; block3:
+;; v66 = f32const 0x1.000000p0
+;; @0052 store user2 little v66, v35 ; v66 = 0x1.000000p0
+;; v67 = iconst.i64 4
+;; v68 = iadd.i64 v35, v67 ; v67 = 4
+;; @0052 jump block2(v68)
+;;
+;; block4:
+;; @0055 jump block1
+;;
+;; block1:
+;; @0055 return
+;; }
diff --git a/tests/disas/array-fill-f64.wat b/tests/disas/array-fill-f64.wat
new file mode 100644
index 0000000000..6b3e2ca6c2
--- /dev/null
+++ b/tests/disas/array-fill-f64.wat
@@ -0,0 +1,203 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut f64)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v f64) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (f64.const 0) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (f64.const 1) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, f64, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: f64, v5: i32):
+;; @0030 trapz v2, user16
+;; @0030 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0030 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0030 v6 = uextend.i64 v2
+;; @0030 v8 = iadd v7, v6
+;; @0030 v9 = iconst.i64 24
+;; @0030 v10 = iadd v8, v9 ; v9 = 24
+;; @0030 v11 = load.i32 user2 readonly v10
+;; @0030 v12 = uadd_overflow_trap v3, v5, user17
+;; @0030 v13 = icmp ugt v12, v11
+;; @0030 trapnz v13, user17
+;; @0030 v15 = uextend.i64 v11
+;; v43 = iconst.i64 3
+;; v44 = ishl v15, v43 ; v43 = 3
+;; v40 = iconst.i64 32
+;; @0030 v17 = ushr v44, v40 ; v40 = 32
+;; @0030 trapnz v17, user2
+;; v53 = iconst.i32 3
+;; v54 = ishl v11, v53 ; v53 = 3
+;; @0030 v19 = iconst.i32 32
+;; @0030 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 32
+;; @0030 v24 = uadd_overflow_trap v2, v20, user2
+;; @0030 v25 = uextend.i64 v24
+;; @0030 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 3
+;; v62 = iadd v60, v19 ; v19 = 32
+;; @0030 v28 = isub v20, v62
+;; @0030 v29 = uextend.i64 v28
+;; @0030 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 3
+;; @0030 v32 = uextend.i64 v64
+;; @0030 v33 = iadd v30, v32
+;; @0030 v14 = iconst.i64 8
+;; @0030 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0030 v36 = icmp eq v35, v33
+;; @0030 brif v36, block4, block3
+;;
+;; block3:
+;; @0030 store.f64 user2 little v4, v35
+;; v66 = iconst.i64 8
+;; v67 = iadd.i64 v35, v66 ; v66 = 8
+;; @0030 jump block2(v67)
+;;
+;; block4:
+;; @0033 jump block1
+;;
+;; block1:
+;; @0033 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @0045 trapz v2, user16
+;; @0045 v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @0045 v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @0045 v6 = uextend.i64 v2
+;; @0045 v8 = iadd v7, v6
+;; @0045 v9 = iconst.i64 24
+;; @0045 v10 = iadd v8, v9 ; v9 = 24
+;; @0045 v11 = load.i32 user2 readonly v10
+;; @0045 v12 = uadd_overflow_trap v3, v4, user17
+;; @0045 v13 = icmp ugt v12, v11
+;; @0045 trapnz v13, user17
+;; @0045 v15 = uextend.i64 v11
+;; v51 = iconst.i64 3
+;; v52 = ishl v15, v51 ; v51 = 3
+;; v48 = iconst.i64 32
+;; @0045 v17 = ushr v52, v48 ; v48 = 32
+;; @0045 trapnz v17, user2
+;; v61 = iconst.i32 3
+;; v62 = ishl v11, v61 ; v61 = 3
+;; @0045 v19 = iconst.i32 32
+;; @0045 v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 32
+;; @0045 v24 = uadd_overflow_trap v2, v20, user2
+;; @0045 v37 = load.i64 notrap aligned v49+40
+;; @0045 v25 = uextend.i64 v24
+;; @0045 v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 3
+;; v70 = iadd v68, v19 ; v19 = 32
+;; @0045 v28 = isub v20, v70
+;; @0045 v29 = uextend.i64 v28
+;; @0045 v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 3
+;; @0045 v32 = uextend.i64 v72
+;; @0045 v33 = iadd v30, v32
+;; @0045 v38 = iadd v7, v37
+;; @0045 v39 = icmp ugt v33, v38
+;; @0045 trapnz v39, user2
+;; @0045 v35 = iconst.i32 0
+;; @0045 call fn0(v0, v30, v35, v32) ; v35 = 0
+;; @0048 jump block1
+;;
+;; block1:
+;; @0048 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @005a trapz v2, user16
+;; @005a v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @005a v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @005a v6 = uextend.i64 v2
+;; @005a v8 = iadd v7, v6
+;; @005a v9 = iconst.i64 24
+;; @005a v10 = iadd v8, v9 ; v9 = 24
+;; @005a v11 = load.i32 user2 readonly v10
+;; @005a v12 = uadd_overflow_trap v3, v4, user17
+;; @005a v13 = icmp ugt v12, v11
+;; @005a trapnz v13, user17
+;; @005a v15 = uextend.i64 v11
+;; v43 = iconst.i64 3
+;; v44 = ishl v15, v43 ; v43 = 3
+;; v40 = iconst.i64 32
+;; @005a v17 = ushr v44, v40 ; v40 = 32
+;; @005a trapnz v17, user2
+;; v53 = iconst.i32 3
+;; v54 = ishl v11, v53 ; v53 = 3
+;; @005a v19 = iconst.i32 32
+;; @005a v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 32
+;; @005a v24 = uadd_overflow_trap v2, v20, user2
+;; @005a v25 = uextend.i64 v24
+;; @005a v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 3
+;; v62 = iadd v60, v19 ; v19 = 32
+;; @005a v28 = isub v20, v62
+;; @005a v29 = uextend.i64 v28
+;; @005a v30 = isub v27, v29
+;; v64 = ishl v4, v53 ; v53 = 3
+;; @005a v32 = uextend.i64 v64
+;; @005a v33 = iadd v30, v32
+;; @004f v5 = f64const 0x1.0000000000000p0
+;; @005a v14 = iconst.i64 8
+;; @005a jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @005a v36 = icmp eq v35, v33
+;; @005a brif v36, block4, block3
+;;
+;; block3:
+;; v66 = f64const 0x1.0000000000000p0
+;; @005a store user2 little v66, v35 ; v66 = 0x1.0000000000000p0
+;; v67 = iconst.i64 8
+;; v68 = iadd.i64 v35, v67 ; v67 = 8
+;; @005a jump block2(v68)
+;;
+;; block4:
+;; @005d jump block1
+;;
+;; block1:
+;; @005d return
+;; }
diff --git a/tests/disas/array-fill-funcref.wat b/tests/disas/array-fill-funcref.wat
new file mode 100644
index 0000000000..bdd6a27f89
--- /dev/null
+++ b/tests/disas/array-fill-funcref.wat
@@ -0,0 +1,233 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut funcref)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v funcref) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.null func) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.func $hi) (local.get $len))
+ )
+
+ (func $hi)
+ (elem declare func $hi)
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i64, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64) -> i64 tail
+;; fn0 = colocated u805306368:28 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i64, v5: i32):
+;; @003b trapz v2, user16
+;; @003b v44 = load.i64 notrap aligned readonly can_move v0+8
+;; @003b v7 = load.i64 notrap aligned readonly can_move v44+32
+;; @003b v6 = uextend.i64 v2
+;; @003b v8 = iadd v7, v6
+;; @003b v9 = iconst.i64 24
+;; @003b v10 = iadd v8, v9 ; v9 = 24
+;; @003b v11 = load.i32 user2 readonly v10
+;; @003b v12 = uadd_overflow_trap v3, v5, user17
+;; @003b v13 = icmp ugt v12, v11
+;; @003b trapnz v13, user17
+;; @003b v15 = uextend.i64 v11
+;; v46 = iconst.i64 2
+;; v47 = ishl v15, v46 ; v46 = 2
+;; v43 = iconst.i64 32
+;; @003b v17 = ushr v47, v43 ; v43 = 32
+;; @003b trapnz v17, user2
+;; v56 = iconst.i32 2
+;; v57 = ishl v11, v56 ; v56 = 2
+;; @003b v19 = iconst.i32 28
+;; @003b v20 = uadd_overflow_trap v57, v19, user2 ; v19 = 28
+;; @003b v24 = uadd_overflow_trap v2, v20, user2
+;; @003b v25 = uextend.i64 v24
+;; @003b v27 = iadd v7, v25
+;; v63 = ishl v3, v56 ; v56 = 2
+;; v65 = iadd v63, v19 ; v19 = 28
+;; @003b v28 = isub v20, v65
+;; @003b v29 = uextend.i64 v28
+;; @003b v30 = isub v27, v29
+;; v67 = ishl v5, v56 ; v56 = 2
+;; @003b v32 = uextend.i64 v67
+;; @003b v33 = iadd v30, v32
+;; @003b v14 = iconst.i64 4
+;; @003b jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @003b v36 = icmp eq v35, v33
+;; @003b brif v36, block4, block3
+;;
+;; block3:
+;; @003b v38 = call fn0(v0, v4)
+;; @003b v39 = ireduce.i32 v38
+;; @003b store user2 little v39, v35
+;; v69 = iconst.i64 4
+;; v70 = iadd.i64 v35, v69 ; v69 = 4
+;; @003b jump block2(v70)
+;;
+;; block4:
+;; @003e jump block1
+;;
+;; block1:
+;; @003e return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @0049 trapz v2, user16
+;; @0049 v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @0049 v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @0049 v6 = uextend.i64 v2
+;; @0049 v8 = iadd v7, v6
+;; @0049 v9 = iconst.i64 24
+;; @0049 v10 = iadd v8, v9 ; v9 = 24
+;; @0049 v11 = load.i32 user2 readonly v10
+;; @0049 v12 = uadd_overflow_trap v3, v4, user17
+;; @0049 v13 = icmp ugt v12, v11
+;; @0049 trapnz v13, user17
+;; @0049 v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @0049 v17 = ushr v52, v48 ; v48 = 32
+;; @0049 trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @0049 v19 = iconst.i32 28
+;; @0049 v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 28
+;; @0049 v24 = uadd_overflow_trap v2, v20, user2
+;; @0049 v37 = load.i64 notrap aligned v49+40
+;; @0049 v25 = uextend.i64 v24
+;; @0049 v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 28
+;; @0049 v28 = isub v20, v70
+;; @0049 v29 = uextend.i64 v28
+;; @0049 v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @0049 v32 = uextend.i64 v72
+;; @0049 v33 = iadd v30, v32
+;; @0049 v38 = iadd v7, v37
+;; @0049 v39 = icmp ugt v33, v38
+;; @0049 trapnz v39, user2
+;; @0049 v35 = iconst.i32 0
+;; @0049 call fn0(v0, v30, v35, v32) ; v35 = 0
+;; @004c jump block1
+;;
+;; block1:
+;; @004c return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32) -> i64 tail
+;; sig1 = (i64 vmctx, i64) -> i64 tail
+;; fn0 = colocated u805306368:7 sig0
+;; fn1 = colocated u805306368:28 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; v54 = stack_addr.i64 ss0
+;; store notrap v2, v54
+;; @0053 v5 = iconst.i32 3
+;; @0053 v7 = call fn0(v0, v5), stack_map=[i32 @ ss0+0] ; v5 = 3
+;; v45 = load.i32 notrap v54
+;; @0057 trapz v45, user16
+;; @0057 v50 = load.i64 notrap aligned readonly can_move v0+8
+;; @0057 v9 = load.i64 notrap aligned readonly can_move v50+32
+;; @0057 v8 = uextend.i64 v45
+;; @0057 v10 = iadd v9, v8
+;; @0057 v11 = iconst.i64 24
+;; @0057 v12 = iadd v10, v11 ; v11 = 24
+;; @0057 v13 = load.i32 user2 readonly v12
+;; @0057 v14 = uadd_overflow_trap v3, v4, user17
+;; @0057 v15 = icmp ugt v14, v13
+;; @0057 trapnz v15, user17
+;; @0057 v17 = uextend.i64 v13
+;; v55 = iconst.i64 2
+;; v56 = ishl v17, v55 ; v55 = 2
+;; v49 = iconst.i64 32
+;; @0057 v19 = ushr v56, v49 ; v49 = 32
+;; @0057 trapnz v19, user2
+;; v65 = iconst.i32 2
+;; v66 = ishl v13, v65 ; v65 = 2
+;; @0057 v21 = iconst.i32 28
+;; @0057 v22 = uadd_overflow_trap v66, v21, user2 ; v21 = 28
+;; @0057 v26 = uadd_overflow_trap v45, v22, user2
+;; @0057 v27 = uextend.i64 v26
+;; @0057 v29 = iadd v9, v27
+;; v72 = ishl v3, v65 ; v65 = 2
+;; v74 = iadd v72, v21 ; v21 = 28
+;; @0057 v30 = isub v22, v74
+;; @0057 v31 = uextend.i64 v30
+;; @0057 v32 = isub v29, v31
+;; v76 = ishl v4, v65 ; v65 = 2
+;; @0057 v34 = uextend.i64 v76
+;; @0057 v35 = iadd v32, v34
+;; @0057 v16 = iconst.i64 4
+;; @0057 jump block2(v32)
+;;
+;; block2(v37: i64):
+;; @0057 v38 = icmp eq v37, v35
+;; @0057 brif v38, block4, block3
+;;
+;; block3:
+;; @0057 v40 = call fn1(v0, v7)
+;; @0057 v41 = ireduce.i32 v40
+;; @0057 store user2 little v41, v37
+;; v78 = iconst.i64 4
+;; v79 = iadd.i64 v37, v78 ; v78 = 4
+;; @0057 jump block2(v79)
+;;
+;; block4:
+;; @005a jump block1
+;;
+;; block1:
+;; @005a return
+;; }
+;;
+;; function u0:3(i64 vmctx, i64) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64):
+;; @005d jump block1
+;;
+;; block1:
+;; @005d return
+;; }
diff --git a/tests/disas/array-fill-i16.wat b/tests/disas/array-fill-i16.wat
new file mode 100644
index 0000000000..ea6dc140c0
--- /dev/null
+++ b/tests/disas/array-fill-i16.wat
@@ -0,0 +1,256 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i16)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const 0) (local.get $len))
+ )
+
+ (func $fill-minus-one (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const -1) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const 0xdead) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @0031 trapz v2, user16
+;; @0031 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0031 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0031 v6 = uextend.i64 v2
+;; @0031 v8 = iadd v7, v6
+;; @0031 v9 = iconst.i64 24
+;; @0031 v10 = iadd v8, v9 ; v9 = 24
+;; @0031 v11 = load.i32 user2 readonly v10
+;; @0031 v12 = uadd_overflow_trap v3, v5, user17
+;; @0031 v13 = icmp ugt v12, v11
+;; @0031 trapnz v13, user17
+;; @0031 v15 = uextend.i64 v11
+;; v46 = iadd v15, v15
+;; v40 = iconst.i64 32
+;; @0031 v17 = ushr v46, v40 ; v40 = 32
+;; @0031 trapnz v17, user2
+;; v52 = iadd v11, v11
+;; @0031 v19 = iconst.i32 28
+;; @0031 v20 = uadd_overflow_trap v52, v19, user2 ; v19 = 28
+;; @0031 v24 = uadd_overflow_trap v2, v20, user2
+;; @0031 v25 = uextend.i64 v24
+;; @0031 v27 = iadd v7, v25
+;; v65 = iadd v3, v3
+;; v69 = iadd v65, v19 ; v19 = 28
+;; @0031 v28 = isub v20, v69
+;; @0031 v29 = uextend.i64 v28
+;; @0031 v30 = isub v27, v29
+;; v71 = iadd v5, v5
+;; @0031 v32 = uextend.i64 v71
+;; @0031 v33 = iadd v30, v32
+;; @0031 v14 = iconst.i64 2
+;; @0031 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0031 v36 = icmp eq v35, v33
+;; @0031 brif v36, block4, block3
+;;
+;; block3:
+;; @0031 istore16.i32 user2 little v4, v35
+;; v75 = iconst.i64 2
+;; v76 = iadd.i64 v35, v75 ; v75 = 2
+;; @0031 jump block2(v76)
+;;
+;; block4:
+;; @0034 jump block1
+;;
+;; block1:
+;; @0034 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003f trapz v2, user16
+;; @003f v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003f v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003f v6 = uextend.i64 v2
+;; @003f v8 = iadd v7, v6
+;; @003f v9 = iconst.i64 24
+;; @003f v10 = iadd v8, v9 ; v9 = 24
+;; @003f v11 = load.i32 user2 readonly v10
+;; @003f v12 = uadd_overflow_trap v3, v4, user17
+;; @003f v13 = icmp ugt v12, v11
+;; @003f trapnz v13, user17
+;; @003f v15 = uextend.i64 v11
+;; v54 = iadd v15, v15
+;; v48 = iconst.i64 32
+;; @003f v17 = ushr v54, v48 ; v48 = 32
+;; @003f trapnz v17, user2
+;; v60 = iadd v11, v11
+;; @003f v19 = iconst.i32 28
+;; @003f v20 = uadd_overflow_trap v60, v19, user2 ; v19 = 28
+;; @003f v24 = uadd_overflow_trap v2, v20, user2
+;; @003f v37 = load.i64 notrap aligned v49+40
+;; @003f v25 = uextend.i64 v24
+;; @003f v27 = iadd v7, v25
+;; v73 = iadd v3, v3
+;; v77 = iadd v73, v19 ; v19 = 28
+;; @003f v28 = isub v20, v77
+;; @003f v29 = uextend.i64 v28
+;; @003f v30 = isub v27, v29
+;; v79 = iadd v4, v4
+;; @003f v32 = uextend.i64 v79
+;; @003f v33 = iadd v30, v32
+;; @003f v38 = iadd v7, v37
+;; @003f v39 = icmp ugt v33, v38
+;; @003f trapnz v39, user2
+;; @003b v5 = iconst.i32 0
+;; @003f call fn0(v0, v30, v5, v32) ; v5 = 0
+;; @0042 jump block1
+;;
+;; block1:
+;; @0042 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @004d trapz v2, user16
+;; @004d v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @004d v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @004d v6 = uextend.i64 v2
+;; @004d v8 = iadd v7, v6
+;; @004d v9 = iconst.i64 24
+;; @004d v10 = iadd v8, v9 ; v9 = 24
+;; @004d v11 = load.i32 user2 readonly v10
+;; @004d v12 = uadd_overflow_trap v3, v4, user17
+;; @004d v13 = icmp ugt v12, v11
+;; @004d trapnz v13, user17
+;; @004d v15 = uextend.i64 v11
+;; v54 = iadd v15, v15
+;; v48 = iconst.i64 32
+;; @004d v17 = ushr v54, v48 ; v48 = 32
+;; @004d trapnz v17, user2
+;; v60 = iadd v11, v11
+;; @004d v19 = iconst.i32 28
+;; @004d v20 = uadd_overflow_trap v60, v19, user2 ; v19 = 28
+;; @004d v24 = uadd_overflow_trap v2, v20, user2
+;; @004d v37 = load.i64 notrap aligned v49+40
+;; @004d v25 = uextend.i64 v24
+;; @004d v27 = iadd v7, v25
+;; v73 = iadd v3, v3
+;; v77 = iadd v73, v19 ; v19 = 28
+;; @004d v28 = isub v20, v77
+;; @004d v29 = uextend.i64 v28
+;; @004d v30 = isub v27, v29
+;; v79 = iadd v4, v4
+;; @004d v32 = uextend.i64 v79
+;; @004d v33 = iadd v30, v32
+;; @004d v38 = iadd v7, v37
+;; @004d v39 = icmp ugt v33, v38
+;; @004d trapnz v39, user2
+;; @004d v35 = iconst.i32 255
+;; @004d call fn0(v0, v30, v35, v32) ; v35 = 255
+;; @0050 jump block1
+;;
+;; block1:
+;; @0050 return
+;; }
+;;
+;; function u0:3(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @005d trapz v2, user16
+;; @005d v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @005d v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @005d v6 = uextend.i64 v2
+;; @005d v8 = iadd v7, v6
+;; @005d v9 = iconst.i64 24
+;; @005d v10 = iadd v8, v9 ; v9 = 24
+;; @005d v11 = load.i32 user2 readonly v10
+;; @005d v12 = uadd_overflow_trap v3, v4, user17
+;; @005d v13 = icmp ugt v12, v11
+;; @005d trapnz v13, user17
+;; @005d v15 = uextend.i64 v11
+;; v46 = iadd v15, v15
+;; v40 = iconst.i64 32
+;; @005d v17 = ushr v46, v40 ; v40 = 32
+;; @005d trapnz v17, user2
+;; v52 = iadd v11, v11
+;; @005d v19 = iconst.i32 28
+;; @005d v20 = uadd_overflow_trap v52, v19, user2 ; v19 = 28
+;; @005d v24 = uadd_overflow_trap v2, v20, user2
+;; @005d v25 = uextend.i64 v24
+;; @005d v27 = iadd v7, v25
+;; v65 = iadd v3, v3
+;; v69 = iadd v65, v19 ; v19 = 28
+;; @005d v28 = isub v20, v69
+;; @005d v29 = uextend.i64 v28
+;; @005d v30 = isub v27, v29
+;; v71 = iadd v4, v4
+;; @005d v32 = uextend.i64 v71
+;; @005d v33 = iadd v30, v32
+;; @0057 v5 = iconst.i32 0xdead
+;; @005d v14 = iconst.i64 2
+;; @005d jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @005d v36 = icmp eq v35, v33
+;; @005d brif v36, block4, block3
+;;
+;; block3:
+;; v75 = iconst.i32 0xdead
+;; @005d istore16 user2 little v75, v35 ; v75 = 0xdead
+;; v76 = iconst.i64 2
+;; v77 = iadd.i64 v35, v76 ; v76 = 2
+;; @005d jump block2(v77)
+;;
+;; block4:
+;; @0060 jump block1
+;;
+;; block1:
+;; @0060 return
+;; }
diff --git a/tests/disas/array-fill-i31ref.wat b/tests/disas/array-fill-i31ref.wat
new file mode 100644
index 0000000000..528d522c10
--- /dev/null
+++ b/tests/disas/array-fill-i31ref.wat
@@ -0,0 +1,203 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc -Ccollector=copying'
+
+(module
+ (type $a (array (mut i31ref)))
+
+ (func $fill-i31thing (param $a (ref $a)) (param $i i32) (param $v i31ref) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.null i31) (local.get $len))
+ )
+
+ (func $fill-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (ref.i31 (i32.const -1)) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @0030 trapz v2, user16
+;; @0030 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0030 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0030 v6 = uextend.i64 v2
+;; @0030 v8 = iadd v7, v6
+;; @0030 v9 = iconst.i64 16
+;; @0030 v10 = iadd v8, v9 ; v9 = 16
+;; @0030 v11 = load.i32 user2 readonly v10
+;; @0030 v12 = uadd_overflow_trap v3, v5, user17
+;; @0030 v13 = icmp ugt v12, v11
+;; @0030 trapnz v13, user17
+;; @0030 v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @0030 v17 = ushr v44, v40 ; v40 = 32
+;; @0030 trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @0030 v19 = iconst.i32 20
+;; @0030 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 20
+;; @0030 v24 = uadd_overflow_trap v2, v20, user2
+;; @0030 v25 = uextend.i64 v24
+;; @0030 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 20
+;; @0030 v28 = isub v20, v62
+;; @0030 v29 = uextend.i64 v28
+;; @0030 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 2
+;; @0030 v32 = uextend.i64 v64
+;; @0030 v33 = iadd v30, v32
+;; @0030 v14 = iconst.i64 4
+;; @0030 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0030 v36 = icmp eq v35, v33
+;; @0030 brif v36, block4, block3
+;;
+;; block3:
+;; @0030 store.i32 user2 little v4, v35
+;; v66 = iconst.i64 4
+;; v67 = iadd.i64 v35, v66 ; v66 = 4
+;; @0030 jump block2(v67)
+;;
+;; block4:
+;; @0033 jump block1
+;;
+;; block1:
+;; @0033 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003e trapz v2, user16
+;; @003e v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003e v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003e v6 = uextend.i64 v2
+;; @003e v8 = iadd v7, v6
+;; @003e v9 = iconst.i64 16
+;; @003e v10 = iadd v8, v9 ; v9 = 16
+;; @003e v11 = load.i32 user2 readonly v10
+;; @003e v12 = uadd_overflow_trap v3, v4, user17
+;; @003e v13 = icmp ugt v12, v11
+;; @003e trapnz v13, user17
+;; @003e v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @003e v17 = ushr v52, v48 ; v48 = 32
+;; @003e trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @003e v19 = iconst.i32 20
+;; @003e v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 20
+;; @003e v24 = uadd_overflow_trap v2, v20, user2
+;; @003e v37 = load.i64 notrap aligned v49+40
+;; @003e v25 = uextend.i64 v24
+;; @003e v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 20
+;; @003e v28 = isub v20, v70
+;; @003e v29 = uextend.i64 v28
+;; @003e v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @003e v32 = uextend.i64 v72
+;; @003e v33 = iadd v30, v32
+;; @003e v38 = iadd v7, v37
+;; @003e v39 = icmp ugt v33, v38
+;; @003e trapnz v39, user2
+;; @003a v5 = iconst.i32 0
+;; @003e call fn0(v0, v30, v5, v32) ; v5 = 0
+;; @0041 jump block1
+;;
+;; block1:
+;; @0041 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @004e trapz v2, user16
+;; @004e v43 = load.i64 notrap aligned readonly can_move v0+8
+;; @004e v9 = load.i64 notrap aligned readonly can_move v43+32
+;; @004e v8 = uextend.i64 v2
+;; @004e v10 = iadd v9, v8
+;; @004e v11 = iconst.i64 16
+;; @004e v12 = iadd v10, v11 ; v11 = 16
+;; @004e v13 = load.i32 user2 readonly v12
+;; @004e v14 = uadd_overflow_trap v3, v4, user17
+;; @004e v15 = icmp ugt v14, v13
+;; @004e trapnz v15, user17
+;; @004e v17 = uextend.i64 v13
+;; v53 = iconst.i64 2
+;; v54 = ishl v17, v53 ; v53 = 2
+;; v42 = iconst.i64 32
+;; @004e v19 = ushr v54, v42 ; v42 = 32
+;; @004e trapnz v19, user2
+;; v63 = iconst.i32 2
+;; v64 = ishl v13, v63 ; v63 = 2
+;; @004e v21 = iconst.i32 20
+;; @004e v22 = uadd_overflow_trap v64, v21, user2 ; v21 = 20
+;; @004e v26 = uadd_overflow_trap v2, v22, user2
+;; @004e v27 = uextend.i64 v26
+;; @004e v29 = iadd v9, v27
+;; v70 = ishl v3, v63 ; v63 = 2
+;; v72 = iadd v70, v21 ; v21 = 20
+;; @004e v30 = isub v22, v72
+;; @004e v31 = uextend.i64 v30
+;; @004e v32 = isub v29, v31
+;; v74 = ishl v4, v63 ; v63 = 2
+;; @004e v34 = uextend.i64 v74
+;; @004e v35 = iadd v32, v34
+;; @0048 v5 = iconst.i32 -1
+;; @004e v16 = iconst.i64 4
+;; @004e jump block2(v32)
+;;
+;; block2(v37: i64):
+;; @004e v38 = icmp eq v37, v35
+;; @004e brif v38, block4, block3
+;;
+;; block3:
+;; v76 = iconst.i32 -1
+;; @004e store user2 little v76, v37 ; v76 = -1
+;; v77 = iconst.i64 4
+;; v78 = iadd.i64 v37, v77 ; v77 = 4
+;; @004e jump block2(v78)
+;;
+;; block4:
+;; @0051 jump block1
+;;
+;; block1:
+;; @0051 return
+;; }
diff --git a/tests/disas/array-fill-i32.wat b/tests/disas/array-fill-i32.wat
new file mode 100644
index 0000000000..e5ee0c3f1b
--- /dev/null
+++ b/tests/disas/array-fill-i32.wat
@@ -0,0 +1,264 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i32)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const 0) (local.get $len))
+ )
+
+ (func $fill-minus-one (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const -1) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i32.const 0xdead) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @0031 trapz v2, user16
+;; @0031 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0031 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0031 v6 = uextend.i64 v2
+;; @0031 v8 = iadd v7, v6
+;; @0031 v9 = iconst.i64 24
+;; @0031 v10 = iadd v8, v9 ; v9 = 24
+;; @0031 v11 = load.i32 user2 readonly v10
+;; @0031 v12 = uadd_overflow_trap v3, v5, user17
+;; @0031 v13 = icmp ugt v12, v11
+;; @0031 trapnz v13, user17
+;; @0031 v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @0031 v17 = ushr v44, v40 ; v40 = 32
+;; @0031 trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @0031 v19 = iconst.i32 28
+;; @0031 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 28
+;; @0031 v24 = uadd_overflow_trap v2, v20, user2
+;; @0031 v25 = uextend.i64 v24
+;; @0031 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 28
+;; @0031 v28 = isub v20, v62
+;; @0031 v29 = uextend.i64 v28
+;; @0031 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 2
+;; @0031 v32 = uextend.i64 v64
+;; @0031 v33 = iadd v30, v32
+;; @0031 v14 = iconst.i64 4
+;; @0031 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0031 v36 = icmp eq v35, v33
+;; @0031 brif v36, block4, block3
+;;
+;; block3:
+;; @0031 store.i32 user2 little v4, v35
+;; v66 = iconst.i64 4
+;; v67 = iadd.i64 v35, v66 ; v66 = 4
+;; @0031 jump block2(v67)
+;;
+;; block4:
+;; @0034 jump block1
+;;
+;; block1:
+;; @0034 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003f trapz v2, user16
+;; @003f v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003f v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003f v6 = uextend.i64 v2
+;; @003f v8 = iadd v7, v6
+;; @003f v9 = iconst.i64 24
+;; @003f v10 = iadd v8, v9 ; v9 = 24
+;; @003f v11 = load.i32 user2 readonly v10
+;; @003f v12 = uadd_overflow_trap v3, v4, user17
+;; @003f v13 = icmp ugt v12, v11
+;; @003f trapnz v13, user17
+;; @003f v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @003f v17 = ushr v52, v48 ; v48 = 32
+;; @003f trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @003f v19 = iconst.i32 28
+;; @003f v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 28
+;; @003f v24 = uadd_overflow_trap v2, v20, user2
+;; @003f v37 = load.i64 notrap aligned v49+40
+;; @003f v25 = uextend.i64 v24
+;; @003f v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 28
+;; @003f v28 = isub v20, v70
+;; @003f v29 = uextend.i64 v28
+;; @003f v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @003f v32 = uextend.i64 v72
+;; @003f v33 = iadd v30, v32
+;; @003f v38 = iadd v7, v37
+;; @003f v39 = icmp ugt v33, v38
+;; @003f trapnz v39, user2
+;; @003b v5 = iconst.i32 0
+;; @003f call fn0(v0, v30, v5, v32) ; v5 = 0
+;; @0042 jump block1
+;;
+;; block1:
+;; @0042 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @004d trapz v2, user16
+;; @004d v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @004d v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @004d v6 = uextend.i64 v2
+;; @004d v8 = iadd v7, v6
+;; @004d v9 = iconst.i64 24
+;; @004d v10 = iadd v8, v9 ; v9 = 24
+;; @004d v11 = load.i32 user2 readonly v10
+;; @004d v12 = uadd_overflow_trap v3, v4, user17
+;; @004d v13 = icmp ugt v12, v11
+;; @004d trapnz v13, user17
+;; @004d v15 = uextend.i64 v11
+;; v51 = iconst.i64 2
+;; v52 = ishl v15, v51 ; v51 = 2
+;; v48 = iconst.i64 32
+;; @004d v17 = ushr v52, v48 ; v48 = 32
+;; @004d trapnz v17, user2
+;; v61 = iconst.i32 2
+;; v62 = ishl v11, v61 ; v61 = 2
+;; @004d v19 = iconst.i32 28
+;; @004d v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 28
+;; @004d v24 = uadd_overflow_trap v2, v20, user2
+;; @004d v37 = load.i64 notrap aligned v49+40
+;; @004d v25 = uextend.i64 v24
+;; @004d v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 2
+;; v70 = iadd v68, v19 ; v19 = 28
+;; @004d v28 = isub v20, v70
+;; @004d v29 = uextend.i64 v28
+;; @004d v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 2
+;; @004d v32 = uextend.i64 v72
+;; @004d v33 = iadd v30, v32
+;; @004d v38 = iadd v7, v37
+;; @004d v39 = icmp ugt v33, v38
+;; @004d trapnz v39, user2
+;; @004d v35 = iconst.i32 255
+;; @004d call fn0(v0, v30, v35, v32) ; v35 = 255
+;; @0050 jump block1
+;;
+;; block1:
+;; @0050 return
+;; }
+;;
+;; function u0:3(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @005d trapz v2, user16
+;; @005d v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @005d v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @005d v6 = uextend.i64 v2
+;; @005d v8 = iadd v7, v6
+;; @005d v9 = iconst.i64 24
+;; @005d v10 = iadd v8, v9 ; v9 = 24
+;; @005d v11 = load.i32 user2 readonly v10
+;; @005d v12 = uadd_overflow_trap v3, v4, user17
+;; @005d v13 = icmp ugt v12, v11
+;; @005d trapnz v13, user17
+;; @005d v15 = uextend.i64 v11
+;; v43 = iconst.i64 2
+;; v44 = ishl v15, v43 ; v43 = 2
+;; v40 = iconst.i64 32
+;; @005d v17 = ushr v44, v40 ; v40 = 32
+;; @005d trapnz v17, user2
+;; v53 = iconst.i32 2
+;; v54 = ishl v11, v53 ; v53 = 2
+;; @005d v19 = iconst.i32 28
+;; @005d v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 28
+;; @005d v24 = uadd_overflow_trap v2, v20, user2
+;; @005d v25 = uextend.i64 v24
+;; @005d v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 2
+;; v62 = iadd v60, v19 ; v19 = 28
+;; @005d v28 = isub v20, v62
+;; @005d v29 = uextend.i64 v28
+;; @005d v30 = isub v27, v29
+;; v64 = ishl v4, v53 ; v53 = 2
+;; @005d v32 = uextend.i64 v64
+;; @005d v33 = iadd v30, v32
+;; @0057 v5 = iconst.i32 0xdead
+;; @005d v14 = iconst.i64 4
+;; @005d jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @005d v36 = icmp eq v35, v33
+;; @005d brif v36, block4, block3
+;;
+;; block3:
+;; v66 = iconst.i32 0xdead
+;; @005d store user2 little v66, v35 ; v66 = 0xdead
+;; v67 = iconst.i64 4
+;; v68 = iadd.i64 v35, v67 ; v67 = 4
+;; @005d jump block2(v68)
+;;
+;; block4:
+;; @0060 jump block1
+;;
+;; block1:
+;; @0060 return
+;; }
diff --git a/tests/disas/array-fill-i64.wat b/tests/disas/array-fill-i64.wat
new file mode 100644
index 0000000000..19ed8421d6
--- /dev/null
+++ b/tests/disas/array-fill-i64.wat
@@ -0,0 +1,264 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i64)))
+
+ (func $fill-anything (param $a (ref $a)) (param $i i32) (param $v i64) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+
+ (func $fill-zero (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i64.const 0) (local.get $len))
+ )
+
+ (func $fill-minus-one (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i64.const -1) (local.get $len))
+ )
+
+ (func $fill-bit-pattern (param $a (ref $a)) (param $i i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (i64.const 1) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i64, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i64, v5: i32):
+;; @0031 trapz v2, user16
+;; @0031 v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @0031 v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @0031 v6 = uextend.i64 v2
+;; @0031 v8 = iadd v7, v6
+;; @0031 v9 = iconst.i64 24
+;; @0031 v10 = iadd v8, v9 ; v9 = 24
+;; @0031 v11 = load.i32 user2 readonly v10
+;; @0031 v12 = uadd_overflow_trap v3, v5, user17
+;; @0031 v13 = icmp ugt v12, v11
+;; @0031 trapnz v13, user17
+;; @0031 v15 = uextend.i64 v11
+;; v43 = iconst.i64 3
+;; v44 = ishl v15, v43 ; v43 = 3
+;; v40 = iconst.i64 32
+;; @0031 v17 = ushr v44, v40 ; v40 = 32
+;; @0031 trapnz v17, user2
+;; v53 = iconst.i32 3
+;; v54 = ishl v11, v53 ; v53 = 3
+;; @0031 v19 = iconst.i32 32
+;; @0031 v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 32
+;; @0031 v24 = uadd_overflow_trap v2, v20, user2
+;; @0031 v25 = uextend.i64 v24
+;; @0031 v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 3
+;; v62 = iadd v60, v19 ; v19 = 32
+;; @0031 v28 = isub v20, v62
+;; @0031 v29 = uextend.i64 v28
+;; @0031 v30 = isub v27, v29
+;; v64 = ishl v5, v53 ; v53 = 3
+;; @0031 v32 = uextend.i64 v64
+;; @0031 v33 = iadd v30, v32
+;; @0031 v14 = iconst.i64 8
+;; @0031 jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @0031 v36 = icmp eq v35, v33
+;; @0031 brif v36, block4, block3
+;;
+;; block3:
+;; @0031 store.i64 user2 little v4, v35
+;; v66 = iconst.i64 8
+;; v67 = iadd.i64 v35, v66 ; v66 = 8
+;; @0031 jump block2(v67)
+;;
+;; block4:
+;; @0034 jump block1
+;;
+;; block1:
+;; @0034 return
+;; }
+;;
+;; function u0:1(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @003f trapz v2, user16
+;; @003f v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @003f v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @003f v6 = uextend.i64 v2
+;; @003f v8 = iadd v7, v6
+;; @003f v9 = iconst.i64 24
+;; @003f v10 = iadd v8, v9 ; v9 = 24
+;; @003f v11 = load.i32 user2 readonly v10
+;; @003f v12 = uadd_overflow_trap v3, v4, user17
+;; @003f v13 = icmp ugt v12, v11
+;; @003f trapnz v13, user17
+;; @003f v15 = uextend.i64 v11
+;; v51 = iconst.i64 3
+;; v52 = ishl v15, v51 ; v51 = 3
+;; v48 = iconst.i64 32
+;; @003f v17 = ushr v52, v48 ; v48 = 32
+;; @003f trapnz v17, user2
+;; v61 = iconst.i32 3
+;; v62 = ishl v11, v61 ; v61 = 3
+;; @003f v19 = iconst.i32 32
+;; @003f v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 32
+;; @003f v24 = uadd_overflow_trap v2, v20, user2
+;; @003f v37 = load.i64 notrap aligned v49+40
+;; @003f v25 = uextend.i64 v24
+;; @003f v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 3
+;; v70 = iadd v68, v19 ; v19 = 32
+;; @003f v28 = isub v20, v70
+;; @003f v29 = uextend.i64 v28
+;; @003f v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 3
+;; @003f v32 = uextend.i64 v72
+;; @003f v33 = iadd v30, v32
+;; @003f v38 = iadd v7, v37
+;; @003f v39 = icmp ugt v33, v38
+;; @003f trapnz v39, user2
+;; @003f v35 = iconst.i32 0
+;; @003f call fn0(v0, v30, v35, v32) ; v35 = 0
+;; @0042 jump block1
+;;
+;; block1:
+;; @0042 return
+;; }
+;;
+;; function u0:2(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @004d trapz v2, user16
+;; @004d v49 = load.i64 notrap aligned readonly can_move v0+8
+;; @004d v7 = load.i64 notrap aligned readonly can_move v49+32
+;; @004d v6 = uextend.i64 v2
+;; @004d v8 = iadd v7, v6
+;; @004d v9 = iconst.i64 24
+;; @004d v10 = iadd v8, v9 ; v9 = 24
+;; @004d v11 = load.i32 user2 readonly v10
+;; @004d v12 = uadd_overflow_trap v3, v4, user17
+;; @004d v13 = icmp ugt v12, v11
+;; @004d trapnz v13, user17
+;; @004d v15 = uextend.i64 v11
+;; v51 = iconst.i64 3
+;; v52 = ishl v15, v51 ; v51 = 3
+;; v48 = iconst.i64 32
+;; @004d v17 = ushr v52, v48 ; v48 = 32
+;; @004d trapnz v17, user2
+;; v61 = iconst.i32 3
+;; v62 = ishl v11, v61 ; v61 = 3
+;; @004d v19 = iconst.i32 32
+;; @004d v20 = uadd_overflow_trap v62, v19, user2 ; v19 = 32
+;; @004d v24 = uadd_overflow_trap v2, v20, user2
+;; @004d v37 = load.i64 notrap aligned v49+40
+;; @004d v25 = uextend.i64 v24
+;; @004d v27 = iadd v7, v25
+;; v68 = ishl v3, v61 ; v61 = 3
+;; v70 = iadd v68, v19 ; v19 = 32
+;; @004d v28 = isub v20, v70
+;; @004d v29 = uextend.i64 v28
+;; @004d v30 = isub v27, v29
+;; v72 = ishl v4, v61 ; v61 = 3
+;; @004d v32 = uextend.i64 v72
+;; @004d v33 = iadd v30, v32
+;; @004d v38 = iadd v7, v37
+;; @004d v39 = icmp ugt v33, v38
+;; @004d trapnz v39, user2
+;; @004d v35 = iconst.i32 255
+;; @004d call fn0(v0, v30, v35, v32) ; v35 = 255
+;; @0050 jump block1
+;;
+;; block1:
+;; @0050 return
+;; }
+;;
+;; function u0:3(i64 vmctx, i64, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32):
+;; @005b trapz v2, user16
+;; @005b v41 = load.i64 notrap aligned readonly can_move v0+8
+;; @005b v7 = load.i64 notrap aligned readonly can_move v41+32
+;; @005b v6 = uextend.i64 v2
+;; @005b v8 = iadd v7, v6
+;; @005b v9 = iconst.i64 24
+;; @005b v10 = iadd v8, v9 ; v9 = 24
+;; @005b v11 = load.i32 user2 readonly v10
+;; @005b v12 = uadd_overflow_trap v3, v4, user17
+;; @005b v13 = icmp ugt v12, v11
+;; @005b trapnz v13, user17
+;; @005b v15 = uextend.i64 v11
+;; v43 = iconst.i64 3
+;; v44 = ishl v15, v43 ; v43 = 3
+;; v40 = iconst.i64 32
+;; @005b v17 = ushr v44, v40 ; v40 = 32
+;; @005b trapnz v17, user2
+;; v53 = iconst.i32 3
+;; v54 = ishl v11, v53 ; v53 = 3
+;; @005b v19 = iconst.i32 32
+;; @005b v20 = uadd_overflow_trap v54, v19, user2 ; v19 = 32
+;; @005b v24 = uadd_overflow_trap v2, v20, user2
+;; @005b v25 = uextend.i64 v24
+;; @005b v27 = iadd v7, v25
+;; v60 = ishl v3, v53 ; v53 = 3
+;; v62 = iadd v60, v19 ; v19 = 32
+;; @005b v28 = isub v20, v62
+;; @005b v29 = uextend.i64 v28
+;; @005b v30 = isub v27, v29
+;; v64 = ishl v4, v53 ; v53 = 3
+;; @005b v32 = uextend.i64 v64
+;; @005b v33 = iadd v30, v32
+;; @0057 v5 = iconst.i64 1
+;; @005b v14 = iconst.i64 8
+;; @005b jump block2(v30)
+;;
+;; block2(v35: i64):
+;; @005b v36 = icmp eq v35, v33
+;; @005b brif v36, block4, block3
+;;
+;; block3:
+;; v66 = iconst.i64 1
+;; @005b store user2 little v66, v35 ; v66 = 1
+;; v67 = iconst.i64 8
+;; v68 = iadd.i64 v35, v67 ; v67 = 8
+;; @005b jump block2(v68)
+;;
+;; block4:
+;; @005e jump block1
+;;
+;; block1:
+;; @005e return
+;; }
diff --git a/tests/disas/component-may-leave-without-signals-based-traps.wat b/tests/disas/component-may-leave-without-signals-based-traps.wat
index 20574ffedc..d3851bc76e 100644
--- a/tests/disas/component-may-leave-without-signals-based-traps.wat
+++ b/tests/disas/component-may-leave-without-signals-based-traps.wat
@@ -44,7 +44,7 @@
;; retq
;; 129: movq %rbx, %rsi
;; 12c: movq 0x10(%rsi), %rax
-;; 130: movq 0x1a0(%rax), %rax
+;; 130: movq 0x190(%rax), %rax
;; 137: movq %rbx, %rdi
;; 13a: callq *%rax
;; 13c: ud2
diff --git a/tests/disas/debug.wat b/tests/disas/debug.wat
index 146965ebf8..cbfa40c8f1 100644
--- a/tests/disas/debug.wat
+++ b/tests/disas/debug.wat
@@ -128,7 +128,7 @@
;; popq %rbp
;; retq
;; 17a: movq 0x10(%rbx), %rax
-;; 17e: movq 0x1a0(%rax), %rax
+;; 17e: movq 0x190(%rax), %rax
;; 185: movq %rbx, %rdi
;; 188: callq *%rax
;; 18a: ud2
@@ -143,7 +143,7 @@
;; movq 8(%r10), %r11
;; movq %r11, 0x38(%r9)
;; movq 0x10(%rdi), %r11
-;; movq 0x198(%r11), %r11
+;; movq 0x188(%r11), %r11
;; movzbq %sil, %rsi
;; callq *%r11
;; movq %rbp, %rsp
@@ -160,7 +160,7 @@
;; movq 8(%r9), %r9
;; movq %r9, 0x38(%r8)
;; movq 0x10(%rdi), %r9
-;; movq 0x1a0(%r9), %r9
+;; movq 0x190(%r9), %r9
;; callq *%r9
;; movq %rbp, %rsp
;; popq %rbp
@@ -203,7 +203,7 @@
;; movq 8(%r11), %rax
;; movq %rax, 0x38(%r10)
;; movq 0x10(%rdi), %rax
-;; movq 0x1d0(%rax), %rcx
+;; movq 0x1c0(%rax), %rcx
;; movq %rdi, %rbx
;; callq *%rcx
;; testb %al, %al
@@ -239,7 +239,7 @@
;; popq %rbp
;; retq
;; 3af: movq 0x10(%rbx), %rax
-;; 3b3: movq 0x1a0(%rax), %rax
+;; 3b3: movq 0x190(%rax), %rax
;; 3ba: movq %rbx, %rdi
;; 3bd: callq *%rax
;; 3bf: ud2
diff --git a/tests/disas/gc/array-fill-i8.wat b/tests/disas/gc/array-fill-i8.wat
new file mode 100644
index 0000000000..4ad703bea4
--- /dev/null
+++ b/tests/disas/gc/array-fill-i8.wat
@@ -0,0 +1,60 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i8)))
+
+ (func $fill (param $a (ref $a)) (param $i i32) (param $v i32) (param $len i32)
+ (array.fill $a (local.get $a) (local.get $i) (local.get $v) (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32, i32, i32, i32) tail {
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:5 sig0
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32, v3: i32, v4: i32, v5: i32):
+;; @0027 trapz v2, user16
+;; @0027 v48 = load.i64 notrap aligned readonly can_move v0+8
+;; @0027 v7 = load.i64 notrap aligned readonly can_move v48+32
+;; @0027 v6 = uextend.i64 v2
+;; @0027 v8 = iadd v7, v6
+;; @0027 v9 = iconst.i64 24
+;; @0027 v10 = iadd v8, v9 ; v9 = 24
+;; @0027 v11 = load.i32 user2 readonly v10
+;; @0027 v12 = uadd_overflow_trap v3, v5, user17
+;; @0027 v13 = icmp ugt v12, v11
+;; @0027 trapnz v13, user17
+;; @0027 v15 = uextend.i64 v11
+;; v47 = iconst.i64 32
+;; @0027 v17 = ushr v15, v47 ; v47 = 32
+;; @0027 trapnz v17, user2
+;; @0027 v19 = iconst.i32 28
+;; @0027 v20 = uadd_overflow_trap v11, v19, user2 ; v19 = 28
+;; @0027 v24 = uadd_overflow_trap v2, v20, user2
+;; @0027 v36 = load.i64 notrap aligned v48+40
+;; @0027 v25 = uextend.i64 v24
+;; @0027 v27 = iadd v7, v25
+;; v56 = iadd v3, v19 ; v19 = 28
+;; @0027 v28 = isub v20, v56
+;; @0027 v29 = uextend.i64 v28
+;; @0027 v30 = isub v27, v29
+;; @0027 v32 = uextend.i64 v5
+;; @0027 v33 = iadd v30, v32
+;; @0027 v37 = iadd v7, v36
+;; @0027 v38 = icmp ugt v33, v37
+;; @0027 trapnz v38, user2
+;; @0027 call fn0(v0, v30, v4, v32)
+;; @002a jump block1
+;;
+;; block1:
+;; @002a return
+;; }
diff --git a/tests/disas/gc/array-new-default-anyref.wat b/tests/disas/gc/array-new-default-anyref.wat
new file mode 100644
index 0000000000..2ab9bd95ec
--- /dev/null
+++ b/tests/disas/gc/array-new-default-anyref.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut anyref)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v4, v35), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-exnref.wat b/tests/disas/gc/array-new-default-exnref.wat
new file mode 100644
index 0000000000..e4c1e5ffa8
--- /dev/null
+++ b/tests/disas/gc/array-new-default-exnref.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc -Wexceptions'
+
+(module
+ (type $a (array (mut exnref)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v4, v35), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-externref.wat b/tests/disas/gc/array-new-default-externref.wat
new file mode 100644
index 0000000000..b6bcaef4a9
--- /dev/null
+++ b/tests/disas/gc/array-new-default-externref.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut externref)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v4, v35), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-f32.wat b/tests/disas/gc/array-new-default-f32.wat
new file mode 100644
index 0000000000..fd5fbd5097
--- /dev/null
+++ b/tests/disas/gc/array-new-default-f32.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut f32)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v29 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v29, v35), stack_map=[i32 @ ss0+0] ; v29 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-f64.wat b/tests/disas/gc/array-new-default-f64.wat
new file mode 100644
index 0000000000..0b3e2744fb
--- /dev/null
+++ b/tests/disas/gc/array-new-default-f64.wat
@@ -0,0 +1,67 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut f64)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 3
+;; v51 = ishl v6, v50 ; v50 = 3
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 32
+;; v57 = iconst.i32 3
+;; v58 = ishl v2, v57 ; v57 = 3
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 32
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; v55 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v55) ; v12 = -1476395008, v55 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v66 = iadd v20, v48 ; v48 = 32
+;; @001f v29 = iconst.i32 0
+;; @001f v35 = isub v28, v66
+;; @001f call fn1(v0, v66, v29, v35), stack_map=[i32 @ ss0+0] ; v29 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-funcref.wat b/tests/disas/gc/array-new-default-funcref.wat
new file mode 100644
index 0000000000..35671fb97f
--- /dev/null
+++ b/tests/disas/gc/array-new-default-funcref.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut funcref)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v29 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v29, v35), stack_map=[i32 @ ss0+0] ; v29 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-i16.wat b/tests/disas/gc/array-new-default-i16.wat
new file mode 100644
index 0000000000..bc3e2de776
--- /dev/null
+++ b/tests/disas/gc/array-new-default-i16.wat
@@ -0,0 +1,67 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i16)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v51 = iconst.i64 1
+;; v52 = ishl v6, v51 ; v51 = 1
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v52, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v56 = iadd v2, v2
+;; @001f v10 = uadd_overflow_trap v5, v56, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v67 = iconst.i64 28
+;; v72 = iadd v20, v67 ; v67 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v35 = isub v28, v72
+;; @001f call fn1(v0, v72, v4, v35), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-i32.wat b/tests/disas/gc/array-new-default-i32.wat
new file mode 100644
index 0000000000..109db6dd0b
--- /dev/null
+++ b/tests/disas/gc/array-new-default-i32.wat
@@ -0,0 +1,68 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i32)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 2
+;; v51 = ishl v6, v50 ; v50 = 2
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; v57 = iconst.i32 2
+;; v58 = ishl v2, v57 ; v57 = 2
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v62 = iconst.i64 28
+;; v67 = iadd v20, v62 ; v62 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v35 = isub v28, v67
+;; @001f call fn1(v0, v67, v4, v35), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-i64.wat b/tests/disas/gc/array-new-default-i64.wat
new file mode 100644
index 0000000000..0bc2f8cdf2
--- /dev/null
+++ b/tests/disas/gc/array-new-default-i64.wat
@@ -0,0 +1,67 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i64)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v50 = iconst.i64 3
+;; v51 = ishl v6, v50 ; v50 = 3
+;; v48 = iconst.i64 32
+;; @001f v8 = ushr v51, v48 ; v48 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 32
+;; v57 = iconst.i32 3
+;; v58 = ishl v2, v57 ; v57 = 3
+;; @001f v10 = uadd_overflow_trap v5, v58, user18 ; v5 = 32
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; v55 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v55) ; v12 = -1476395008, v55 = 8
+;; v47 = stack_addr.i64 ss0
+;; store notrap v17, v47
+;; @001f v45 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v45+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v43 = iconst.i64 24
+;; @001f v21 = iadd v20, v43 ; v43 = 24
+;; @001f store user2 v2, v21
+;; @001f v31 = load.i64 notrap aligned v45+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v32 = iadd v18, v31
+;; @001f v33 = icmp ugt v28, v32
+;; @001f trapnz v33, user2
+;; v66 = iadd v20, v48 ; v48 = 32
+;; @001f v29 = iconst.i32 0
+;; @001f v35 = isub v28, v66
+;; @001f call fn1(v0, v66, v29, v35), stack_map=[i32 @ ss0+0] ; v29 = 0
+;; v36 = load.i32 notrap v47
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v36
+;; }
diff --git a/tests/disas/gc/array-new-default-i8.wat b/tests/disas/gc/array-new-default-i8.wat
new file mode 100644
index 0000000000..662357e838
--- /dev/null
+++ b/tests/disas/gc/array-new-default-i8.wat
@@ -0,0 +1,64 @@
+;;! target = 'x86_64'
+;;! test = 'optimize'
+;;! flags = '-Wgc'
+
+(module
+ (type $a (array (mut i8)))
+
+ (func $fill (param $len i32) (result (ref $a))
+ (array.new_default $a (local.get $len))
+ )
+)
+;; function u0:0(i64 vmctx, i64, i32) -> i32 tail {
+;; ss0 = explicit_slot 4, align = 4
+;; gv0 = vmctx
+;; gv1 = load.i64 notrap aligned readonly gv0+8
+;; gv2 = load.i64 notrap aligned gv1+24
+;; gv3 = vmctx
+;; gv4 = load.i64 notrap aligned readonly can_move gv3+8
+;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
+;; gv6 = load.i64 notrap aligned gv4+40
+;; sig0 = (i64 vmctx, i32, i32, i32, i32) -> i32 tail
+;; sig1 = (i64 vmctx, i64, i32, i64) tail
+;; fn0 = colocated u805306368:27 sig0
+;; fn1 = colocated u805306368:5 sig1
+;; stack_limit = gv2
+;;
+;; block0(v0: i64, v1: i64, v2: i32):
+;; @001f v6 = uextend.i64 v2
+;; v47 = iconst.i64 32
+;; @001f v8 = ushr v6, v47 ; v47 = 32
+;; @001f trapnz v8, user18
+;; @001f v5 = iconst.i32 28
+;; @001f v10 = uadd_overflow_trap v5, v2, user18 ; v5 = 28
+;; @001f v12 = iconst.i32 -1476395008
+;; @001f v14 = load.i64 notrap aligned readonly can_move v0+40
+;; @001f v15 = load.i32 notrap aligned readonly can_move v14
+;; @001f v16 = iconst.i32 8
+;; @001f v17 = call fn0(v0, v12, v15, v10, v16) ; v12 = -1476395008, v16 = 8
+;; v46 = stack_addr.i64 ss0
+;; store notrap v17, v46
+;; @001f v44 = load.i64 notrap aligned readonly can_move v0+8
+;; @001f v18 = load.i64 notrap aligned readonly can_move v44+32
+;; @001f v19 = uextend.i64 v17
+;; @001f v20 = iadd v18, v19
+;; v42 = iconst.i64 24
+;; @001f v21 = iadd v20, v42 ; v42 = 24
+;; @001f store user2 v2, v21
+;; @001f v30 = load.i64 notrap aligned v44+40
+;; @001f v27 = uextend.i64 v10
+;; @001f v28 = iadd v20, v27
+;; @001f v31 = iadd v18, v30
+;; @001f v32 = icmp ugt v28, v31
+;; @001f trapnz v32, user2
+;; v52 = iconst.i64 28
+;; v57 = iadd v20, v52 ; v52 = 28
+;; @001f v4 = iconst.i32 0
+;; @001f v34 = isub v28, v57
+;; @001f call fn1(v0, v57, v4, v34), stack_map=[i32 @ ss0+0] ; v4 = 0
+;; v35 = load.i32 notrap v46
+;; @0022 jump block1
+;;
+;; block1:
+;; @0022 return v35
+;; }
diff --git a/tests/disas/gc/copying/br-on-cast-fail.wat b/tests/disas/gc/copying/br-on-cast-fail.wat
index 2b1215391d..845bd5a27f 100644
--- a/tests/disas/gc/copying/br-on-cast-fail.wat
+++ b/tests/disas/gc/copying/br-on-cast-fail.wat
@@ -26,7 +26,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/copying/br-on-cast.wat b/tests/disas/gc/copying/br-on-cast.wat
index 967060f290..518ba235e3 100644
--- a/tests/disas/gc/copying/br-on-cast.wat
+++ b/tests/disas/gc/copying/br-on-cast.wat
@@ -26,7 +26,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/copying/call-indirect-and-subtyping.wat b/tests/disas/gc/copying/call-indirect-and-subtyping.wat
index 1b3d1758ce..88f1c18cfb 100644
--- a/tests/disas/gc/copying/call-indirect-and-subtyping.wat
+++ b/tests/disas/gc/copying/call-indirect-and-subtyping.wat
@@ -25,7 +25,7 @@
;; sig1 = (i64 vmctx, i32, i64) -> i64 tail
;; sig2 = (i64 vmctx, i32, i32) -> i32 tail
;; fn0 = colocated u805306368:9 sig1
-;; fn1 = colocated u805306368:36 sig2
+;; fn1 = colocated u805306368:34 sig2
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/copying/ref-cast.wat b/tests/disas/gc/copying/ref-cast.wat
index b78acee385..1be0c3bbd0 100644
--- a/tests/disas/gc/copying/ref-cast.wat
+++ b/tests/disas/gc/copying/ref-cast.wat
@@ -17,7 +17,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/copying/ref-test-concrete-func-type.wat b/tests/disas/gc/copying/ref-test-concrete-func-type.wat
index 24e8ea9b0e..4bc0f9e62b 100644
--- a/tests/disas/gc/copying/ref-test-concrete-func-type.wat
+++ b/tests/disas/gc/copying/ref-test-concrete-func-type.wat
@@ -13,7 +13,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i64):
diff --git a/tests/disas/gc/copying/ref-test-concrete-type.wat b/tests/disas/gc/copying/ref-test-concrete-type.wat
index 858c1e9c99..6f3e0ba068 100644
--- a/tests/disas/gc/copying/ref-test-concrete-type.wat
+++ b/tests/disas/gc/copying/ref-test-concrete-type.wat
@@ -16,7 +16,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/drc/br-on-cast-fail.wat b/tests/disas/gc/drc/br-on-cast-fail.wat
index 779728b16b..c761cfbc99 100644
--- a/tests/disas/gc/drc/br-on-cast-fail.wat
+++ b/tests/disas/gc/drc/br-on-cast-fail.wat
@@ -27,7 +27,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/drc/br-on-cast.wat b/tests/disas/gc/drc/br-on-cast.wat
index 8c73f1c2d2..e014d6d4bb 100644
--- a/tests/disas/gc/drc/br-on-cast.wat
+++ b/tests/disas/gc/drc/br-on-cast.wat
@@ -27,7 +27,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/drc/call-indirect-and-subtyping.wat b/tests/disas/gc/drc/call-indirect-and-subtyping.wat
index cb164e1b6c..ad12f0d2f0 100644
--- a/tests/disas/gc/drc/call-indirect-and-subtyping.wat
+++ b/tests/disas/gc/drc/call-indirect-and-subtyping.wat
@@ -26,7 +26,7 @@
;; sig1 = (i64 vmctx, i32, i64) -> i64 tail
;; sig2 = (i64 vmctx, i32, i32) -> i32 tail
;; fn0 = colocated u805306368:9 sig1
-;; fn1 = colocated u805306368:36 sig2
+;; fn1 = colocated u805306368:34 sig2
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/drc/ref-cast.wat b/tests/disas/gc/drc/ref-cast.wat
index acb1d1cd6c..fb473992d6 100644
--- a/tests/disas/gc/drc/ref-cast.wat
+++ b/tests/disas/gc/drc/ref-cast.wat
@@ -18,7 +18,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/drc/ref-test-concrete-func-type.wat b/tests/disas/gc/drc/ref-test-concrete-func-type.wat
index be90e6da8c..54b1268c10 100644
--- a/tests/disas/gc/drc/ref-test-concrete-func-type.wat
+++ b/tests/disas/gc/drc/ref-test-concrete-func-type.wat
@@ -14,7 +14,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i64):
diff --git a/tests/disas/gc/drc/ref-test-concrete-type.wat b/tests/disas/gc/drc/ref-test-concrete-type.wat
index 8d1d7b60c4..6d0266369e 100644
--- a/tests/disas/gc/drc/ref-test-concrete-type.wat
+++ b/tests/disas/gc/drc/ref-test-concrete-type.wat
@@ -17,7 +17,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/null/br-on-cast-fail.wat b/tests/disas/gc/null/br-on-cast-fail.wat
index 036149471d..102674f7d2 100644
--- a/tests/disas/gc/null/br-on-cast-fail.wat
+++ b/tests/disas/gc/null/br-on-cast-fail.wat
@@ -27,7 +27,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/null/br-on-cast.wat b/tests/disas/gc/null/br-on-cast.wat
index 3b2b44cf6b..84ba976d8f 100644
--- a/tests/disas/gc/null/br-on-cast.wat
+++ b/tests/disas/gc/null/br-on-cast.wat
@@ -27,7 +27,7 @@
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
;; sig1 = (i64 vmctx, i64) tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/null/call-indirect-and-subtyping.wat b/tests/disas/gc/null/call-indirect-and-subtyping.wat
index da487877fe..36b5114a88 100644
--- a/tests/disas/gc/null/call-indirect-and-subtyping.wat
+++ b/tests/disas/gc/null/call-indirect-and-subtyping.wat
@@ -26,7 +26,7 @@
;; sig1 = (i64 vmctx, i32, i64) -> i64 tail
;; sig2 = (i64 vmctx, i32, i32) -> i32 tail
;; fn0 = colocated u805306368:9 sig1
-;; fn1 = colocated u805306368:36 sig2
+;; fn1 = colocated u805306368:34 sig2
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/null/ref-cast.wat b/tests/disas/gc/null/ref-cast.wat
index 6d428d1e7f..d62c24edd8 100644
--- a/tests/disas/gc/null/ref-cast.wat
+++ b/tests/disas/gc/null/ref-cast.wat
@@ -18,7 +18,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/gc/null/ref-test-concrete-func-type.wat b/tests/disas/gc/null/ref-test-concrete-func-type.wat
index 03caba586c..9120b465ea 100644
--- a/tests/disas/gc/null/ref-test-concrete-func-type.wat
+++ b/tests/disas/gc/null/ref-test-concrete-func-type.wat
@@ -14,7 +14,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i64):
diff --git a/tests/disas/gc/null/ref-test-concrete-type.wat b/tests/disas/gc/null/ref-test-concrete-type.wat
index c53b4e8d92..a18a4cbfdd 100644
--- a/tests/disas/gc/null/ref-test-concrete-type.wat
+++ b/tests/disas/gc/null/ref-test-concrete-type.wat
@@ -17,7 +17,7 @@
;; gv5 = load.i64 notrap aligned readonly can_move gv4+32
;; gv6 = load.i64 notrap aligned gv4+40
;; sig0 = (i64 vmctx, i32, i32) -> i32 tail
-;; fn0 = colocated u805306368:36 sig0
+;; fn0 = colocated u805306368:34 sig0
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64, v2: i32):
diff --git a/tests/disas/metadata-for-internal-asserts.wat b/tests/disas/metadata-for-internal-asserts.wat
index 1a8312d70e..4dd6039b51 100644
--- a/tests/disas/metadata-for-internal-asserts.wat
+++ b/tests/disas/metadata-for-internal-asserts.wat
@@ -39,7 +39,7 @@
;; popq %rbp
;; retq
;; 5e: movq 0x10(%rbx), %rax
-;; 62: movq 0x1a0(%rax), %rax
+;; 62: movq 0x190(%rax), %rax
;; 69: movq %rbx, %rdi
;; 6c: callq *%rax
;; 6e: ud2
diff --git a/tests/disas/riscv64-component-builtins-asm.wat b/tests/disas/riscv64-component-builtins-asm.wat
index 9ffc63faa9..adb9364fa3 100644
--- a/tests/disas/riscv64-component-builtins-asm.wat
+++ b/tests/disas/riscv64-component-builtins-asm.wat
@@ -54,7 +54,7 @@
;; ret
;; mv a1, s5
;; ld a0, 0x10(a1)
-;; ld a2, 0x1a0(a0)
+;; ld a2, 0x190(a0)
;; mv a0, a1
;; jalr a2
;; .byte 0x00, 0x00, 0x00, 0x00
diff --git a/tests/disas/riscv64-component-builtins.wat b/tests/disas/riscv64-component-builtins.wat
index d202882c5d..e1ab366a08 100644
--- a/tests/disas/riscv64-component-builtins.wat
+++ b/tests/disas/riscv64-component-builtins.wat
@@ -34,7 +34,7 @@
;;
;; block1 cold:
;; v15 = load.i64 notrap aligned readonly v1+16
-;; v16 = load.i64 notrap aligned readonly v15+416
+;; v16 = load.i64 notrap aligned readonly v15+400
;; call_indirect sig1, v16(v1)
;; trap user1
;;
diff --git a/tests/disas/stack-switching/resume-suspend-data-passing.wat b/tests/disas/stack-switching/resume-suspend-data-passing.wat
index e64a971569..148afc8ec5 100644
--- a/tests/disas/stack-switching/resume-suspend-data-passing.wat
+++ b/tests/disas/stack-switching/resume-suspend-data-passing.wat
@@ -153,7 +153,7 @@
;; sig0 = (i64 vmctx, i32) -> i64 tail
;; sig1 = (i64 vmctx, i64, i32, i32) -> i64 tail
;; fn0 = colocated u805306368:7 sig0
-;; fn1 = colocated u805306368:53 sig1
+;; fn1 = colocated u805306368:51 sig1
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64):
diff --git a/tests/disas/stack-switching/resume-suspend.wat b/tests/disas/stack-switching/resume-suspend.wat
index 3505ddb759..96430f7297 100644
--- a/tests/disas/stack-switching/resume-suspend.wat
+++ b/tests/disas/stack-switching/resume-suspend.wat
@@ -114,7 +114,7 @@
;; sig0 = (i64 vmctx, i32) -> i64 tail
;; sig1 = (i64 vmctx, i64, i32, i32) -> i64 tail
;; fn0 = colocated u805306368:7 sig0
-;; fn1 = colocated u805306368:53 sig1
+;; fn1 = colocated u805306368:51 sig1
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64):
diff --git a/tests/disas/stack-switching/symmetric-switch.wat b/tests/disas/stack-switching/symmetric-switch.wat
index faa06ffd06..578e0f1cb7 100644
--- a/tests/disas/stack-switching/symmetric-switch.wat
+++ b/tests/disas/stack-switching/symmetric-switch.wat
@@ -34,7 +34,7 @@
;; sig0 = (i64 vmctx, i32) -> i64 tail
;; sig1 = (i64 vmctx, i64, i32, i32) -> i64 tail
;; fn0 = colocated u805306368:7 sig0
-;; fn1 = colocated u805306368:53 sig1
+;; fn1 = colocated u805306368:51 sig1
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64):
@@ -249,7 +249,7 @@
;; sig0 = (i64 vmctx, i32) -> i64 tail
;; sig1 = (i64 vmctx, i64, i32, i32) -> i64 tail
;; fn0 = colocated u805306368:7 sig0
-;; fn1 = colocated u805306368:53 sig1
+;; fn1 = colocated u805306368:51 sig1
;; stack_limit = gv2
;;
;; block0(v0: i64, v1: i64):
diff --git a/tests/disas/x64-simd-round-without-sse41.wat b/tests/disas/x64-simd-round-without-sse41.wat
index def5b2b8b5..cca72da966 100644
--- a/tests/disas/x64-simd-round-without-sse41.wat
+++ b/tests/disas/x64-simd-round-without-sse41.wat
@@ -17,7 +17,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f32) -> f32 tail
-;; fn0 = colocated u805306368:39 sig0
+;; fn0 = colocated u805306368:37 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -49,7 +49,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f32) -> f32 tail
-;; fn0 = colocated u805306368:41 sig0
+;; fn0 = colocated u805306368:39 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -81,7 +81,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f32) -> f32 tail
-;; fn0 = colocated u805306368:43 sig0
+;; fn0 = colocated u805306368:41 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -113,7 +113,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f32) -> f32 tail
-;; fn0 = colocated u805306368:45 sig0
+;; fn0 = colocated u805306368:43 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -145,7 +145,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f64) -> f64 tail
-;; fn0 = colocated u805306368:40 sig0
+;; fn0 = colocated u805306368:38 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -171,7 +171,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f64) -> f64 tail
-;; fn0 = colocated u805306368:42 sig0
+;; fn0 = colocated u805306368:40 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -197,7 +197,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f64) -> f64 tail
-;; fn0 = colocated u805306368:44 sig0
+;; fn0 = colocated u805306368:42 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;
@@ -223,7 +223,7 @@
;; gv2 = load.i64 notrap aligned gv1+24
;; gv3 = vmctx
;; sig0 = (i64 vmctx, f64) -> f64 tail
-;; fn0 = colocated u805306368:46 sig0
+;; fn0 = colocated u805306368:44 sig0
;; const0 = 0x00000000000000000000000000000000
;; stack_limit = gv2
;;