diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7de8c5348c..72462c24bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: with: submodules: true - uses: ./.github/actions/install-rust - - uses: bytecodealliance/wasmtime/.github/actions/binary-compatible-builds@main + - uses: bytecodealliance/wasmtime/.github/actions/binary-compatible-builds@release-28.0.0 with: name: ${{ matrix.build }} if: matrix.build != 'wasm32-wasip1' diff --git a/crates/wasm-smith/src/core.rs b/crates/wasm-smith/src/core.rs index d9d406600d..db9309cb09 100644 --- a/crates/wasm-smith/src/core.rs +++ b/crates/wasm-smith/src/core.rs @@ -900,7 +900,7 @@ impl Module { } fn arbitrary_super_type_of_val_type( - &mut self, + &self, u: &mut Unstructured, ty: ValType, ) -> Result { @@ -938,8 +938,23 @@ impl Module { ) -> Result { use {AbstractHeapType as AHT, CompositeInnerType as CT, HeapType as HT}; + // If GC is disabled then favor the "top" type of the input type. if !self.config.gc_enabled { - return Ok(ty); + return Ok(match ty { + HeapType::Concrete(i) => { + let CompositeType { inner, shared } = &self.ty(i).composite_type; + let ty = match inner { + CompositeInnerType::Array(_) => AbstractHeapType::Array, + CompositeInnerType::Struct(_) => AbstractHeapType::Struct, + CompositeInnerType::Func(_) => AbstractHeapType::Func, + }; + HeapType::Abstract { + shared: *shared, + ty, + } + } + HeapType::Abstract { .. } => ty, + }); } let mut choices = vec![ty]; diff --git a/crates/wasm-smith/src/core/code_builder.rs b/crates/wasm-smith/src/core/code_builder.rs index c8c2671474..95bd8c3c70 100644 --- a/crates/wasm-smith/src/core/code_builder.rs +++ b/crates/wasm-smith/src/core/code_builder.rs @@ -2654,21 +2654,28 @@ fn select_valid(module: &Module, builder: &mut CodeBuilder) -> bool { } fn select( - _: &mut Unstructured, - _module: &Module, + u: &mut Unstructured, + module: &Module, builder: &mut CodeBuilder, instructions: &mut Vec, ) -> Result<()> { builder.pop_operand(); - let t = builder.pop_operand(); - let u = builder.pop_operand(); - let ty = t.or(u); - builder.allocs.operands.push(ty); - match ty { - Some(ty @ ValType::Ref(_)) => instructions.push(Instruction::TypedSelect(ty)), + let a = builder.pop_operand(); + let b = builder.pop_operand(); + let ty = a.or(b); + let ty = match ty { + Some(ty @ ValType::Ref(_)) => { + let ty = module.arbitrary_super_type_of_val_type(u, ty)?; + instructions.push(Instruction::TypedSelect(ty)); + Some(ty) + } Some(ValType::I32) | Some(ValType::I64) | Some(ValType::F32) | Some(ValType::F64) - | Some(ValType::V128) | None => instructions.push(Instruction::Select), - } + | Some(ValType::V128) | None => { + instructions.push(Instruction::Select); + ty + } + }; + builder.allocs.operands.push(ty); Ok(()) } @@ -5442,13 +5449,9 @@ fn ref_func( ) -> Result<()> { let i = *u.choose(&builder.allocs.referenced_functions)?; let ty = module.funcs[usize::try_from(i).unwrap()].0; - builder.push_operand(Some(ValType::Ref(if module.config.gc_enabled { - RefType { - nullable: false, - heap_type: HeapType::Concrete(ty), - } - } else { - RefType::FUNCREF + builder.push_operand(Some(ValType::Ref(RefType { + nullable: false, + heap_type: HeapType::Concrete(ty), }))); instructions.push(Instruction::RefFunc(i)); Ok(())