diff --git a/ci/generate-spec-tests.rs b/ci/generate-spec-tests.rs index dbc9d0b2c2..fcd79dd9bc 100644 --- a/ci/generate-spec-tests.rs +++ b/ci/generate-spec-tests.rs @@ -40,7 +40,12 @@ fn copy_test(src: &Path, dst: &Path) { return; } - let mut contents = format!(";; RUN: wast \\\n"); + let directive = match dst.file_name().and_then(|s| s.to_str()) { + Some("exact-func-import.wast") => "FAIL", + Some(_) | None => "RUN", + }; + + let mut contents = format!(";; {directive}: wast \\\n"); contents.push_str(";; --assert default \\\n"); // Allow certain assert_malformed tests to be interpreted as assert_invalid @@ -73,8 +78,7 @@ fn copy_test(src: &Path, dst: &Path) { Some("threads") => "wasm1,threads", Some("custom-page-sizes") => "wasm3,custom-page-sizes", Some("wide-arithmetic") => "wasm3,wide-arithmetic", - // not implemented yet - Some("custom-descriptors") => return, + Some("custom-descriptors") => "wasm3,custom-descriptors", Some(proposal) => panic!("unsupported proposal: {}", proposal), }; contents.push_str(&format!(";; --features={features} \\\n")); diff --git a/crates/wasm-encoder/src/core/code.rs b/crates/wasm-encoder/src/core/code.rs index fb87217a5a..a738ceb63c 100644 --- a/crates/wasm-encoder/src/core/code.rs +++ b/crates/wasm-encoder/src/core/code.rs @@ -1316,6 +1316,20 @@ pub enum Instruction<'a> { I64Sub128, I64MulWideS, I64MulWideU, + + RefGetDesc(u32), + RefCastDescNonNull(HeapType), + RefCastDescNullable(HeapType), + BrOnCastDesc { + relative_depth: u32, + from_ref_type: RefType, + to_ref_type: RefType, + }, + BrOnCastDescFail { + relative_depth: u32, + from_ref_type: RefType, + to_ref_type: RefType, + }, } impl Encode for Instruction<'_> { @@ -2144,6 +2158,19 @@ impl Encode for Instruction<'_> { Instruction::I64Sub128 => sink.i64_sub128(), Instruction::I64MulWideS => sink.i64_mul_wide_s(), Instruction::I64MulWideU => sink.i64_mul_wide_u(), + Instruction::RefGetDesc(type_index) => sink.ref_get_desc(type_index), + Instruction::RefCastDescNonNull(hty) => sink.ref_cast_desc_non_null(hty), + Instruction::RefCastDescNullable(hty) => sink.ref_cast_desc_nullable(hty), + Instruction::BrOnCastDesc { + relative_depth, + from_ref_type, + to_ref_type, + } => sink.br_on_cast_desc(relative_depth, from_ref_type, to_ref_type), + Instruction::BrOnCastDescFail { + relative_depth, + from_ref_type, + to_ref_type, + } => sink.br_on_cast_desc_fail(relative_depth, from_ref_type, to_ref_type), }; } } diff --git a/crates/wasm-encoder/src/core/instructions.rs b/crates/wasm-encoder/src/core/instructions.rs index 8ae2fcb784..bc0e226077 100644 --- a/crates/wasm-encoder/src/core/instructions.rs +++ b/crates/wasm-encoder/src/core/instructions.rs @@ -4609,4 +4609,62 @@ impl<'a> InstructionSink<'a> { 22u32.encode(self.sink); self } + + /// Encode [`Instruction::RefGetDesc`]. + pub fn ref_get_desc(&mut self, type_index: u32) -> &mut Self { + self.sink.push(0xFB); + 34u32.encode(self.sink); + type_index.encode(self.sink); + self + } + + /// Encode [`Instruction::RefCastDescNonNull`]. + pub fn ref_cast_desc_non_null(&mut self, ht: HeapType) -> &mut Self { + self.sink.push(0xFB); + 35u32.encode(self.sink); + ht.encode(self.sink); + self + } + + /// Encode [`Instruction::RefCastDescNullable`]. + pub fn ref_cast_desc_nullable(&mut self, ht: HeapType) -> &mut Self { + self.sink.push(0xFB); + 36u32.encode(self.sink); + ht.encode(self.sink); + self + } + + /// Encode [`Instruction::BrOnCastDesc`]. + pub fn br_on_cast_desc( + &mut self, + relative_depth: u32, + from_ref_type: RefType, + to_ref_type: RefType, + ) -> &mut Self { + self.sink.push(0xFB); + 37u32.encode(self.sink); + let cast_flags = (from_ref_type.nullable as u8) | ((to_ref_type.nullable as u8) << 1); + self.sink.push(cast_flags); + relative_depth.encode(self.sink); + from_ref_type.heap_type.encode(self.sink); + to_ref_type.heap_type.encode(self.sink); + self + } + + /// Encode [`Instruction::BrOnCastDescFail`]. + pub fn br_on_cast_desc_fail( + &mut self, + relative_depth: u32, + from_ref_type: RefType, + to_ref_type: RefType, + ) -> &mut Self { + self.sink.push(0xFB); + 38u32.encode(self.sink); + let cast_flags = (from_ref_type.nullable as u8) | ((to_ref_type.nullable as u8) << 1); + self.sink.push(cast_flags); + relative_depth.encode(self.sink); + from_ref_type.heap_type.encode(self.sink); + to_ref_type.heap_type.encode(self.sink); + self + } } diff --git a/crates/wasm-encoder/src/core/types.rs b/crates/wasm-encoder/src/core/types.rs index a84ffd3fc3..9bc9faddb1 100644 --- a/crates/wasm-encoder/src/core/types.rs +++ b/crates/wasm-encoder/src/core/types.rs @@ -22,6 +22,10 @@ pub struct CompositeType { /// Whether the type is shared. This is part of the /// shared-everything-threads proposal. pub shared: bool, + /// Optional descriptor attribute. + pub descriptor: Option, + /// Optional describes attribute. + pub describes: Option, } /// A [`CompositeType`] can contain one of these types. @@ -362,6 +366,8 @@ pub enum HeapType { /// A concrete Wasm-defined type at the given index. Concrete(u32), + /// An exact type. + Exact(u32), } impl HeapType { @@ -402,6 +408,11 @@ impl Encode for HeapType { // Note that this is encoded as a signed type rather than unsigned // as it's decoded as an s33 HeapType::Concrete(i) => i64::from(*i).encode(sink), + // Exact type is u32 + HeapType::Exact(i) => { + sink.push(0x62); + u32::from(*i).encode(sink) + } } } } @@ -669,6 +680,14 @@ impl<'a> CoreTypeEncoder<'a> { if ty.composite_type.shared { self.bytes.push(0x65); } + if let Some(index) = ty.composite_type.describes { + self.bytes.push(0x4c); + index.encode(self.bytes); + } + if let Some(index) = ty.composite_type.descriptor { + self.bytes.push(0x4d); + index.encode(self.bytes); + } match &ty.composite_type.inner { CompositeInnerType::Func(ty) => { self.encode_function(ty.params().iter().copied(), ty.results().iter().copied()) @@ -715,6 +734,8 @@ mod tests { composite_type: CompositeType { inner: CompositeInnerType::Func(FuncType::new([], [])), shared: false, + descriptor: None, + describes: None, }, }); diff --git a/crates/wasm-encoder/src/reencode.rs b/crates/wasm-encoder/src/reencode.rs index 46f87d98bd..c9ba454172 100644 --- a/crates/wasm-encoder/src/reencode.rs +++ b/crates/wasm-encoder/src/reencode.rs @@ -1170,6 +1170,14 @@ pub mod utils { Ok(crate::CompositeType { inner, shared: composite_ty.shared, + descriptor: composite_ty + .descriptor_idx + .map(|i| reencoder.type_index_unpacked(i.unpack())) + .transpose()?, + describes: composite_ty + .describes_idx + .map(|i| reencoder.type_index_unpacked(i.unpack())) + .transpose()?, }) } @@ -1269,6 +1277,9 @@ pub mod utils { wasmparser::HeapType::Concrete(i) => { crate::HeapType::Concrete(reencoder.type_index_unpacked(i)?) } + wasmparser::HeapType::Exact(i) => { + crate::HeapType::Exact(reencoder.type_index_unpacked(i)?) + } wasmparser::HeapType::Abstract { shared, ty } => crate::HeapType::Abstract { shared, ty: reencoder.abstract_heap_type(ty)?, diff --git a/crates/wasm-mutate/src/module.rs b/crates/wasm-mutate/src/module.rs index 0fd6755af7..450d6a9606 100644 --- a/crates/wasm-mutate/src/module.rs +++ b/crates/wasm-mutate/src/module.rs @@ -87,6 +87,7 @@ pub fn map_ref_type(ref_ty: wasmparser::RefType) -> Result { nullable: ref_ty.is_nullable(), heap_type: match ref_ty.heap_type() { wasmparser::HeapType::Concrete(i) => HeapType::Concrete(i.as_module_index().unwrap()), + wasmparser::HeapType::Exact(i) => HeapType::Exact(i.as_module_index().unwrap()), wasmparser::HeapType::Abstract { shared, ty } => { let ty = ty.into(); HeapType::Abstract { shared, ty } diff --git a/crates/wasm-smith/src/config.rs b/crates/wasm-smith/src/config.rs index 4d10420751..f7f248ff6c 100644 --- a/crates/wasm-smith/src/config.rs +++ b/crates/wasm-smith/src/config.rs @@ -428,6 +428,12 @@ define_config! { /// Defaults to `true`. pub gc_enabled: bool = true, + /// Determines whether the custom descriptors proposal is enabled when + /// generating a Wasm module. + /// + /// Defaults to `true`. + pub custom_descriptors_enabled: bool = false, + /// Determines whether the custom-page-sizes proposal is enabled when /// generating a Wasm module. /// @@ -876,6 +882,7 @@ impl<'a> Arbitrary<'a> for Config { custom_page_sizes_enabled: false, wide_arithmetic_enabled: false, shared_everything_threads_enabled: false, + custom_descriptors_enabled: false, }; config.sanitize(); Ok(config) @@ -908,6 +915,7 @@ impl Config { // also disable shared-everything-threads. if !self.gc_enabled { self.shared_everything_threads_enabled = false; + self.custom_descriptors_enabled = false; } // If simd is disabled then disable all relaxed simd instructions as @@ -972,6 +980,10 @@ impl Config { ); features.set(WasmFeatures::EXTENDED_CONST, self.extended_const_enabled); features.set(WasmFeatures::WIDE_ARITHMETIC, self.wide_arithmetic_enabled); + features.set( + WasmFeatures::CUSTOM_DESCRIPTORS, + self.custom_descriptors_enabled, + ); features } diff --git a/crates/wasm-smith/src/core.rs b/crates/wasm-smith/src/core.rs index e90de0d091..d9a5932639 100644 --- a/crates/wasm-smith/src/core.rs +++ b/crates/wasm-smith/src/core.rs @@ -283,6 +283,8 @@ impl SubType { pub(crate) struct CompositeType { pub inner: CompositeInnerType, pub shared: bool, + pub descriptor: Option, + pub describes: Option, } impl CompositeType { @@ -291,6 +293,8 @@ impl CompositeType { Self { inner: CompositeInnerType::Func(func), shared, + descriptor: None, + describes: None, } } @@ -328,6 +332,8 @@ impl From<&CompositeType> for wasm_encoder::CompositeType { wasm_encoder::CompositeType { shared: ty.shared, inner, + descriptor: ty.descriptor, + describes: ty.describes, } } } @@ -532,7 +538,8 @@ impl Module { } } - (HT::Concrete(a), HT::Abstract { shared, ty }) => { + (HT::Concrete(a), HT::Abstract { shared, ty }) + | (HT::Exact(a), HT::Abstract { shared, ty }) => { let a_ty = &self.ty(a).composite_type; if a_ty.shared != shared { return false; @@ -546,7 +553,8 @@ impl Module { } } - (HT::Abstract { shared, ty }, HT::Concrete(b)) => { + (HT::Abstract { shared, ty }, HT::Concrete(b)) + | (HT::Abstract { shared, ty }, HT::Exact(b)) => { let b_ty = &self.ty(b).composite_type; if shared != b_ty.shared { return false; @@ -558,7 +566,7 @@ impl Module { } } - (HT::Concrete(mut a), HT::Concrete(b)) => loop { + (HT::Concrete(mut a), HT::Concrete(b)) | (HT::Exact(mut a), HT::Concrete(b)) => loop { if a == b { return true; } @@ -568,6 +576,10 @@ impl Module { return false; } }, + + (HT::Concrete(a), HT::Exact(b)) | (HT::Exact(a), HT::Exact(b)) => { + return a == b; + } } } @@ -698,6 +710,8 @@ impl Module { let composite_type = CompositeType { inner: CompositeInnerType::Func(func_type), shared, + descriptor: None, + describes: None, }; return Ok(SubType { is_final: true, @@ -870,6 +884,12 @@ impl Module { if let Some(subs) = self.super_to_sub_types.get(&idx) { choices.extend(subs.iter().copied().map(HT::Concrete)); } + if self.config.custom_descriptors_enabled { + choices.push(HT::Exact(idx)); + if let Some(subs) = self.super_to_sub_types.get(&idx) { + choices.extend(subs.iter().copied().map(HT::Concrete)); + } + } match self .types .get(usize::try_from(idx).unwrap()) @@ -892,6 +912,7 @@ impl Module { } } } + HT::Exact(_) => (), } Ok(*u.choose(&choices)?) } @@ -1036,6 +1057,7 @@ impl Module { idx = supertype; } } + HT::Exact(_) => (), } Ok(*u.choose(&choices)?) } @@ -1048,6 +1070,8 @@ impl Module { return Ok(CompositeType { shared, inner: CT::Func(self.propagate_shared(shared, |m| m.arbitrary_func_type(u))?), + descriptor: None, + describes: None, }); } @@ -1057,14 +1081,20 @@ impl Module { inner: CT::Array(ArrayType( self.propagate_shared(shared, |m| m.arbitrary_field_type(u))?, )), + descriptor: None, + describes: None, }), 1 => Ok(CompositeType { shared, inner: CT::Func(self.propagate_shared(shared, |m| m.arbitrary_func_type(u))?), + descriptor: None, + describes: None, }), 2 => Ok(CompositeType { shared, inner: CT::Struct(self.propagate_shared(shared, |m| m.arbitrary_struct_type(u))?), + descriptor: None, // TODO generate descriptor info when custom_descriptors_enabled + describes: None, }), _ => unreachable!(), } @@ -2972,7 +3002,9 @@ impl Module { fn is_shared_ref_type(&self, ty: RefType) -> bool { match ty.heap_type { HeapType::Abstract { shared, .. } => shared, - HeapType::Concrete(i) => self.types[i as usize].composite_type.shared, + HeapType::Concrete(i) | HeapType::Exact(i) => { + self.types[i as usize].composite_type.shared + } } } @@ -3482,6 +3514,14 @@ impl TryFrom for CompositeType { Ok(CompositeType { inner: inner_type, shared: value.shared, + descriptor: value + .descriptor_idx + .map(|idx| idx.as_module_index().ok_or(())) + .transpose()?, + describes: value + .describes_idx + .map(|idx| idx.as_module_index().ok_or(())) + .transpose()?, }) } } diff --git a/crates/wasmparser/src/arity.rs b/crates/wasmparser/src/arity.rs index 9eef6fa828..6b3c03e77c 100644 --- a/crates/wasmparser/src/arity.rs +++ b/crates/wasmparser/src/arity.rs @@ -160,8 +160,26 @@ fn visit_call_indirect(module: &dyn ModuleArity, ty: u32, _table: u32) -> Option } fn visit_struct_new(module: &dyn ModuleArity, ty: u32) -> Option<(u32, u32)> { - let (params, _results) = module.sub_type_arity(module.sub_type_at(ty)?)?; - Some((params, 1)) + let ty = module.sub_type_at(ty)?; + let descriptor = if let Some(_) = ty.composite_type.descriptor_idx { + 1 + } else { + 0 + }; + let (params, _results) = module.sub_type_arity(ty)?; + Some((params + descriptor, 1)) +} + +fn visit_struct_new_default(module: &dyn ModuleArity, ty: u32) -> Option<(u32, u32)> { + let ty = module.sub_type_at(ty)?; + Some(( + if let Some(_) = ty.composite_type.descriptor_idx { + 1 + } else { + 0 + }, + 1, + )) } fn visit_array_new_fixed(_module: &dyn ModuleArity, _ty: u32, size: u32) -> Option<(u32, u32)> { @@ -289,3 +307,23 @@ fn visit_switch(module: &dyn ModuleArity, cont: u32, _tag: u32) -> Option<(u32, module.sub_type_arity(module.sub_type_of_ref_type(&last_param.as_reference_type()?)?)?; Some((params, cont_params)) } + +fn visit_br_on_cast_desc( + module: &dyn ModuleArity, + depth: u32, + _from: RefType, + _to: RefType, +) -> Option<(u32, u32)> { + let (params, _) = visit_br(module, depth)?; + Some((params + 1, params)) +} + +fn visit_br_on_cast_desc_fail( + module: &dyn ModuleArity, + depth: u32, + _from: RefType, + _to: RefType, +) -> Option<(u32, u32)> { + let (params, _) = visit_br(module, depth)?; + Some((params + 1, params)) +} diff --git a/crates/wasmparser/src/binary_reader.rs b/crates/wasmparser/src/binary_reader.rs index 611d8ee98f..d70849e074 100644 --- a/crates/wasmparser/src/binary_reader.rs +++ b/crates/wasmparser/src/binary_reader.rs @@ -1362,6 +1362,56 @@ impl<'a> BinaryReader<'a> { 0x1d => visitor.visit_i31_get_s(), 0x1e => visitor.visit_i31_get_u(), + 0x22 => visitor.visit_ref_get_desc(self.read()?), + 0x23 => visitor.visit_ref_cast_desc_non_null(self.read()?), + 0x24 => visitor.visit_ref_cast_desc_nullable(self.read()?), + 0x25 => { + let pos = self.original_position(); + let cast_flags = self.read_u8()?; + let relative_depth = self.read_var_u32()?; + let (from_type_nullable, to_type_nullable) = match cast_flags { + 0b00 => (false, false), + 0b01 => (true, false), + 0b10 => (false, true), + 0b11 => (true, true), + _ => bail!(pos, "invalid cast flags: {cast_flags:08b}"), + }; + let from_heap_type = self.read()?; + let from_ref_type = + RefType::new(from_type_nullable, from_heap_type).ok_or_else(|| { + format_err!(pos, "implementation error: type index too large") + })?; + let to_heap_type = self.read()?; + let to_ref_type = + RefType::new(to_type_nullable, to_heap_type).ok_or_else(|| { + format_err!(pos, "implementation error: type index too large") + })?; + visitor.visit_br_on_cast_desc(relative_depth, from_ref_type, to_ref_type) + } + 0x26 => { + let pos = self.original_position(); + let cast_flags = self.read_u8()?; + let relative_depth = self.read_var_u32()?; + let (from_type_nullable, to_type_nullable) = match cast_flags { + 0 => (false, false), + 1 => (true, false), + 2 => (false, true), + 3 => (true, true), + _ => bail!(pos, "invalid cast flags: {cast_flags:08b}"), + }; + let from_heap_type = self.read()?; + let from_ref_type = + RefType::new(from_type_nullable, from_heap_type).ok_or_else(|| { + format_err!(pos, "implementation error: type index too large") + })?; + let to_heap_type = self.read()?; + let to_ref_type = + RefType::new(to_type_nullable, to_heap_type).ok_or_else(|| { + format_err!(pos, "implementation error: type index too large") + })?; + visitor.visit_br_on_cast_desc_fail(relative_depth, from_ref_type, to_ref_type) + } + _ => bail!(pos, "unknown 0xfb subopcode: 0x{code:x}"), }) } diff --git a/crates/wasmparser/src/features.rs b/crates/wasmparser/src/features.rs index 6072bb44c0..c3fcbeaa63 100644 --- a/crates/wasmparser/src/features.rs +++ b/crates/wasmparser/src/features.rs @@ -300,6 +300,9 @@ define_wasm_features! { /// /// This is a subcomponent of the "lime1" feature. pub bulk_memory_opt: BULK_MEMORY_OPT(1 << 35) = true; + + // Custom descriptors proposal. + pub custom_descriptors: CUSTOM_DESCRIPTORS(1 << 36) = false; } } diff --git a/crates/wasmparser/src/lib.rs b/crates/wasmparser/src/lib.rs index 818322247f..bf2b3f6466 100644 --- a/crates/wasmparser/src/lib.rs +++ b/crates/wasmparser/src/lib.rs @@ -259,7 +259,7 @@ macro_rules! _for_each_operator_group { @gc { RefEq => visit_ref_eq (arity 2 -> 1) StructNew { struct_type_index: u32 } => visit_struct_new (arity custom) - StructNewDefault { struct_type_index: u32 } => visit_struct_new_default (arity 0 -> 1) + StructNewDefault { struct_type_index: u32 } => visit_struct_new_default (arity custom) StructGet { struct_type_index: u32, field_index: u32 } => visit_struct_get (arity 1 -> 1) StructGetS { struct_type_index: u32, field_index: u32 } => visit_struct_get_s (arity 1 -> 1) StructGetU { struct_type_index: u32, field_index: u32 } => visit_struct_get_u (arity 1 -> 1) @@ -297,6 +297,20 @@ macro_rules! _for_each_operator_group { RefI31 => visit_ref_i31 (arity 1 -> 1) I31GetS => visit_i31_get_s (arity 1 -> 1) I31GetU => visit_i31_get_u (arity 1 -> 1) + + RefGetDesc { type_index: u32 } => visit_ref_get_desc (arity 1 -> 1) + RefCastDescNonNull { hty: $crate::HeapType } => visit_ref_cast_desc_non_null (arity 2 -> 1) + RefCastDescNullable { hty: $crate::HeapType } => visit_ref_cast_desc_nullable (arity 2 -> 1) + BrOnCastDesc { + relative_depth: u32, + from_ref_type: $crate::RefType, + to_ref_type: $crate::RefType + } => visit_br_on_cast_desc (arity custom) + BrOnCastDescFail { + relative_depth: u32, + from_ref_type: $crate::RefType, + to_ref_type: $crate::RefType + } => visit_br_on_cast_desc_fail (arity custom) } // 0xFC operators diff --git a/crates/wasmparser/src/readers/core/types.rs b/crates/wasmparser/src/readers/core/types.rs index 5b35dccbf9..bbb6b7daa9 100644 --- a/crates/wasmparser/src/readers/core/types.rs +++ b/crates/wasmparser/src/readers/core/types.rs @@ -489,6 +489,8 @@ impl SubType { composite_type: CompositeType { inner: CompositeInnerType::Func(signature), shared, + descriptor_idx: None, + describes_idx: None, }, } } @@ -523,6 +525,12 @@ impl SubType { if let Some(idx) = &mut self.supertype_idx { f(idx)?; } + if let Some(idx) = &mut self.composite_type.descriptor_idx { + f(idx)?; + } + if let Some(idx) = &mut self.composite_type.describes_idx { + f(idx)?; + } match &mut self.composite_type.inner { CompositeInnerType::Func(ty) => { for ty in ty.params_mut() { @@ -580,6 +588,10 @@ pub struct CompositeType { /// Is the composite type shared? This is part of the /// shared-everything-threads proposal. pub shared: bool, + /// The descriptor type. + pub descriptor_idx: Option, + /// The descriptor for type. + pub describes_idx: Option, } impl fmt::Display for CompositeType { @@ -936,7 +948,11 @@ impl ValType { ValType::Ref(r) => { if let Some(mut idx) = r.type_index() { map(&mut idx)?; - *r = RefType::concrete(r.is_nullable(), idx); + *r = if r.is_exact_type_ref() { + RefType::exact(r.is_nullable(), idx) + } else { + RefType::concrete(r.is_nullable(), idx) + } } } ValType::I32 | ValType::I64 | ValType::F32 | ValType::F64 | ValType::V128 => {} @@ -956,14 +972,14 @@ impl ValType { /// The GC proposal introduces heap types: any, eq, i31, struct, array, /// nofunc, noextern, none. // -// RefType is a bit-packed enum that fits in a `u24` aka `[u8; 3]`. Note that +// RefType is a bit-packed enum that fits in a u32. Note that // its content is opaque (and subject to change), but its API is stable. // // It has the following internal structure: // // ``` -// [nullable:u1 concrete==1:u1 index:u22] -// [nullable:u1 concrete==0:u1 shared:u1 abstype:u4 (unused):u17] +// [concrete==1:u1 exact:u1 nullable:u1 index:u22] +// [concrete==0:u1 (unused):u1 nullable:u1 shared:u1 abstype:u4 (unused):u17] // ``` // // Where @@ -974,6 +990,8 @@ impl ValType { // index (encoded in a following bit-packing section) or of a known fixed // type, // +// - `exact` determites if the ref is of an exact type, +// // - `index` is the type index, // // - `shared` determines if the ref is shared, but only if it is not concrete in @@ -1003,7 +1021,7 @@ impl ValType { // 0000 = none // ``` #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct RefType([u8; 3]); +pub struct RefType(u32); impl fmt::Debug for RefType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -1032,6 +1050,9 @@ impl fmt::Debug for RefType { write!(f, "(ref {index})") } } + HeapType::Exact(index) => { + write!(f, "(ref (exact {index}))") + } } } } @@ -1065,8 +1086,9 @@ fn can_fit_max_wasm_types_in_ref_type() { impl RefType { // These bits are valid for all `RefType`s. - const NULLABLE_BIT: u32 = 1 << 23; - const CONCRETE_BIT: u32 = 1 << 22; + const CONCRETE_BIT: u32 = 1 << 24; + const EXACT_BIT: u32 = 1 << 23; + const NULLABLE_BIT: u32 = 1 << 22; // The `abstype` field is valid only when `concrete == 0`. const SHARED_BIT: u32 = 1 << 21; @@ -1186,25 +1208,14 @@ impl RefType { index & Self::INDEX_MASK == index } - const fn u24_to_u32(bytes: [u8; 3]) -> u32 { - let expanded_bytes = [bytes[0], bytes[1], bytes[2], 0]; - u32::from_le_bytes(expanded_bytes) - } - - const fn u32_to_u24(x: u32) -> [u8; 3] { - let bytes = x.to_le_bytes(); - debug_assert!(bytes[3] == 0); - [bytes[0], bytes[1], bytes[2]] - } - #[inline] const fn as_u32(&self) -> u32 { - Self::u24_to_u32(self.0) + self.0 } #[inline] const fn from_u32(x: u32) -> Self { - debug_assert!(x & (0b11111111 << 24) == 0); + debug_assert!(x & (0b1111111 << 25) == 0); // Either concrete or it must be a known abstract type. debug_assert!( @@ -1228,7 +1239,7 @@ impl RefType { ) ); - RefType(Self::u32_to_u24(x)) + RefType(x) } /// Create a reference to a concrete Wasm-defined type at the given @@ -1243,6 +1254,14 @@ impl RefType { RefType::from_u32(nullable32 | Self::CONCRETE_BIT | index) } + /// Create a reference to exact type. + pub fn exact(nullable: bool, index: PackedIndex) -> Self { + let index: u32 = PackedIndex::to_u32(index); + debug_assert!(Self::can_represent_type_index(index)); + let nullable32 = Self::NULLABLE_BIT * nullable as u32; + RefType::from_u32(nullable32 | Self::EXACT_BIT | Self::CONCRETE_BIT | index) + } + /// Create a new `RefType`. /// /// Returns `None` when the heap type's type index (if any) is beyond this @@ -1251,6 +1270,7 @@ impl RefType { let base32 = Self::NULLABLE_BIT * (nullable as u32); match heap_type { HeapType::Concrete(index) => Some(RefType::concrete(nullable, index.pack()?)), + HeapType::Exact(index) => Some(RefType::exact(nullable, index.pack()?)), HeapType::Abstract { shared, ty } => { use AbstractHeapType::*; let base32 = base32 | (Self::SHARED_BIT * (shared as u32)); @@ -1294,6 +1314,11 @@ impl RefType { self.as_u32() & Self::CONCRETE_BIT != 0 } + /// Is this an exact reference to a type? + pub const fn is_exact_type_ref(&self) -> bool { + !self.as_u32() & (Self::EXACT_BIT | Self::CONCRETE_BIT) == 0 + } + /// If this is a reference to a concrete Wasm-defined type, get its /// type index. pub fn type_index(&self) -> Option { @@ -1340,6 +1365,11 @@ impl RefType { !self.is_concrete_type_ref() && self.abstype() == Self::CONT_ABSTYPE } + /// Is this none type? + pub const fn is_none_ref(&self) -> bool { + !self.is_concrete_type_ref() && self.abstype() == Self::NONE_ABSTYPE + } + /// Is this ref type nullable? pub const fn is_nullable(&self) -> bool { self.as_u32() & Self::NULLABLE_BIT != 0 @@ -1368,7 +1398,11 @@ impl RefType { pub fn heap_type(&self) -> HeapType { let s = self.as_u32(); if self.is_concrete_type_ref() { - HeapType::Concrete(self.type_index().unwrap().unpack()) + if !self.is_exact_type_ref() { + HeapType::Concrete(self.type_index().unwrap().unpack()) + } else { + HeapType::Exact(self.type_index().unwrap().unpack()) + } } else { use AbstractHeapType::*; let shared = s & Self::SHARED_BIT != 0; @@ -1471,6 +1505,13 @@ impl RefType { "(ref $type)" } } + HeapType::Exact(_) => { + if nullable { + "(ref null (exact $type))" + } else { + "(ref (exact $type))" + } + } } } } @@ -1491,6 +1532,10 @@ pub enum HeapType { /// /// Introduced in the function-references proposal. Concrete(UnpackedIndex), + /// An exact, user-defined type. + /// + /// Introduced in the custom-descriptors proposal. + Exact(UnpackedIndex), } impl HeapType { @@ -1712,6 +1757,7 @@ impl<'a> FromReader<'a> for ValType { // | 0x65 | -27 | shared $t | shared-everything proposal | // | 0x64 | -28 | ref $t | gc proposal, prefix byte | // | 0x63 | -29 | ref null $t | gc proposal, prefix byte | + // | 0x62 | -30 | exact $t | custom descriptor proposal | // | 0x60 | -32 | func $t | prefix byte | // | 0x5f | -33 | struct $t | gc proposal, prefix byte | // | 0x5e | -34 | array $t | gc proposal, prefix byte | @@ -1774,6 +1820,7 @@ impl<'a> FromReader<'a> for RefType { RefType::new(nullable, reader.read()?) .ok_or_else(|| crate::BinaryReaderError::new("type index too large", pos)) } + 0x62 => Err(crate::BinaryReaderError::new("unexpected exact type", pos)), _ => { // Reclassify errors as invalid reference types here because // that's the "root" of what was being parsed rather than @@ -1820,6 +1867,11 @@ impl<'a> FromReader<'a> for HeapType { let ty = reader.read()?; Ok(HeapType::Abstract { shared: true, ty }) } + 0x62 => { + reader.read_u8()?; + let idx = reader.read_var_u32()?; + Ok(HeapType::Exact(UnpackedIndex::Module(idx))) + } _ => { // Reclassify errors as "invalid heap type" here because // that's the "root" of what was being parsed rather than @@ -2027,6 +2079,28 @@ fn read_composite_type( } else { (false, opcode) }; + let (describes_idx, opcode) = if opcode == 0x4c { + let idx = PackedIndex::from_module_index(reader.read_var_u32()?).ok_or_else(|| { + BinaryReaderError::new( + "type index greater than implementation limits", + reader.original_position(), + ) + })?; + (Some(idx), reader.read_u8()?) + } else { + (None, opcode) + }; + let (descriptor_idx, opcode) = if opcode == 0x4d { + let idx = PackedIndex::from_module_index(reader.read_var_u32()?).ok_or_else(|| { + BinaryReaderError::new( + "type index greater than implementation limits", + reader.original_position(), + ) + })?; + (Some(idx), reader.read_u8()?) + } else { + (None, opcode) + }; let inner = match opcode { 0x60 => CompositeInnerType::Func(reader.read()?), 0x5e => CompositeInnerType::Array(reader.read()?), @@ -2034,7 +2108,12 @@ fn read_composite_type( 0x5d => CompositeInnerType::Cont(reader.read()?), x => return reader.invalid_leading_byte(x, "type"), }; - Ok(CompositeType { shared, inner }) + Ok(CompositeType { + shared, + inner, + descriptor_idx, + describes_idx, + }) } impl<'a> FromReader<'a> for RecGroup { diff --git a/crates/wasmparser/src/validator.rs b/crates/wasmparser/src/validator.rs index c675ece0f0..05fe047989 100644 --- a/crates/wasmparser/src/validator.rs +++ b/crates/wasmparser/src/validator.rs @@ -277,6 +277,15 @@ impl WasmFeatures { Err("function references required for index reference types") } } + HeapType::Exact(_) => { + // Exact types were introduced wit hthe custom descriptors + // proposal. + if self.custom_descriptors() { + Ok(()) + } else { + Err("custom descriptors required for exact reference types") + } + } HeapType::Abstract { shared, ty } => { use AbstractHeapType::*; if shared && !self.shared_everything_threads() { diff --git a/crates/wasmparser/src/validator/component_types.rs b/crates/wasmparser/src/validator/component_types.rs index 64ddf1ccae..8b474ec73a 100644 --- a/crates/wasmparser/src/validator/component_types.rs +++ b/crates/wasmparser/src/validator/component_types.rs @@ -1159,7 +1159,7 @@ impl ArgOrField { pub(crate) fn as_concrete_ref(self) -> Option { match self.as_ref_type()?.heap_type() { HeapType::Abstract { .. } => None, - HeapType::Concrete(idx) => { + HeapType::Concrete(idx) | HeapType::Exact(idx) => { let id = idx .as_core_type_id() .expect("validation only sees core type ids"); diff --git a/crates/wasmparser/src/validator/core.rs b/crates/wasmparser/src/validator/core.rs index ab38a0daf4..f8a4e2df41 100644 --- a/crates/wasmparser/src/validator/core.rs +++ b/crates/wasmparser/src/validator/core.rs @@ -838,7 +838,7 @@ impl Module { // Check that the heap type is valid. let type_index = match ty { HeapType::Abstract { .. } => return Ok(()), - HeapType::Concrete(type_index) => type_index, + HeapType::Concrete(type_index) | HeapType::Exact(type_index) => type_index, }; match type_index { UnpackedIndex::Module(idx) => { diff --git a/crates/wasmparser/src/validator/core/canonical.rs b/crates/wasmparser/src/validator/core/canonical.rs index 89f78da70a..7351d7c2d5 100644 --- a/crates/wasmparser/src/validator/core/canonical.rs +++ b/crates/wasmparser/src/validator/core/canonical.rs @@ -115,6 +115,7 @@ pub(crate) trait InternRecGroup { self.add_type_id(id); if is_new { self.check_subtype(rec_group_id, id, types, offset)?; + self.check_descriptors(rec_group_id, id, types, offset)?; } } @@ -162,6 +163,123 @@ pub(crate) trait InternRecGroup { Ok(()) } + fn check_descriptors( + &mut self, + rec_group: RecGroupId, + id: CoreTypeId, + types: &TypeList, + offset: usize, + ) -> Result<()> { + let ty = &types[id].composite_type; + if ty.descriptor_idx.is_some() || ty.describes_idx.is_some() { + if !self.features().custom_descriptors() { + return Err(BinaryReaderError::new( + "custom descriptors proposal must be enabled to use descriptor and describes", + offset, + )); + } + match &ty.inner { + CompositeInnerType::Struct(_) => (), + _ => { + return Err(BinaryReaderError::new( + if ty.descriptor_idx.is_some() { + "descriptor clause on non-struct type" + } else { + "describes clause on non-struct type" + }, + offset, + )); + } + } + } + + let map_cannonical = |idx: PackedIndex| -> Result { + self.at_packed_index(types, rec_group, idx, offset) + }; + + let descriptor_idx = if let Some(i) = ty.descriptor_idx { + Some(map_cannonical(i)?) + } else { + None + }; + let describes_idx = if let Some(i) = ty.describes_idx { + Some(map_cannonical(i)?) + } else { + None + }; + + if let Some(supertype_index) = types[id].supertype_idx { + debug_assert!(supertype_index.is_canonical()); + let sup_id = map_cannonical(supertype_index)?; + if let Some(descriptor_idx) = descriptor_idx { + if types[sup_id].composite_type.descriptor_idx.is_some() + && (types[descriptor_idx].supertype_idx.is_none() + || (map_cannonical(types[descriptor_idx].supertype_idx.unwrap())? + != map_cannonical( + types[sup_id].composite_type.descriptor_idx.unwrap(), + )?)) + { + bail!( + offset, + "supertype of described type must be described by supertype of descriptor", + ); + } + } else if types[sup_id].composite_type.descriptor_idx.is_some() { + bail!( + offset, + "supertype of type without descriptor cannot have descriptor", + ); + } + match ( + types[id].composite_type.describes_idx, + types[sup_id].composite_type.describes_idx, + ) { + (Some(a), Some(b)) => { + let a_id = self.at_packed_index(types, rec_group, a, offset)?; + if types[a_id].supertype_idx.is_none() + || (map_cannonical(types[a_id].supertype_idx.unwrap())? + != map_cannonical(b)?) + { + bail!(offset, "supertype of descriptor does not match"); + } + } + (None, None) => (), + (None, Some(_)) => { + bail!( + offset, + "supertype of non-descriptor type cannot be a descriptor" + ); + } + (Some(_), None) => { + bail!(offset, "supertype of descriptor must be a descriptor"); + } + } + } + if let Some(descriptor_idx) = descriptor_idx { + let describes_idx = if let Some(i) = types[descriptor_idx].composite_type.describes_idx + { + Some(map_cannonical(i)?) + } else { + None + }; + if describes_idx.is_none() || id != describes_idx.unwrap() { + bail!(offset, "descriptor with no matching describes",); + } + } + if let Some(describes_idx) = describes_idx { + let descriptor_idx = if let Some(i) = types[describes_idx].composite_type.descriptor_idx + { + Some(map_cannonical(i)?) + } else { + None + }; + if descriptor_idx.is_none() || id != descriptor_idx.unwrap() { + bail!(offset, "describes with no matching descriptor",); + } + } + Ok(()) + } + fn check_composite_type( &mut self, ty: &CompositeType, @@ -348,6 +466,12 @@ impl<'a> TypeCanonicalizer<'a> { } } + if let Some(idx) = ty.composite_type.describes_idx.as_mut() { + if idx.as_module_index().map_or(false, |i| i >= type_index) { + bail!(self.offset, "forward describes reference"); + } + } + ty.remap_indices(&mut |idx| self.canonicalize_type_index(idx))?; } diff --git a/crates/wasmparser/src/validator/func.rs b/crates/wasmparser/src/validator/func.rs index 9f21fca6a3..e53a4c93e6 100644 --- a/crates/wasmparser/src/validator/func.rs +++ b/crates/wasmparser/src/validator/func.rs @@ -335,6 +335,8 @@ mod tests { composite_type: crate::CompositeType { inner: crate::CompositeInnerType::Func(crate::FuncType::new([], [])), shared: false, + descriptor_idx: None, + describes_idx: None, }, }) } diff --git a/crates/wasmparser/src/validator/operators.rs b/crates/wasmparser/src/validator/operators.rs index 60654e6e7b..4dc4b534b5 100644 --- a/crates/wasmparser/src/validator/operators.rs +++ b/crates/wasmparser/src/validator/operators.rs @@ -261,7 +261,7 @@ enum MaybeType { // current expected size. #[test] fn assert_maybe_type_small() { - assert!(core::mem::size_of::() == 4); + assert!(core::mem::size_of::() == 8); } impl core::fmt::Display for MaybeType { @@ -588,7 +588,7 @@ where if cfg!(debug_assertions) { match maybe_ty { MaybeType::Known(ValType::Ref(r)) => match r.heap_type() { - HeapType::Concrete(index) => { + HeapType::Concrete(index) | HeapType::Exact(index) => { debug_assert!( matches!(index, UnpackedIndex::Id(_)), "only ref types referencing `CoreTypeId`s can \ @@ -620,6 +620,28 @@ where self.push_operand(ref_ty) } + fn push_exact_ref(&mut self, nullable: bool, type_index: u32) -> Result<()> { + let mut heap_ty = HeapType::Exact(UnpackedIndex::Module(type_index)); + + // Canonicalize the module index into an id. + self.resources.check_heap_type(&mut heap_ty, self.offset)?; + debug_assert!(matches!(heap_ty, HeapType::Exact(UnpackedIndex::Id(_)))); + + let ref_ty = RefType::new(nullable, heap_ty).ok_or_else(|| { + format_err!(self.offset, "implementation limit: type index too large") + })?; + + self.push_operand(ref_ty) + } + + fn push_exact_ref_if_available(&mut self, nullable: bool, type_index: u32) -> Result<()> { + if self.features.custom_descriptors() { + self.push_exact_ref(nullable, type_index) + } else { + self.push_concrete_ref(nullable, type_index) + } + } + fn pop_concrete_ref(&mut self, nullable: bool, type_index: u32) -> Result { let mut heap_ty = HeapType::Concrete(UnpackedIndex::Module(type_index)); @@ -634,6 +656,27 @@ where self.pop_operand(Some(ref_ty.into())) } + fn pop_concrete_or_exact_ref( + &mut self, + nullable: bool, + type_index: u32, + ) -> Result<(MaybeType, bool)> { + let ty = self.pop_concrete_ref(nullable, type_index)?; + let is_exact = match ty { + MaybeType::Known(ValType::Ref(rt)) if rt.is_exact_type_ref() || rt.is_none_ref() => { + let mut heap_ty = HeapType::Exact(UnpackedIndex::Module(type_index)); + self.resources.check_heap_type(&mut heap_ty, self.offset)?; + let expected = RefType::new(nullable, heap_ty).ok_or_else(|| { + format_err!(self.offset, "implementation limit: type index too large") + })?; + self.resources.is_subtype(rt.into(), expected.into()) + } + MaybeType::Bottom => true, + _ => false, + }; + Ok((ty, is_exact)) + } + /// Pop the given label types, checking that they are indeed present on the /// stack, and then push them back on again. fn pop_push_label_types( @@ -1291,6 +1334,120 @@ where self.push_operand(sub_ty) } + /// Common helper to check type hierarchy for `br_on_cast` operators. + fn check_br_on_cast_type_hierarchy( + &self, + from_ref_type: RefType, + to_ref_type: RefType, + ) -> Result<()> { + if self.features.custom_descriptors() { + // The constraint C |- rt_2 <: rt_1 on branching cast instructions + // before the custom descriptors proposal is relaxed to the constraint + // that rt_1 and rt_2 share some arbitrary valid supertype rt', i.e. + // that rt_1 and rt_2 must be in the same heap type hierarchy. + let from_ref_type_top = self.resources.top_type(&from_ref_type.heap_type()); + let to_ref_type_top = self.resources.top_type(&to_ref_type.heap_type()); + if from_ref_type_top != to_ref_type_top { + bail!( + self.offset, + "type mismatch: {from_ref_type} and {to_ref_type} have different heap type hierarchies" + ); + } + return Ok(()); + } + + if !self + .resources + .is_subtype(to_ref_type.into(), from_ref_type.into()) + { + bail!( + self.offset, + "type mismatch: expected {from_ref_type}, found {to_ref_type}" + ); + } + Ok(()) + } + + /// Common helper to check descriptor for the specified type. + fn check_descriptor(&self, heap_type: HeapType) -> Result { + Ok(match heap_type { + HeapType::Exact(idx) | HeapType::Concrete(idx) => { + if let Some(descriptor_idx) = self + .sub_type_at(idx.as_module_index().unwrap())? + .composite_type + .descriptor_idx + { + u32::try_from(crate::validator::types::TypeIdentifier::index( + &descriptor_idx.as_core_type_id().unwrap(), + )) + .unwrap() + } else { + bail!(self.offset, "cast target must have descriptor") + } + } + _ => bail!(self.offset, "unexpected heap type"), + }) + } + + fn check_maybe_exact_descriptor_ref(&mut self, heap_type: HeapType) -> Result { + let descriptor_idx = self.check_descriptor(heap_type)?; + let (ty, _is_exact) = self.pop_concrete_or_exact_ref(true, descriptor_idx)?; + let is_exact = if let HeapType::Exact(_) = heap_type { + let mut descriptor_ty = HeapType::Exact(UnpackedIndex::Module(descriptor_idx)); + self.resources + .check_heap_type(&mut descriptor_ty, self.offset)?; + let descriptor_ty = ValType::Ref( + RefType::new(true, descriptor_ty) + .expect("existing heap types should be within our limits"), + ); + + match ty { + MaybeType::Known(actual) if !self.resources.is_subtype(actual, descriptor_ty) => { + bail!( + self.offset, + "type mismatch: expected descriptor of exact type {descriptor_ty} found {actual}", + ); + } + _ => (), + } + true + } else { + false + }; + Ok(is_exact) + } + + /// Common helper for both nullable and non-nullable variants of `ref.cast_desc` + /// instructions. + fn check_ref_cast_desc(&mut self, nullable: bool, heap_type: HeapType) -> Result<()> { + let is_exact = self.check_maybe_exact_descriptor_ref(heap_type)?; + + self.check_downcast(nullable, heap_type)?; + + let idx = { + let mut heap_type = heap_type; + self.resources + .check_heap_type(&mut heap_type, self.offset)?; + match heap_type { + HeapType::Concrete(index) | HeapType::Exact(index) => { + index.pack().ok_or_else(|| { + BinaryReaderError::new( + "implementation limit: type index too large", + self.offset, + ) + })? + } + _ => panic!(), + } + }; + + self.push_operand(if is_exact { + RefType::exact(nullable, idx) + } else { + RefType::concrete(nullable, idx) + }) + } + /// Common helper for checking the types of globals accessed with atomic RMW /// instructions, which only allow `i32` and `i64`. fn check_atomic_global_rmw_ty(&self, global_index: u32) -> Result { @@ -3275,14 +3432,26 @@ where Ok(()) } fn visit_struct_new(&mut self, struct_type_index: u32) -> Self::Output { + if let Some(descriptor_idx) = self + .sub_type_at(struct_type_index)? + .composite_type + .descriptor_idx + { + let ty = ValType::Ref(RefType::exact(true, descriptor_idx)); + self.pop_operand(Some(ty))?; + } let struct_ty = self.struct_type_at(struct_type_index)?; for ty in struct_ty.fields.iter().rev() { self.pop_operand(Some(ty.element_type.unpack()))?; } - self.push_concrete_ref(false, struct_type_index)?; + self.push_exact_ref_if_available(false, struct_type_index)?; Ok(()) } fn visit_struct_new_default(&mut self, type_index: u32) -> Self::Output { + if let Some(descriptor_idx) = self.sub_type_at(type_index)?.composite_type.descriptor_idx { + let ty = ValType::Ref(RefType::exact(true, descriptor_idx)); + self.pop_operand(Some(ty))?; + } let ty = self.struct_type_at(type_index)?; for field in ty.fields.iter() { let val_ty = field.element_type.unpack(); @@ -3293,7 +3462,7 @@ where ); } } - self.push_concrete_ref(false, type_index)?; + self.push_exact_ref_if_available(false, type_index)?; Ok(()) } fn visit_struct_get(&mut self, struct_type_index: u32, field_index: u32) -> Self::Output { @@ -3514,7 +3683,7 @@ where let array_ty = self.array_type_at(type_index)?; self.pop_operand(Some(ValType::I32))?; self.pop_operand(Some(array_ty.element_type.unpack()))?; - self.push_concrete_ref(false, type_index) + self.push_exact_ref_if_available(false, type_index) } fn visit_array_new_default(&mut self, type_index: u32) -> Self::Output { let ty = self.array_type_at(type_index)?; @@ -3526,7 +3695,7 @@ where ); } self.pop_operand(Some(ValType::I32))?; - self.push_concrete_ref(false, type_index) + self.push_exact_ref_if_available(false, type_index) } fn visit_array_new_fixed(&mut self, type_index: u32, n: u32) -> Self::Output { let array_ty = self.array_type_at(type_index)?; @@ -3534,7 +3703,7 @@ where for _ in 0..n { self.pop_operand(Some(elem_ty))?; } - self.push_concrete_ref(false, type_index) + self.push_exact_ref_if_available(false, type_index) } fn visit_array_new_data(&mut self, type_index: u32, data_index: u32) -> Self::Output { let array_ty = self.array_type_at(type_index)?; @@ -3549,7 +3718,7 @@ where self.check_data_segment(data_index)?; self.pop_operand(Some(ValType::I32))?; self.pop_operand(Some(ValType::I32))?; - self.push_concrete_ref(false, type_index) + self.push_exact_ref_if_available(false, type_index) } fn visit_array_new_elem(&mut self, type_index: u32, elem_index: u32) -> Self::Output { let array_ty = self.array_type_at(type_index)?; @@ -3573,7 +3742,7 @@ where } self.pop_operand(Some(ValType::I32))?; self.pop_operand(Some(ValType::I32))?; - self.push_concrete_ref(false, type_index) + self.push_exact_ref_if_available(false, type_index) } fn visit_array_get(&mut self, type_index: u32) -> Self::Output { let array_ty = self.array_type_at(type_index)?; @@ -3897,15 +4066,7 @@ where self.resources .check_ref_type(&mut to_ref_type, self.offset)?; - if !self - .resources - .is_subtype(to_ref_type.into(), from_ref_type.into()) - { - bail!( - self.offset, - "type mismatch: expected {from_ref_type}, found {to_ref_type}" - ); - } + self.check_br_on_cast_type_hierarchy(from_ref_type, to_ref_type)?; let (block_ty, frame_kind) = self.jump(relative_depth)?; let mut label_types = self.label_types(block_ty, frame_kind)?; @@ -3941,15 +4102,7 @@ where self.resources .check_ref_type(&mut to_ref_type, self.offset)?; - if !self - .resources - .is_subtype(to_ref_type.into(), from_ref_type.into()) - { - bail!( - self.offset, - "type mismatch: expected {from_ref_type}, found {to_ref_type}" - ); - } + self.check_br_on_cast_type_hierarchy(from_ref_type, to_ref_type)?; let (block_ty, frame_kind) = self.jump(relative_depth)?; let mut label_tys = self.label_types(block_ty, frame_kind)?; @@ -4231,6 +4384,107 @@ where fn visit_i64_mul_wide_u(&mut self) -> Result<()> { self.check_i64_mul_wide() } + + fn visit_ref_get_desc(&mut self, type_index: u32) -> Self::Output { + let (_, is_exact) = self.pop_concrete_or_exact_ref(true, type_index)?; + match self.sub_type_at(type_index)?.composite_type.descriptor_idx { + Some(descriptor_idx) => { + let ref_ty = if is_exact { + RefType::exact(false, descriptor_idx) + } else { + RefType::concrete(false, descriptor_idx) + }; + self.push_operand(ref_ty) + } + None => bail!(self.offset, "expected type with descriptor"), + } + } + + fn visit_ref_cast_desc_non_null(&mut self, heap_type: HeapType) -> Self::Output { + self.check_ref_cast_desc(false, heap_type) + } + fn visit_ref_cast_desc_nullable(&mut self, heap_type: HeapType) -> Self::Output { + self.check_ref_cast_desc(true, heap_type) + } + fn visit_br_on_cast_desc( + &mut self, + relative_depth: u32, + mut from_ref_type: RefType, + mut to_ref_type: RefType, + ) -> Self::Output { + let described_ty = to_ref_type.heap_type(); + + self.resources + .check_ref_type(&mut from_ref_type, self.offset)?; + self.resources + .check_ref_type(&mut to_ref_type, self.offset)?; + + self.check_br_on_cast_type_hierarchy(from_ref_type, to_ref_type)?; + + self.check_maybe_exact_descriptor_ref(described_ty)?; + + let (block_ty, frame_kind) = self.jump(relative_depth)?; + let mut label_types = self.label_types(block_ty, frame_kind)?; + + match label_types.next_back() { + Some(label_ty) if self.resources.is_subtype(to_ref_type.into(), label_ty) => { + self.pop_operand(Some(from_ref_type.into()))?; + } + Some(label_ty) => bail!( + self.offset, + "type mismatch: casting to type {to_ref_type}, but it does not match \ + label result type {label_ty}" + ), + None => bail!( + self.offset, + "type mismatch: br_on_cast to label with empty types, must have a reference type" + ), + }; + + self.pop_push_label_types(label_types)?; + let diff_ty = RefType::difference(from_ref_type, to_ref_type); + self.push_operand(diff_ty)?; + Ok(()) + } + fn visit_br_on_cast_desc_fail( + &mut self, + relative_depth: u32, + mut from_ref_type: RefType, + mut to_ref_type: RefType, + ) -> Self::Output { + let described_ty = to_ref_type.heap_type(); + + self.resources + .check_ref_type(&mut from_ref_type, self.offset)?; + self.resources + .check_ref_type(&mut to_ref_type, self.offset)?; + + self.check_br_on_cast_type_hierarchy(from_ref_type, to_ref_type)?; + + self.check_maybe_exact_descriptor_ref(described_ty)?; + + let (block_ty, frame_kind) = self.jump(relative_depth)?; + let mut label_tys = self.label_types(block_ty, frame_kind)?; + + let diff_ty = RefType::difference(from_ref_type, to_ref_type); + match label_tys.next_back() { + Some(label_ty) if self.resources.is_subtype(diff_ty.into(), label_ty) => { + self.pop_operand(Some(from_ref_type.into()))?; + } + Some(label_ty) => bail!( + self.offset, + "type mismatch: expected label result type {label_ty}, found {diff_ty}" + ), + None => bail!( + self.offset, + "type mismatch: expected a reference type, found nothing" + ), + } + + self.pop_push_label_types(label_tys)?; + self.push_operand(to_ref_type)?; + Ok(()) + } } #[derive(Clone, Debug)] diff --git a/crates/wasmparser/src/validator/types.rs b/crates/wasmparser/src/validator/types.rs index c072218caa..738f3f9cad 100644 --- a/crates/wasmparser/src/validator/types.rs +++ b/crates/wasmparser/src/validator/types.rs @@ -1136,7 +1136,8 @@ impl TypeList { }, ) => a_shared == b_shared && a_ty.is_subtype_of(b_ty), - (HT::Concrete(a), HT::Abstract { shared, ty }) => { + (HT::Concrete(a), HT::Abstract { shared, ty }) + | (HT::Exact(a), HT::Abstract { shared, ty }) => { let a_ty = &subtype(a_group, a).composite_type; if a_ty.shared != shared { return false; @@ -1153,7 +1154,8 @@ impl TypeList { } } - (HT::Abstract { shared, ty }, HT::Concrete(b)) => { + (HT::Abstract { shared, ty }, HT::Concrete(b)) + | (HT::Abstract { shared, ty }, HT::Exact(b)) => { let b_ty = &subtype(b_group, b).composite_type; if shared != b_ty.shared { return false; @@ -1169,9 +1171,13 @@ impl TypeList { } } - (HT::Concrete(a), HT::Concrete(b)) => { + (HT::Concrete(a), HT::Concrete(b)) | (HT::Exact(a), HT::Concrete(b)) => { self.id_is_subtype(core_type_id(a_group, a), core_type_id(b_group, b)) } + + (HT::Exact(a), HT::Exact(b)) => core_type_id(a_group, a) == core_type_id(b_group, b), + + (HT::Concrete(_), HT::Exact(_)) => false, } } @@ -1206,7 +1212,7 @@ impl TypeList { pub fn reftype_is_shared(&self, ty: RefType) -> bool { match ty.heap_type() { HeapType::Abstract { shared, .. } => shared, - HeapType::Concrete(index) => { + HeapType::Concrete(index) | HeapType::Exact(index) => { self[index.as_core_type_id().unwrap()].composite_type.shared } } @@ -1219,7 +1225,7 @@ impl TypeList { pub fn top_type(&self, heap_type: &HeapType) -> HeapType { use AbstractHeapType::*; match *heap_type { - HeapType::Concrete(idx) => { + HeapType::Concrete(idx) | HeapType::Exact(idx) => { let ty = &self[idx.as_core_type_id().unwrap()].composite_type; let shared = ty.shared; match ty.inner { diff --git a/crates/wasmprinter/src/lib.rs b/crates/wasmprinter/src/lib.rs index 141536b817..c452d3d957 100644 --- a/crates/wasmprinter/src/lib.rs +++ b/crates/wasmprinter/src/lib.rs @@ -936,6 +936,20 @@ impl Printer<'_, '_> { self.start_group("shared")?; self.result.write_str(" ")?; } + if let Some(idx) = ty.describes_idx { + self.start_group("describes")?; + self.result.write_str(" ")?; + self.print_idx(&state.core.type_names, idx.as_module_index().unwrap())?; + self.end_group()?; + self.result.write_str(" ")?; + } + if let Some(idx) = ty.descriptor_idx { + self.start_group("descriptor")?; + self.result.write_str(" ")?; + self.print_idx(&state.core.type_names, idx.as_module_index().unwrap())?; + self.end_group()?; + self.result.write_str(" ")?; + } let r = match &ty.inner { CompositeInnerType::Func(ty) => { self.start_group("func")?; @@ -991,6 +1005,8 @@ impl Printer<'_, '_> { CompositeType { inner: CompositeInnerType::Func(ty), shared: false, + descriptor_idx: None, + describes_idx: None, }, .. })) => self.print_func_type(state, ty, names_for).map(Some), @@ -1154,6 +1170,11 @@ impl Printer<'_, '_> { HeapType::Concrete(i) => { self.print_idx(&state.core.type_names, i.as_module_index().unwrap())?; } + HeapType::Exact(i) => { + self.start_group("exact ")?; + self.print_idx(&state.core.type_names, i.as_module_index().unwrap())?; + self.end_group()?; + } HeapType::Abstract { shared, ty } => { use AbstractHeapType::*; if shared { diff --git a/crates/wasmprinter/src/operator.rs b/crates/wasmprinter/src/operator.rs index 35cdc85256..466a40b38e 100644 --- a/crates/wasmprinter/src/operator.rs +++ b/crates/wasmprinter/src/operator.rs @@ -765,6 +765,23 @@ macro_rules! define_visit { $self.push_str(" ")?; $self.printer.print_field_idx($self.state, $ty, $field)?; ); + + (payload $self:ident RefGetDesc $hty:ident) => ( + $self.struct_type_index($hty)?; + ); + (payload $self:ident RefCastDescNonNull $hty:ident) => ( + $self.push_str(" ")?; + let rty = RefType::new(false, $hty) + .ok_or_else(|| anyhow!("implementation limit: type index too large"))?; + $self.printer.print_reftype($self.state, rty)?; + ); + (payload $self:ident RefCastDescNullable $hty:ident) => ( + $self.push_str(" ")?; + let rty = RefType::new(true, $hty) + .ok_or_else(|| anyhow!("implementation limit: type index too large"))?; + $self.printer.print_reftype($self.state, rty)?; + ); + (payload $self:ident $op:ident $($arg:ident)*) => ( $($self.$arg($arg)?;)* ); @@ -1388,6 +1405,11 @@ macro_rules! define_visit { (name I64Sub128) => ("i64.sub128"); (name I64MulWideS) => ("i64.mul_wide_s"); (name I64MulWideU) => ("i64.mul_wide_u"); + (name RefGetDesc) => ("ref.get_desc"); + (name RefCastDescNonNull) => ("ref.cast_desc"); + (name RefCastDescNullable) => ("ref.cast_desc"); + (name BrOnCastDesc) => ("br_on_cast_desc"); + (name BrOnCastDescFail) => ("br_on_cast_desc_fail"); } impl<'a> VisitOperator<'a> for PrintOperator<'_, '_, '_, '_> { diff --git a/crates/wast/src/component/resolve.rs b/crates/wast/src/component/resolve.rs index 9ff8618382..dd7d274d09 100644 --- a/crates/wast/src/component/resolve.rs +++ b/crates/wast/src/component/resolve.rs @@ -672,7 +672,7 @@ impl<'a> Resolver<'a> { ValType::I32 | ValType::I64 | ValType::F32 | ValType::F64 | ValType::V128 => {} ValType::Ref(r) => match &mut r.heap { core::HeapType::Abstract { .. } => {} - core::HeapType::Concrete(id) => { + core::HeapType::Concrete(id) | core::HeapType::Exact(id) => { self.resolve_ns(id, Ns::Type)?; } }, diff --git a/crates/wast/src/core/binary.rs b/crates/wast/src/core/binary.rs index cc27b92c99..09b491b83c 100644 --- a/crates/wast/src/core/binary.rs +++ b/crates/wast/src/core/binary.rs @@ -383,6 +383,8 @@ impl TypeDef<'_> { InnerTypeKind::Cont(ct) => Cont(ct.into()), }, shared: self.shared, + descriptor: self.descriptor.map(|i| i.unwrap_u32()), + describes: self.describes.map(|i| i.unwrap_u32()), }; wasm_encoder::SubType { composite_type, @@ -438,6 +440,7 @@ impl From> for wasm_encoder::HeapType { Self::Abstract { shared, ty } } HeapType::Concrete(i) => Self::Concrete(i.unwrap_u32()), + HeapType::Exact(i) => Self::Exact(i.unwrap_u32()), } } } @@ -1520,3 +1523,43 @@ impl Encode for BrOnCastFail<'_> { self.to_type.heap.encode(e); } } + +impl Encode for RefCastDesc<'_> { + fn encode(&self, e: &mut Vec) { + e.push(0xfb); + if self.r#type.nullable { + e.push(0x24); + } else { + e.push(0x23); + } + self.r#type.heap.encode(e); + } +} + +impl Encode for BrOnCastDesc<'_> { + fn encode(&self, e: &mut Vec) { + e.push(0xfb); + e.push(0x25); + e.push(br_on_cast_flags( + self.from_type.nullable, + self.to_type.nullable, + )); + self.label.encode(e); + self.from_type.heap.encode(e); + self.to_type.heap.encode(e); + } +} + +impl Encode for BrOnCastDescFail<'_> { + fn encode(&self, e: &mut Vec) { + e.push(0xfb); + e.push(0x26); + e.push(br_on_cast_flags( + self.from_type.nullable, + self.to_type.nullable, + )); + self.label.encode(e); + self.from_type.heap.encode(e); + self.to_type.heap.encode(e); + } +} diff --git a/crates/wast/src/core/expr.rs b/crates/wast/src/core/expr.rs index 20927b4c8f..723d1de6b8 100644 --- a/crates/wast/src/core/expr.rs +++ b/crates/wast/src/core/expr.rs @@ -1202,6 +1202,12 @@ instructions! { I64Sub128 : [0xfc, 20] : "i64.sub128", I64MulWideS : [0xfc, 21] : "i64.mul_wide_s", I64MulWideU : [0xfc, 22] : "i64.mul_wide_u", + + // Custom descriptors + RefGetDesc(Index<'a>): [0xfb, 34] : "ref.get_desc", + RefCastDesc(RefCastDesc<'a>) : [] : "ref.cast_desc", + BrOnCastDesc(Box>) : [] : "br_on_cast_desc", + BrOnCastDescFail(Box>) : [] : "br_on_cast_desc_fail", } } @@ -1946,6 +1952,63 @@ impl<'a> Parse<'a> for BrOnCastFail<'a> { } } +/// Extra data associated with the `ref.cast_desc` instruction +#[derive(Debug, Clone)] +pub struct RefCastDesc<'a> { + /// The type to cast to. + pub r#type: RefType<'a>, +} + +impl<'a> Parse<'a> for RefCastDesc<'a> { + fn parse(parser: Parser<'a>) -> Result { + Ok(RefCastDesc { + r#type: parser.parse()?, + }) + } +} + +/// Extra data associated with the `br_on_cast_desc` instruction +#[derive(Debug, Clone)] +pub struct BrOnCastDesc<'a> { + /// The label to branch to. + pub label: Index<'a>, + /// The type we're casting from. + pub from_type: RefType<'a>, + /// The type we're casting to. + pub to_type: RefType<'a>, +} + +impl<'a> Parse<'a> for BrOnCastDesc<'a> { + fn parse(parser: Parser<'a>) -> Result { + Ok(BrOnCastDesc { + label: parser.parse()?, + from_type: parser.parse()?, + to_type: parser.parse()?, + }) + } +} + +/// Extra data associated with the `br_on_cast_desc_fail` instruction +#[derive(Debug, Clone)] +pub struct BrOnCastDescFail<'a> { + /// The label to branch to. + pub label: Index<'a>, + /// The type we're casting from. + pub from_type: RefType<'a>, + /// The type we're casting to. + pub to_type: RefType<'a>, +} + +impl<'a> Parse<'a> for BrOnCastDescFail<'a> { + fn parse(parser: Parser<'a>) -> Result { + Ok(BrOnCastDescFail { + label: parser.parse()?, + from_type: parser.parse()?, + to_type: parser.parse()?, + }) + } +} + /// The memory ordering for atomic instructions. /// /// For an in-depth explanation of memory orderings, see the C++ documentation diff --git a/crates/wast/src/core/resolve/names.rs b/crates/wast/src/core/resolve/names.rs index 533e43f050..eff77e75db 100644 --- a/crates/wast/src/core/resolve/names.rs +++ b/crates/wast/src/core/resolve/names.rs @@ -673,6 +673,23 @@ impl<'a, 'b> ExprResolver<'a, 'b> { self.resolver.resolve(&mut s.tag_index, Ns::Tag)?; } + RefGetDesc(i) => { + self.resolver.resolve(i, Ns::Type)?; + } + RefCastDesc(i) => { + self.resolver.resolve_reftype(&mut i.r#type)?; + } + BrOnCastDesc(i) => { + self.resolve_label(&mut i.label)?; + self.resolver.resolve_reftype(&mut i.to_type)?; + self.resolver.resolve_reftype(&mut i.from_type)?; + } + BrOnCastDescFail(i) => { + self.resolve_label(&mut i.label)?; + self.resolver.resolve_reftype(&mut i.to_type)?; + self.resolver.resolve_reftype(&mut i.from_type)?; + } + _ => {} } Ok(()) @@ -813,6 +830,12 @@ pub(crate) trait ResolveCoreType<'a> { if let Some(parent) = &mut ty.parent { self.resolve_type_name(parent)?; } + if let Some(descriptor) = &mut ty.descriptor { + self.resolve_type_name(descriptor)?; + } + if let Some(describes) = &mut ty.describes { + self.resolve_type_name(describes)?; + } match &mut ty.kind { InnerTypeKind::Func(func) => self.resolve_type_func(func), InnerTypeKind::Struct(struct_) => { @@ -853,7 +876,7 @@ pub(crate) trait ResolveCoreType<'a> { fn resolve_heaptype(&mut self, ty: &mut HeapType<'a>) -> Result<(), Error> { match ty { - HeapType::Concrete(i) => { + HeapType::Concrete(i) | HeapType::Exact(i) => { self.resolve_type_name(i)?; } HeapType::Abstract { .. } => {} diff --git a/crates/wast/src/core/resolve/types.rs b/crates/wast/src/core/resolve/types.rs index 7a7e36c9d2..3030c1c21a 100644 --- a/crates/wast/src/core/resolve/types.rs +++ b/crates/wast/src/core/resolve/types.rs @@ -264,6 +264,8 @@ impl<'a> TypeKey<'a> for FuncKey<'a> { }), shared, parent: None, + descriptor: None, + describes: None, final_type: None, } } diff --git a/crates/wast/src/core/types.rs b/crates/wast/src/core/types.rs index 7e8ebcf134..639c5e223a 100644 --- a/crates/wast/src/core/types.rs +++ b/crates/wast/src/core/types.rs @@ -114,6 +114,9 @@ pub enum HeapType<'a> { /// A reference to a concrete function, struct, or array type defined by /// Wasm: `ref T`. This is part of the function references and GC proposals. Concrete(Index<'a>), + /// A reference to an exact type. + /// This is part of the custom descriptors proposal. + Exact(Index<'a>), } impl<'a> Parse<'a> for HeapType<'a> { @@ -123,11 +126,16 @@ impl<'a> Parse<'a> for HeapType<'a> { Ok(HeapType::Concrete(parser.parse()?)) } else if l.peek::()? { parser.parens(|p| { - p.parse::()?; - Ok(HeapType::Abstract { - shared: true, - ty: p.parse()?, - }) + if l.peek::()? { + p.parse::()?; + Ok(HeapType::Exact(p.parse()?)) + } else { + p.parse::()?; + Ok(HeapType::Abstract { + shared: true, + ty: p.parse()?, + }) + } }) } else if l.peek::()? { Ok(HeapType::Abstract { @@ -950,49 +958,99 @@ pub struct TypeDef<'a> { pub shared: bool, /// The declared parent type of this definition. pub parent: Option>, + /// The descriptor type. + pub descriptor: Option>, + /// The descriptor for type. + pub describes: Option>, /// Whether this type is final or not. By default types are final. pub final_type: Option, } +fn parse_optional<'a, K: Peek + Parse<'a>, R, T>( + parser: Parser<'a>, + parse: impl FnOnce(Parser<'a>) -> Result, + default: R, + f: impl FnOnce(Parser<'a>, R) -> Result, +) -> Result { + if parser.peek::()? { + parser.parse::()?; + let result: R = parse(parser)?; + parser.parens(|parser: Parser| f(parser, result)) + } else { + f(parser, default) + } +} + +fn expect_parens_close_then_open<'a>(parser: Parser<'a>) -> Result<()> { + parser.step(|cursor| { + let cursor = match cursor.rparen()? { + Some(rest) => rest, + None => return Err(cursor.error("expected `(`")), + }; + match cursor.lparen()? { + Some(rest) => Ok(((), rest)), + None => Err(cursor.error("expected `(`")), + } + }) +} + impl<'a> Parse<'a> for TypeDef<'a> { fn parse(parser: Parser<'a>) -> Result { let parse_shared_and_kind = |parser: Parser<'a>| { - if parser.peek::()? { - parser.parse::()?; - parser.parens(|parser| { + parse_optional::( + parser, + |_| Ok(true), + false, + |parser, shared| { + let describes = if parser.peek::()? { + parser.parse::()?; + let index = parser.parse::()?; + expect_parens_close_then_open(parser)?; + Some(index) + } else { + None + }; + let descriptor = if parser.peek::()? { + parser.parse::()?; + let index = parser.parse::()?; + expect_parens_close_then_open(parser)?; + Some(index) + } else { + None + }; let kind = parser.parse()?; - Ok((true, kind)) - }) - } else { - let kind = parser.parse()?; - Ok((false, kind)) - } + Ok((shared, descriptor, describes, kind)) + }, + ) }; - let (parent, (shared, kind), final_type) = if parser.peek::()? { - parser.parse::()?; + let (parent, (shared, descriptor, describes, kind), final_type) = + if parser.peek::()? { + parser.parse::()?; - let final_type: Option = if parser.peek::()? { - parser.parse::()?; - Some(true) - } else { - Some(false) - }; + let final_type: Option = if parser.peek::()? { + parser.parse::()?; + Some(true) + } else { + Some(false) + }; - let parent = if parser.peek::>()? { - parser.parse()? + let parent = if parser.peek::>()? { + parser.parse()? + } else { + None + }; + let pair = parser.parens(parse_shared_and_kind)?; + (parent, pair, final_type) } else { - None + (None, parse_shared_and_kind(parser)?, None) }; - let pair = parser.parens(parse_shared_and_kind)?; - (parent, pair, final_type) - } else { - (None, parse_shared_and_kind(parser)?, None) - }; Ok(TypeDef { kind, shared, parent, + descriptor, + describes, final_type, }) } diff --git a/crates/wast/src/lib.rs b/crates/wast/src/lib.rs index 6dfa3d0bad..febe78c421 100644 --- a/crates/wast/src/lib.rs +++ b/crates/wast/src/lib.rs @@ -416,10 +416,13 @@ pub mod kw { custom_keyword!(data); custom_keyword!(declare); custom_keyword!(delegate); + custom_keyword!(descriptor); + custom_keyword!(describes); custom_keyword!(r#do = "do"); custom_keyword!(dtor); custom_keyword!(elem); custom_keyword!(end); + custom_keyword!(exact); custom_keyword!(tag); custom_keyword!(exn); custom_keyword!(exnref); diff --git a/crates/wit-component/src/gc.rs b/crates/wit-component/src/gc.rs index b1f7437343..217d5585d0 100644 --- a/crates/wit-component/src/gc.rs +++ b/crates/wit-component/src/gc.rs @@ -454,7 +454,7 @@ impl<'a> Module<'a> { fn heapty(&mut self, ty: HeapType) { match ty { HeapType::Abstract { .. } => {} - HeapType::Concrete(i) => self.ty(i.as_module_index().unwrap()), + HeapType::Concrete(i) | HeapType::Exact(i) => self.ty(i.as_module_index().unwrap()), } } diff --git a/tests/cli/custom-descriptors-disabled.wast b/tests/cli/custom-descriptors-disabled.wast new file mode 100644 index 0000000000..34962e4edd --- /dev/null +++ b/tests/cli/custom-descriptors-disabled.wast @@ -0,0 +1,26 @@ +;; RUN: wast --assert default --snapshot tests/snapshots % + +(assert_invalid + (module + (type $t (struct)) + (func (param (ref (exact $t)))) + ) + "custom descriptors required for exact reference types") + +(assert_invalid + (module + (rec + (type (descriptor 1) (struct (field i32))) + (type (func)) + ) + ) + "custom descriptors proposal must be enabled") + +(assert_invalid + (module + (rec + (type (func)) + (type (describes 0) (struct (field (ref 0)))) + ) + ) + "custom descriptors proposal must be enabled") diff --git a/tests/cli/custom-descriptors-ops.wast b/tests/cli/custom-descriptors-ops.wast new file mode 100644 index 0000000000..05fb69b565 --- /dev/null +++ b/tests/cli/custom-descriptors-ops.wast @@ -0,0 +1,191 @@ +;; RUN: wast --assert default --snapshot tests/snapshots % -f custom-descriptors + +;; --enable-gc + +(module + (type $f (func (result i32))) + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + ) + + (import "" "rtt1" (global $g1 (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (ref (exact $t2sub)))) + + (elem declare func $f_impl) + (func $f_impl (type $f) (result i32) + unreachable + ) + + (func $test-struct-new + i32.const 3 + global.get $g1 + struct.new $t1 + drop + + global.get $g1 + struct.new_default $t1 + drop + + global.get $g1sub + struct.new_default $t1sub + drop + ) + + (func $test-exact-types + (local $l_any anyref) + (local $l_struct structref) + (local $l_t2 (ref $t2)) + (local $l_t2_e (ref (exact $t2))) + global.get $g1 + local.set $l_any + global.get $g1 + local.set $l_struct + global.get $g1 + local.set $l_t2 + global.get $g1 + local.set $l_t2_e + + global.get $g1sub + local.set $l_struct + global.get $g1sub + local.set $l_t2 + + local.get $l_any + ref.cast (ref null $t2) + ref.cast (ref (exact $t2)) + local.set $l_t2_e + ) + + (func $test-struct-new-result + (local (ref (exact $t2))) + ref.func $f_impl + struct.new $t2 + local.set 0 + ) + + (func $test-get-desc (param $rtt (ref (exact $t2))) + local.get $rtt + struct.new_default $t1 + ref.get_desc $t1 + local.set $rtt + ) + + (func $test-get-desc-2 (result (ref (exact $t2))) + unreachable + ref.get_desc $t1 + ) + + (func $test-cast-desc (param $i (ref $t1)) (param $desc (ref null (exact $t2))) (result (ref null (exact $t1))) + local.get $i + local.get $desc + ref.cast_desc (ref null (exact $t1)) + ) + + (func $test-br_on_cast_desc (param $i (ref null $t1sub)) (param $desc (ref null $t2)) (result (ref null $t1)) + local.get $i + local.get $desc + br_on_cast_desc 0 (ref null $t1sub) (ref null $t1) + ) + + (func $test-br_on_cast_desc_fail (param $i (ref null $t1sub)) (param $desc (ref null $t2)) (result (ref null $t1)) + local.get $i + local.get $desc + br_on_cast_desc_fail 0 (ref null $t1sub) (ref null $t1) + ) +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + + (import "" "rtt1" (global $g1 (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (ref (exact $t2sub)))) + + (func $test-struct-new-non-exact-1 + global.get $g1sub + i32.const 3 + struct.new $t1 + drop + ) + ) + "type mismatch: expected (ref null (exact" +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + + (import "" "rtt1" (global $g1 (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (ref (exact $t2sub)))) + + (func $test-struct-new-non-exact-2 (param (ref $t2)) + local.get 0 + struct.new_default $t1 + drop + ) + ) + "type mismatch: expected (ref null (exact" +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + + (import "" "rtt1" (global $g1 (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (ref (exact $t2sub)))) + + (func $test-struct-new-non-exact-3 + global.get $g1 + i32.const 2 + f32.const 1 + struct.new $t1sub + drop + ) + ) + "type mismatch: expected (ref null (exact" +) + + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + + (import "" "rtt1" (global $g1 (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (ref (exact $t2sub)))) + + (func $test-br_on_cast_desc-bad-types (param $i (ref null $f)) (param $desc (ref null $t2)) (result (ref null $t1)) + local.get $i + local.get $desc + br_on_cast_desc 0 (ref null $f) (ref null $t1) + ) + + ) + "type mismatch:" +) diff --git a/tests/cli/custom-descriptors.wast b/tests/cli/custom-descriptors.wast new file mode 100644 index 0000000000..973e62d9f4 --- /dev/null +++ b/tests/cli/custom-descriptors.wast @@ -0,0 +1,166 @@ +;; RUN: wast --assert default --snapshot tests/snapshots % -f custom-descriptors + +;; --enable-gc + +(module + (rec + (type $t1 (descriptor $t2) (struct (field i32))) + (type $t2 (describes $t1) (struct (field (ref $f)))) + (type $f (func (result i32))) + ) +) + +(assert_invalid + (module + (rec + (type $f (func (result i32))) + (type $t2 (describes $t1) (struct (field (ref $f)))) + (type $t1 (descriptor $t2) (struct (field i32))) + ) + ) + "forward describes reference" +) + +(assert_invalid + (module + (rec + (type $t1 (descriptor $t2) (array f32)) + (type $t2 (describes $t1) (struct (field funcref))) + ) + ) + "descriptor clause on non-struct type" +) + +(assert_invalid + (module + (rec + (type $t1 (descriptor $t2) (struct (field i32))) + (type $t2 (describes $t1) (func)) + ) + ) + "describes clause on non-struct type" +) + +(module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + ) + "supertype of described type must be described by supertype of descriptor" +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1n (sub (descriptor $t2n) (struct (field i64)))) + (type $t2n (sub (describes $t1n) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2n (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + ) + "supertype of described type must be described by supertype of descriptor" +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + ) + "supertype of type without descriptor cannot have descriptor" +) + +(assert_invalid + (module + (rec + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (sub $t1 (descriptor $t2sub) (struct (field i32 f32)))) + (type $t2sub (sub $t2 (describes $t1sub) (struct (field (ref $f) (ref $f))))) + (type $t2sub-n (sub $t2sub (struct (field (ref $f) (ref $f) (ref $f))))) + (type $f (func (result i32))) + ) + ) + "supertype of non-descriptor type cannot be a descriptor" +) + +(assert_invalid + (module + (rec + (type $t0 (sub (struct (field (ref $f))))) + (type $t1 (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (sub $t0 (describes $t1) (struct (field (ref $f))))) + (type $f (func (result i32))) + ) + ) + "supertype of descriptor must be a descriptor" +) + +(assert_invalid + (module + (rec + (type $f (func (result i32))) + (type $t1 (descriptor $t2) (struct (field i32))) + (type $t2 (struct (field (ref $f)))) + ) + ) + "descriptor with no matching describes" +) + +(assert_invalid + (module + (rec + (type $f (func (result i32))) + (type $t1 (descriptor $t2) (struct (field i32))) + (type $t1b (descriptor $t2) (struct (field i32))) + (type $t2 (describes $t1b) (struct (field (ref $f)))) + ) + ) + "descriptor with no matching describes" +) + + +(assert_invalid + (module + (rec + (type $f (func (result i32))) + (type $t1 (struct (field i32))) + (type $t2 (describes $t1) (struct (field (ref $f)))) + ) + ) + "describes with no matching descriptor" +) + +(assert_invalid + (module + (rec + (type $f (func (result i32))) + (type $t1 (descriptor $t2) (struct (field i32))) + (type $t2 (describes $t1) (struct (field (ref $f)))) + (type $t2b (describes $t1) (struct (field (ref $f)))) + ) + ) + "describes with no matching descriptor" +) diff --git a/tests/cli/dump-branch-hints.wat.stdout b/tests/cli/dump-branch-hints.wat.stdout index 9836b36909..dd5e5e701e 100644 --- a/tests/cli/dump-branch-hints.wat.stdout +++ b/tests/cli/dump-branch-hints.wat.stdout @@ -3,7 +3,7 @@ 0x8 | 01 04 | type section 0xa | 01 | 1 count --- rec group 0 (implicit) --- - 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0xe | 03 02 | func section 0x10 | 01 | 1 count 0x11 | 00 | [func 0] type 0 diff --git a/tests/cli/dump-elem-segments.wat.stdout b/tests/cli/dump-elem-segments.wat.stdout index 7228f869bf..f21f86184f 100644 --- a/tests/cli/dump-elem-segments.wat.stdout +++ b/tests/cli/dump-elem-segments.wat.stdout @@ -3,7 +3,7 @@ 0x8 | 01 04 | type section 0xa | 01 | 1 count --- rec group 0 (implicit) --- - 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0xe | 03 02 | func section 0x10 | 01 | 1 count 0x11 | 00 | [func 0] type 0 diff --git a/tests/cli/dump-llvm-object.wat.stdout b/tests/cli/dump-llvm-object.wat.stdout index fb518e2210..cdcb83450d 100644 --- a/tests/cli/dump-llvm-object.wat.stdout +++ b/tests/cli/dump-llvm-object.wat.stdout @@ -3,21 +3,21 @@ 0x8 | 01 22 | type section 0xa | 06 | 6 count --- rec group 0 (implicit) --- - 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false } } + 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 1 (implicit) --- - 0xf | 60 04 7f 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32], results: [I32] }), shared: false } } + 0xf | 60 04 7f 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 7f 01 7f --- rec group 2 (implicit) --- - 0x17 | 60 05 7f 7f | [type 2] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32, I32], results: [I32] }), shared: false } } + 0x17 | 60 05 7f 7f | [type 2] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32, I32], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 7f 7f 01 | 7f --- rec group 3 (implicit) --- - 0x20 | 60 01 7f 01 | [type 3] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32] }), shared: false } } + 0x20 | 60 01 7f 01 | [type 3] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f --- rec group 4 (implicit) --- - 0x25 | 60 00 01 7f | [type 4] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [I32] }), shared: false } } + 0x25 | 60 00 01 7f | [type 4] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 5 (implicit) --- - 0x29 | 60 00 00 | [type 5] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x29 | 60 00 00 | [type 5] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x2c | 02 8b 01 | import section 0x2f | 04 | 4 count 0x30 | 03 65 6e 76 | import [memory 0] Import { module: "env", name: "__linear_memory", ty: Memory(MemoryType { memory64: false, shared: false, initial: 1, maximum: None, page_size_log2: None }) } diff --git a/tests/cli/dump/alias.wat.stdout b/tests/cli/dump/alias.wat.stdout index 7100013041..a4504f0c02 100644 --- a/tests/cli/dump/alias.wat.stdout +++ b/tests/cli/dump/alias.wat.stdout @@ -31,7 +31,7 @@ 0x57 | 01 04 | type section 0x59 | 01 | 1 count --- rec group 0 (implicit) --- - 0x5a | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x5a | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x5d | 03 02 | func section 0x5f | 01 | 1 count 0x60 | 00 | [func 0] type 0 diff --git a/tests/cli/dump/alias2.wat.stdout b/tests/cli/dump/alias2.wat.stdout index 47695fca9e..d1e3991bd3 100644 --- a/tests/cli/dump/alias2.wat.stdout +++ b/tests/cli/dump/alias2.wat.stdout @@ -127,7 +127,7 @@ 0x158 | 01 04 | type section 0x15a | 01 | 1 count --- rec group 0 (implicit) --- - 0x15b | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x15b | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x15e | 03 02 | func section 0x160 | 01 | 1 count 0x161 | 00 | [func 0] type 0 @@ -164,7 +164,7 @@ 0x1a2 | 01 04 | type section 0x1a4 | 01 | 1 count --- rec group 0 (implicit) --- - 0x1a5 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x1a5 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x1a8 | 02 19 | import section 0x1aa | 04 | 4 count 0x1ab | 00 01 31 00 | import [func 0] Import { module: "", name: "1", ty: Func(0) } diff --git a/tests/cli/dump/blockty.wat.stdout b/tests/cli/dump/blockty.wat.stdout index a923deea11..e005a15559 100644 --- a/tests/cli/dump/blockty.wat.stdout +++ b/tests/cli/dump/blockty.wat.stdout @@ -3,16 +3,16 @@ 0x8 | 01 17 | type section 0xa | 05 | 5 count --- rec group 0 (implicit) --- - 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 1 (implicit) --- - 0xe | 60 00 01 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [I32] }), shared: false } } + 0xe | 60 00 01 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 2 (implicit) --- - 0x12 | 60 01 7f 00 | [type 2] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false } } + 0x12 | 60 01 7f 00 | [type 2] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 3 (implicit) --- - 0x16 | 60 01 7f 01 | [type 3] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32] }), shared: false } } + 0x16 | 60 01 7f 01 | [type 3] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f --- rec group 4 (implicit) --- - 0x1b | 60 01 7f 02 | [type 4] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32, I32] }), shared: false } } + 0x1b | 60 01 7f 02 | [type 4] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [I32, I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 7f 0x21 | 03 02 | func section 0x23 | 01 | 1 count diff --git a/tests/cli/dump/bundled.wat.stdout b/tests/cli/dump/bundled.wat.stdout index ff40ee87fe..49c7404bbd 100644 --- a/tests/cli/dump/bundled.wat.stdout +++ b/tests/cli/dump/bundled.wat.stdout @@ -26,7 +26,7 @@ 0x54 | 01 09 | type section 0x56 | 01 | 1 count --- rec group 0 (implicit) --- - 0x57 | 60 04 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32], results: [I32] }), shared: false } } + 0x57 | 60 04 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32, I32], results: [I32] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 7f 01 7f 0x5f | 03 02 | func section 0x61 | 01 | 1 count @@ -63,10 +63,10 @@ 0xa0 | 01 09 | type section 0xa2 | 02 | 2 count --- rec group 0 (implicit) --- - 0xa3 | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [] }), shared: false } } + 0xa3 | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } | 00 --- rec group 1 (implicit) --- - 0xa8 | 60 00 00 | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xa8 | 60 00 00 | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0xab | 02 12 | import section 0xad | 01 | 1 count 0xae | 09 77 61 73 | import [func 0] Import { module: "wasi-file", name: "read", ty: Func(0) } @@ -107,10 +107,10 @@ 0x101 | 01 0c | type section 0x103 | 02 | 2 count --- rec group 0 (implicit) --- - 0x104 | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [] }), shared: false } } + 0x104 | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } | 00 --- rec group 1 (implicit) --- - 0x109 | 60 03 7f 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32], results: [] }), shared: false } } + 0x109 | 60 03 7f 7f | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32, I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 00 0x10f | 02 12 | import section 0x111 | 01 | 1 count diff --git a/tests/cli/dump/component-expand-bundle.wat.stdout b/tests/cli/dump/component-expand-bundle.wat.stdout index d46b131707..4c5619538a 100644 --- a/tests/cli/dump/component-expand-bundle.wat.stdout +++ b/tests/cli/dump/component-expand-bundle.wat.stdout @@ -6,7 +6,7 @@ 0x12 | 01 04 | type section 0x14 | 01 | 1 count --- rec group 0 (implicit) --- - 0x15 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x15 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x18 | 03 02 | func section 0x1a | 01 | 1 count 0x1b | 00 | [func 0] type 0 @@ -30,7 +30,7 @@ 0x3d | 01 04 | type section 0x3f | 01 | 1 count --- rec group 0 (implicit) --- - 0x40 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x40 | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x43 | 02 06 | import section 0x45 | 01 | 1 count 0x46 | 00 01 61 00 | import [func 0] Import { module: "", name: "a", ty: Func(0) } diff --git a/tests/cli/dump/import-modules.wat.stdout b/tests/cli/dump/import-modules.wat.stdout index 6ce5dff9f5..2b50be09ce 100644 --- a/tests/cli/dump/import-modules.wat.stdout +++ b/tests/cli/dump/import-modules.wat.stdout @@ -2,7 +2,7 @@ | 0d 00 01 00 0x8 | 03 0d | core type section 0xa | 01 | 1 count - 0xb | 50 02 01 60 | [core type 0] Module([Type(RecGroup { inner: Implicit((14, SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } })) }), Import(Import { module: "", name: "f", ty: Func(0) })]) + 0xb | 50 02 01 60 | [core type 0] Module([Type(RecGroup { inner: Implicit((14, SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } })) }), Import(Import { module: "", name: "f", ty: Func(0) })]) | 00 00 00 00 | 01 66 00 00 0x17 | 0a 07 | component import section @@ -15,7 +15,7 @@ 0x2a | 01 04 | type section 0x2c | 01 | 1 count --- rec group 0 (implicit) --- - 0x2d | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0x2d | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x30 | 03 02 | func section 0x32 | 01 | 1 count 0x33 | 00 | [func 0] type 0 diff --git a/tests/cli/dump/module-types.wat.stdout b/tests/cli/dump/module-types.wat.stdout index 8a8c2d5b24..52e1b1badf 100644 --- a/tests/cli/dump/module-types.wat.stdout +++ b/tests/cli/dump/module-types.wat.stdout @@ -2,7 +2,7 @@ | 0d 00 01 00 0x8 | 03 23 | core type section 0xa | 01 | 1 count - 0xb | 50 05 01 60 | [core type 0] Module([Type(RecGroup { inner: Implicit((14, SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } })) }), Import(Import { module: "", name: "f", ty: Func(0) }), Import(Import { module: "", name: "g", ty: Global(GlobalType { content_type: I32, mutable: false, shared: false }) }), Import(Import { module: "", name: "t", ty: Table(TableType { element_type: funcref, table64: false, initial: 1, maximum: None, shared: false }) }), Import(Import { module: "", name: "m", ty: Memory(MemoryType { memory64: false, shared: false, initial: 1, maximum: None, page_size_log2: None }) })]) + 0xb | 50 05 01 60 | [core type 0] Module([Type(RecGroup { inner: Implicit((14, SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } })) }), Import(Import { module: "", name: "f", ty: Func(0) }), Import(Import { module: "", name: "g", ty: Global(GlobalType { content_type: I32, mutable: false, shared: false }) }), Import(Import { module: "", name: "t", ty: Table(TableType { element_type: funcref, table64: false, initial: 1, maximum: None, shared: false }) }), Import(Import { module: "", name: "m", ty: Memory(MemoryType { memory64: false, shared: false, initial: 1, maximum: None, page_size_log2: None }) })]) | 00 00 00 00 | 01 66 00 00 | 00 00 01 67 diff --git a/tests/cli/dump/names.wat.stdout b/tests/cli/dump/names.wat.stdout index 41ee06cc51..7c5e5de259 100644 --- a/tests/cli/dump/names.wat.stdout +++ b/tests/cli/dump/names.wat.stdout @@ -3,7 +3,7 @@ 0x8 | 01 05 | type section 0xa | 01 | 1 count --- rec group 0 (implicit) --- - 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false } } + 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0xf | 03 02 | func section 0x11 | 01 | 1 count 0x12 | 00 | [func 0] type 0 diff --git a/tests/cli/dump/rec-group.wat.stdout b/tests/cli/dump/rec-group.wat.stdout index 07317e38a4..20d5142571 100644 --- a/tests/cli/dump/rec-group.wat.stdout +++ b/tests/cli/dump/rec-group.wat.stdout @@ -4,25 +4,25 @@ 0xa | 04 | 4 count --- rec group 0 (explicit) --- 0xb | 4e 01 | - 0xd | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [F64] }), shared: false } } + 0xd | 60 02 7f 7f | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32, I32], results: [F64] }), shared: false, descriptor_idx: None, describes_idx: None } } | 01 7c --- rec group 1 (explicit) --- 0x13 | 4e 03 | - 0x15 | 50 00 5f 01 | [type 1] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: false }] }), shared: false } } + 0x15 | 50 00 5f 01 | [type 1] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: false }] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 00 - 0x1b | 50 00 5f 01 | [type 2] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: true }] }), shared: false } } + 0x1b | 50 00 5f 01 | [type 2] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: true }] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 01 - 0x21 | 50 00 5f 08 | [type 3] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: true }, FieldType { element_type: Val(I64), mutable: true }, FieldType { element_type: Val(F32), mutable: true }, FieldType { element_type: Val(F64), mutable: true }, FieldType { element_type: Val(V128), mutable: true }, FieldType { element_type: Val(Ref(funcref)), mutable: true }, FieldType { element_type: Val(Ref(externref)), mutable: true }, FieldType { element_type: Val(Ref((ref null (module 2)))), mutable: true }] }), shared: false } } + 0x21 | 50 00 5f 08 | [type 3] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Struct(StructType { fields: [FieldType { element_type: Val(I32), mutable: true }, FieldType { element_type: Val(I64), mutable: true }, FieldType { element_type: Val(F32), mutable: true }, FieldType { element_type: Val(F64), mutable: true }, FieldType { element_type: Val(V128), mutable: true }, FieldType { element_type: Val(Ref(funcref)), mutable: true }, FieldType { element_type: Val(Ref(externref)), mutable: true }, FieldType { element_type: Val(Ref((ref null (module 2)))), mutable: true }] }), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 01 7e 01 | 7d 01 7c 01 | 7b 01 70 01 | 6f 01 63 02 | 01 --- rec group 2 (implicit) --- - 0x36 | 50 00 5e 7f | [type 4] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Array(ArrayType(FieldType { element_type: Val(I32), mutable: false })), shared: false } } + 0x36 | 50 00 5e 7f | [type 4] SubType { is_final: false, supertype_idx: None, composite_type: CompositeType { inner: Array(ArrayType(FieldType { element_type: Val(I32), mutable: false })), shared: false, descriptor_idx: None, describes_idx: None } } | 00 --- rec group 3 (implicit) --- - 0x3b | 50 01 04 5e | [type 5] SubType { is_final: false, supertype_idx: Some(CoreTypeIndex { kind: "module", index: 4 }), composite_type: CompositeType { inner: Array(ArrayType(FieldType { element_type: Val(I32), mutable: false })), shared: false } } + 0x3b | 50 01 04 5e | [type 5] SubType { is_final: false, supertype_idx: Some(CoreTypeIndex { kind: "module", index: 4 }), composite_type: CompositeType { inner: Array(ArrayType(FieldType { element_type: Val(I32), mutable: false })), shared: false, descriptor_idx: None, describes_idx: None } } | 7f 00 0x41 | 00 0e | custom section 0x43 | 04 6e 61 6d | name: "name" diff --git a/tests/cli/dump/select.wat.stdout b/tests/cli/dump/select.wat.stdout index 98937ed108..0559788422 100644 --- a/tests/cli/dump/select.wat.stdout +++ b/tests/cli/dump/select.wat.stdout @@ -3,7 +3,7 @@ 0x8 | 01 04 | type section 0xa | 01 | 1 count --- rec group 0 (implicit) --- - 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xb | 60 00 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0xe | 03 02 | func section 0x10 | 01 | 1 count 0x11 | 00 | [func 0] type 0 diff --git a/tests/cli/dump/simple.wat.stdout b/tests/cli/dump/simple.wat.stdout index b01a25e80b..a5fbf05922 100644 --- a/tests/cli/dump/simple.wat.stdout +++ b/tests/cli/dump/simple.wat.stdout @@ -3,9 +3,9 @@ 0x8 | 01 08 | type section 0xa | 02 | 2 count --- rec group 0 (implicit) --- - 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false } } + 0xb | 60 01 7f 00 | [type 0] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [I32], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } --- rec group 1 (implicit) --- - 0xf | 60 00 00 | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false } } + 0xf | 60 00 00 | [type 1] SubType { is_final: true, supertype_idx: None, composite_type: CompositeType { inner: Func(FuncType { params: [], results: [] }), shared: false, descriptor_idx: None, describes_idx: None } } 0x12 | 02 07 | import section 0x14 | 01 | 1 count 0x15 | 01 6d 01 6e | import [func 0] Import { module: "m", name: "n", ty: Func(0) } diff --git a/tests/cli/print-operand-stack-folded.wat.stdout b/tests/cli/print-operand-stack-folded.wat.stdout index 13de435f13..c0a6be47e0 100644 --- a/tests/cli/print-operand-stack-folded.wat.stdout +++ b/tests/cli/print-operand-stack-folded.wat.stdout @@ -23,10 +23,10 @@ (i32.const 7 (; [i32 i32] ;)))) (table.set 0 (; [] ;) (i32.const 2 (; [i32] ;)) - (struct.new_default $st (; [i32 (ref (id 1))] ;))) + (struct.new_default $st (; [i32 (ref (exact (id 1)))] ;))) (table.set 0 (; [] ;) (i32.const 3 (; [i32] ;)) - (array.new_default $at (; [i32 (ref (id 2))] ;) + (array.new_default $at (; [i32 (ref (exact (id 2)))] ;) (i32.const 0 (; [i32 i32] ;)))) (table.set 0 (; [] ;) (i32.const 4 (; [i32] ;)) diff --git a/tests/cli/print-operand-stack.wat.stdout b/tests/cli/print-operand-stack.wat.stdout index e1e61b2865..505626c40f 100644 --- a/tests/cli/print-operand-stack.wat.stdout +++ b/tests/cli/print-operand-stack.wat.stdout @@ -31,7 +31,7 @@ i32.const 2 ;; [i32] struct.new_default $st - ;; [i32 (ref (id 1))] + ;; [i32 (ref (exact (id 1)))] table.set 0 ;; [] i32.const 3 @@ -39,7 +39,7 @@ i32.const 0 ;; [i32 i32] array.new_default $at - ;; [i32 (ref (id 2))] + ;; [i32 (ref (exact (id 2)))] table.set 0 ;; [] i32.const 4 diff --git a/tests/cli/spec/proposals/custom-descriptors/array_new_exact.wast b/tests/cli/spec/proposals/custom-descriptors/array_new_exact.wast new file mode 100644 index 0000000000..e8523e27da --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/array_new_exact.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/array_new_exact.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/binary-descriptors.wast b/tests/cli/spec/proposals/custom-descriptors/binary-descriptors.wast new file mode 100644 index 0000000000..db581806f5 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/binary-descriptors.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/binary-descriptors.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/binary.wast b/tests/cli/spec/proposals/custom-descriptors/binary.wast new file mode 100644 index 0000000000..2d5bdfb59d --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/binary.wast @@ -0,0 +1,7 @@ +;; RUN: wast \ +;; --assert default \ +;; --assert permissive \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/binary.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/br_on_cast.wast b/tests/cli/spec/proposals/custom-descriptors/br_on_cast.wast new file mode 100644 index 0000000000..88274a7e45 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/br_on_cast.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/br_on_cast.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc.wast b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc.wast new file mode 100644 index 0000000000..7258cd9997 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc_fail.wast b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc_fail.wast new file mode 100644 index 0000000000..3f079ae577 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_desc_fail.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/br_on_cast_fail.wast b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_fail.wast new file mode 100644 index 0000000000..3a65b4bf0c --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/br_on_cast_fail.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/descriptors.wast b/tests/cli/spec/proposals/custom-descriptors/descriptors.wast new file mode 100644 index 0000000000..2c5deca768 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/descriptors.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/descriptors.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/exact-casts.wast b/tests/cli/spec/proposals/custom-descriptors/exact-casts.wast new file mode 100644 index 0000000000..f709eb764c --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/exact-casts.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/exact-casts.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast b/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast new file mode 100644 index 0000000000..2b37727194 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast @@ -0,0 +1,6 @@ +;; FAIL: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/exact-func-import.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast.stderr b/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast.stderr new file mode 100644 index 0000000000..50a4f665e8 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/exact-func-import.wast.stderr @@ -0,0 +1,5 @@ +error: expected `)` + --> tests/testsuite/proposals/custom-descriptors/exact-func-import.wast:3:26 + | + 3 | (import "" "" (func $1 (exact (type 0)))) + | ^ diff --git a/tests/cli/spec/proposals/custom-descriptors/exact.wast b/tests/cli/spec/proposals/custom-descriptors/exact.wast new file mode 100644 index 0000000000..01fab8aa37 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/exact.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/exact.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/ref_cast_desc.wast b/tests/cli/spec/proposals/custom-descriptors/ref_cast_desc.wast new file mode 100644 index 0000000000..6173573dcd --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/ref_cast_desc.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/ref_cast_desc.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/ref_get_desc.wast b/tests/cli/spec/proposals/custom-descriptors/ref_get_desc.wast new file mode 100644 index 0000000000..2904173abd --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/ref_get_desc.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/ref_get_desc.wast diff --git a/tests/cli/spec/proposals/custom-descriptors/struct_new_desc.wast b/tests/cli/spec/proposals/custom-descriptors/struct_new_desc.wast new file mode 100644 index 0000000000..a5d4061860 --- /dev/null +++ b/tests/cli/spec/proposals/custom-descriptors/struct_new_desc.wast @@ -0,0 +1,6 @@ +;; RUN: wast \ +;; --assert default \ +;; --snapshot tests/snapshots \ +;; --ignore-error-messages \ +;; --features=wasm3,custom-descriptors \ +;; tests/testsuite/proposals/custom-descriptors/struct_new_desc.wast diff --git a/tests/cli/validate-unknown-features.wat.stderr b/tests/cli/validate-unknown-features.wat.stderr index a07287ad9f..fb52bd61e2 100644 --- a/tests/cli/validate-unknown-features.wat.stderr +++ b/tests/cli/validate-unknown-features.wat.stderr @@ -1,4 +1,4 @@ error: invalid value 'unknown' for '--features ': unknown feature `unknown` -Valid features: mutable-global, saturating-float-to-int, sign-extension, reference-types, multi-value, bulk-memory, simd, relaxed-simd, threads, shared-everything-threads, tail-call, floats, multi-memory, exceptions, memory64, extended-const, component-model, function-references, memory-control, gc, custom-page-sizes, legacy-exceptions, gc-types, stack-switching, wide-arithmetic, cm-values, cm-nested-names, cm-async, cm-async-stackful, cm-async-builtins, cm-threading, cm-error-context, cm-fixed-size-list, cm-gc, call-indirect-overlong, bulk-memory-opt, mvp, wasm1, wasm2, wasm3, lime1, all +Valid features: mutable-global, saturating-float-to-int, sign-extension, reference-types, multi-value, bulk-memory, simd, relaxed-simd, threads, shared-everything-threads, tail-call, floats, multi-memory, exceptions, memory64, extended-const, component-model, function-references, memory-control, gc, custom-page-sizes, legacy-exceptions, gc-types, stack-switching, wide-arithmetic, cm-values, cm-nested-names, cm-async, cm-async-stackful, cm-async-builtins, cm-threading, cm-error-context, cm-fixed-size-list, cm-gc, call-indirect-overlong, bulk-memory-opt, custom-descriptors, mvp, wasm1, wasm2, wasm3, lime1, all For more information, try '--help'. diff --git a/tests/snapshots/cli/custom-descriptors-disabled.wast.json b/tests/snapshots/cli/custom-descriptors-disabled.wast.json new file mode 100644 index 0000000000..de3d7a534b --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors-disabled.wast.json @@ -0,0 +1,26 @@ +{ + "source_filename": "tests/cli/custom-descriptors-disabled.wast", + "commands": [ + { + "type": "assert_invalid", + "line": 4, + "filename": "custom-descriptors-disabled.0.wasm", + "module_type": "binary", + "text": "custom descriptors required for exact reference types" + }, + { + "type": "assert_invalid", + "line": 11, + "filename": "custom-descriptors-disabled.1.wasm", + "module_type": "binary", + "text": "custom descriptors proposal must be enabled" + }, + { + "type": "assert_invalid", + "line": 20, + "filename": "custom-descriptors-disabled.2.wasm", + "module_type": "binary", + "text": "custom descriptors proposal must be enabled" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/cli/custom-descriptors-ops.wast.json b/tests/snapshots/cli/custom-descriptors-ops.wast.json new file mode 100644 index 0000000000..1a4ebce47e --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors-ops.wast.json @@ -0,0 +1,39 @@ +{ + "source_filename": "tests/cli/custom-descriptors-ops.wast", + "commands": [ + { + "type": "module", + "line": 5, + "filename": "custom-descriptors-ops.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 101, + "filename": "custom-descriptors-ops.1.wasm", + "module_type": "binary", + "text": "type mismatch: expected (ref null (exact" + }, + { + "type": "assert_invalid", + "line": 124, + "filename": "custom-descriptors-ops.2.wasm", + "module_type": "binary", + "text": "type mismatch: expected (ref null (exact" + }, + { + "type": "assert_invalid", + "line": 146, + "filename": "custom-descriptors-ops.3.wasm", + "module_type": "binary", + "text": "type mismatch: expected (ref null (exact" + }, + { + "type": "assert_invalid", + "line": 171, + "filename": "custom-descriptors-ops.4.wasm", + "module_type": "binary", + "text": "type mismatch:" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/cli/custom-descriptors-ops.wast/0.print b/tests/snapshots/cli/custom-descriptors-ops.wast/0.print new file mode 100644 index 0000000000..db0d1ed03c --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors-ops.wast/0.print @@ -0,0 +1,82 @@ +(module + (type $f (;0;) (func (result i32))) + (rec + (type $t1 (;1;) (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (;2;) (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (;3;) (sub $t1 (descriptor $t2sub) (struct (field i32) (field f32)))) + (type $t2sub (;4;) (sub $t2 (describes $t1sub) (struct (field (ref $f)) (field (ref $f))))) + ) + (type (;5;) (func)) + (type (;6;) (func (param (ref (exact $t2))))) + (type (;7;) (func (result (ref (exact $t2))))) + (type (;8;) (func (param (ref $t1) (ref null (exact $t2))) (result (ref null (exact $t1))))) + (type (;9;) (func (param (ref null $t1sub) (ref null $t2)) (result (ref null $t1)))) + (import "" "rtt1" (global $g1 (;0;) (ref (exact $t2)))) + (import "" "rtt1sub" (global $g1sub (;1;) (ref (exact $t2sub)))) + (elem (;0;) declare func $f_impl) + (func $f_impl (;0;) (type $f) (result i32) + unreachable + ) + (func $test-struct-new (;1;) (type 5) + i32.const 3 + global.get $g1 + struct.new $t1 + drop + global.get $g1 + struct.new_default $t1 + drop + global.get $g1sub + struct.new_default $t1sub + drop + ) + (func $test-exact-types (;2;) (type 5) + (local $l_any anyref) (local $l_struct structref) (local $l_t2 (ref $t2)) (local $l_t2_e (ref (exact $t2))) + global.get $g1 + local.set $l_any + global.get $g1 + local.set $l_struct + global.get $g1 + local.set $l_t2 + global.get $g1 + local.set $l_t2_e + global.get $g1sub + local.set $l_struct + global.get $g1sub + local.set $l_t2 + local.get $l_any + ref.cast (ref null $t2) + ref.cast (ref (exact $t2)) + local.set $l_t2_e + ) + (func $test-struct-new-result (;3;) (type 5) + (local (ref (exact $t2))) + ref.func $f_impl + struct.new $t2 + local.set 0 + ) + (func $test-get-desc (;4;) (type 6) (param $rtt (ref (exact $t2))) + local.get $rtt + struct.new_default $t1 + ref.get_desc $t1 + local.set $rtt + ) + (func $test-get-desc-2 (;5;) (type 7) (result (ref (exact $t2))) + unreachable + ref.get_desc $t1 + ) + (func $test-cast-desc (;6;) (type 8) (param $i (ref $t1)) (param $desc (ref null (exact $t2))) (result (ref null (exact $t1))) + local.get $i + local.get $desc + ref.cast_desc (ref null (exact $t1)) + ) + (func $test-br_on_cast_desc (;7;) (type 9) (param $i (ref null $t1sub)) (param $desc (ref null $t2)) (result (ref null $t1)) + local.get $i + local.get $desc + br_on_cast_desc 0 (ref null $t1sub) (ref null $t1) + ) + (func $test-br_on_cast_desc_fail (;8;) (type 9) (param $i (ref null $t1sub)) (param $desc (ref null $t2)) (result (ref null $t1)) + local.get $i + local.get $desc + br_on_cast_desc_fail 0 (ref null $t1sub) (ref null $t1) + ) +) diff --git a/tests/snapshots/cli/custom-descriptors.wast.json b/tests/snapshots/cli/custom-descriptors.wast.json new file mode 100644 index 0000000000..b75c7b711e --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors.wast.json @@ -0,0 +1,101 @@ +{ + "source_filename": "tests/cli/custom-descriptors.wast", + "commands": [ + { + "type": "module", + "line": 5, + "filename": "custom-descriptors.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 14, + "filename": "custom-descriptors.1.wasm", + "module_type": "binary", + "text": "forward describes reference" + }, + { + "type": "assert_invalid", + "line": 25, + "filename": "custom-descriptors.2.wasm", + "module_type": "binary", + "text": "descriptor clause on non-struct type" + }, + { + "type": "assert_invalid", + "line": 35, + "filename": "custom-descriptors.3.wasm", + "module_type": "binary", + "text": "describes clause on non-struct type" + }, + { + "type": "module", + "line": 44, + "filename": "custom-descriptors.4.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 55, + "filename": "custom-descriptors.5.wasm", + "module_type": "binary", + "text": "supertype of described type must be described by supertype of descriptor" + }, + { + "type": "assert_invalid", + "line": 68, + "filename": "custom-descriptors.6.wasm", + "module_type": "binary", + "text": "supertype of described type must be described by supertype of descriptor" + }, + { + "type": "assert_invalid", + "line": 83, + "filename": "custom-descriptors.7.wasm", + "module_type": "binary", + "text": "supertype of type without descriptor cannot have descriptor" + }, + { + "type": "assert_invalid", + "line": 96, + "filename": "custom-descriptors.8.wasm", + "module_type": "binary", + "text": "supertype of non-descriptor type cannot be a descriptor" + }, + { + "type": "assert_invalid", + "line": 110, + "filename": "custom-descriptors.9.wasm", + "module_type": "binary", + "text": "supertype of descriptor must be a descriptor" + }, + { + "type": "assert_invalid", + "line": 122, + "filename": "custom-descriptors.10.wasm", + "module_type": "binary", + "text": "descriptor with no matching describes" + }, + { + "type": "assert_invalid", + "line": 133, + "filename": "custom-descriptors.11.wasm", + "module_type": "binary", + "text": "descriptor with no matching describes" + }, + { + "type": "assert_invalid", + "line": 146, + "filename": "custom-descriptors.12.wasm", + "module_type": "binary", + "text": "describes with no matching descriptor" + }, + { + "type": "assert_invalid", + "line": 157, + "filename": "custom-descriptors.13.wasm", + "module_type": "binary", + "text": "describes with no matching descriptor" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/cli/custom-descriptors.wast/0.print b/tests/snapshots/cli/custom-descriptors.wast/0.print new file mode 100644 index 0000000000..c8d241eb3b --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors.wast/0.print @@ -0,0 +1,7 @@ +(module + (rec + (type $t1 (;0;) (descriptor $t2) (struct (field i32))) + (type $t2 (;1;) (describes $t1) (struct (field (ref $f)))) + (type $f (;2;) (func (result i32))) + ) +) diff --git a/tests/snapshots/cli/custom-descriptors.wast/4.print b/tests/snapshots/cli/custom-descriptors.wast/4.print new file mode 100644 index 0000000000..e5a52378b7 --- /dev/null +++ b/tests/snapshots/cli/custom-descriptors.wast/4.print @@ -0,0 +1,9 @@ +(module + (rec + (type $t1 (;0;) (sub (descriptor $t2) (struct (field i32)))) + (type $t2 (;1;) (sub (describes $t1) (struct (field (ref $f))))) + (type $t1sub (;2;) (sub $t1 (descriptor $t2sub) (struct (field i32) (field f32)))) + (type $t2sub (;3;) (sub $t2 (describes $t1sub) (struct (field (ref $f)) (field (ref $f))))) + (type $f (;4;) (func (result i32))) + ) +) diff --git a/tests/snapshots/testsuite/array.wast.json b/tests/snapshots/testsuite/array.wast.json index 7d0b0c46d2..6d4d15ae60 100644 --- a/tests/snapshots/testsuite/array.wast.json +++ b/tests/snapshots/testsuite/array.wast.json @@ -702,7 +702,7 @@ "line": 293, "filename": "array.9.wasm", "module_type": "binary", - "text": "array is immutable" + "text": "immutable array" }, { "type": "assert_invalid", diff --git a/tests/snapshots/testsuite/array_copy.wast.json b/tests/snapshots/testsuite/array_copy.wast.json index 7dc1dd2698..56be4bf4ba 100644 --- a/tests/snapshots/testsuite/array_copy.wast.json +++ b/tests/snapshots/testsuite/array_copy.wast.json @@ -6,7 +6,7 @@ "line": 6, "filename": "array_copy.0.wasm", "module_type": "binary", - "text": "array is immutable" + "text": "immutable array" }, { "type": "assert_invalid", diff --git a/tests/snapshots/testsuite/array_fill.wast.json b/tests/snapshots/testsuite/array_fill.wast.json index e7efb98a70..e9dc78c847 100644 --- a/tests/snapshots/testsuite/array_fill.wast.json +++ b/tests/snapshots/testsuite/array_fill.wast.json @@ -6,7 +6,7 @@ "line": 6, "filename": "array_fill.0.wasm", "module_type": "binary", - "text": "array is immutable" + "text": "immutable array" }, { "type": "assert_invalid", diff --git a/tests/snapshots/testsuite/array_init_data.wast.json b/tests/snapshots/testsuite/array_init_data.wast.json index 42ee86de47..94b2a2448a 100644 --- a/tests/snapshots/testsuite/array_init_data.wast.json +++ b/tests/snapshots/testsuite/array_init_data.wast.json @@ -6,7 +6,7 @@ "line": 6, "filename": "array_init_data.0.wasm", "module_type": "binary", - "text": "array is immutable" + "text": "immutable array" }, { "type": "assert_invalid", diff --git a/tests/snapshots/testsuite/array_init_elem.wast.json b/tests/snapshots/testsuite/array_init_elem.wast.json index 03f1798826..04d091f3ea 100644 --- a/tests/snapshots/testsuite/array_init_elem.wast.json +++ b/tests/snapshots/testsuite/array_init_elem.wast.json @@ -6,7 +6,7 @@ "line": 6, "filename": "array_init_elem.0.wasm", "module_type": "binary", - "text": "array is immutable" + "text": "immutable array" }, { "type": "assert_invalid", diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast.json new file mode 100644 index 0000000000..636dffe3f9 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast.json @@ -0,0 +1,11 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/array_new_exact.wast", + "commands": [ + { + "type": "module", + "line": 1, + "filename": "array_new_exact.0.wasm", + "module_type": "binary" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast/0.print new file mode 100644 index 0000000000..2d931d0579 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/array_new_exact.wast/0.print @@ -0,0 +1,33 @@ +(module + (type $a1 (;0;) (array i8)) + (type $a2 (;1;) (array (mut funcref))) + (type (;2;) (func (result (ref (exact $a1))))) + (type (;3;) (func (result (ref (exact $a2))))) + (elem (;0;) funcref) + (func (;0;) (type 2) (result (ref (exact $a1))) + i32.const 0 + i32.const 0 + array.new $a1 + ) + (func (;1;) (type 2) (result (ref (exact $a1))) + i32.const 0 + array.new_default $a1 + ) + (func (;2;) (type 2) (result (ref (exact $a1))) + i32.const 0 + i32.const 1 + i32.const 2 + array.new_fixed $a1 3 + ) + (func (;3;) (type 2) (result (ref (exact $a1))) + i32.const 0 + i32.const 0 + array.new_data $a1 0 + ) + (func (;4;) (type 3) (result (ref (exact $a2))) + i32.const 0 + i32.const 0 + array.new_elem $a2 0 + ) + (data (;0;) "abc") +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast.json new file mode 100644 index 0000000000..5eccd3966f --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast.json @@ -0,0 +1,38 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/binary-descriptors.wast", + "commands": [ + { + "type": "module", + "line": 2, + "filename": "binary-descriptors.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 21, + "filename": "binary-descriptors.1.wasm", + "module_type": "binary", + "text": "malformed definition type" + }, + { + "type": "assert_malformed", + "line": 44, + "filename": "binary-descriptors.2.wasm", + "module_type": "binary", + "text": "malformed definition type" + }, + { + "type": "module", + "line": 66, + "filename": "binary-descriptors.3.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 92, + "filename": "binary-descriptors.4.wasm", + "module_type": "binary", + "text": "malformed definition type" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/0.print new file mode 100644 index 0000000000..0ddaa9d274 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/0.print @@ -0,0 +1,6 @@ +(module + (rec + (type (;0;) (descriptor 1) (struct)) + (type (;1;) (describes 0) (struct)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/3.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/3.print new file mode 100644 index 0000000000..836f906b70 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary-descriptors.wast/3.print @@ -0,0 +1,7 @@ +(module + (rec + (type (;0;) (descriptor 1) (struct)) + (type (;1;) (describes 0) (descriptor 2) (struct)) + (type (;2;) (describes 1) (struct)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast.json new file mode 100644 index 0000000000..f7b419db3f --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast.json @@ -0,0 +1,862 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/binary.wast", + "commands": [ + { + "type": "module", + "line": 1, + "filename": "binary.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 2, + "filename": "binary.1.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 3, + "name": "M1", + "filename": "binary.2.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 4, + "name": "M2", + "filename": "binary.3.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 6, + "filename": "binary.4.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 7, + "filename": "binary.5.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 8, + "filename": "binary.6.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 9, + "filename": "binary.7.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 10, + "filename": "binary.8.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 11, + "filename": "binary.9.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 12, + "filename": "binary.10.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 13, + "filename": "binary.11.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 14, + "filename": "binary.12.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 15, + "filename": "binary.13.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 16, + "filename": "binary.14.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 17, + "filename": "binary.15.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 18, + "filename": "binary.16.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 21, + "filename": "binary.17.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 24, + "filename": "binary.18.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 25, + "filename": "binary.19.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 28, + "filename": "binary.20.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 31, + "filename": "binary.21.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 34, + "filename": "binary.22.wasm", + "module_type": "binary", + "text": "magic header not detected" + }, + { + "type": "assert_malformed", + "line": 37, + "filename": "binary.23.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 38, + "filename": "binary.24.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 39, + "filename": "binary.25.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 40, + "filename": "binary.26.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 41, + "filename": "binary.27.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 42, + "filename": "binary.28.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 43, + "filename": "binary.29.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 44, + "filename": "binary.30.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 45, + "filename": "binary.31.wasm", + "module_type": "binary", + "text": "unknown binary version" + }, + { + "type": "assert_malformed", + "line": 48, + "filename": "binary.32.wasm", + "module_type": "binary", + "text": "malformed section id" + }, + { + "type": "assert_malformed", + "line": 49, + "filename": "binary.33.wasm", + "module_type": "binary", + "text": "malformed section id" + }, + { + "type": "assert_malformed", + "line": 50, + "filename": "binary.34.wasm", + "module_type": "binary", + "text": "malformed section id" + }, + { + "type": "assert_malformed", + "line": 51, + "filename": "binary.35.wasm", + "module_type": "binary", + "text": "malformed section id" + }, + { + "type": "assert_malformed", + "line": 52, + "filename": "binary.36.wasm", + "module_type": "binary", + "text": "malformed section id" + }, + { + "type": "assert_malformed", + "line": 56, + "filename": "binary.37.wasm", + "module_type": "binary", + "text": "END opcode expected" + }, + { + "type": "assert_malformed", + "line": 77, + "filename": "binary.38.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 93, + "filename": "binary.39.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "assert_malformed", + "line": 113, + "filename": "binary.40.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 126, + "filename": "binary.41.wasm", + "module_type": "binary", + "text": "integer too large" + }, + { + "type": "assert_malformed", + "line": 143, + "filename": "binary.42.wasm", + "module_type": "binary", + "text": "integer too large" + }, + { + "type": "assert_malformed", + "line": 160, + "filename": "binary.43.wasm", + "module_type": "binary", + "text": "too many locals" + }, + { + "type": "assert_malformed", + "line": 176, + "filename": "binary.44.wasm", + "module_type": "binary", + "text": "too many locals" + }, + { + "type": "module", + "line": 194, + "filename": "binary.45.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 210, + "filename": "binary.46.wasm", + "module_type": "binary", + "text": "function and code section have inconsistent lengths" + }, + { + "type": "assert_malformed", + "line": 220, + "filename": "binary.47.wasm", + "module_type": "binary", + "text": "function and code section have inconsistent lengths" + }, + { + "type": "assert_malformed", + "line": 229, + "filename": "binary.48.wasm", + "module_type": "binary", + "text": "function and code section have inconsistent lengths" + }, + { + "type": "assert_malformed", + "line": 240, + "filename": "binary.49.wasm", + "module_type": "binary", + "text": "function and code section have inconsistent lengths" + }, + { + "type": "module", + "line": 250, + "filename": "binary.50.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 256, + "filename": "binary.51.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 263, + "filename": "binary.52.wasm", + "module_type": "binary", + "text": "data count and data section have inconsistent lengths" + }, + { + "type": "assert_malformed", + "line": 275, + "filename": "binary.53.wasm", + "module_type": "binary", + "text": "data count and data section have inconsistent lengths" + }, + { + "type": "assert_malformed", + "line": 287, + "filename": "binary.54.wasm", + "module_type": "binary", + "text": "data count and data section have inconsistent lengths" + }, + { + "type": "module", + "line": 296, + "filename": "binary.55.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 303, + "filename": "binary.56.wasm", + "module_type": "binary", + "text": "data count section required" + }, + { + "type": "assert_malformed", + "line": 326, + "filename": "binary.57.wasm", + "module_type": "binary", + "text": "data count section required" + }, + { + "type": "assert_malformed", + "line": 346, + "filename": "binary.58.wasm", + "module_type": "binary", + "text": "illegal opcode" + }, + { + "type": "assert_malformed", + "line": 374, + "filename": "binary.59.wasm", + "module_type": "binary", + "text": "malformed reference type" + }, + { + "type": "module", + "line": 401, + "filename": "binary.60.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 426, + "filename": "binary.61.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 452, + "filename": "binary.62.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 459, + "filename": "binary.63.wasm", + "module_type": "binary", + "text": "length out of bounds" + }, + { + "type": "assert_malformed", + "line": 470, + "filename": "binary.64.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 480, + "filename": "binary.65.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 489, + "filename": "binary.66.wasm", + "module_type": "binary", + "text": "malformed import kind" + }, + { + "type": "assert_malformed", + "line": 499, + "filename": "binary.67.wasm", + "module_type": "binary", + "text": "malformed import kind" + }, + { + "type": "assert_malformed", + "line": 510, + "filename": "binary.68.wasm", + "module_type": "binary", + "text": "malformed import kind" + }, + { + "type": "assert_malformed", + "line": 520, + "filename": "binary.69.wasm", + "module_type": "binary", + "text": "malformed import kind" + }, + { + "type": "assert_malformed", + "line": 533, + "filename": "binary.70.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 552, + "filename": "binary.71.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 576, + "filename": "binary.72.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 583, + "filename": "binary.73.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 593, + "filename": "binary.74.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "assert_malformed", + "line": 602, + "filename": "binary.75.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "assert_malformed", + "line": 612, + "filename": "binary.76.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "module", + "line": 623, + "filename": "binary.77.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 630, + "filename": "binary.78.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 640, + "filename": "binary.79.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "assert_malformed", + "line": 648, + "filename": "binary.80.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "assert_malformed", + "line": 657, + "filename": "binary.81.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "assert_malformed", + "line": 666, + "filename": "binary.82.wasm", + "module_type": "binary", + "text": "malformed limits flags" + }, + { + "type": "module", + "line": 676, + "filename": "binary.83.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 683, + "filename": "binary.84.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 694, + "filename": "binary.85.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 704, + "filename": "binary.86.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 717, + "filename": "binary.87.wasm", + "module_type": "binary", + "text": "length out of bounds" + }, + { + "type": "assert_malformed", + "line": 738, + "filename": "binary.88.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 758, + "filename": "binary.89.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 772, + "filename": "binary.90.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 788, + "filename": "binary.91.wasm", + "module_type": "binary", + "text": "unexpected end" + }, + { + "type": "assert_malformed", + "line": 805, + "filename": "binary.92.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 822, + "filename": "binary.93.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 831, + "filename": "binary.94.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 844, + "filename": "binary.95.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "assert_malformed", + "line": 857, + "filename": "binary.96.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "assert_malformed", + "line": 871, + "filename": "binary.97.wasm", + "module_type": "binary", + "text": "section size mismatch" + }, + { + "type": "module", + "line": 884, + "filename": "binary.98.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 902, + "filename": "binary.99.wasm", + "module_type": "binary", + "text": "unexpected end of section or function" + }, + { + "type": "module", + "line": 935, + "filename": "binary.100.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 949, + "filename": "binary.101.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 966, + "filename": "binary.102.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 978, + "filename": "binary.103.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 990, + "filename": "binary.104.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1000, + "filename": "binary.105.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1010, + "filename": "binary.106.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1020, + "filename": "binary.107.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1030, + "filename": "binary.108.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1040, + "filename": "binary.109.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1050, + "filename": "binary.110.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1060, + "filename": "binary.111.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1070, + "filename": "binary.112.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1080, + "filename": "binary.113.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1090, + "filename": "binary.114.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1100, + "filename": "binary.115.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1110, + "filename": "binary.116.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1120, + "filename": "binary.117.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1130, + "filename": "binary.118.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1140, + "filename": "binary.119.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1152, + "filename": "binary.120.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1164, + "filename": "binary.121.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1174, + "filename": "binary.122.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1184, + "filename": "binary.123.wasm", + "module_type": "binary", + "text": "unexpected content after last section" + }, + { + "type": "assert_malformed", + "line": 1198, + "filename": "binary.124.wasm", + "module_type": "binary", + "text": "illegal opcode ff" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/0.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/0.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/1.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/1.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/100.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/100.print new file mode 100644 index 0000000000..d90addbeb7 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/100.print @@ -0,0 +1,5 @@ +(module + (type (;0;) (func)) + (start 0) + (func (;0;) (type 0)) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/2.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/2.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/2.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/3.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/3.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/3.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/45.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/45.print new file mode 100644 index 0000000000..5b779b0575 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/45.print @@ -0,0 +1,6 @@ +(module + (type (;0;) (func)) + (func (;0;) (type 0) + (local f32 f32) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/50.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/50.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/50.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/51.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/51.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/51.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/55.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/55.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/55.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/60.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/60.print new file mode 100644 index 0000000000..f60ef5c6a4 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/60.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (table (;0;) 0 funcref) + (memory (;0;) 0) + (elem (;0;) funcref (ref.func 0)) + (func (;0;) (type 0)) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/61.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/61.print new file mode 100644 index 0000000000..b959a17a4a --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/61.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (table (;0;) 0 funcref) + (memory (;0;) 0) + (elem (;0;) funcref (ref.null func)) + (func (;0;) (type 0)) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/62.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/62.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/62.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/65.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/65.print new file mode 100644 index 0000000000..4e56904c89 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/65.print @@ -0,0 +1,3 @@ +(module + (type (;0;) (func (param i32))) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/72.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/72.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/72.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/77.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/77.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/77.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/83.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/83.print new file mode 100644 index 0000000000..3af8f25454 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/83.print @@ -0,0 +1 @@ +(module) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/86.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/86.print new file mode 100644 index 0000000000..bb1df0f6c7 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/86.print @@ -0,0 +1,5 @@ +(module + (type (;0;) (func)) + (func (;0;) (type 0)) + (func (;1;) (type 0)) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/89.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/89.print new file mode 100644 index 0000000000..e3c7ff0b0d --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/89.print @@ -0,0 +1,5 @@ +(module + (type (;0;) (func)) + (table (;0;) 1 funcref) + (func (;0;) (type 0)) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/93.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/93.print new file mode 100644 index 0000000000..ffba26a4b1 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/93.print @@ -0,0 +1,3 @@ +(module + (memory (;0;) 1) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/98.print b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/98.print new file mode 100644 index 0000000000..7d6e8576d7 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/binary.wast/98.print @@ -0,0 +1,12 @@ +(module + (type (;0;) (func)) + (func (;0;) (type 0) + block ;; label = @1 + i32.const 1 + if ;; label = @2 + i32.const 1 + br_table 2 + end + end + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast.json new file mode 100644 index 0000000000..dd3590ba1f --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast.json @@ -0,0 +1,590 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/br_on_cast.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "br_on_cast.0.wasm", + "module_type": "binary" + }, + { + "type": "action", + "line": 69, + "action": { + "type": "invoke", + "field": "init", + "args": [ + { + "type": "externref", + "value": "0" + } + ] + } + }, + { + "type": "assert_return", + "line": 71, + "action": { + "type": "invoke", + "field": "br_on_null", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 72, + "action": { + "type": "invoke", + "field": "br_on_null", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 73, + "action": { + "type": "invoke", + "field": "br_on_null", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 74, + "action": { + "type": "invoke", + "field": "br_on_null", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 75, + "action": { + "type": "invoke", + "field": "br_on_null", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 77, + "action": { + "type": "invoke", + "field": "br_on_i31", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 78, + "action": { + "type": "invoke", + "field": "br_on_i31", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "7" + } + ] + }, + { + "type": "assert_return", + "line": 79, + "action": { + "type": "invoke", + "field": "br_on_i31", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 80, + "action": { + "type": "invoke", + "field": "br_on_i31", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 81, + "action": { + "type": "invoke", + "field": "br_on_i31", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 83, + "action": { + "type": "invoke", + "field": "br_on_struct", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 84, + "action": { + "type": "invoke", + "field": "br_on_struct", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 85, + "action": { + "type": "invoke", + "field": "br_on_struct", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "6" + } + ] + }, + { + "type": "assert_return", + "line": 86, + "action": { + "type": "invoke", + "field": "br_on_struct", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 87, + "action": { + "type": "invoke", + "field": "br_on_struct", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 89, + "action": { + "type": "invoke", + "field": "br_on_array", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 90, + "action": { + "type": "invoke", + "field": "br_on_array", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 91, + "action": { + "type": "invoke", + "field": "br_on_array", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 92, + "action": { + "type": "invoke", + "field": "br_on_array", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "3" + } + ] + }, + { + "type": "assert_return", + "line": 93, + "action": { + "type": "invoke", + "field": "br_on_array", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 95, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 96, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 97, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 98, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 99, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "module", + "line": 104, + "filename": "br_on_cast.1.wasm", + "module_type": "binary" + }, + { + "type": "action", + "line": 205, + "action": { + "type": "invoke", + "field": "test-sub", + "args": [] + } + }, + { + "type": "action", + "line": 206, + "action": { + "type": "invoke", + "field": "test-canon", + "args": [] + } + }, + { + "type": "module", + "line": 211, + "filename": "br_on_cast.2.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 236, + "filename": "br_on_cast.3.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 245, + "filename": "br_on_cast.4.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 254, + "filename": "br_on_cast.5.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 263, + "filename": "br_on_cast.6.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 275, + "filename": "br_on_cast.7.wasm", + "module_type": "binary", + "text": "type mismatch" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/0.print new file mode 100644 index 0000000000..3b0ae0ec4b --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/0.print @@ -0,0 +1,106 @@ +(module + (type $ft (;0;) (func (result i32))) + (type $st (;1;) (struct (field i16))) + (type $at (;2;) (array i8)) + (type (;3;) (func (param externref))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param structref) (result (ref $st)))) + (type (;6;) (func (param structref) (result (ref $at)))) + (table (;0;) 10 anyref) + (export "init" (func 1)) + (export "br_on_null" (func 2)) + (export "br_on_i31" (func 3)) + (export "br_on_struct" (func 4)) + (export "br_on_array" (func 5)) + (export "null-diff" (func 6)) + (elem (;0;) declare func $f) + (func $f (;0;) (type $ft) (result i32) + i32.const 9 + ) + (func (;1;) (type 3) (param $x externref) + i32.const 0 + ref.null any + table.set 0 + i32.const 1 + i32.const 7 + ref.i31 + table.set 0 + i32.const 2 + i32.const 6 + struct.new $st + table.set 0 + i32.const 3 + i32.const 5 + i32.const 3 + array.new $at + table.set 0 + i32.const 4 + local.get $x + any.convert_extern + table.set 0 + ) + (func (;2;) (type 4) (param $i i32) (result i32) + block $l + local.get $i + table.get 0 + br_on_null $l + i32.const -1 + return + end + i32.const 0 + ) + (func (;3;) (type 4) (param $i i32) (result i32) + block $l (result (ref i31)) + local.get $i + table.get 0 + br_on_cast $l anyref (ref i31) + i32.const -1 + return + end + i31.get_u + ) + (func (;4;) (type 4) (param $i i32) (result i32) + block $l (result (ref struct)) + local.get $i + table.get 0 + br_on_cast $l anyref (ref struct) + i32.const -1 + return + end + block $l2 (type 5) (param structref) (result (ref $st)) + block $l3 (type 6) (param structref) (result (ref $at)) + br_on_cast $l2 structref (ref $st) + br_on_cast $l3 anyref (ref $at) + i32.const -2 + return + end + i32.const 0 + array.get_u $at + return + end + struct.get_s $st 0 + ) + (func (;5;) (type 4) (param $i i32) (result i32) + block $l (result (ref array)) + local.get $i + table.get 0 + br_on_cast $l anyref (ref array) + i32.const -1 + return + end + array.len + ) + (func (;6;) (type 4) (param $i i32) (result i32) + block $l (result structref) + block (result (ref any)) ;; label = @2 + local.get $i + table.get 0 + br_on_cast $l anyref structref + end + i32.const 0 + return + end + i32.const 1 + return + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/27.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/27.print new file mode 100644 index 0000000000..5b7b1e9078 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/27.print @@ -0,0 +1,268 @@ +(module + (type $t0 (;0;) (sub (struct))) + (type $t1 (;1;) (sub $t0 (struct (field i32)))) + (type $t1' (;2;) (sub $t0 (struct (field i32)))) + (type $t2 (;3;) (sub $t1 (struct (field i32) (field i32)))) + (type $t2' (;4;) (sub $t1' (struct (field i32) (field i32)))) + (type $t3 (;5;) (sub $t0 (struct (field i32) (field i32)))) + (type $t0' (;6;) (sub $t0 (struct))) + (type $t4 (;7;) (sub $t0' (struct (field i32) (field i32)))) + (type (;8;) (func)) + (table (;0;) 20 structref) + (export "test-sub" (func 1)) + (export "test-canon" (func 2)) + (func $init (;0;) (type 8) + i32.const 0 + struct.new_default $t0 + table.set 0 + i32.const 10 + struct.new_default $t0' + table.set 0 + i32.const 1 + struct.new_default $t1 + table.set 0 + i32.const 11 + struct.new_default $t1' + table.set 0 + i32.const 2 + struct.new_default $t2 + table.set 0 + i32.const 12 + struct.new_default $t2' + table.set 0 + i32.const 3 + struct.new_default $t3 + table.set 0 + i32.const 4 + struct.new_default $t4 + table.set 0 + ) + (func (;1;) (type 8) + call $init + block $l (result structref) + block (result structref) ;; label = @2 + ref.null struct + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast 0 (;@2;) structref (ref $t4) + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t4) + end + drop + i32.const 0 + table.get 0 + br_on_cast $l anyref (ref $t1) + i32.const 3 + table.get 0 + br_on_cast $l anyref (ref $t1) + i32.const 4 + table.get 0 + br_on_cast $l anyref (ref $t1) + i32.const 0 + table.get 0 + br_on_cast $l anyref (ref $t2) + i32.const 1 + table.get 0 + br_on_cast $l anyref (ref $t2) + i32.const 3 + table.get 0 + br_on_cast $l anyref (ref $t2) + i32.const 4 + table.get 0 + br_on_cast $l anyref (ref $t2) + i32.const 0 + table.get 0 + br_on_cast $l anyref (ref $t3) + i32.const 1 + table.get 0 + br_on_cast $l anyref (ref $t3) + i32.const 2 + table.get 0 + br_on_cast $l anyref (ref $t3) + i32.const 4 + table.get 0 + br_on_cast $l anyref (ref $t3) + i32.const 0 + table.get 0 + br_on_cast $l anyref (ref $t4) + i32.const 1 + table.get 0 + br_on_cast $l anyref (ref $t4) + i32.const 2 + table.get 0 + br_on_cast $l anyref (ref $t4) + i32.const 3 + table.get 0 + br_on_cast $l anyref (ref $t4) + return + end + unreachable + ) + (func (;2;) (type 8) + call $init + block $l + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0') + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0') + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0') + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0') + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0') + end + drop + block (result structref) ;; label = @2 + i32.const 10 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 11 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 12 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1') + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1') + end + drop + block (result structref) ;; label = @2 + i32.const 11 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 12 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t2') + end + drop + block (result structref) ;; label = @2 + i32.const 12 + table.get 0 + br_on_cast 0 (;@2;) structref (ref $t2) + end + drop + return + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/30.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/30.print new file mode 100644 index 0000000000..10d55dc84b --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast.wast/30.print @@ -0,0 +1,44 @@ +(module + (type $t (;0;) (struct)) + (type (;1;) (func (param (ref any)) (result (ref $t)))) + (type (;2;) (func (param anyref) (result (ref $t)))) + (type (;3;) (func (param (ref any)) (result (ref null $t)))) + (type (;4;) (func (param anyref) (result (ref null $t)))) + (type (;5;) (func (result anyref))) + (func (;0;) (type 1) (param (ref any)) (result (ref $t)) + block (result (ref any)) ;; label = @1 + local.get 0 + br_on_cast 1 (ref any) (ref $t) + end + unreachable + ) + (func (;1;) (type 2) (param anyref) (result (ref $t)) + block (result anyref) ;; label = @1 + local.get 0 + br_on_cast 1 anyref (ref $t) + end + unreachable + ) + (func (;2;) (type 3) (param (ref any)) (result (ref null $t)) + block (result (ref any)) ;; label = @1 + local.get 0 + br_on_cast 1 (ref any) (ref null $t) + end + unreachable + ) + (func (;3;) (type 4) (param anyref) (result (ref null $t)) + block (result anyref) ;; label = @1 + local.get 0 + br_on_cast 1 anyref (ref null $t) + end + unreachable + ) + (func (;4;) (type 5) (result anyref) + unreachable + br_on_cast 0 eqref anyref + ) + (func (;5;) (type 5) (result anyref) + unreachable + br_on_cast 0 structref arrayref + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast.json new file mode 100644 index 0000000000..a3a6963ad7 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast.json @@ -0,0 +1,1386 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "br_on_cast_desc.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 456, + "filename": "br_on_cast_desc.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 685, + "filename": "br_on_cast_desc.2.wasm", + "module_type": "binary", + "text": "unknown type" + }, + { + "type": "assert_invalid", + "line": 697, + "filename": "br_on_cast_desc.3.wasm", + "module_type": "binary", + "text": "type any does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 709, + "filename": "br_on_cast_desc.4.wasm", + "module_type": "binary", + "text": "type none does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 721, + "filename": "br_on_cast_desc.5.wasm", + "module_type": "binary", + "text": "type 0 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 734, + "filename": "br_on_cast_desc.6.wasm", + "module_type": "binary", + "text": "type 1 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 748, + "filename": "br_on_cast_desc.7.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 765, + "filename": "br_on_cast_desc.8.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 782, + "filename": "br_on_cast_desc.9.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 799, + "filename": "br_on_cast_desc.10.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 818, + "filename": "br_on_cast_desc.11.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 835, + "filename": "br_on_cast_desc.12.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 851, + "filename": "br_on_cast_desc.13.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 870, + "filename": "br_on_cast_desc.14.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 889, + "filename": "br_on_cast_desc.15.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 908, + "filename": "br_on_cast_desc.16.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 926, + "filename": "br_on_cast_desc.17.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 946, + "filename": "br_on_cast_desc.18.wasm", + "module_type": "binary", + "text": "constant expression required" + }, + { + "type": "module", + "line": 959, + "filename": "br_on_cast_desc.19.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 1004, + "filename": "br_on_cast_desc.20.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1021, + "filename": "br_on_cast_desc.21.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1039, + "filename": "br_on_cast_desc.22.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1058, + "filename": "br_on_cast_desc.23.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1077, + "filename": "br_on_cast_desc.24.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1096, + "filename": "br_on_cast_desc.25.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "module", + "line": 1116, + "filename": "br_on_cast_desc.26.wasm", + "module_type": "binary" + }, + { + "type": "assert_trap", + "line": 1801, + "action": { + "type": "invoke", + "field": "self-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1802, + "action": { + "type": "invoke", + "field": "self-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1803, + "action": { + "type": "invoke", + "field": "self-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1804, + "action": { + "type": "invoke", + "field": "self-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1805, + "action": { + "type": "invoke", + "field": "self-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1807, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1808, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1809, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1810, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1811, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1813, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1814, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1815, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1816, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1817, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1819, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1820, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1821, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1822, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1823, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1825, + "action": { + "type": "invoke", + "field": "down-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1826, + "action": { + "type": "invoke", + "field": "down-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1827, + "action": { + "type": "invoke", + "field": "down-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1828, + "action": { + "type": "invoke", + "field": "down-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1829, + "action": { + "type": "invoke", + "field": "down-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1831, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1832, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1833, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1834, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1835, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1837, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1838, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1839, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1840, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1841, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1843, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1844, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1845, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1846, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1847, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1849, + "action": { + "type": "invoke", + "field": "up-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1850, + "action": { + "type": "invoke", + "field": "up-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1851, + "action": { + "type": "invoke", + "field": "up-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1852, + "action": { + "type": "invoke", + "field": "up-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1853, + "action": { + "type": "invoke", + "field": "up-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1855, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1856, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1857, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1858, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1859, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1861, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1862, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1863, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1864, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1866, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1867, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1868, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1869, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1871, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1872, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1873, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1874, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1876, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1877, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1878, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1879, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1881, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1882, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1883, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1884, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1886, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1887, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1888, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1889, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1891, + "action": { + "type": "invoke", + "field": "i31-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1892, + "action": { + "type": "invoke", + "field": "i31-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1893, + "action": { + "type": "invoke", + "field": "i31-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1894, + "action": { + "type": "invoke", + "field": "i31-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1896, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1897, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1898, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1899, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1901, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1902, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1903, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1904, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_trap", + "line": 1906, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1907, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1908, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1909, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "module", + "line": 1911, + "filename": "br_on_cast_desc.27.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 1992, + "action": { + "type": "invoke", + "field": "cast-succeeds-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1993, + "action": { + "type": "invoke", + "field": "cast-succeeds-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1994, + "action": { + "type": "invoke", + "field": "cast-fails-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1995, + "action": { + "type": "invoke", + "field": "cast-fails-val", + "args": [] + }, + "expected": [] + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/0.print new file mode 100644 index 0000000000..74ba979407 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/0.print @@ -0,0 +1,432 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type (;4;) (func (param anyref (ref null $b)) (result (ref null $a)))) + (type (;5;) (func (param anyref (ref null $b)) (result (ref $a)))) + (type (;6;) (func (param anyref (ref $b)) (result (ref null $a)))) + (type (;7;) (func (param anyref (ref $b)) (result (ref $a)))) + (type (;8;) (func (param (ref any) (ref null $b)) (result (ref null $a)))) + (type (;9;) (func (param (ref any) (ref null $b)) (result (ref $a)))) + (type (;10;) (func (param (ref any) (ref $b)) (result (ref null $a)))) + (type (;11;) (func (param (ref any) (ref $b)) (result (ref $a)))) + (type (;12;) (func (param anyref (ref null $d)) (result (ref null $a)))) + (type (;13;) (func (param anyref (ref null $d)) (result (ref $a)))) + (type (;14;) (func (param anyref (ref $d)) (result (ref null $a)))) + (type (;15;) (func (param anyref (ref $d)) (result (ref $a)))) + (type (;16;) (func (param (ref any) (ref null $d)) (result (ref null $a)))) + (type (;17;) (func (param (ref any) (ref null $d)) (result (ref $a)))) + (type (;18;) (func (param (ref any) (ref $d)) (result (ref null $a)))) + (type (;19;) (func (param (ref any) (ref $d)) (result (ref $a)))) + (type (;20;) (func (param anyref (ref null (exact $d))) (result (ref null $a)))) + (type (;21;) (func (param anyref (ref null (exact $d))) (result (ref $a)))) + (type (;22;) (func (param anyref (ref (exact $d))) (result (ref null $a)))) + (type (;23;) (func (param anyref (ref (exact $d))) (result (ref $a)))) + (type (;24;) (func (param (ref any) (ref null (exact $d))) (result (ref null $a)))) + (type (;25;) (func (param (ref any) (ref null (exact $d))) (result (ref $a)))) + (type (;26;) (func (param (ref any) (ref (exact $d))) (result (ref null $a)))) + (type (;27;) (func (param (ref any) (ref (exact $d))) (result (ref $a)))) + (type (;28;) (func (param anyref (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;29;) (func (param anyref (ref null (exact $b))) (result (ref (exact $a))))) + (type (;30;) (func (param anyref (ref (exact $b))) (result (ref null (exact $a))))) + (type (;31;) (func (param anyref (ref (exact $b))) (result (ref (exact $a))))) + (type (;32;) (func (param (ref any) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;33;) (func (param (ref any) (ref null (exact $b))) (result (ref (exact $a))))) + (type (;34;) (func (param (ref any) (ref (exact $b))) (result (ref null (exact $a))))) + (type (;35;) (func (param (ref any) (ref (exact $b))) (result (ref (exact $a))))) + (type (;36;) (func (param anyref) (result (ref null $a)))) + (type (;37;) (func (param anyref) (result (ref $a)))) + (type (;38;) (func (param (ref any)) (result (ref null $a)))) + (type (;39;) (func (param (ref any)) (result (ref $a)))) + (type (;40;) (func (param anyref) (result (ref null (exact $a))))) + (type (;41;) (func (param anyref) (result (ref (exact $a))))) + (type (;42;) (func (param (ref any)) (result (ref null (exact $a))))) + (type (;43;) (func (param (ref any)) (result (ref (exact $a))))) + (func (;0;) (type 4) (param anyref (ref null $b)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;1;) (type 5) (param anyref (ref null $b)) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;2;) (type 6) (param anyref (ref $b)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;3;) (type 7) (param anyref (ref $b)) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;4;) (type 8) (param (ref any) (ref null $b)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;5;) (type 9) (param (ref any) (ref null $b)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;6;) (type 10) (param (ref any) (ref $b)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;7;) (type 11) (param (ref any) (ref $b)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;8;) (type 12) (param anyref (ref null $d)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;9;) (type 13) (param anyref (ref null $d)) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;10;) (type 14) (param anyref (ref $d)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;11;) (type 15) (param anyref (ref $d)) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;12;) (type 16) (param (ref any) (ref null $d)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;13;) (type 17) (param (ref any) (ref null $d)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;14;) (type 18) (param (ref any) (ref $d)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;15;) (type 19) (param (ref any) (ref $d)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;16;) (type 20) (param anyref (ref null (exact $d))) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;17;) (type 21) (param anyref (ref null (exact $d))) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;18;) (type 22) (param anyref (ref (exact $d))) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;19;) (type 23) (param anyref (ref (exact $d))) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;20;) (type 24) (param (ref any) (ref null (exact $d))) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;21;) (type 25) (param (ref any) (ref null (exact $d))) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;22;) (type 26) (param (ref any) (ref (exact $d))) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;23;) (type 27) (param (ref any) (ref (exact $d))) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;24;) (type 28) (param anyref (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;25;) (type 29) (param anyref (ref null (exact $b))) (result (ref (exact $a))) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref (exact $a)) + end + unreachable + ) + (func (;26;) (type 30) (param anyref (ref (exact $b))) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;27;) (type 31) (param anyref (ref (exact $b))) (result (ref (exact $a))) + block (result anyref) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref (exact $a)) + end + unreachable + ) + (func (;28;) (type 32) (param (ref any) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;29;) (type 33) (param (ref any) (ref null (exact $b))) (result (ref (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref (exact $a)) + end + unreachable + ) + (func (;30;) (type 34) (param (ref any) (ref (exact $b))) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;31;) (type 35) (param (ref any) (ref (exact $b))) (result (ref (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref any) (ref (exact $a)) + end + unreachable + ) + (func (;32;) (type 36) (param anyref) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;33;) (type 37) (param anyref) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;34;) (type 38) (param (ref any)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;35;) (type 39) (param (ref any)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;36;) (type 40) (param anyref) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;37;) (type 41) (param anyref) (result (ref (exact $a))) + block (result anyref) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 anyref (ref (exact $a)) + end + unreachable + ) + (func (;38;) (type 42) (param (ref any)) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;39;) (type 43) (param (ref any)) (result (ref (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc 1 (ref any) (ref (exact $a)) + end + unreachable + ) + (func (;40;) (type 36) (param anyref) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;41;) (type 37) (param anyref) (result (ref $a)) + block (result anyref) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 anyref (ref $a) + end + unreachable + ) + (func (;42;) (type 38) (param (ref any)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;43;) (type 39) (param (ref any)) (result (ref $a)) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 (ref any) (ref $a) + end + unreachable + ) + (func (;44;) (type 40) (param anyref) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;45;) (type 41) (param anyref) (result (ref (exact $a))) + block (result anyref) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 anyref (ref (exact $a)) + end + unreachable + ) + (func (;46;) (type 42) (param (ref any)) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;47;) (type 43) (param (ref any)) (result (ref (exact $a))) + block (result (ref any)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc 1 (ref any) (ref (exact $a)) + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/1.print new file mode 100644 index 0000000000..288fd44ff3 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/1.print @@ -0,0 +1,203 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (descriptor $e) (struct))) + (type $e (;4;) (describes $d) (struct)) + ) + (type (;5;) (func (param (ref null $a) (ref null $b)) (result (ref null $a)))) + (type (;6;) (func (param (ref null $a) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;7;) (func (param i31ref (ref null $b)) (result (ref null $a)))) + (type (;8;) (func (param i31ref (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;9;) (func (param (ref null $e) (ref null $b)) (result (ref null $a)))) + (type (;10;) (func (param (ref null $e) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;11;) (func (param (ref null (exact $e)) (ref null $b)) (result (ref null $a)))) + (type (;12;) (func (param (ref null (exact $e)) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;13;) (func (param (ref null $c) (ref null $b)) (result (ref null $a)))) + (type (;14;) (func (param (ref null $c) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;15;) (func (param (ref null (exact $c)) (ref null $b)) (result (ref null $a)))) + (type (;16;) (func (param (ref null (exact $c)) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;17;) (func (param (ref null $a) (ref null $d)) (result (ref null $c)))) + (type (;18;) (func (param (ref null $a) (ref null (exact $d))) (result (ref null (exact $c))))) + (type (;19;) (func (param (ref null (exact $a)) (ref null $d)) (result (ref null $c)))) + (type (;20;) (func (param (ref null (exact $a)) (ref null (exact $d))) (result (ref null (exact $c))))) + (type (;21;) (func (param (ref null $b)) (result (ref null $a)))) + (type (;22;) (func (param (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;23;) (func (param anyref (ref null $e)) (result (ref null $d)))) + (type (;24;) (func (param anyref (ref null (exact $e))) (result (ref null (exact $d))))) + (func (;0;) (type 5) (param (ref null $a) (ref null $b)) (result (ref null $a)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $a) (ref null $a) + end + unreachable + ) + (func (;1;) (type 6) (param (ref null $a) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $a) (ref null (exact $a)) + end + unreachable + ) + (func (;2;) (type 7) (param i31ref (ref null $b)) (result (ref null $a)) + block (result (ref i31)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 i31ref (ref null $a) + end + unreachable + ) + (func (;3;) (type 8) (param i31ref (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref i31)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 i31ref (ref null (exact $a)) + end + unreachable + ) + (func (;4;) (type 9) (param (ref null $e) (ref null $b)) (result (ref null $a)) + block (result (ref $e)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $e) (ref null $a) + end + unreachable + ) + (func (;5;) (type 10) (param (ref null $e) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref $e)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $e) (ref null (exact $a)) + end + unreachable + ) + (func (;6;) (type 11) (param (ref null (exact $e)) (ref null $b)) (result (ref null $a)) + block (result (ref (exact $e))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $e)) (ref null $a) + end + unreachable + ) + (func (;7;) (type 12) (param (ref null (exact $e)) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref (exact $e))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $e)) (ref null (exact $a)) + end + unreachable + ) + (func (;8;) (type 13) (param (ref null $c) (ref null $b)) (result (ref null $a)) + block (result (ref $c)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $c) (ref null $a) + end + ) + (func (;9;) (type 14) (param (ref null $c) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref $c)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $c) (ref null (exact $a)) + end + unreachable + ) + (func (;10;) (type 15) (param (ref null (exact $c)) (ref null $b)) (result (ref null $a)) + block (result (ref (exact $c))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $c)) (ref null $a) + end + ) + (func (;11;) (type 16) (param (ref null (exact $c)) (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref (exact $c))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $c)) (ref null (exact $a)) + end + unreachable + ) + (func (;12;) (type 17) (param (ref null $a) (ref null $d)) (result (ref null $c)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $a) (ref null $c) + end + unreachable + ) + (func (;13;) (type 18) (param (ref null $a) (ref null (exact $d))) (result (ref null (exact $c))) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null $a) (ref null (exact $c)) + end + unreachable + ) + (func (;14;) (type 19) (param (ref null (exact $a)) (ref null $d)) (result (ref null $c)) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $a)) (ref null $c) + end + unreachable + ) + (func (;15;) (type 20) (param (ref null (exact $a)) (ref null (exact $d))) (result (ref null (exact $c))) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 (ref null (exact $a)) (ref null (exact $c)) + end + unreachable + ) + (func (;16;) (type 21) (param (ref null $b)) (result (ref null $a)) + block (result (ref $a)) ;; label = @1 + ref.null none + local.get 0 + br_on_cast_desc 1 nullref (ref null $a) + end + unreachable + ) + (func (;17;) (type 22) (param (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref $a)) ;; label = @1 + ref.null none + local.get 0 + br_on_cast_desc 1 nullref (ref null (exact $a)) + end + unreachable + ) + (func (;18;) (type 21) (param (ref null $b)) (result (ref null $a)) + block (result (ref any)) ;; label = @1 + unreachable + local.get 0 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;19;) (type 22) (param (ref null (exact $b))) (result (ref null (exact $a))) + block (result (ref any)) ;; label = @1 + unreachable + local.get 0 + br_on_cast_desc 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;20;) (type 23) (param anyref (ref null $e)) (result (ref null $d)) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $d) + end + unreachable + ) + (func (;21;) (type 24) (param anyref (ref null (exact $e))) (result (ref null (exact $d))) + block (result (ref any)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null (exact $d)) + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/117.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/117.print new file mode 100644 index 0000000000..94a6095c63 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/117.print @@ -0,0 +1,103 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (param i32 i32))) + (type (;3;) (func (param eqref eqref))) + (type (;4;) (func)) + (type (;5;) (func (result i32 i32 eqref))) + (global $b1 (;0;) (ref (exact $b)) struct.new $b) + (global $b2 (;1;) (ref (exact $b)) struct.new $b) + (global $a1 (;2;) (ref (exact $a)) global.get $b1 struct.new $a) + (export "cast-succeeds-null" (func 2)) + (export "cast-succeeds-val" (func 3)) + (export "cast-fails-null" (func 4)) + (export "cast-fails-val" (func 5)) + (func $assert-eq-i32 (;0;) (type 2) (param i32 i32) + local.get 0 + local.get 1 + i32.eq + if ;; label = @1 + return + else + unreachable + end + ) + (func $assert-eq-ref (;1;) (type 3) (param eqref eqref) + local.get 0 + local.get 1 + ref.eq + if ;; label = @1 + return + else + unreachable + end + ) + (func (;2;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + ref.null none + global.get $b1 + br_on_cast_desc 0 (;@1;) eqref (ref null $a) + unreachable + end + ref.null none + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + ) + (func (;3;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + global.get $a1 + global.get $b1 + br_on_cast_desc 0 (;@1;) eqref (ref null $a) + unreachable + end + global.get $a1 + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + ) + (func (;4;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + ref.null none + global.get $b2 + br_on_cast_desc 0 (;@1;) eqref (ref $a) + ref.null none + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + return + end + unreachable + ) + (func (;5;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + global.get $a1 + global.get $b2 + br_on_cast_desc 0 (;@1;) eqref (ref $a) + global.get $a1 + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + return + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/19.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/19.print new file mode 100644 index 0000000000..838a1ebd8a --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/19.print @@ -0,0 +1,40 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (param anyref (ref null $b)) (result i32 (ref null $a)))) + (type (;3;) (func (result i32 (ref any)))) + (type (;4;) (func (param anyref (ref null $b)) (result i32 i64 (ref null $a)))) + (type (;5;) (func (result i32 i64 (ref any)))) + (type (;6;) (func (param anyref (ref null $b)) (result eqref (ref null $a)))) + (type (;7;) (func (result anyref (ref any)))) + (func (;0;) (type 2) (param anyref (ref null $b)) (result i32 (ref null $a)) + block (type 3) (result i32 (ref any)) ;; label = @1 + i32.const 42 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;1;) (type 4) (param anyref (ref null $b)) (result i32 i64 (ref null $a)) + block (type 5) (result i32 i64 (ref any)) ;; label = @1 + i32.const 42 + i64.const 1337 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) + (func (;2;) (type 6) (param anyref (ref null $b)) (result eqref (ref null $a)) + block (type 7) (result anyref (ref any)) ;; label = @1 + local.get 1 + local.get 0 + local.get 1 + br_on_cast_desc 1 anyref (ref null $a) + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/26.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/26.print new file mode 100644 index 0000000000..7e1d7cbec0 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc.wast/26.print @@ -0,0 +1,1109 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type $no-desc (;4;) (struct)) + (type (;5;) (func (result i32))) + (global $b1-exact (;0;) (ref null (exact $b)) struct.new $b) + (global $b2-exact (;1;) (ref null (exact $b)) struct.new $b) + (global $b1 (;2;) (ref null $b) global.get $b1-exact) + (global $b2 (;3;) (ref null $b) global.get $b2-exact) + (global $a1 (;4;) (ref null $a) global.get $b1-exact struct.new $a) + (global $d1-exact (;5;) (ref null (exact $d)) struct.new $d) + (global $d2-exact (;6;) (ref null (exact $d)) struct.new $d) + (global $d1 (;7;) (ref null $d) global.get $d1-exact) + (global $d2 (;8;) (ref null $d) global.get $d2-exact) + (global $c1 (;9;) (ref null $c) global.get $d1-exact struct.new $c) + (global $c1-as-a (;10;) (ref null $a) global.get $c1) + (global $a-null (;11;) (ref null (exact $a)) ref.null none) + (global $b-null (;12;) (ref null (exact $b)) ref.null none) + (global $c-null (;13;) (ref null (exact $c)) ref.null none) + (global $d-null (;14;) (ref null (exact $d)) ref.null none) + (global $no-desc (;15;) (ref null (exact $no-desc)) struct.new $no-desc) + (global $no-desc-null (;16;) (ref null (exact $no-desc)) ref.null none) + (global $i31 (;17;) anyref i32.const 0 ref.i31) + (global $i31-null (;18;) anyref ref.null i31) + (export "self-nullable-null-null" (func 0)) + (export "self-nullable-val-null" (func 1)) + (export "self-nullable-null-desc" (func 2)) + (export "self-nullable-val-desc" (func 3)) + (export "self-nullable-val-other" (func 4)) + (export "self-nonnullable-null-null" (func 5)) + (export "self-nonnullable-val-null" (func 6)) + (export "self-nonnullable-null-desc" (func 7)) + (export "self-nonnullable-val-desc" (func 8)) + (export "self-nonnullable-val-other" (func 9)) + (export "self-exact-nullable-null-null" (func 10)) + (export "self-exact-nullable-val-null" (func 11)) + (export "self-exact-nullable-null-desc" (func 12)) + (export "self-exact-nullable-val-desc" (func 13)) + (export "self-exact-nullable-val-other" (func 14)) + (export "self-exact-nonnullable-null-null" (func 15)) + (export "self-exact-nonnullable-val-null" (func 16)) + (export "self-exact-nonnullable-null-desc" (func 17)) + (export "self-exact-nonnullable-val-desc" (func 18)) + (export "self-exact-nonnullable-val-other" (func 19)) + (export "down-nullable-null-null" (func 20)) + (export "down-nullable-val-null" (func 21)) + (export "down-nullable-null-desc" (func 22)) + (export "down-nullable-val-desc" (func 23)) + (export "down-nullable-val-other" (func 24)) + (export "down-nonnullable-null-null" (func 25)) + (export "down-nonnullable-val-null" (func 26)) + (export "down-nonnullable-null-desc" (func 27)) + (export "down-nonnullable-val-desc" (func 28)) + (export "down-nonnullable-val-other" (func 29)) + (export "down-exact-nullable-null-null" (func 30)) + (export "down-exact-nullable-val-null" (func 31)) + (export "down-exact-nullable-null-desc" (func 32)) + (export "down-exact-nullable-val-desc" (func 33)) + (export "down-exact-nullable-val-other" (func 34)) + (export "down-exact-nonnullable-null-null" (func 35)) + (export "down-exact-nonnullable-val-null" (func 36)) + (export "down-exact-nonnullable-null-desc" (func 37)) + (export "down-exact-nonnullable-val-desc" (func 38)) + (export "down-exact-nonnullable-val-other" (func 39)) + (export "up-nullable-null-null" (func 40)) + (export "up-nullable-val-null" (func 41)) + (export "up-nullable-null-desc" (func 42)) + (export "up-nullable-val-desc" (func 43)) + (export "up-nullable-val-other" (func 44)) + (export "up-nonnullable-null-null" (func 45)) + (export "up-nonnullable-val-null" (func 46)) + (export "up-nonnullable-null-desc" (func 47)) + (export "up-nonnullable-val-desc" (func 48)) + (export "up-nonnullable-val-other" (func 49)) + (export "up-exact-nullable-null-null" (func 50)) + (export "up-exact-nullable-val-null" (func 51)) + (export "up-exact-nullable-null-desc" (func 52)) + (export "up-exact-nullable-val-other" (func 53)) + (export "up-exact-nonnullable-null-null" (func 54)) + (export "up-exact-nonnullable-val-null" (func 55)) + (export "up-exact-nonnullable-null-desc" (func 56)) + (export "up-exact-nonnullable-val-other" (func 57)) + (export "nodesc-nullable-null-null" (func 58)) + (export "nodesc-nullable-val-null" (func 59)) + (export "nodesc-nullable-null-desc" (func 60)) + (export "nodesc-nullable-val-other" (func 61)) + (export "nodesc-nonnullable-null-null" (func 62)) + (export "nodesc-nonnullable-val-null" (func 63)) + (export "nodesc-nonnullable-null-desc" (func 64)) + (export "nodesc-nonnullable-val-other" (func 65)) + (export "nodesc-exact-nullable-null-null" (func 66)) + (export "nodesc-exact-nullable-val-null" (func 67)) + (export "nodesc-exact-nullable-null-desc" (func 68)) + (export "nodesc-exact-nullable-val-other" (func 69)) + (export "nodesc-exact-nonnullable-null-null" (func 70)) + (export "nodesc-exact-nonnullable-val-null" (func 71)) + (export "nodesc-exact-nonnullable-null-desc" (func 72)) + (export "nodesc-exact-nonnullable-val-other" (func 73)) + (export "i31-nullable-null-null" (func 74)) + (export "i31-nullable-val-null" (func 75)) + (export "i31-nullable-null-desc" (func 76)) + (export "i31-nullable-val-other" (func 77)) + (export "i31-nonnullable-null-null" (func 78)) + (export "i31-nonnullable-val-null" (func 79)) + (export "i31-nonnullable-null-desc" (func 80)) + (export "i31-nonnullable-val-other" (func 81)) + (export "i31-exact-nullable-null-null" (func 82)) + (export "i31-exact-nullable-val-null" (func 83)) + (export "i31-exact-nullable-null-desc" (func 84)) + (export "i31-exact-nullable-val-other" (func 85)) + (export "i31-exact-nonnullable-null-null" (func 86)) + (export "i31-exact-nonnullable-val-null" (func 87)) + (export "i31-exact-nonnullable-null-desc" (func 88)) + (export "i31-exact-nonnullable-val-other" (func 89)) + (func (;0;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;1;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;2;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;3;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;4;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;5;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;6;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;7;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;8;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;9;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;10;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;11;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;12;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;13;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;14;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;15;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;16;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;17;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;18;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;19;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;20;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;21;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;22;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;23;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;24;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;25;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;26;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;27;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;28;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;29;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2 + br_on_cast_desc 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;30;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;31;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;32;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;33;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;34;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;35;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;36;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;37;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;38;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;39;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;40;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;41;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;42;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;43;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;44;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d2 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;45;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;46;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;47;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;48;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;49;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d2 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;50;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;51;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;52;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;53;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;54;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;55;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;56;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;57;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;58;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;59;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;60;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;61;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;62;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;63;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;64;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;65;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;66;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;67;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;68;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;69;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;70;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;71;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;72;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;73;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;74;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;75;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;76;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;77;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;78;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;79;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;80;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;81;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1 + br_on_cast_desc 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;82;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;83;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;84;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;85;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;86;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;87;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;88;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;89;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1-exact + br_on_cast_desc 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast.json new file mode 100644 index 0000000000..3b9bf96d63 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast.json @@ -0,0 +1,1386 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "br_on_cast_desc_fail.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 432, + "filename": "br_on_cast_desc_fail.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 663, + "filename": "br_on_cast_desc_fail.2.wasm", + "module_type": "binary", + "text": "unknown type" + }, + { + "type": "assert_invalid", + "line": 675, + "filename": "br_on_cast_desc_fail.3.wasm", + "module_type": "binary", + "text": "type any does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 687, + "filename": "br_on_cast_desc_fail.4.wasm", + "module_type": "binary", + "text": "type none does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 699, + "filename": "br_on_cast_desc_fail.5.wasm", + "module_type": "binary", + "text": "type 0 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 712, + "filename": "br_on_cast_desc_fail.6.wasm", + "module_type": "binary", + "text": "type 1 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 726, + "filename": "br_on_cast_desc_fail.7.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 743, + "filename": "br_on_cast_desc_fail.8.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 760, + "filename": "br_on_cast_desc_fail.9.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 777, + "filename": "br_on_cast_desc_fail.10.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 796, + "filename": "br_on_cast_desc_fail.11.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 813, + "filename": "br_on_cast_desc_fail.12.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 829, + "filename": "br_on_cast_desc_fail.13.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 850, + "filename": "br_on_cast_desc_fail.14.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 871, + "filename": "br_on_cast_desc_fail.15.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 892, + "filename": "br_on_cast_desc_fail.16.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 912, + "filename": "br_on_cast_desc_fail.17.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 931, + "filename": "br_on_cast_desc_fail.18.wasm", + "module_type": "binary", + "text": "constant expression required" + }, + { + "type": "module", + "line": 944, + "filename": "br_on_cast_desc_fail.19.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 989, + "filename": "br_on_cast_desc_fail.20.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1006, + "filename": "br_on_cast_desc_fail.21.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1024, + "filename": "br_on_cast_desc_fail.22.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1043, + "filename": "br_on_cast_desc_fail.23.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1062, + "filename": "br_on_cast_desc_fail.24.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 1082, + "filename": "br_on_cast_desc_fail.25.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "module", + "line": 1102, + "filename": "br_on_cast_desc_fail.26.wasm", + "module_type": "binary" + }, + { + "type": "assert_trap", + "line": 1787, + "action": { + "type": "invoke", + "field": "self-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1788, + "action": { + "type": "invoke", + "field": "self-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1789, + "action": { + "type": "invoke", + "field": "self-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1790, + "action": { + "type": "invoke", + "field": "self-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1791, + "action": { + "type": "invoke", + "field": "self-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1793, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1794, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1795, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1796, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1797, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1799, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1800, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1801, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1802, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1803, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1805, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1806, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1807, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1808, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1809, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1811, + "action": { + "type": "invoke", + "field": "down-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1812, + "action": { + "type": "invoke", + "field": "down-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1813, + "action": { + "type": "invoke", + "field": "down-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1814, + "action": { + "type": "invoke", + "field": "down-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1815, + "action": { + "type": "invoke", + "field": "down-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1817, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1818, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1819, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1820, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1821, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1823, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1824, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1825, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1826, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1827, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1829, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1830, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1831, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1832, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1833, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1835, + "action": { + "type": "invoke", + "field": "up-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1836, + "action": { + "type": "invoke", + "field": "up-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1837, + "action": { + "type": "invoke", + "field": "up-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1838, + "action": { + "type": "invoke", + "field": "up-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1839, + "action": { + "type": "invoke", + "field": "up-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1841, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1842, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1843, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1844, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1845, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1847, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1848, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1849, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1850, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1852, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1853, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1854, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1855, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1857, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1858, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1859, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1860, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1862, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1863, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1864, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1865, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1867, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1868, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1869, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1870, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1872, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1873, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1874, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1875, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1877, + "action": { + "type": "invoke", + "field": "i31-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1878, + "action": { + "type": "invoke", + "field": "i31-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1879, + "action": { + "type": "invoke", + "field": "i31-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1880, + "action": { + "type": "invoke", + "field": "i31-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1882, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1883, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1884, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1885, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1887, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1888, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1889, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 1890, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_trap", + "line": 1892, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 1893, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 1894, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 1895, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-other", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "module", + "line": 1897, + "filename": "br_on_cast_desc_fail.27.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 1978, + "action": { + "type": "invoke", + "field": "cast-succeeds-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1979, + "action": { + "type": "invoke", + "field": "cast-succeeds-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1980, + "action": { + "type": "invoke", + "field": "cast-fails-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 1981, + "action": { + "type": "invoke", + "field": "cast-fails-val", + "args": [] + }, + "expected": [] + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/0.print new file mode 100644 index 0000000000..f3768ad71c --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/0.print @@ -0,0 +1,395 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type (;4;) (func (param anyref (ref null $b)) (result (ref any)))) + (type (;5;) (func (param anyref (ref null $b)) (result anyref))) + (type (;6;) (func (param anyref (ref $b)) (result (ref any)))) + (type (;7;) (func (param anyref (ref $b)) (result anyref))) + (type (;8;) (func (param (ref any) (ref null $b)) (result (ref any)))) + (type (;9;) (func (param (ref any) (ref $b)) (result (ref any)))) + (type (;10;) (func (param anyref (ref null $d)) (result (ref any)))) + (type (;11;) (func (param anyref (ref null $d)) (result anyref))) + (type (;12;) (func (param anyref (ref $d)) (result (ref any)))) + (type (;13;) (func (param anyref (ref $d)) (result anyref))) + (type (;14;) (func (param (ref any) (ref null $d)) (result (ref any)))) + (type (;15;) (func (param (ref any) (ref $d)) (result (ref any)))) + (type (;16;) (func (param anyref (ref null (exact $d))) (result (ref any)))) + (type (;17;) (func (param anyref (ref null (exact $d))) (result anyref))) + (type (;18;) (func (param anyref (ref (exact $d))) (result (ref any)))) + (type (;19;) (func (param anyref (ref (exact $d))) (result anyref))) + (type (;20;) (func (param (ref any) (ref null (exact $d))) (result (ref any)))) + (type (;21;) (func (param (ref any) (ref (exact $d))) (result (ref any)))) + (type (;22;) (func (param anyref (ref null (exact $b))) (result (ref any)))) + (type (;23;) (func (param anyref (ref null (exact $b))) (result anyref))) + (type (;24;) (func (param anyref (ref (exact $b))) (result (ref any)))) + (type (;25;) (func (param anyref (ref (exact $b))) (result anyref))) + (type (;26;) (func (param (ref any) (ref null (exact $b))) (result (ref any)))) + (type (;27;) (func (param (ref any) (ref (exact $b))) (result (ref any)))) + (type (;28;) (func (param anyref) (result (ref any)))) + (type (;29;) (func (param anyref) (result anyref))) + (type (;30;) (func (param (ref any)) (result (ref any)))) + (func (;0;) (type 4) (param anyref (ref null $b)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;1;) (type 5) (param anyref (ref null $b)) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;2;) (type 6) (param anyref (ref $b)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;3;) (type 7) (param anyref (ref $b)) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;4;) (type 8) (param (ref any) (ref null $b)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;5;) (type 8) (param (ref any) (ref null $b)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;6;) (type 9) (param (ref any) (ref $b)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;7;) (type 9) (param (ref any) (ref $b)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;8;) (type 10) (param anyref (ref null $d)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;9;) (type 11) (param anyref (ref null $d)) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;10;) (type 12) (param anyref (ref $d)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;11;) (type 13) (param anyref (ref $d)) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;12;) (type 14) (param (ref any) (ref null $d)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;13;) (type 14) (param (ref any) (ref null $d)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;14;) (type 15) (param (ref any) (ref $d)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;15;) (type 15) (param (ref any) (ref $d)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;16;) (type 16) (param anyref (ref null (exact $d))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;17;) (type 17) (param anyref (ref null (exact $d))) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;18;) (type 18) (param anyref (ref (exact $d))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;19;) (type 19) (param anyref (ref (exact $d))) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;20;) (type 20) (param (ref any) (ref null (exact $d))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;21;) (type 20) (param (ref any) (ref null (exact $d))) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;22;) (type 21) (param (ref any) (ref (exact $d))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;23;) (type 21) (param (ref any) (ref (exact $d))) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;24;) (type 22) (param anyref (ref null (exact $b))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;25;) (type 23) (param anyref (ref null (exact $b))) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref (exact $a)) + end + ) + (func (;26;) (type 24) (param anyref (ref (exact $b))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;27;) (type 25) (param anyref (ref (exact $b))) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref (exact $a)) + end + ) + (func (;28;) (type 26) (param (ref any) (ref null (exact $b))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;29;) (type 26) (param (ref any) (ref null (exact $b))) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref (exact $a)) + end + ) + (func (;30;) (type 27) (param (ref any) (ref (exact $b))) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;31;) (type 27) (param (ref any) (ref (exact $b))) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref any) (ref (exact $a)) + end + ) + (func (;32;) (type 28) (param anyref) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;33;) (type 29) (param anyref) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;34;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;35;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;36;) (type 28) (param anyref) (result (ref any)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;37;) (type 29) (param anyref) (result anyref) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 anyref (ref (exact $a)) + end + ) + (func (;38;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;39;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + unreachable + br_on_cast_desc_fail 1 (ref any) (ref (exact $a)) + end + ) + (func (;40;) (type 28) (param anyref) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;41;) (type 29) (param anyref) (result anyref) + block (result (ref $a)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 anyref (ref $a) + end + ) + (func (;42;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 (ref any) (ref null $a) + end + unreachable + ) + (func (;43;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref $a)) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 (ref any) (ref $a) + end + ) + (func (;44;) (type 28) (param anyref) (result (ref any)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;45;) (type 29) (param anyref) (result anyref) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 anyref (ref (exact $a)) + end + ) + (func (;46;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 (ref any) (ref null (exact $a)) + end + unreachable + ) + (func (;47;) (type 30) (param (ref any)) (result (ref any)) + block (result (ref (exact $a))) ;; label = @1 + local.get 0 + ref.null none + br_on_cast_desc_fail 1 (ref any) (ref (exact $a)) + end + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/1.print new file mode 100644 index 0000000000..1c206fd496 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/1.print @@ -0,0 +1,207 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (descriptor $e) (struct))) + (type $e (;4;) (describes $d) (struct)) + ) + (type (;5;) (func (param (ref null $a) (ref null $b)) (result (ref $a)))) + (type (;6;) (func (param (ref null $a) (ref null (exact $b))) (result (ref $a)))) + (type (;7;) (func (param i31ref (ref null $b)) (result (ref i31)))) + (type (;8;) (func (param i31ref (ref null (exact $b))) (result (ref i31)))) + (type (;9;) (func (param (ref null $e) (ref null $b)) (result (ref $e)))) + (type (;10;) (func (param (ref null $e) (ref null (exact $b))) (result (ref $e)))) + (type (;11;) (func (param (ref null (exact $e)) (ref null $b)) (result (ref (exact $e))))) + (type (;12;) (func (param (ref null (exact $e)) (ref null (exact $b))) (result (ref (exact $e))))) + (type (;13;) (func (param (ref null $c) (ref null $b)) (result (ref $c)))) + (type (;14;) (func (param (ref null $c) (ref null (exact $b))) (result (ref $c)))) + (type (;15;) (func (param (ref null (exact $c)) (ref null $b)) (result (ref $c)))) + (type (;16;) (func (param (ref null (exact $c)) (ref null (exact $b))) (result (ref $c)))) + (type (;17;) (func (param (ref null $a) (ref null $d)) (result (ref $a)))) + (type (;18;) (func (param (ref null $a) (ref null (exact $d))) (result (ref $a)))) + (type (;19;) (func (param (ref null (exact $a)) (ref null $d)) (result (ref (exact $a))))) + (type (;20;) (func (param (ref null (exact $a)) (ref null (exact $d))) (result (ref (exact $a))))) + (type (;21;) (func (param (ref null $b)) (result (ref $a)))) + (type (;22;) (func (param (ref null (exact $b))) (result (ref $a)))) + (type (;23;) (func (param (ref null $b)) (result (ref any)))) + (type (;24;) (func (param (ref null (exact $b))) (result (ref any)))) + (type (;25;) (func (param anyref (ref null $e)) (result (ref any)))) + (type (;26;) (func (param anyref (ref null (exact $e))) (result (ref any)))) + (func (;0;) (type 5) (param (ref null $a) (ref null $b)) (result (ref $a)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $a) (ref null $a) + end + unreachable + ) + (func (;1;) (type 6) (param (ref null $a) (ref null (exact $b))) (result (ref $a)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $a) (ref null (exact $a)) + end + unreachable + ) + (func (;2;) (type 7) (param i31ref (ref null $b)) (result (ref i31)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 i31ref (ref null $a) + end + unreachable + ) + (func (;3;) (type 8) (param i31ref (ref null (exact $b))) (result (ref i31)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 i31ref (ref null (exact $a)) + end + unreachable + ) + (func (;4;) (type 9) (param (ref null $e) (ref null $b)) (result (ref $e)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $e) (ref null $a) + end + unreachable + ) + (func (;5;) (type 10) (param (ref null $e) (ref null (exact $b))) (result (ref $e)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $e) (ref null (exact $a)) + end + unreachable + ) + (func (;6;) (type 11) (param (ref null (exact $e)) (ref null $b)) (result (ref (exact $e))) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $e)) (ref null $a) + end + unreachable + ) + (func (;7;) (type 12) (param (ref null (exact $e)) (ref null (exact $b))) (result (ref (exact $e))) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $e)) (ref null (exact $a)) + end + unreachable + ) + (func (;8;) (type 13) (param (ref null $c) (ref null $b)) (result (ref $c)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $c) (ref null $a) + end + unreachable + ) + (func (;9;) (type 14) (param (ref null $c) (ref null (exact $b))) (result (ref $c)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $c) (ref null (exact $a)) + end + unreachable + ) + (func (;10;) (type 15) (param (ref null (exact $c)) (ref null $b)) (result (ref $c)) + block (result (ref null $a)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $c)) (ref null $a) + end + unreachable + ) + (func (;11;) (type 16) (param (ref null (exact $c)) (ref null (exact $b))) (result (ref $c)) + block (result (ref null (exact $a))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $c)) (ref null (exact $a)) + end + unreachable + ) + (func (;12;) (type 17) (param (ref null $a) (ref null $d)) (result (ref $a)) + block (result (ref null $c)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $a) (ref null $c) + end + unreachable + ) + (func (;13;) (type 18) (param (ref null $a) (ref null (exact $d))) (result (ref $a)) + block (result (ref null (exact $c))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null $a) (ref null (exact $c)) + end + unreachable + ) + (func (;14;) (type 19) (param (ref null (exact $a)) (ref null $d)) (result (ref (exact $a))) + block (result (ref null $c)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $a)) (ref null $c) + end + unreachable + ) + (func (;15;) (type 20) (param (ref null (exact $a)) (ref null (exact $d))) (result (ref (exact $a))) + block (result (ref null (exact $c))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 (ref null (exact $a)) (ref null (exact $c)) + end + unreachable + ) + (func (;16;) (type 21) (param (ref null $b)) (result (ref $a)) + block (result (ref null $a)) ;; label = @1 + ref.null none + local.get 0 + br_on_cast_desc_fail 1 nullref (ref null $a) + end + unreachable + ) + (func (;17;) (type 22) (param (ref null (exact $b))) (result (ref $a)) + block (result (ref null (exact $a))) ;; label = @1 + ref.null none + local.get 0 + br_on_cast_desc_fail 1 nullref (ref null (exact $a)) + end + unreachable + ) + (func (;18;) (type 23) (param (ref null $b)) (result (ref any)) + block (result (ref null $a)) ;; label = @1 + unreachable + local.get 0 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;19;) (type 24) (param (ref null (exact $b))) (result (ref any)) + block (result (ref null (exact $a))) ;; label = @1 + unreachable + local.get 0 + br_on_cast_desc_fail 1 anyref (ref null (exact $a)) + end + unreachable + ) + (func (;20;) (type 25) (param anyref (ref null $e)) (result (ref any)) + block (result (ref null $d)) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $d) + end + unreachable + ) + (func (;21;) (type 26) (param anyref (ref null (exact $e))) (result (ref any)) + block (result (ref null (exact $d))) ;; label = @1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null (exact $d)) + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/117.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/117.print new file mode 100644 index 0000000000..42cd055787 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/117.print @@ -0,0 +1,103 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (param i32 i32))) + (type (;3;) (func (param eqref eqref))) + (type (;4;) (func)) + (type (;5;) (func (result i32 i32 eqref))) + (global $b1 (;0;) (ref (exact $b)) struct.new $b) + (global $b2 (;1;) (ref (exact $b)) struct.new $b) + (global $a1 (;2;) (ref (exact $a)) global.get $b1 struct.new $a) + (export "cast-succeeds-null" (func 2)) + (export "cast-succeeds-val" (func 3)) + (export "cast-fails-null" (func 4)) + (export "cast-fails-val" (func 5)) + (func $assert-eq-i32 (;0;) (type 2) (param i32 i32) + local.get 0 + local.get 1 + i32.eq + if ;; label = @1 + return + else + unreachable + end + ) + (func $assert-eq-ref (;1;) (type 3) (param eqref eqref) + local.get 0 + local.get 1 + ref.eq + if ;; label = @1 + return + else + unreachable + end + ) + (func (;2;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + ref.null none + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) eqref (ref null $a) + ref.null none + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + return + end + unreachable + ) + (func (;3;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + global.get $a1 + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) eqref (ref null $a) + global.get $a1 + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + return + end + unreachable + ) + (func (;4;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + ref.null none + global.get $b2 + br_on_cast_desc_fail 0 (;@1;) eqref (ref $a) + unreachable + end + ref.null none + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + ) + (func (;5;) (type 4) + block (type 5) (result i32 i32 eqref) ;; label = @1 + i32.const 1 + i32.const 2 + global.get $a1 + global.get $b2 + br_on_cast_desc_fail 0 (;@1;) eqref (ref $a) + unreachable + end + global.get $a1 + call $assert-eq-ref + i32.const 2 + call $assert-eq-i32 + i32.const 1 + call $assert-eq-i32 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/19.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/19.print new file mode 100644 index 0000000000..d2945e7f69 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/19.print @@ -0,0 +1,40 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (param anyref (ref null $b)) (result i32 (ref any)))) + (type (;3;) (func (result i32 (ref null $a)))) + (type (;4;) (func (param anyref (ref null $b)) (result i32 i64 (ref any)))) + (type (;5;) (func (result i32 i64 (ref null $a)))) + (type (;6;) (func (param anyref (ref null $b)) (result eqref (ref any)))) + (type (;7;) (func (result anyref (ref null $a)))) + (func (;0;) (type 2) (param anyref (ref null $b)) (result i32 (ref any)) + block (type 3) (result i32 (ref null $a)) ;; label = @1 + i32.const 42 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;1;) (type 4) (param anyref (ref null $b)) (result i32 i64 (ref any)) + block (type 5) (result i32 i64 (ref null $a)) ;; label = @1 + i32.const 42 + i64.const 1337 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) + (func (;2;) (type 6) (param anyref (ref null $b)) (result eqref (ref any)) + block (type 7) (result anyref (ref null $a)) ;; label = @1 + local.get 1 + local.get 0 + local.get 1 + br_on_cast_desc_fail 1 anyref (ref null $a) + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/26.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/26.print new file mode 100644 index 0000000000..b72a056ec2 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_desc_fail.wast/26.print @@ -0,0 +1,1109 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type $no-desc (;4;) (struct)) + (type (;5;) (func (result i32))) + (global $b1-exact (;0;) (ref null (exact $b)) struct.new $b) + (global $b2-exact (;1;) (ref null (exact $b)) struct.new $b) + (global $b1 (;2;) (ref null $b) global.get $b1-exact) + (global $b2 (;3;) (ref null $b) global.get $b2-exact) + (global $a1 (;4;) (ref null $a) global.get $b1-exact struct.new $a) + (global $d1-exact (;5;) (ref null (exact $d)) struct.new $d) + (global $d2-exact (;6;) (ref null (exact $d)) struct.new $d) + (global $d1 (;7;) (ref null $d) global.get $d1-exact) + (global $d2 (;8;) (ref null $d) global.get $d2-exact) + (global $c1 (;9;) (ref null $c) global.get $d1-exact struct.new $c) + (global $c1-as-a (;10;) (ref null $a) global.get $c1) + (global $a-null (;11;) (ref null (exact $a)) ref.null none) + (global $b-null (;12;) (ref null (exact $b)) ref.null none) + (global $c-null (;13;) (ref null (exact $c)) ref.null none) + (global $d-null (;14;) (ref null (exact $d)) ref.null none) + (global $no-desc (;15;) (ref null (exact $no-desc)) struct.new $no-desc) + (global $no-desc-null (;16;) (ref null (exact $no-desc)) ref.null none) + (global $i31 (;17;) anyref i32.const 0 ref.i31) + (global $i31-null (;18;) anyref ref.null i31) + (export "self-nullable-null-null" (func 0)) + (export "self-nullable-val-null" (func 1)) + (export "self-nullable-null-desc" (func 2)) + (export "self-nullable-val-desc" (func 3)) + (export "self-nullable-val-other" (func 4)) + (export "self-nonnullable-null-null" (func 5)) + (export "self-nonnullable-val-null" (func 6)) + (export "self-nonnullable-null-desc" (func 7)) + (export "self-nonnullable-val-desc" (func 8)) + (export "self-nonnullable-val-other" (func 9)) + (export "self-exact-nullable-null-null" (func 10)) + (export "self-exact-nullable-val-null" (func 11)) + (export "self-exact-nullable-null-desc" (func 12)) + (export "self-exact-nullable-val-desc" (func 13)) + (export "self-exact-nullable-val-other" (func 14)) + (export "self-exact-nonnullable-null-null" (func 15)) + (export "self-exact-nonnullable-val-null" (func 16)) + (export "self-exact-nonnullable-null-desc" (func 17)) + (export "self-exact-nonnullable-val-desc" (func 18)) + (export "self-exact-nonnullable-val-other" (func 19)) + (export "down-nullable-null-null" (func 20)) + (export "down-nullable-val-null" (func 21)) + (export "down-nullable-null-desc" (func 22)) + (export "down-nullable-val-desc" (func 23)) + (export "down-nullable-val-other" (func 24)) + (export "down-nonnullable-null-null" (func 25)) + (export "down-nonnullable-val-null" (func 26)) + (export "down-nonnullable-null-desc" (func 27)) + (export "down-nonnullable-val-desc" (func 28)) + (export "down-nonnullable-val-other" (func 29)) + (export "down-exact-nullable-null-null" (func 30)) + (export "down-exact-nullable-val-null" (func 31)) + (export "down-exact-nullable-null-desc" (func 32)) + (export "down-exact-nullable-val-desc" (func 33)) + (export "down-exact-nullable-val-other" (func 34)) + (export "down-exact-nonnullable-null-null" (func 35)) + (export "down-exact-nonnullable-val-null" (func 36)) + (export "down-exact-nonnullable-null-desc" (func 37)) + (export "down-exact-nonnullable-val-desc" (func 38)) + (export "down-exact-nonnullable-val-other" (func 39)) + (export "up-nullable-null-null" (func 40)) + (export "up-nullable-val-null" (func 41)) + (export "up-nullable-null-desc" (func 42)) + (export "up-nullable-val-desc" (func 43)) + (export "up-nullable-val-other" (func 44)) + (export "up-nonnullable-null-null" (func 45)) + (export "up-nonnullable-val-null" (func 46)) + (export "up-nonnullable-null-desc" (func 47)) + (export "up-nonnullable-val-desc" (func 48)) + (export "up-nonnullable-val-other" (func 49)) + (export "up-exact-nullable-null-null" (func 50)) + (export "up-exact-nullable-val-null" (func 51)) + (export "up-exact-nullable-null-desc" (func 52)) + (export "up-exact-nullable-val-other" (func 53)) + (export "up-exact-nonnullable-null-null" (func 54)) + (export "up-exact-nonnullable-val-null" (func 55)) + (export "up-exact-nonnullable-null-desc" (func 56)) + (export "up-exact-nonnullable-val-other" (func 57)) + (export "nodesc-nullable-null-null" (func 58)) + (export "nodesc-nullable-val-null" (func 59)) + (export "nodesc-nullable-null-desc" (func 60)) + (export "nodesc-nullable-val-other" (func 61)) + (export "nodesc-nonnullable-null-null" (func 62)) + (export "nodesc-nonnullable-val-null" (func 63)) + (export "nodesc-nonnullable-null-desc" (func 64)) + (export "nodesc-nonnullable-val-other" (func 65)) + (export "nodesc-exact-nullable-null-null" (func 66)) + (export "nodesc-exact-nullable-val-null" (func 67)) + (export "nodesc-exact-nullable-null-desc" (func 68)) + (export "nodesc-exact-nullable-val-other" (func 69)) + (export "nodesc-exact-nonnullable-null-null" (func 70)) + (export "nodesc-exact-nonnullable-val-null" (func 71)) + (export "nodesc-exact-nonnullable-null-desc" (func 72)) + (export "nodesc-exact-nonnullable-val-other" (func 73)) + (export "i31-nullable-null-null" (func 74)) + (export "i31-nullable-val-null" (func 75)) + (export "i31-nullable-null-desc" (func 76)) + (export "i31-nullable-val-other" (func 77)) + (export "i31-nonnullable-null-null" (func 78)) + (export "i31-nonnullable-val-null" (func 79)) + (export "i31-nonnullable-null-desc" (func 80)) + (export "i31-nonnullable-val-other" (func 81)) + (export "i31-exact-nullable-null-null" (func 82)) + (export "i31-exact-nullable-val-null" (func 83)) + (export "i31-exact-nullable-null-desc" (func 84)) + (export "i31-exact-nullable-val-other" (func 85)) + (export "i31-exact-nonnullable-null-null" (func 86)) + (export "i31-exact-nonnullable-val-null" (func 87)) + (export "i31-exact-nonnullable-null-desc" (func 88)) + (export "i31-exact-nonnullable-val-other" (func 89)) + (func (;0;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;1;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;2;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;3;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;4;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;5;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;6;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;7;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;8;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;9;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;10;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;11;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;12;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;13;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;14;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;15;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;16;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;17;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;18;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;19;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a1 + global.get $b2-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;20;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;21;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;22;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;23;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;24;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;25;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;26;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;27;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;28;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;29;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $c) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;30;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;31;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;32;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;33;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;34;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;35;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;36;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;37;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $a-null + global.get $d1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;38;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;39;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1-as-a + global.get $d2-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $c)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;40;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;41;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;42;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;43;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;44;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;45;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;46;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;47;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;48;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;49;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $d2 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;50;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;51;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;52;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;53;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;54;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;55;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;56;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;57;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $c1 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;58;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;59;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;60;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;61;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;62;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;63;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;64;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;65;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;66;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;67;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;68;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;69;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;70;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;71;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;72;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;73;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $no-desc + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;74;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;75;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;76;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;77;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref null $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;78;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;79;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;80;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;81;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1 + br_on_cast_desc_fail 0 (;@1;) anyref (ref $a) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;82;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;83;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;84;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;85;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref null (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;86;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;87;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b-null + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;88;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31-null + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) + (func (;89;) (type 5) (result i32) + block (result anyref) ;; label = @1 + global.get $i31 + global.get $b1-exact + br_on_cast_desc_fail 0 (;@1;) anyref (ref (exact $a)) + i32.const 0 + return + end + i32.const 1 + return + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast.json new file mode 100644 index 0000000000..0db2ffd2d2 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast.json @@ -0,0 +1,590 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "br_on_cast_fail.0.wasm", + "module_type": "binary" + }, + { + "type": "action", + "line": 69, + "action": { + "type": "invoke", + "field": "init", + "args": [ + { + "type": "externref", + "value": "0" + } + ] + } + }, + { + "type": "assert_return", + "line": 71, + "action": { + "type": "invoke", + "field": "br_on_non_null", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 72, + "action": { + "type": "invoke", + "field": "br_on_non_null", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 73, + "action": { + "type": "invoke", + "field": "br_on_non_null", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 74, + "action": { + "type": "invoke", + "field": "br_on_non_null", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 75, + "action": { + "type": "invoke", + "field": "br_on_non_null", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 77, + "action": { + "type": "invoke", + "field": "br_on_non_i31", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 78, + "action": { + "type": "invoke", + "field": "br_on_non_i31", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "7" + } + ] + }, + { + "type": "assert_return", + "line": 79, + "action": { + "type": "invoke", + "field": "br_on_non_i31", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 80, + "action": { + "type": "invoke", + "field": "br_on_non_i31", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 81, + "action": { + "type": "invoke", + "field": "br_on_non_i31", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 83, + "action": { + "type": "invoke", + "field": "br_on_non_struct", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 84, + "action": { + "type": "invoke", + "field": "br_on_non_struct", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 85, + "action": { + "type": "invoke", + "field": "br_on_non_struct", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "6" + } + ] + }, + { + "type": "assert_return", + "line": 86, + "action": { + "type": "invoke", + "field": "br_on_non_struct", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 87, + "action": { + "type": "invoke", + "field": "br_on_non_struct", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 89, + "action": { + "type": "invoke", + "field": "br_on_non_array", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 90, + "action": { + "type": "invoke", + "field": "br_on_non_array", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 91, + "action": { + "type": "invoke", + "field": "br_on_non_array", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 92, + "action": { + "type": "invoke", + "field": "br_on_non_array", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "3" + } + ] + }, + { + "type": "assert_return", + "line": 93, + "action": { + "type": "invoke", + "field": "br_on_non_array", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "-1" + } + ] + }, + { + "type": "assert_return", + "line": 95, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "0" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 96, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "1" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 97, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "2" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 98, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "3" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 99, + "action": { + "type": "invoke", + "field": "null-diff", + "args": [ + { + "type": "i32", + "value": "4" + } + ] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "module", + "line": 104, + "filename": "br_on_cast_fail.1.wasm", + "module_type": "binary" + }, + { + "type": "action", + "line": 220, + "action": { + "type": "invoke", + "field": "test-sub", + "args": [] + } + }, + { + "type": "action", + "line": 221, + "action": { + "type": "invoke", + "field": "test-canon", + "args": [] + } + }, + { + "type": "module", + "line": 226, + "filename": "br_on_cast_fail.2.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 251, + "filename": "br_on_cast_fail.3.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 260, + "filename": "br_on_cast_fail.4.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 269, + "filename": "br_on_cast_fail.5.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 277, + "filename": "br_on_cast_fail.6.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 288, + "filename": "br_on_cast_fail.7.wasm", + "module_type": "binary", + "text": "type mismatch" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/0.print new file mode 100644 index 0000000000..36bca64cb8 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/0.print @@ -0,0 +1,110 @@ +(module + (type $ft (;0;) (func (result i32))) + (type $st (;1;) (struct (field i16))) + (type $at (;2;) (array i8)) + (type (;3;) (func (param externref))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param structref) (result (ref $st)))) + (type (;6;) (func (param structref) (result (ref $at)))) + (table (;0;) 10 anyref) + (export "init" (func 1)) + (export "br_on_non_null" (func 2)) + (export "br_on_non_i31" (func 3)) + (export "br_on_non_struct" (func 4)) + (export "br_on_non_array" (func 5)) + (export "null-diff" (func 6)) + (elem (;0;) declare func $f) + (func $f (;0;) (type $ft) (result i32) + i32.const 9 + ) + (func (;1;) (type 3) (param $x externref) + i32.const 0 + ref.null any + table.set 0 + i32.const 1 + i32.const 7 + ref.i31 + table.set 0 + i32.const 2 + i32.const 6 + struct.new $st + table.set 0 + i32.const 3 + i32.const 5 + i32.const 3 + array.new $at + table.set 0 + i32.const 4 + local.get $x + any.convert_extern + table.set 0 + ) + (func (;2;) (type 4) (param $i i32) (result i32) + block $l (result (ref any)) + local.get $i + table.get 0 + br_on_non_null $l + i32.const 0 + return + end + i32.const -1 + return + ) + (func (;3;) (type 4) (param $i i32) (result i32) + block $l (result anyref) + local.get $i + table.get 0 + br_on_cast_fail $l anyref (ref i31) + i31.get_u + return + end + i32.const -1 + return + ) + (func (;4;) (type 4) (param $i i32) (result i32) + block $l (result anyref) + local.get $i + table.get 0 + br_on_cast_fail $l anyref (ref struct) + block $l2 (type 5) (param structref) (result (ref $st)) + block $l3 (type 6) (param structref) (result (ref $at)) + br_on_cast $l2 structref (ref $st) + br_on_cast $l3 anyref (ref $at) + i32.const -2 + return + end + i32.const 0 + array.get_u $at + return + end + struct.get_s $st 0 + return + end + i32.const -1 + return + ) + (func (;5;) (type 4) (param $i i32) (result i32) + block $l (result anyref) + local.get $i + table.get 0 + br_on_cast_fail $l anyref (ref array) + array.len + return + end + i32.const -1 + return + ) + (func (;6;) (type 4) (param $i i32) (result i32) + block $l (result (ref any)) + block (result structref) ;; label = @2 + local.get $i + table.get 0 + br_on_cast_fail $l anyref structref + end + i32.const 1 + return + end + i32.const 0 + return + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/27.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/27.print new file mode 100644 index 0000000000..246f1f5049 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/27.print @@ -0,0 +1,281 @@ +(module + (type $t0 (;0;) (sub (struct))) + (type $t1 (;1;) (sub $t0 (struct (field i32)))) + (type $t1' (;2;) (sub $t0 (struct (field i32)))) + (type $t2 (;3;) (sub $t1 (struct (field i32) (field i32)))) + (type $t2' (;4;) (sub $t1' (struct (field i32) (field i32)))) + (type $t3 (;5;) (sub $t0 (struct (field i32) (field i32)))) + (type $t0' (;6;) (sub $t0 (struct))) + (type $t4 (;7;) (sub $t0' (struct (field i32) (field i32)))) + (type (;8;) (func)) + (table (;0;) 20 structref) + (export "test-sub" (func 1)) + (export "test-canon" (func 2)) + (func $init (;0;) (type 8) + i32.const 0 + struct.new_default $t0 + table.set 0 + i32.const 10 + struct.new_default $t0 + table.set 0 + i32.const 1 + struct.new_default $t1 + table.set 0 + i32.const 11 + struct.new_default $t1' + table.set 0 + i32.const 2 + struct.new_default $t2 + table.set 0 + i32.const 12 + struct.new_default $t2' + table.set 0 + i32.const 3 + struct.new_default $t3 + table.set 0 + i32.const 4 + struct.new_default $t4 + table.set 0 + ) + (func (;1;) (type 8) + call $init + block $l (result structref) + ref.null struct + br_on_cast_fail $l structref (ref null $t0) + i32.const 0 + table.get 0 + br_on_cast_fail $l structref (ref null $t0) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref null $t0) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref null $t0) + i32.const 3 + table.get 0 + br_on_cast_fail $l structref (ref null $t0) + i32.const 4 + table.get 0 + br_on_cast_fail $l structref (ref null $t0) + i32.const 0 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 3 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 4 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + ref.null struct + br_on_cast_fail $l structref (ref null $t1) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref null $t1) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref null $t1) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref $t1) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t1) + ref.null struct + br_on_cast_fail $l structref (ref null $t2) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref null $t2) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t2) + ref.null struct + br_on_cast_fail $l structref (ref null $t3) + i32.const 3 + table.get 0 + br_on_cast_fail $l structref (ref null $t3) + i32.const 3 + table.get 0 + br_on_cast_fail $l structref (ref $t3) + ref.null struct + br_on_cast_fail $l structref (ref null $t4) + i32.const 4 + table.get 0 + br_on_cast_fail $l structref (ref null $t4) + i32.const 4 + table.get 0 + br_on_cast_fail $l structref (ref $t4) + block (result structref) ;; label = @2 + ref.null struct + br_on_cast_fail 0 (;@2;) structref (ref $t0) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast_fail 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t1) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast_fail 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t2) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast_fail 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + i32.const 4 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t3) + end + drop + block (result structref) ;; label = @2 + ref.null struct + br_on_cast_fail 0 (;@2;) structref (ref $t4) + end + drop + block (result structref) ;; label = @2 + i32.const 0 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t4) + end + drop + block (result structref) ;; label = @2 + i32.const 1 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t4) + end + drop + block (result structref) ;; label = @2 + i32.const 2 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t4) + end + drop + block (result structref) ;; label = @2 + i32.const 3 + table.get 0 + br_on_cast_fail 0 (;@2;) structref (ref $t4) + end + drop + return + end + unreachable + ) + (func (;2;) (type 8) + call $init + block $l (result structref) + i32.const 0 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 3 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 4 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 10 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 11 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 12 + table.get 0 + br_on_cast_fail $l structref (ref $t0) + i32.const 1 + table.get 0 + br_on_cast_fail $l structref (ref $t1') + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t1') + i32.const 11 + table.get 0 + br_on_cast_fail $l structref (ref $t1) + i32.const 12 + table.get 0 + br_on_cast_fail $l structref (ref $t1) + i32.const 2 + table.get 0 + br_on_cast_fail $l structref (ref $t2') + i32.const 12 + table.get 0 + br_on_cast_fail $l structref (ref $t2) + return + end + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/30.print b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/30.print new file mode 100644 index 0000000000..6af8c39862 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/br_on_cast_fail.wast/30.print @@ -0,0 +1,39 @@ +(module + (type $t (;0;) (struct)) + (type (;1;) (func (param (ref any)) (result (ref any)))) + (type (;2;) (func (param anyref) (result anyref))) + (type (;3;) (func (result anyref))) + (func (;0;) (type 1) (param (ref any)) (result (ref any)) + block (result (ref $t)) ;; label = @1 + local.get 0 + br_on_cast_fail 1 (ref any) (ref $t) + end + ) + (func (;1;) (type 2) (param anyref) (result anyref) + block (result (ref $t)) ;; label = @1 + local.get 0 + br_on_cast_fail 1 anyref (ref $t) + end + ) + (func (;2;) (type 1) (param (ref any)) (result (ref any)) + block (result (ref null $t)) ;; label = @1 + local.get 0 + br_on_cast_fail 1 (ref any) (ref null $t) + end + ref.as_non_null + ) + (func (;3;) (type 2) (param anyref) (result anyref) + block (result (ref null $t)) ;; label = @1 + local.get 0 + br_on_cast_fail 1 anyref (ref null $t) + end + ) + (func (;4;) (type 3) (result anyref) + unreachable + br_on_cast_fail 0 eqref anyref + ) + (func (;5;) (type 3) (result anyref) + unreachable + br_on_cast_fail 0 structref arrayref + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast.json new file mode 100644 index 0000000000..4cf7fdb038 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast.json @@ -0,0 +1,391 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/descriptors.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "descriptors.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 37, + "filename": "descriptors.1.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 49, + "filename": "descriptors.2.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 60, + "filename": "descriptors.3.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_invalid", + "line": 72, + "filename": "descriptors.4.wasm", + "module_type": "binary", + "text": "descriptor type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 79, + "filename": "descriptors.5.wasm", + "module_type": "binary", + "text": "described type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 86, + "filename": "descriptors.6.wasm", + "module_type": "binary", + "text": "descriptor type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 94, + "filename": "descriptors.7.wasm", + "module_type": "binary", + "text": "described type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 102, + "filename": "descriptors.8.wasm", + "module_type": "binary", + "text": "descriptor type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 110, + "filename": "descriptors.9.wasm", + "module_type": "binary", + "text": "described type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 118, + "filename": "descriptors.10.wasm", + "module_type": "binary", + "text": "type is not described by its descriptor" + }, + { + "type": "assert_invalid", + "line": 128, + "filename": "descriptors.11.wasm", + "module_type": "binary", + "text": "described type is not described by descriptor" + }, + { + "type": "assert_invalid", + "line": 138, + "filename": "descriptors.12.wasm", + "module_type": "binary", + "text": "forward use of described type" + }, + { + "type": "assert_invalid", + "line": 148, + "filename": "descriptors.13.wasm", + "module_type": "binary", + "text": "forward use of described type" + }, + { + "type": "assert_invalid", + "line": 155, + "filename": "descriptors.14.wasm", + "module_type": "binary", + "text": "descriptor type is outside rec group" + }, + { + "type": "assert_invalid", + "line": 163, + "filename": "descriptors.15.wasm", + "module_type": "binary", + "text": "descriptor type must be a struct" + }, + { + "type": "assert_invalid", + "line": 173, + "filename": "descriptors.16.wasm", + "module_type": "binary", + "text": "described type must be a struct" + }, + { + "type": "assert_invalid", + "line": 183, + "filename": "descriptors.17.wasm", + "module_type": "binary", + "text": "descriptor type must be a struct" + }, + { + "type": "assert_invalid", + "line": 193, + "filename": "descriptors.18.wasm", + "module_type": "binary", + "text": "descriptor type must be a struct" + }, + { + "type": "assert_invalid", + "line": 203, + "filename": "descriptors.19.wasm", + "module_type": "binary", + "text": "described type must be a struct" + }, + { + "type": "assert_invalid", + "line": 213, + "filename": "descriptors.20.wasm", + "module_type": "binary", + "text": "descriptor type must be a struct" + }, + { + "type": "module", + "line": 224, + "filename": "descriptors.21.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 233, + "filename": "descriptors.22.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 242, + "filename": "descriptors.23.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 255, + "filename": "descriptors.24.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 262, + "filename": "descriptors.25.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 274, + "filename": "descriptors.26.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 284, + "filename": "descriptors.27.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 300, + "filename": "descriptors.28.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 310, + "filename": "descriptors.29.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 325, + "filename": "descriptors.30.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 335, + "filename": "descriptors.31.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 349, + "filename": "descriptors.32.wasm", + "module_type": "binary", + "text": "descriptor type 3 does not match" + }, + { + "type": "assert_invalid", + "line": 360, + "filename": "descriptors.33.wasm", + "module_type": "binary", + "text": "descriptor type 3 does not match" + }, + { + "type": "assert_invalid", + "line": 377, + "filename": "descriptors.34.wasm", + "module_type": "binary", + "text": "described type 2 does not match" + }, + { + "type": "assert_invalid", + "line": 388, + "filename": "descriptors.35.wasm", + "module_type": "binary", + "text": "described type 2 does not match" + }, + { + "type": "assert_invalid", + "line": 404, + "filename": "descriptors.36.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 415, + "filename": "descriptors.37.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 428, + "filename": "descriptors.38.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 446, + "filename": "descriptors.39.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 457, + "filename": "descriptors.40.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 470, + "filename": "descriptors.41.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 487, + "filename": "descriptors.42.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 498, + "filename": "descriptors.43.wasm", + "module_type": "binary", + "text": "sub type 2 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 514, + "filename": "descriptors.44.wasm", + "module_type": "binary", + "text": "sub type 1 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 524, + "filename": "descriptors.45.wasm", + "module_type": "binary", + "text": "sub type 1 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 538, + "filename": "descriptors.46.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 549, + "filename": "descriptors.47.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 1" + }, + { + "type": "assert_invalid", + "line": 565, + "filename": "descriptors.48.wasm", + "module_type": "binary", + "text": "descriptor type 5 does not match" + }, + { + "type": "assert_invalid", + "line": 578, + "filename": "descriptors.49.wasm", + "module_type": "binary", + "text": "descriptor type 5 does not match" + }, + { + "type": "assert_invalid", + "line": 593, + "filename": "descriptors.50.wasm", + "module_type": "binary", + "text": "sub type 5 does not match super type 2" + }, + { + "type": "assert_invalid", + "line": 606, + "filename": "descriptors.51.wasm", + "module_type": "binary", + "text": "sub type 5 does not match super type 2" + }, + { + "type": "assert_invalid", + "line": 624, + "filename": "descriptors.52.wasm", + "module_type": "binary", + "text": "described type 3 does not match" + }, + { + "type": "assert_invalid", + "line": 637, + "filename": "descriptors.53.wasm", + "module_type": "binary", + "text": "described type 3 does not match" + }, + { + "type": "assert_invalid", + "line": 652, + "filename": "descriptors.54.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 0" + }, + { + "type": "assert_invalid", + "line": 665, + "filename": "descriptors.55.wasm", + "module_type": "binary", + "text": "sub type 3 does not match super type 0" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/0.print new file mode 100644 index 0000000000..cb7783b80a --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/0.print @@ -0,0 +1,31 @@ +(module + (rec + (type (;0;) (descriptor 1) (struct)) + (type (;1;) (describes 0) (struct)) + ) + (rec + (type $a (;2;) (descriptor $b) (struct)) + (type $b (;3;) (describes $a) (struct)) + ) + (rec + (type $c (;4;) (sub (descriptor $d) (struct))) + (type $d (;5;) (sub (describes $c) (struct))) + ) + (rec + (type $e (;6;) (descriptor $f) (struct)) + (type $f (;7;) (describes $e) (struct)) + ) + (rec + (type $g (;8;) (sub $c (descriptor $h) (struct))) + (type $h (;9;) (sub $d (describes $g) (struct))) + ) + (rec + (type $i (;10;) (sub final $g (descriptor $j) (struct (field i32)))) + (type $j (;11;) (sub final $h (describes $i) (struct (field f32)))) + ) + (rec + (type $k (;12;) (descriptor $l) (struct)) + (type $l (;13;) (describes $k) (descriptor $m) (struct)) + (type $m (;14;) (describes $l) (struct)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/21.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/21.print new file mode 100644 index 0000000000..a7fb7366bb --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/21.print @@ -0,0 +1,8 @@ +(module + (rec + (type $A (;0;) (sub (descriptor $A.desc) (struct))) + (type $A.desc (;1;) (sub (describes $A) (struct))) + (type $B (;2;) (sub $A (descriptor $B.desc) (struct))) + (type $B.desc (;3;) (sub $A.desc (describes $B) (struct))) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/22.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/22.print new file mode 100644 index 0000000000..b7baeb0329 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/22.print @@ -0,0 +1,8 @@ +(module + (rec + (type $A (;0;) (sub (descriptor $A.desc) (struct))) + (type $B (;1;) (sub $A (descriptor $B.desc) (struct))) + (type $A.desc (;2;) (sub (describes $A) (struct))) + (type $B.desc (;3;) (sub $A.desc (describes $B) (struct))) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/23.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/23.print new file mode 100644 index 0000000000..a3776712cb --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/23.print @@ -0,0 +1,10 @@ +(module + (rec + (type $A (;0;) (sub (descriptor $A.desc) (struct))) + (type $A.desc (;1;) (sub (describes $A) (struct))) + ) + (rec + (type $B (;2;) (sub $A (descriptor $B.desc) (struct))) + (type $B.desc (;3;) (sub $A.desc (describes $B) (struct))) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/24.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/24.print new file mode 100644 index 0000000000..03818dedb0 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/24.print @@ -0,0 +1,7 @@ +(module + (rec + (type $A (;0;) (sub (struct))) + (type $B (;1;) (sub $A (descriptor $B.desc) (struct))) + (type $B.desc (;2;) (sub (describes $B) (struct))) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/25.print b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/25.print new file mode 100644 index 0000000000..9251f03fe3 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/descriptors.wast/25.print @@ -0,0 +1,9 @@ +(module + (rec + (type $A (;0;) (sub (struct))) + ) + (rec + (type $B (;1;) (sub $A (descriptor $B.desc) (struct))) + (type $B.desc (;2;) (sub (describes $B) (struct))) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast.json new file mode 100644 index 0000000000..ee55b26089 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast.json @@ -0,0 +1,1271 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/exact-casts.wast", + "commands": [ + { + "type": "module", + "line": 4, + "filename": "exact-casts.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 170, + "action": { + "type": "invoke", + "field": "self-nullable", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 171, + "action": { + "type": "invoke", + "field": "self-nullable-global", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 172, + "action": { + "type": "invoke", + "field": "self-nullable-call", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 173, + "action": { + "type": "invoke", + "field": "self-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 175, + "action": { + "type": "invoke", + "field": "self-nonnullable", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 176, + "action": { + "type": "invoke", + "field": "self-nonnullable-global", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 177, + "action": { + "type": "invoke", + "field": "self-nonnullable-call", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 178, + "action": { + "type": "invoke", + "field": "self-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 180, + "action": { + "type": "invoke", + "field": "sub-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 181, + "action": { + "type": "invoke", + "field": "sub-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 182, + "action": { + "type": "invoke", + "field": "sub-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 183, + "action": { + "type": "invoke", + "field": "sub-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 185, + "action": { + "type": "invoke", + "field": "sub-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 186, + "action": { + "type": "invoke", + "field": "sub-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 187, + "action": { + "type": "invoke", + "field": "sub-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 188, + "action": { + "type": "invoke", + "field": "sub-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 190, + "action": { + "type": "invoke", + "field": "super-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 191, + "action": { + "type": "invoke", + "field": "super-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 192, + "action": { + "type": "invoke", + "field": "super-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 193, + "action": { + "type": "invoke", + "field": "super-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 195, + "action": { + "type": "invoke", + "field": "super-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 196, + "action": { + "type": "invoke", + "field": "super-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 197, + "action": { + "type": "invoke", + "field": "super-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 198, + "action": { + "type": "invoke", + "field": "super-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 200, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 201, + "action": { + "type": "invoke", + "field": "no-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 202, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 203, + "action": { + "type": "invoke", + "field": "no-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 205, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 206, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 207, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 208, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 210, + "action": { + "type": "invoke", + "field": "yes-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 211, + "action": { + "type": "invoke", + "field": "no-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 212, + "action": { + "type": "invoke", + "field": "yes-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 213, + "action": { + "type": "invoke", + "field": "no-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "module", + "line": 216, + "filename": "exact-casts.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 382, + "action": { + "type": "invoke", + "field": "self-nullable", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_return", + "line": 383, + "action": { + "type": "invoke", + "field": "self-nullable-global", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_return", + "line": 384, + "action": { + "type": "invoke", + "field": "self-nullable-call", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_return", + "line": 385, + "action": { + "type": "invoke", + "field": "self-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 387, + "action": { + "type": "invoke", + "field": "self-nonnullable", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_return", + "line": 388, + "action": { + "type": "invoke", + "field": "self-nonnullable-global", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_return", + "line": 389, + "action": { + "type": "invoke", + "field": "self-nonnullable-call", + "args": [] + }, + "expected": [ + { + "type": "arrayref" + } + ] + }, + { + "type": "assert_trap", + "line": 390, + "action": { + "type": "invoke", + "field": "self-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 392, + "action": { + "type": "invoke", + "field": "sub-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 393, + "action": { + "type": "invoke", + "field": "sub-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 394, + "action": { + "type": "invoke", + "field": "sub-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 395, + "action": { + "type": "invoke", + "field": "sub-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 397, + "action": { + "type": "invoke", + "field": "sub-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 398, + "action": { + "type": "invoke", + "field": "sub-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 399, + "action": { + "type": "invoke", + "field": "sub-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 400, + "action": { + "type": "invoke", + "field": "sub-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 402, + "action": { + "type": "invoke", + "field": "super-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 403, + "action": { + "type": "invoke", + "field": "super-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 404, + "action": { + "type": "invoke", + "field": "super-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 405, + "action": { + "type": "invoke", + "field": "super-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 407, + "action": { + "type": "invoke", + "field": "super-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 408, + "action": { + "type": "invoke", + "field": "super-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 409, + "action": { + "type": "invoke", + "field": "super-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 410, + "action": { + "type": "invoke", + "field": "super-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 412, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 413, + "action": { + "type": "invoke", + "field": "no-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 414, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 415, + "action": { + "type": "invoke", + "field": "no-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 417, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 418, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 419, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 420, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 422, + "action": { + "type": "invoke", + "field": "yes-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 423, + "action": { + "type": "invoke", + "field": "no-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 424, + "action": { + "type": "invoke", + "field": "yes-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 425, + "action": { + "type": "invoke", + "field": "no-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "module", + "line": 428, + "filename": "exact-casts.2.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 594, + "action": { + "type": "invoke", + "field": "self-nullable", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_return", + "line": 595, + "action": { + "type": "invoke", + "field": "self-nullable-global", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_return", + "line": 596, + "action": { + "type": "invoke", + "field": "self-nullable-call", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_return", + "line": 597, + "action": { + "type": "invoke", + "field": "self-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullfuncref" + } + ] + }, + { + "type": "assert_return", + "line": 599, + "action": { + "type": "invoke", + "field": "self-nonnullable", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_return", + "line": 600, + "action": { + "type": "invoke", + "field": "self-nonnullable-global", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_return", + "line": 601, + "action": { + "type": "invoke", + "field": "self-nonnullable-call", + "args": [] + }, + "expected": [ + { + "type": "funcref" + } + ] + }, + { + "type": "assert_trap", + "line": 602, + "action": { + "type": "invoke", + "field": "self-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 604, + "action": { + "type": "invoke", + "field": "sub-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 605, + "action": { + "type": "invoke", + "field": "sub-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 606, + "action": { + "type": "invoke", + "field": "sub-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 607, + "action": { + "type": "invoke", + "field": "sub-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullfuncref" + } + ] + }, + { + "type": "assert_trap", + "line": 609, + "action": { + "type": "invoke", + "field": "sub-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 610, + "action": { + "type": "invoke", + "field": "sub-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 611, + "action": { + "type": "invoke", + "field": "sub-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 612, + "action": { + "type": "invoke", + "field": "sub-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 614, + "action": { + "type": "invoke", + "field": "super-nullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 615, + "action": { + "type": "invoke", + "field": "super-nullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 616, + "action": { + "type": "invoke", + "field": "super-nullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 617, + "action": { + "type": "invoke", + "field": "super-nullable-null", + "args": [] + }, + "expected": [ + { + "type": "nullfuncref" + } + ] + }, + { + "type": "assert_trap", + "line": 619, + "action": { + "type": "invoke", + "field": "super-nonnullable", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 620, + "action": { + "type": "invoke", + "field": "super-nonnullable-global", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 621, + "action": { + "type": "invoke", + "field": "super-nonnullable-call", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_trap", + "line": 622, + "action": { + "type": "invoke", + "field": "super-nonnullable-null", + "args": [] + }, + "text": "cast failure" + }, + { + "type": "assert_return", + "line": 624, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 625, + "action": { + "type": "invoke", + "field": "no-br-on-cast-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 626, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 627, + "action": { + "type": "invoke", + "field": "no-br-on-cast-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 629, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 630, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-val", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 631, + "action": { + "type": "invoke", + "field": "no-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 632, + "action": { + "type": "invoke", + "field": "yes-br-on-cast-fail-null", + "args": [] + }, + "expected": [] + }, + { + "type": "assert_return", + "line": 634, + "action": { + "type": "invoke", + "field": "yes-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 635, + "action": { + "type": "invoke", + "field": "no-ref-test-val", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 636, + "action": { + "type": "invoke", + "field": "yes-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 637, + "action": { + "type": "invoke", + "field": "no-ref-test-null", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/0.print new file mode 100644 index 0000000000..54fad36b2d --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/0.print @@ -0,0 +1,227 @@ +(module + (type $super (;0;) (sub (struct))) + (type $sub (;1;) (sub $super (struct))) + (type (;2;) (func (result anyref))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (global $super (;0;) anyref struct.new $super) + (global $sub (;1;) anyref struct.new $sub) + (export "self-nullable" (func 2)) + (export "self-nullable-global" (func 3)) + (export "self-nullable-call" (func 4)) + (export "self-nullable-null" (func 5)) + (export "self-nonnullable" (func 6)) + (export "self-nonnullable-global" (func 7)) + (export "self-nonnullable-call" (func 8)) + (export "self-nonnullable-null" (func 9)) + (export "sub-nullable" (func 10)) + (export "sub-nullable-global" (func 11)) + (export "sub-nullable-call" (func 12)) + (export "sub-nullable-null" (func 13)) + (export "sub-nonnullable" (func 14)) + (export "sub-nonnullable-global" (func 15)) + (export "sub-nonnullable-call" (func 16)) + (export "sub-nonnullable-null" (func 17)) + (export "super-nullable" (func 18)) + (export "super-nullable-global" (func 19)) + (export "super-nullable-call" (func 20)) + (export "super-nullable-null" (func 21)) + (export "super-nonnullable" (func 22)) + (export "super-nonnullable-global" (func 23)) + (export "super-nonnullable-call" (func 24)) + (export "super-nonnullable-null" (func 25)) + (export "yes-br-on-cast-val" (func 26)) + (export "no-br-on-cast-val" (func 27)) + (export "yes-br-on-cast-null" (func 28)) + (export "no-br-on-cast-null" (func 29)) + (export "no-br-on-cast-fail-val" (func 30)) + (export "yes-br-on-cast-fail-val" (func 31)) + (export "no-br-on-cast-fail-null" (func 32)) + (export "yes-br-on-cast-fail-null" (func 33)) + (export "yes-ref-test-val" (func 34)) + (export "no-ref-test-val" (func 35)) + (export "yes-ref-test-null" (func 36)) + (export "no-ref-test-null" (func 37)) + (func $super (;0;) (type 2) (result anyref) + struct.new $super + ) + (func $sub (;1;) (type 2) (result anyref) + struct.new $sub + ) + (func (;2;) (type 2) (result anyref) + struct.new $super + ref.cast (ref null (exact $super)) + ) + (func (;3;) (type 2) (result anyref) + global.get $super + ref.cast (ref null (exact $super)) + ) + (func (;4;) (type 2) (result anyref) + call $super + ref.cast (ref null (exact $super)) + ) + (func (;5;) (type 2) (result anyref) + ref.null $super + ref.cast (ref null (exact $super)) + ) + (func (;6;) (type 2) (result anyref) + struct.new $super + ref.cast (ref (exact $super)) + ) + (func (;7;) (type 2) (result anyref) + global.get $super + ref.cast (ref (exact $super)) + ) + (func (;8;) (type 2) (result anyref) + call $super + ref.cast (ref (exact $super)) + ) + (func (;9;) (type 2) (result anyref) + ref.null $super + ref.cast (ref (exact $super)) + ) + (func (;10;) (type 2) (result anyref) + struct.new $sub + ref.cast (ref null (exact $super)) + ) + (func (;11;) (type 2) (result anyref) + global.get $sub + ref.cast (ref null (exact $super)) + ) + (func (;12;) (type 2) (result anyref) + call $sub + ref.cast (ref null (exact $super)) + ) + (func (;13;) (type 2) (result anyref) + ref.null $sub + ref.cast (ref null (exact $super)) + ) + (func (;14;) (type 2) (result anyref) + struct.new $sub + ref.cast (ref (exact $super)) + ) + (func (;15;) (type 2) (result anyref) + global.get $sub + ref.cast (ref (exact $super)) + ) + (func (;16;) (type 2) (result anyref) + call $sub + ref.cast (ref (exact $super)) + ) + (func (;17;) (type 2) (result anyref) + ref.null $sub + ref.cast (ref (exact $super)) + ) + (func (;18;) (type 2) (result anyref) + struct.new $super + ref.cast (ref null (exact $sub)) + ) + (func (;19;) (type 2) (result anyref) + global.get $super + ref.cast (ref null (exact $sub)) + ) + (func (;20;) (type 2) (result anyref) + call $super + ref.cast (ref null (exact $sub)) + ) + (func (;21;) (type 2) (result anyref) + ref.null $super + ref.cast (ref null (exact $sub)) + ) + (func (;22;) (type 2) (result anyref) + struct.new $super + ref.cast (ref (exact $sub)) + ) + (func (;23;) (type 2) (result anyref) + global.get $super + ref.cast (ref (exact $sub)) + ) + (func (;24;) (type 2) (result anyref) + call $super + ref.cast (ref (exact $sub)) + ) + (func (;25;) (type 2) (result anyref) + ref.null $super + ref.cast (ref (exact $sub)) + ) + (func (;26;) (type 3) + block (result anyref) ;; label = @1 + global.get $super + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;27;) (type 3) + block (result anyref) ;; label = @1 + global.get $sub + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;28;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast 0 (;@1;) anyref (ref null (exact $super)) + unreachable + end + return + ) + (func (;29;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;30;) (type 3) + block (result anyref) ;; label = @1 + global.get $super + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;31;) (type 3) + block (result anyref) ;; label = @1 + global.get $sub + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;32;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast_fail 0 (;@1;) anyref (ref null (exact $super)) + return + end + unreachable + ) + (func (;33;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;34;) (type 4) (result i32) + global.get $super + ref.test (ref (exact $super)) + ) + (func (;35;) (type 4) (result i32) + global.get $sub + ref.test (ref (exact $super)) + ) + (func (;36;) (type 4) (result i32) + ref.null none + ref.test (ref null (exact $super)) + ) + (func (;37;) (type 4) (result i32) + ref.null none + ref.test (ref (exact $super)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/37.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/37.print new file mode 100644 index 0000000000..a04051b2ea --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/37.print @@ -0,0 +1,227 @@ +(module + (type $super (;0;) (sub (array i8))) + (type $sub (;1;) (sub $super (array i8))) + (type (;2;) (func (result anyref))) + (type (;3;) (func)) + (type (;4;) (func (result i32))) + (global $super (;0;) anyref array.new_fixed $super 0) + (global $sub (;1;) anyref array.new_fixed $sub 0) + (export "self-nullable" (func 2)) + (export "self-nullable-global" (func 3)) + (export "self-nullable-call" (func 4)) + (export "self-nullable-null" (func 5)) + (export "self-nonnullable" (func 6)) + (export "self-nonnullable-global" (func 7)) + (export "self-nonnullable-call" (func 8)) + (export "self-nonnullable-null" (func 9)) + (export "sub-nullable" (func 10)) + (export "sub-nullable-global" (func 11)) + (export "sub-nullable-call" (func 12)) + (export "sub-nullable-null" (func 13)) + (export "sub-nonnullable" (func 14)) + (export "sub-nonnullable-global" (func 15)) + (export "sub-nonnullable-call" (func 16)) + (export "sub-nonnullable-null" (func 17)) + (export "super-nullable" (func 18)) + (export "super-nullable-global" (func 19)) + (export "super-nullable-call" (func 20)) + (export "super-nullable-null" (func 21)) + (export "super-nonnullable" (func 22)) + (export "super-nonnullable-global" (func 23)) + (export "super-nonnullable-call" (func 24)) + (export "super-nonnullable-null" (func 25)) + (export "yes-br-on-cast-val" (func 26)) + (export "no-br-on-cast-val" (func 27)) + (export "yes-br-on-cast-null" (func 28)) + (export "no-br-on-cast-null" (func 29)) + (export "no-br-on-cast-fail-val" (func 30)) + (export "yes-br-on-cast-fail-val" (func 31)) + (export "no-br-on-cast-fail-null" (func 32)) + (export "yes-br-on-cast-fail-null" (func 33)) + (export "yes-ref-test-val" (func 34)) + (export "no-ref-test-val" (func 35)) + (export "yes-ref-test-null" (func 36)) + (export "no-ref-test-null" (func 37)) + (func $super (;0;) (type 2) (result anyref) + array.new_fixed $super 0 + ) + (func $sub (;1;) (type 2) (result anyref) + array.new_fixed $sub 0 + ) + (func (;2;) (type 2) (result anyref) + array.new_fixed $super 0 + ref.cast (ref null (exact $super)) + ) + (func (;3;) (type 2) (result anyref) + global.get $super + ref.cast (ref null (exact $super)) + ) + (func (;4;) (type 2) (result anyref) + call $super + ref.cast (ref null (exact $super)) + ) + (func (;5;) (type 2) (result anyref) + ref.null $super + ref.cast (ref null (exact $super)) + ) + (func (;6;) (type 2) (result anyref) + array.new_fixed $super 0 + ref.cast (ref (exact $super)) + ) + (func (;7;) (type 2) (result anyref) + global.get $super + ref.cast (ref (exact $super)) + ) + (func (;8;) (type 2) (result anyref) + call $super + ref.cast (ref (exact $super)) + ) + (func (;9;) (type 2) (result anyref) + ref.null $super + ref.cast (ref (exact $super)) + ) + (func (;10;) (type 2) (result anyref) + array.new_fixed $sub 0 + ref.cast (ref null (exact $super)) + ) + (func (;11;) (type 2) (result anyref) + global.get $sub + ref.cast (ref null (exact $super)) + ) + (func (;12;) (type 2) (result anyref) + call $sub + ref.cast (ref null (exact $super)) + ) + (func (;13;) (type 2) (result anyref) + ref.null $sub + ref.cast (ref null (exact $super)) + ) + (func (;14;) (type 2) (result anyref) + array.new_fixed $sub 0 + ref.cast (ref (exact $super)) + ) + (func (;15;) (type 2) (result anyref) + global.get $sub + ref.cast (ref (exact $super)) + ) + (func (;16;) (type 2) (result anyref) + call $sub + ref.cast (ref (exact $super)) + ) + (func (;17;) (type 2) (result anyref) + ref.null $sub + ref.cast (ref (exact $super)) + ) + (func (;18;) (type 2) (result anyref) + array.new_fixed $super 0 + ref.cast (ref null (exact $sub)) + ) + (func (;19;) (type 2) (result anyref) + global.get $super + ref.cast (ref null (exact $sub)) + ) + (func (;20;) (type 2) (result anyref) + call $super + ref.cast (ref null (exact $sub)) + ) + (func (;21;) (type 2) (result anyref) + ref.null $super + ref.cast (ref null (exact $sub)) + ) + (func (;22;) (type 2) (result anyref) + array.new_fixed $super 0 + ref.cast (ref (exact $sub)) + ) + (func (;23;) (type 2) (result anyref) + global.get $super + ref.cast (ref (exact $sub)) + ) + (func (;24;) (type 2) (result anyref) + call $super + ref.cast (ref (exact $sub)) + ) + (func (;25;) (type 2) (result anyref) + ref.null $super + ref.cast (ref (exact $sub)) + ) + (func (;26;) (type 3) + block (result anyref) ;; label = @1 + global.get $super + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;27;) (type 3) + block (result anyref) ;; label = @1 + global.get $sub + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;28;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast 0 (;@1;) anyref (ref null (exact $super)) + unreachable + end + return + ) + (func (;29;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;30;) (type 3) + block (result anyref) ;; label = @1 + global.get $super + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + return + end + unreachable + ) + (func (;31;) (type 3) + block (result anyref) ;; label = @1 + global.get $sub + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;32;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast_fail 0 (;@1;) anyref (ref null (exact $super)) + return + end + unreachable + ) + (func (;33;) (type 3) + block (result anyref) ;; label = @1 + ref.null none + br_on_cast_fail 0 (;@1;) anyref (ref (exact $super)) + unreachable + end + return + ) + (func (;34;) (type 4) (result i32) + global.get $super + ref.test (ref (exact $super)) + ) + (func (;35;) (type 4) (result i32) + global.get $sub + ref.test (ref (exact $super)) + ) + (func (;36;) (type 4) (result i32) + ref.null none + ref.test (ref null (exact $super)) + ) + (func (;37;) (type 4) (result i32) + ref.null none + ref.test (ref (exact $super)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/74.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/74.print new file mode 100644 index 0000000000..ff2c6f7164 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact-casts.wast/74.print @@ -0,0 +1,226 @@ +(module + (type $super (;0;) (sub (func (result funcref)))) + (type $sub (;1;) (sub $super (func (result funcref)))) + (type (;2;) (func)) + (type (;3;) (func (result i32))) + (global $super (;0;) funcref ref.func $super) + (global $sub (;1;) funcref ref.func $sub) + (export "self-nullable" (func 2)) + (export "self-nullable-global" (func 3)) + (export "self-nullable-call" (func 4)) + (export "self-nullable-null" (func 5)) + (export "self-nonnullable" (func 6)) + (export "self-nonnullable-global" (func 7)) + (export "self-nonnullable-call" (func 8)) + (export "self-nonnullable-null" (func 9)) + (export "sub-nullable" (func 10)) + (export "sub-nullable-global" (func 11)) + (export "sub-nullable-call" (func 12)) + (export "sub-nullable-null" (func 13)) + (export "sub-nonnullable" (func 14)) + (export "sub-nonnullable-global" (func 15)) + (export "sub-nonnullable-call" (func 16)) + (export "sub-nonnullable-null" (func 17)) + (export "super-nullable" (func 18)) + (export "super-nullable-global" (func 19)) + (export "super-nullable-call" (func 20)) + (export "super-nullable-null" (func 21)) + (export "super-nonnullable" (func 22)) + (export "super-nonnullable-global" (func 23)) + (export "super-nonnullable-call" (func 24)) + (export "super-nonnullable-null" (func 25)) + (export "yes-br-on-cast-val" (func 26)) + (export "no-br-on-cast-val" (func 27)) + (export "yes-br-on-cast-null" (func 28)) + (export "no-br-on-cast-null" (func 29)) + (export "no-br-on-cast-fail-val" (func 30)) + (export "yes-br-on-cast-fail-val" (func 31)) + (export "no-br-on-cast-fail-null" (func 32)) + (export "yes-br-on-cast-fail-null" (func 33)) + (export "yes-ref-test-val" (func 34)) + (export "no-ref-test-val" (func 35)) + (export "yes-ref-test-null" (func 36)) + (export "no-ref-test-null" (func 37)) + (func $super (;0;) (type $super) (result funcref) + ref.func $super + ) + (func $sub (;1;) (type $sub) (result funcref) + ref.func $sub + ) + (func (;2;) (type $super) (result funcref) + ref.func $super + ref.cast (ref null (exact $super)) + ) + (func (;3;) (type $super) (result funcref) + global.get $super + ref.cast (ref null (exact $super)) + ) + (func (;4;) (type $super) (result funcref) + call $super + ref.cast (ref null (exact $super)) + ) + (func (;5;) (type $super) (result funcref) + ref.null $super + ref.cast (ref null (exact $super)) + ) + (func (;6;) (type $super) (result funcref) + ref.func $super + ref.cast (ref (exact $super)) + ) + (func (;7;) (type $super) (result funcref) + global.get $super + ref.cast (ref (exact $super)) + ) + (func (;8;) (type $super) (result funcref) + call $super + ref.cast (ref (exact $super)) + ) + (func (;9;) (type $super) (result funcref) + ref.null $super + ref.cast (ref (exact $super)) + ) + (func (;10;) (type $super) (result funcref) + ref.func $sub + ref.cast (ref null (exact $super)) + ) + (func (;11;) (type $super) (result funcref) + global.get $sub + ref.cast (ref null (exact $super)) + ) + (func (;12;) (type $super) (result funcref) + call $sub + ref.cast (ref null (exact $super)) + ) + (func (;13;) (type $super) (result funcref) + ref.null $sub + ref.cast (ref null (exact $super)) + ) + (func (;14;) (type $super) (result funcref) + ref.func $sub + ref.cast (ref (exact $super)) + ) + (func (;15;) (type $super) (result funcref) + global.get $sub + ref.cast (ref (exact $super)) + ) + (func (;16;) (type $super) (result funcref) + call $sub + ref.cast (ref (exact $super)) + ) + (func (;17;) (type $super) (result funcref) + ref.null $sub + ref.cast (ref (exact $super)) + ) + (func (;18;) (type $super) (result funcref) + ref.func $super + ref.cast (ref null (exact $sub)) + ) + (func (;19;) (type $super) (result funcref) + global.get $super + ref.cast (ref null (exact $sub)) + ) + (func (;20;) (type $super) (result funcref) + call $super + ref.cast (ref null (exact $sub)) + ) + (func (;21;) (type $super) (result funcref) + ref.null $super + ref.cast (ref null (exact $sub)) + ) + (func (;22;) (type $super) (result funcref) + ref.func $super + ref.cast (ref (exact $sub)) + ) + (func (;23;) (type $super) (result funcref) + global.get $super + ref.cast (ref (exact $sub)) + ) + (func (;24;) (type $super) (result funcref) + call $super + ref.cast (ref (exact $sub)) + ) + (func (;25;) (type $super) (result funcref) + ref.null $super + ref.cast (ref (exact $sub)) + ) + (func (;26;) (type 2) + block (result funcref) ;; label = @1 + global.get $super + br_on_cast 0 (;@1;) funcref (ref (exact $super)) + unreachable + end + return + ) + (func (;27;) (type 2) + block (result funcref) ;; label = @1 + global.get $sub + br_on_cast 0 (;@1;) funcref (ref (exact $super)) + return + end + unreachable + ) + (func (;28;) (type 2) + block (result funcref) ;; label = @1 + ref.null nofunc + br_on_cast 0 (;@1;) funcref (ref null (exact $super)) + unreachable + end + return + ) + (func (;29;) (type 2) + block (result funcref) ;; label = @1 + ref.null nofunc + br_on_cast 0 (;@1;) funcref (ref (exact $super)) + return + end + unreachable + ) + (func (;30;) (type 2) + block (result funcref) ;; label = @1 + global.get $super + br_on_cast_fail 0 (;@1;) funcref (ref (exact $super)) + return + end + unreachable + ) + (func (;31;) (type 2) + block (result funcref) ;; label = @1 + global.get $sub + br_on_cast_fail 0 (;@1;) funcref (ref (exact $super)) + unreachable + end + return + ) + (func (;32;) (type 2) + block (result funcref) ;; label = @1 + ref.null nofunc + br_on_cast_fail 0 (;@1;) funcref (ref null (exact $super)) + return + end + unreachable + ) + (func (;33;) (type 2) + block (result funcref) ;; label = @1 + ref.null nofunc + br_on_cast_fail 0 (;@1;) funcref (ref (exact $super)) + unreachable + end + return + ) + (func (;34;) (type 3) (result i32) + global.get $super + ref.test (ref (exact $super)) + ) + (func (;35;) (type 3) (result i32) + global.get $sub + ref.test (ref (exact $super)) + ) + (func (;36;) (type 3) (result i32) + ref.null nofunc + ref.test (ref null (exact $super)) + ) + (func (;37;) (type 3) (result i32) + ref.null nofunc + ref.test (ref (exact $super)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast.json new file mode 100644 index 0000000000..971f78a4d3 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast.json @@ -0,0 +1,241 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/exact.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "exact.0.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 23, + "filename": "exact.1.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 29, + "filename": "exact.2.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 35, + "filename": "exact.3.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 41, + "filename": "exact.4.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 47, + "filename": "exact.5.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 53, + "filename": "exact.6.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 59, + "filename": "exact.7.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 65, + "filename": "exact.8.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 71, + "filename": "exact.9.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 77, + "filename": "exact.10.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 85, + "filename": "exact.11.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 93, + "filename": "exact.12.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "assert_malformed", + "line": 101, + "filename": "exact.13.wat", + "module_type": "text", + "text": "unexpected token" + }, + { + "type": "module", + "line": 111, + "filename": "exact.14.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 125, + "filename": "exact.15.wasm", + "module_type": "binary" + }, + { + "type": "assert_malformed", + "line": 140, + "filename": "exact.16.wasm", + "module_type": "binary", + "text": "malformed storage type" + }, + { + "type": "assert_malformed", + "line": 156, + "filename": "exact.17.wasm", + "module_type": "binary", + "text": "malformed storage type" + }, + { + "type": "module", + "line": 175, + "filename": "exact.18.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 183, + "filename": "exact.19.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 191, + "filename": "exact.20.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 199, + "filename": "exact.21.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 207, + "filename": "exact.22.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 218, + "filename": "exact.23.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 229, + "filename": "exact.24.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 237, + "filename": "exact.25.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 245, + "filename": "exact.26.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 253, + "filename": "exact.27.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 261, + "filename": "exact.28.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 270, + "filename": "exact.29.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 280, + "filename": "exact.30.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 292, + "filename": "exact.31.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 304, + "filename": "exact.32.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 316, + "filename": "exact.33.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "module", + "line": 327, + "filename": "exact.34.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 336, + "filename": "exact.35.wasm", + "module_type": "binary", + "text": "type mismatch" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/0.print new file mode 100644 index 0000000000..ae75f75bba --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/0.print @@ -0,0 +1,14 @@ +(module + (rec + (type $struct (;0;) (struct (field (ref null (exact $func))))) + (type $array (;1;) (array (ref null (exact $struct)))) + (type $func (;2;) (func (param (ref (exact $struct))) (result (ref (exact $array))))) + ) + (type (;3;) (func (param (ref (exact $struct))) (result (ref (exact $func))))) + (table (;0;) 0 (ref null (exact $array))) + (global (;0;) (ref null (exact $struct)) ref.null (exact $struct)) + (elem (;0;) (ref null $func)) + (func $f (;0;) (type 3) (param (ref (exact $struct))) (result (ref (exact $func))) + unreachable + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/14.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/14.print new file mode 100644 index 0000000000..ea80bfc613 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/14.print @@ -0,0 +1,3 @@ +(module + (type (;0;) (struct (field (ref (exact 0))))) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/15.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/15.print new file mode 100644 index 0000000000..4ec7c4089f --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/15.print @@ -0,0 +1,3 @@ +(module + (type (;0;) (struct (field (ref null (exact 0))))) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/18.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/18.print new file mode 100644 index 0000000000..f10263d947 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/18.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (struct)) + (type (;1;) (func (param (ref none)) (result (ref (exact 0))))) + (func (;0;) (type 1) (param (ref none)) (result (ref (exact 0))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/19.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/19.print new file mode 100644 index 0000000000..38eb040d60 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/19.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (param (ref nofunc)) (result (ref (exact 0))))) + (func (;0;) (type 1) (param (ref nofunc)) (result (ref (exact 0))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/20.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/20.print new file mode 100644 index 0000000000..06f65927ed --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/20.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (struct)) + (type (;1;) (func (param (ref (exact 0))) (result (ref (exact 0))))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref (exact 0))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/21.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/21.print new file mode 100644 index 0000000000..345ed03990 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/21.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (param (ref (exact 0))) (result (ref (exact 0))))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref (exact 0))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/22.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/22.print new file mode 100644 index 0000000000..d9c4b2c08e --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/22.print @@ -0,0 +1,10 @@ +(module + (type (;0;) (struct)) + (type (;1;) (struct)) + (type (;2;) (struct (field (ref 0)))) + (type (;3;) (struct (field (ref 1)))) + (type (;4;) (func (param (ref (exact 2))) (result (ref (exact 3))))) + (func (;0;) (type 4) (param (ref (exact 2))) (result (ref (exact 3))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/23.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/23.print new file mode 100644 index 0000000000..827ad886c4 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/23.print @@ -0,0 +1,10 @@ +(module + (type (;0;) (struct)) + (type (;1;) (struct)) + (type (;2;) (func (param (ref 0)))) + (type (;3;) (func (param (ref 1)))) + (type (;4;) (func (param (ref (exact 3))) (result (ref (exact 2))))) + (func (;0;) (type 4) (param (ref (exact 3))) (result (ref (exact 2))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/24.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/24.print new file mode 100644 index 0000000000..f6d6e6cc89 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/24.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (struct)) + (type (;1;) (func (param (ref (exact 0))) (result (ref 0)))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref 0)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/25.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/25.print new file mode 100644 index 0000000000..6222435f47 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/25.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (param (ref (exact 0))) (result (ref 0)))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref 0)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/26.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/26.print new file mode 100644 index 0000000000..a287fe176a --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/26.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (struct)) + (type (;1;) (func (param (ref (exact 0))) (result (ref any)))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref any)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/27.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/27.print new file mode 100644 index 0000000000..1993052ede --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/27.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (func)) + (type (;1;) (func (param (ref (exact 0))) (result (ref func)))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref func)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/28.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/28.print new file mode 100644 index 0000000000..434c64ad59 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/28.print @@ -0,0 +1,8 @@ +(module + (type $super (;0;) (sub (struct))) + (type $sub (;1;) (sub $super (struct))) + (type (;2;) (func (param (ref (exact $sub))) (result (ref $super)))) + (func (;0;) (type 2) (param (ref (exact $sub))) (result (ref $super)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/29.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/29.print new file mode 100644 index 0000000000..65ff01ab42 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/29.print @@ -0,0 +1,8 @@ +(module + (type $super (;0;) (sub (func))) + (type $sub (;1;) (sub $super (func))) + (type (;2;) (func (param (ref (exact $sub))) (result (ref $super)))) + (func (;0;) (type 2) (param (ref (exact $sub))) (result (ref $super)) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/34.print b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/34.print new file mode 100644 index 0000000000..e6aa6beb94 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/exact.wast/34.print @@ -0,0 +1,7 @@ +(module + (type (;0;) (struct)) + (type (;1;) (func (param (ref (exact 0))) (result (ref null (exact 0))))) + (func (;0;) (type 1) (param (ref (exact 0))) (result (ref null (exact 0))) + local.get 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast.json new file mode 100644 index 0000000000..5ce5a25f20 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast.json @@ -0,0 +1,1115 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/ref_cast_desc.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "ref_cast_desc.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 168, + "filename": "ref_cast_desc.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 267, + "filename": "ref_cast_desc.2.wasm", + "module_type": "binary", + "text": "unknown type" + }, + { + "type": "assert_invalid", + "line": 277, + "filename": "ref_cast_desc.3.wasm", + "module_type": "binary", + "text": "type any does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 287, + "filename": "ref_cast_desc.4.wasm", + "module_type": "binary", + "text": "type none does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 297, + "filename": "ref_cast_desc.5.wasm", + "module_type": "binary", + "text": "type 0 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 308, + "filename": "ref_cast_desc.6.wasm", + "module_type": "binary", + "text": "type 1 does not have a descriptor" + }, + { + "type": "assert_invalid", + "line": 322, + "filename": "ref_cast_desc.7.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 336, + "filename": "ref_cast_desc.8.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 350, + "filename": "ref_cast_desc.9.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 364, + "filename": "ref_cast_desc.10.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 380, + "filename": "ref_cast_desc.11.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 394, + "filename": "ref_cast_desc.12.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 410, + "filename": "ref_cast_desc.13.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 426, + "filename": "ref_cast_desc.14.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 442, + "filename": "ref_cast_desc.15.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 458, + "filename": "ref_cast_desc.16.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 474, + "filename": "ref_cast_desc.17.wasm", + "module_type": "binary", + "text": "constant expression required" + }, + { + "type": "module", + "line": 487, + "filename": "ref_cast_desc.18.wasm", + "module_type": "binary" + }, + { + "type": "assert_trap", + "line": 812, + "action": { + "type": "invoke", + "field": "self-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 813, + "action": { + "type": "invoke", + "field": "self-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 814, + "action": { + "type": "invoke", + "field": "self-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 815, + "action": { + "type": "invoke", + "field": "self-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 816, + "action": { + "type": "invoke", + "field": "self-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 818, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 819, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 820, + "action": { + "type": "invoke", + "field": "self-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_return", + "line": 821, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 822, + "action": { + "type": "invoke", + "field": "self-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 824, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 825, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 826, + "action": { + "type": "invoke", + "field": "self-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 827, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 828, + "action": { + "type": "invoke", + "field": "self-exact-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 830, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 831, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 832, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_return", + "line": 833, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 834, + "action": { + "type": "invoke", + "field": "self-exact-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 836, + "action": { + "type": "invoke", + "field": "down-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 837, + "action": { + "type": "invoke", + "field": "down-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 838, + "action": { + "type": "invoke", + "field": "down-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 839, + "action": { + "type": "invoke", + "field": "down-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 840, + "action": { + "type": "invoke", + "field": "down-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 842, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 843, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 844, + "action": { + "type": "invoke", + "field": "down-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_return", + "line": 845, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 846, + "action": { + "type": "invoke", + "field": "down-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 848, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 849, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 850, + "action": { + "type": "invoke", + "field": "down-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 851, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 852, + "action": { + "type": "invoke", + "field": "down-exact-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 854, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 855, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 856, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_return", + "line": 857, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 858, + "action": { + "type": "invoke", + "field": "down-exact-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 860, + "action": { + "type": "invoke", + "field": "up-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 861, + "action": { + "type": "invoke", + "field": "up-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 862, + "action": { + "type": "invoke", + "field": "up-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_return", + "line": 863, + "action": { + "type": "invoke", + "field": "up-nullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 864, + "action": { + "type": "invoke", + "field": "up-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 866, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 867, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 868, + "action": { + "type": "invoke", + "field": "up-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_return", + "line": 869, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-desc", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 870, + "action": { + "type": "invoke", + "field": "up-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 872, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 873, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 874, + "action": { + "type": "invoke", + "field": "up-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 875, + "action": { + "type": "invoke", + "field": "up-exact-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 877, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 878, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 879, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 880, + "action": { + "type": "invoke", + "field": "up-exact-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 882, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 883, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 884, + "action": { + "type": "invoke", + "field": "nodesc-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 885, + "action": { + "type": "invoke", + "field": "nodesc-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 887, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 888, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 889, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 890, + "action": { + "type": "invoke", + "field": "nodesc-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 892, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 893, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 894, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 895, + "action": { + "type": "invoke", + "field": "nodesc-exact-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 897, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 898, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 899, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 900, + "action": { + "type": "invoke", + "field": "nodesc-exact-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 902, + "action": { + "type": "invoke", + "field": "i31-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 903, + "action": { + "type": "invoke", + "field": "i31-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 904, + "action": { + "type": "invoke", + "field": "i31-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 905, + "action": { + "type": "invoke", + "field": "i31-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 907, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 908, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 909, + "action": { + "type": "invoke", + "field": "i31-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 910, + "action": { + "type": "invoke", + "field": "i31-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 912, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 913, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_return", + "line": 914, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-null-desc", + "args": [] + }, + "expected": [ + { + "type": "nullref" + } + ] + }, + { + "type": "assert_trap", + "line": 915, + "action": { + "type": "invoke", + "field": "i31-exact-nullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 917, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 918, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 919, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-null-desc", + "args": [] + }, + "text": "descriptor cast failure" + }, + { + "type": "assert_trap", + "line": 920, + "action": { + "type": "invoke", + "field": "i31-exact-nonnullable-val-other", + "args": [] + }, + "text": "descriptor cast failure" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/0.print new file mode 100644 index 0000000000..b625fbb227 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/0.print @@ -0,0 +1,288 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type (;4;) (func (param anyref (ref null $b)) (result (ref null $a)))) + (type (;5;) (func (param anyref (ref null $b)) (result (ref $a)))) + (type (;6;) (func (param anyref (ref $b)) (result (ref null $a)))) + (type (;7;) (func (param anyref (ref $b)) (result (ref $a)))) + (type (;8;) (func (param (ref any) (ref null $b)) (result (ref null $a)))) + (type (;9;) (func (param (ref any) (ref null $b)) (result (ref $a)))) + (type (;10;) (func (param (ref any) (ref $b)) (result (ref null $a)))) + (type (;11;) (func (param (ref any) (ref $b)) (result (ref $a)))) + (type (;12;) (func (param anyref (ref null $d)) (result (ref null $a)))) + (type (;13;) (func (param anyref (ref null $d)) (result (ref $a)))) + (type (;14;) (func (param anyref (ref $d)) (result (ref null $a)))) + (type (;15;) (func (param anyref (ref $d)) (result (ref $a)))) + (type (;16;) (func (param (ref any) (ref null $d)) (result (ref null $a)))) + (type (;17;) (func (param (ref any) (ref null $d)) (result (ref $a)))) + (type (;18;) (func (param (ref any) (ref $d)) (result (ref null $a)))) + (type (;19;) (func (param (ref any) (ref $d)) (result (ref $a)))) + (type (;20;) (func (param anyref (ref null (exact $d))) (result (ref null $a)))) + (type (;21;) (func (param anyref (ref null (exact $d))) (result (ref $a)))) + (type (;22;) (func (param anyref (ref (exact $d))) (result (ref null $a)))) + (type (;23;) (func (param anyref (ref (exact $d))) (result (ref $a)))) + (type (;24;) (func (param (ref any) (ref null (exact $d))) (result (ref null $a)))) + (type (;25;) (func (param (ref any) (ref null (exact $d))) (result (ref $a)))) + (type (;26;) (func (param (ref any) (ref (exact $d))) (result (ref null $a)))) + (type (;27;) (func (param (ref any) (ref (exact $d))) (result (ref $a)))) + (type (;28;) (func (param anyref (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;29;) (func (param anyref (ref null (exact $b))) (result (ref (exact $a))))) + (type (;30;) (func (param anyref (ref (exact $b))) (result (ref null (exact $a))))) + (type (;31;) (func (param anyref (ref (exact $b))) (result (ref (exact $a))))) + (type (;32;) (func (param (ref any) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;33;) (func (param (ref any) (ref null (exact $b))) (result (ref (exact $a))))) + (type (;34;) (func (param (ref any) (ref (exact $b))) (result (ref null (exact $a))))) + (type (;35;) (func (param (ref any) (ref (exact $b))) (result (ref (exact $a))))) + (type (;36;) (func (param anyref) (result (ref null $a)))) + (type (;37;) (func (param anyref) (result (ref $a)))) + (type (;38;) (func (param (ref any)) (result (ref null $a)))) + (type (;39;) (func (param (ref any)) (result (ref $a)))) + (type (;40;) (func (param anyref) (result (ref null (exact $a))))) + (type (;41;) (func (param anyref) (result (ref (exact $a))))) + (type (;42;) (func (param (ref any)) (result (ref null (exact $a))))) + (type (;43;) (func (param (ref any)) (result (ref (exact $a))))) + (func (;0;) (type 4) (param anyref (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;1;) (type 5) (param anyref (ref null $b)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;2;) (type 6) (param anyref (ref $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;3;) (type 7) (param anyref (ref $b)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;4;) (type 8) (param (ref any) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;5;) (type 9) (param (ref any) (ref null $b)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;6;) (type 10) (param (ref any) (ref $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;7;) (type 11) (param (ref any) (ref $b)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;8;) (type 12) (param anyref (ref null $d)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;9;) (type 13) (param anyref (ref null $d)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;10;) (type 14) (param anyref (ref $d)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;11;) (type 15) (param anyref (ref $d)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;12;) (type 16) (param (ref any) (ref null $d)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;13;) (type 17) (param (ref any) (ref null $d)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;14;) (type 18) (param (ref any) (ref $d)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;15;) (type 19) (param (ref any) (ref $d)) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;16;) (type 20) (param anyref (ref null (exact $d))) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;17;) (type 21) (param anyref (ref null (exact $d))) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;18;) (type 22) (param anyref (ref (exact $d))) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;19;) (type 23) (param anyref (ref (exact $d))) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;20;) (type 24) (param (ref any) (ref null (exact $d))) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;21;) (type 25) (param (ref any) (ref null (exact $d))) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;22;) (type 26) (param (ref any) (ref (exact $d))) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;23;) (type 27) (param (ref any) (ref (exact $d))) (result (ref $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref $a) + ) + (func (;24;) (type 28) (param anyref (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;25;) (type 29) (param anyref (ref null (exact $b))) (result (ref (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref (exact $a)) + ) + (func (;26;) (type 30) (param anyref (ref (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;27;) (type 31) (param anyref (ref (exact $b))) (result (ref (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref (exact $a)) + ) + (func (;28;) (type 32) (param (ref any) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;29;) (type 33) (param (ref any) (ref null (exact $b))) (result (ref (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref (exact $a)) + ) + (func (;30;) (type 34) (param (ref any) (ref (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;31;) (type 35) (param (ref any) (ref (exact $b))) (result (ref (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref (exact $a)) + ) + (func (;32;) (type 36) (param anyref) (result (ref null $a)) + local.get 0 + unreachable + ref.cast_desc (ref null $a) + ) + (func (;33;) (type 37) (param anyref) (result (ref $a)) + local.get 0 + unreachable + ref.cast_desc (ref $a) + ) + (func (;34;) (type 38) (param (ref any)) (result (ref null $a)) + local.get 0 + unreachable + ref.cast_desc (ref null $a) + ) + (func (;35;) (type 39) (param (ref any)) (result (ref $a)) + local.get 0 + unreachable + ref.cast_desc (ref $a) + ) + (func (;36;) (type 40) (param anyref) (result (ref null (exact $a))) + local.get 0 + unreachable + ref.cast_desc (ref null (exact $a)) + ) + (func (;37;) (type 41) (param anyref) (result (ref (exact $a))) + local.get 0 + unreachable + ref.cast_desc (ref (exact $a)) + ) + (func (;38;) (type 42) (param (ref any)) (result (ref null (exact $a))) + local.get 0 + unreachable + ref.cast_desc (ref null (exact $a)) + ) + (func (;39;) (type 43) (param (ref any)) (result (ref (exact $a))) + local.get 0 + unreachable + ref.cast_desc (ref (exact $a)) + ) + (func (;40;) (type 36) (param anyref) (result (ref null $a)) + local.get 0 + ref.null none + ref.cast_desc (ref null $a) + ) + (func (;41;) (type 37) (param anyref) (result (ref $a)) + local.get 0 + ref.null none + ref.cast_desc (ref $a) + ) + (func (;42;) (type 38) (param (ref any)) (result (ref null $a)) + local.get 0 + ref.null none + ref.cast_desc (ref null $a) + ) + (func (;43;) (type 39) (param (ref any)) (result (ref $a)) + local.get 0 + ref.null none + ref.cast_desc (ref $a) + ) + (func (;44;) (type 40) (param anyref) (result (ref null (exact $a))) + local.get 0 + ref.null none + ref.cast_desc (ref null (exact $a)) + ) + (func (;45;) (type 41) (param anyref) (result (ref (exact $a))) + local.get 0 + ref.null none + ref.cast_desc (ref (exact $a)) + ) + (func (;46;) (type 42) (param (ref any)) (result (ref null (exact $a))) + local.get 0 + ref.null none + ref.cast_desc (ref null (exact $a)) + ) + (func (;47;) (type 43) (param (ref any)) (result (ref (exact $a))) + local.get 0 + ref.null none + ref.cast_desc (ref (exact $a)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/1.print new file mode 100644 index 0000000000..154b36e026 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/1.print @@ -0,0 +1,139 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (descriptor $e) (struct))) + (type $e (;4;) (describes $d) (struct)) + ) + (type (;5;) (func (param (ref null $a) (ref null $b)) (result (ref null $a)))) + (type (;6;) (func (param (ref null $a) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;7;) (func (param i31ref (ref null $b)) (result (ref null $a)))) + (type (;8;) (func (param i31ref (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;9;) (func (param (ref null $e) (ref null $b)) (result (ref null $a)))) + (type (;10;) (func (param (ref null $e) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;11;) (func (param (ref null (exact $e)) (ref null $b)) (result (ref null $a)))) + (type (;12;) (func (param (ref null (exact $e)) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;13;) (func (param (ref null $c) (ref null $b)) (result (ref null $a)))) + (type (;14;) (func (param (ref null $c) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;15;) (func (param (ref null (exact $c)) (ref null $b)) (result (ref null $a)))) + (type (;16;) (func (param (ref null (exact $c)) (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;17;) (func (param (ref null $a) (ref null $d)) (result (ref null $c)))) + (type (;18;) (func (param (ref null $a) (ref null (exact $d))) (result (ref null (exact $c))))) + (type (;19;) (func (param (ref null (exact $a)) (ref null $d)) (result (ref null $c)))) + (type (;20;) (func (param (ref null (exact $a)) (ref null (exact $d))) (result (ref null (exact $c))))) + (type (;21;) (func (param (ref null $b)) (result (ref null $a)))) + (type (;22;) (func (param (ref null (exact $b))) (result (ref null (exact $a))))) + (type (;23;) (func (param anyref (ref null $e)) (result (ref null $d)))) + (type (;24;) (func (param anyref (ref null (exact $e))) (result (ref null (exact $d))))) + (func (;0;) (type 5) (param (ref null $a) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;1;) (type 6) (param (ref null $a) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;2;) (type 7) (param i31ref (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;3;) (type 8) (param i31ref (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;4;) (type 9) (param (ref null $e) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;5;) (type 10) (param (ref null $e) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;6;) (type 11) (param (ref null (exact $e)) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;7;) (type 12) (param (ref null (exact $e)) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;8;) (type 13) (param (ref null $c) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;9;) (type 14) (param (ref null $c) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;10;) (type 15) (param (ref null (exact $c)) (ref null $b)) (result (ref null $a)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $a) + ) + (func (;11;) (type 16) (param (ref null (exact $c)) (ref null (exact $b))) (result (ref null (exact $a))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $a)) + ) + (func (;12;) (type 17) (param (ref null $a) (ref null $d)) (result (ref null $c)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $c) + ) + (func (;13;) (type 18) (param (ref null $a) (ref null (exact $d))) (result (ref null (exact $c))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $c)) + ) + (func (;14;) (type 19) (param (ref null (exact $a)) (ref null $d)) (result (ref null $c)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $c) + ) + (func (;15;) (type 20) (param (ref null (exact $a)) (ref null (exact $d))) (result (ref null (exact $c))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $c)) + ) + (func (;16;) (type 21) (param (ref null $b)) (result (ref null $a)) + ref.null none + local.get 0 + ref.cast_desc (ref null $a) + ) + (func (;17;) (type 22) (param (ref null (exact $b))) (result (ref null (exact $a))) + ref.null none + local.get 0 + ref.cast_desc (ref null (exact $a)) + ) + (func (;18;) (type 21) (param (ref null $b)) (result (ref null $a)) + unreachable + local.get 0 + ref.cast_desc (ref null $a) + ) + (func (;19;) (type 22) (param (ref null (exact $b))) (result (ref null (exact $a))) + unreachable + local.get 0 + ref.cast_desc (ref null (exact $a)) + ) + (func (;20;) (type 23) (param anyref (ref null $e)) (result (ref null $d)) + local.get 0 + local.get 1 + ref.cast_desc (ref null $d) + ) + (func (;21;) (type 24) (param anyref (ref null (exact $e))) (result (ref null (exact $d))) + local.get 0 + local.get 1 + ref.cast_desc (ref null (exact $d)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/18.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/18.print new file mode 100644 index 0000000000..42c6a36cde --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_cast_desc.wast/18.print @@ -0,0 +1,569 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type $no-desc (;4;) (struct)) + (type (;5;) (func (result anyref))) + (global $b1-exact (;0;) (ref null (exact $b)) struct.new $b) + (global $b2-exact (;1;) (ref null (exact $b)) struct.new $b) + (global $b1 (;2;) (ref null $b) global.get $b1-exact) + (global $b2 (;3;) (ref null $b) global.get $b2-exact) + (global $a1 (;4;) (ref null $a) global.get $b1-exact struct.new $a) + (global $d1-exact (;5;) (ref null (exact $d)) struct.new $d) + (global $d2-exact (;6;) (ref null (exact $d)) struct.new $d) + (global $d1 (;7;) (ref null $d) global.get $d1-exact) + (global $d2 (;8;) (ref null $d) global.get $d2-exact) + (global $c1 (;9;) (ref null $c) global.get $d1-exact struct.new $c) + (global $c1-as-a (;10;) (ref null $a) global.get $c1) + (global $a-null (;11;) (ref null (exact $a)) ref.null none) + (global $b-null (;12;) (ref null (exact $b)) ref.null none) + (global $c-null (;13;) (ref null (exact $c)) ref.null none) + (global $d-null (;14;) (ref null (exact $d)) ref.null none) + (global $no-desc (;15;) (ref null (exact $no-desc)) struct.new $no-desc) + (global $no-desc-null (;16;) (ref null (exact $no-desc)) ref.null none) + (global $i31 (;17;) anyref i32.const 0 ref.i31) + (global $i31-null (;18;) anyref ref.null i31) + (export "self-nullable-null-null" (func 0)) + (export "self-nullable-val-null" (func 1)) + (export "self-nullable-null-desc" (func 2)) + (export "self-nullable-val-desc" (func 3)) + (export "self-nullable-val-other" (func 4)) + (export "self-nonnullable-null-null" (func 5)) + (export "self-nonnullable-val-null" (func 6)) + (export "self-nonnullable-null-desc" (func 7)) + (export "self-nonnullable-val-desc" (func 8)) + (export "self-nonnullable-val-other" (func 9)) + (export "self-exact-nullable-null-null" (func 10)) + (export "self-exact-nullable-val-null" (func 11)) + (export "self-exact-nullable-null-desc" (func 12)) + (export "self-exact-nullable-val-desc" (func 13)) + (export "self-exact-nullable-val-other" (func 14)) + (export "self-exact-nonnullable-null-null" (func 15)) + (export "self-exact-nonnullable-val-null" (func 16)) + (export "self-exact-nonnullable-null-desc" (func 17)) + (export "self-exact-nonnullable-val-desc" (func 18)) + (export "self-exact-nonnullable-val-other" (func 19)) + (export "down-nullable-null-null" (func 20)) + (export "down-nullable-val-null" (func 21)) + (export "down-nullable-null-desc" (func 22)) + (export "down-nullable-val-desc" (func 23)) + (export "down-nullable-val-other" (func 24)) + (export "down-nonnullable-null-null" (func 25)) + (export "down-nonnullable-val-null" (func 26)) + (export "down-nonnullable-null-desc" (func 27)) + (export "down-nonnullable-val-desc" (func 28)) + (export "down-nonnullable-val-other" (func 29)) + (export "down-exact-nullable-null-null" (func 30)) + (export "down-exact-nullable-val-null" (func 31)) + (export "down-exact-nullable-null-desc" (func 32)) + (export "down-exact-nullable-val-desc" (func 33)) + (export "down-exact-nullable-val-other" (func 34)) + (export "down-exact-nonnullable-null-null" (func 35)) + (export "down-exact-nonnullable-val-null" (func 36)) + (export "down-exact-nonnullable-null-desc" (func 37)) + (export "down-exact-nonnullable-val-desc" (func 38)) + (export "down-exact-nonnullable-val-other" (func 39)) + (export "up-nullable-null-null" (func 40)) + (export "up-nullable-val-null" (func 41)) + (export "up-nullable-null-desc" (func 42)) + (export "up-nullable-val-desc" (func 43)) + (export "up-nullable-val-other" (func 44)) + (export "up-nonnullable-null-null" (func 45)) + (export "up-nonnullable-val-null" (func 46)) + (export "up-nonnullable-null-desc" (func 47)) + (export "up-nonnullable-val-desc" (func 48)) + (export "up-nonnullable-val-other" (func 49)) + (export "up-exact-nullable-null-null" (func 50)) + (export "up-exact-nullable-val-null" (func 51)) + (export "up-exact-nullable-null-desc" (func 52)) + (export "up-exact-nullable-val-other" (func 53)) + (export "up-exact-nonnullable-null-null" (func 54)) + (export "up-exact-nonnullable-val-null" (func 55)) + (export "up-exact-nonnullable-null-desc" (func 56)) + (export "up-exact-nonnullable-val-other" (func 57)) + (export "nodesc-nullable-null-null" (func 58)) + (export "nodesc-nullable-val-null" (func 59)) + (export "nodesc-nullable-null-desc" (func 60)) + (export "nodesc-nullable-val-other" (func 61)) + (export "nodesc-nonnullable-null-null" (func 62)) + (export "nodesc-nonnullable-val-null" (func 63)) + (export "nodesc-nonnullable-null-desc" (func 64)) + (export "nodesc-nonnullable-val-other" (func 65)) + (export "nodesc-exact-nullable-null-null" (func 66)) + (export "nodesc-exact-nullable-val-null" (func 67)) + (export "nodesc-exact-nullable-null-desc" (func 68)) + (export "nodesc-exact-nullable-val-other" (func 69)) + (export "nodesc-exact-nonnullable-null-null" (func 70)) + (export "nodesc-exact-nonnullable-val-null" (func 71)) + (export "nodesc-exact-nonnullable-null-desc" (func 72)) + (export "nodesc-exact-nonnullable-val-other" (func 73)) + (export "i31-nullable-null-null" (func 74)) + (export "i31-nullable-val-null" (func 75)) + (export "i31-nullable-null-desc" (func 76)) + (export "i31-nullable-val-other" (func 77)) + (export "i31-nonnullable-null-null" (func 78)) + (export "i31-nonnullable-val-null" (func 79)) + (export "i31-nonnullable-null-desc" (func 80)) + (export "i31-nonnullable-val-other" (func 81)) + (export "i31-exact-nullable-null-null" (func 82)) + (export "i31-exact-nullable-val-null" (func 83)) + (export "i31-exact-nullable-null-desc" (func 84)) + (export "i31-exact-nullable-val-other" (func 85)) + (export "i31-exact-nonnullable-null-null" (func 86)) + (export "i31-exact-nonnullable-val-null" (func 87)) + (export "i31-exact-nonnullable-null-desc" (func 88)) + (export "i31-exact-nonnullable-val-other" (func 89)) + (func (;0;) (type 5) (result anyref) + global.get $a-null + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;1;) (type 5) (result anyref) + global.get $a1 + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;2;) (type 5) (result anyref) + global.get $a-null + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;3;) (type 5) (result anyref) + global.get $a1 + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;4;) (type 5) (result anyref) + global.get $a1 + global.get $b2 + ref.cast_desc (ref null $a) + ) + (func (;5;) (type 5) (result anyref) + global.get $a-null + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;6;) (type 5) (result anyref) + global.get $a1 + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;7;) (type 5) (result anyref) + global.get $a-null + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;8;) (type 5) (result anyref) + global.get $a1 + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;9;) (type 5) (result anyref) + global.get $a1 + global.get $b2 + ref.cast_desc (ref $a) + ) + (func (;10;) (type 5) (result anyref) + global.get $a-null + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;11;) (type 5) (result anyref) + global.get $a1 + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;12;) (type 5) (result anyref) + global.get $a-null + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;13;) (type 5) (result anyref) + global.get $a1 + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;14;) (type 5) (result anyref) + global.get $a1 + global.get $b2-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;15;) (type 5) (result anyref) + global.get $a-null + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;16;) (type 5) (result anyref) + global.get $a1 + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;17;) (type 5) (result anyref) + global.get $a-null + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;18;) (type 5) (result anyref) + global.get $a1 + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;19;) (type 5) (result anyref) + global.get $a1 + global.get $b2-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;20;) (type 5) (result anyref) + global.get $a-null + global.get $d-null + ref.cast_desc (ref null $c) + ) + (func (;21;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d-null + ref.cast_desc (ref null $c) + ) + (func (;22;) (type 5) (result anyref) + global.get $a-null + global.get $d1 + ref.cast_desc (ref null $c) + ) + (func (;23;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d1 + ref.cast_desc (ref null $c) + ) + (func (;24;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d2 + ref.cast_desc (ref null $c) + ) + (func (;25;) (type 5) (result anyref) + global.get $a-null + global.get $d-null + ref.cast_desc (ref $c) + ) + (func (;26;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d-null + ref.cast_desc (ref $c) + ) + (func (;27;) (type 5) (result anyref) + global.get $a-null + global.get $d1 + ref.cast_desc (ref $c) + ) + (func (;28;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d1 + ref.cast_desc (ref $c) + ) + (func (;29;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d2 + ref.cast_desc (ref $c) + ) + (func (;30;) (type 5) (result anyref) + global.get $a-null + global.get $d-null + ref.cast_desc (ref null (exact $c)) + ) + (func (;31;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d-null + ref.cast_desc (ref null (exact $c)) + ) + (func (;32;) (type 5) (result anyref) + global.get $a-null + global.get $d1-exact + ref.cast_desc (ref null (exact $c)) + ) + (func (;33;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d1-exact + ref.cast_desc (ref null (exact $c)) + ) + (func (;34;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d2-exact + ref.cast_desc (ref null (exact $c)) + ) + (func (;35;) (type 5) (result anyref) + global.get $a-null + global.get $d-null + ref.cast_desc (ref (exact $c)) + ) + (func (;36;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d-null + ref.cast_desc (ref (exact $c)) + ) + (func (;37;) (type 5) (result anyref) + global.get $a-null + global.get $d1-exact + ref.cast_desc (ref (exact $c)) + ) + (func (;38;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d1-exact + ref.cast_desc (ref (exact $c)) + ) + (func (;39;) (type 5) (result anyref) + global.get $c1-as-a + global.get $d2-exact + ref.cast_desc (ref (exact $c)) + ) + (func (;40;) (type 5) (result anyref) + global.get $c-null + global.get $d-null + ref.cast_desc (ref null $a) + ) + (func (;41;) (type 5) (result anyref) + global.get $c1 + global.get $d-null + ref.cast_desc (ref null $a) + ) + (func (;42;) (type 5) (result anyref) + global.get $c-null + global.get $d1 + ref.cast_desc (ref null $a) + ) + (func (;43;) (type 5) (result anyref) + global.get $c1 + global.get $d1 + ref.cast_desc (ref null $a) + ) + (func (;44;) (type 5) (result anyref) + global.get $c1 + global.get $d2 + ref.cast_desc (ref null $a) + ) + (func (;45;) (type 5) (result anyref) + global.get $c-null + global.get $d-null + ref.cast_desc (ref $a) + ) + (func (;46;) (type 5) (result anyref) + global.get $c1 + global.get $d-null + ref.cast_desc (ref $a) + ) + (func (;47;) (type 5) (result anyref) + global.get $c-null + global.get $d1 + ref.cast_desc (ref $a) + ) + (func (;48;) (type 5) (result anyref) + global.get $c1 + global.get $d1 + ref.cast_desc (ref $a) + ) + (func (;49;) (type 5) (result anyref) + global.get $c1 + global.get $d2 + ref.cast_desc (ref $a) + ) + (func (;50;) (type 5) (result anyref) + global.get $c-null + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;51;) (type 5) (result anyref) + global.get $c1 + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;52;) (type 5) (result anyref) + global.get $c-null + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;53;) (type 5) (result anyref) + global.get $c1 + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;54;) (type 5) (result anyref) + global.get $c-null + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;55;) (type 5) (result anyref) + global.get $c1 + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;56;) (type 5) (result anyref) + global.get $c-null + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;57;) (type 5) (result anyref) + global.get $c1 + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;58;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;59;) (type 5) (result anyref) + global.get $no-desc + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;60;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;61;) (type 5) (result anyref) + global.get $no-desc + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;62;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;63;) (type 5) (result anyref) + global.get $no-desc + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;64;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;65;) (type 5) (result anyref) + global.get $no-desc + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;66;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;67;) (type 5) (result anyref) + global.get $no-desc + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;68;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;69;) (type 5) (result anyref) + global.get $no-desc + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;70;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;71;) (type 5) (result anyref) + global.get $no-desc + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;72;) (type 5) (result anyref) + global.get $no-desc-null + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;73;) (type 5) (result anyref) + global.get $no-desc + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;74;) (type 5) (result anyref) + global.get $i31-null + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;75;) (type 5) (result anyref) + global.get $i31 + global.get $b-null + ref.cast_desc (ref null $a) + ) + (func (;76;) (type 5) (result anyref) + global.get $i31-null + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;77;) (type 5) (result anyref) + global.get $i31 + global.get $b1 + ref.cast_desc (ref null $a) + ) + (func (;78;) (type 5) (result anyref) + global.get $i31-null + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;79;) (type 5) (result anyref) + global.get $i31 + global.get $b-null + ref.cast_desc (ref $a) + ) + (func (;80;) (type 5) (result anyref) + global.get $i31-null + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;81;) (type 5) (result anyref) + global.get $i31 + global.get $b1 + ref.cast_desc (ref $a) + ) + (func (;82;) (type 5) (result anyref) + global.get $i31-null + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;83;) (type 5) (result anyref) + global.get $i31 + global.get $b-null + ref.cast_desc (ref null (exact $a)) + ) + (func (;84;) (type 5) (result anyref) + global.get $i31-null + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;85;) (type 5) (result anyref) + global.get $i31 + global.get $b1-exact + ref.cast_desc (ref null (exact $a)) + ) + (func (;86;) (type 5) (result anyref) + global.get $i31-null + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;87;) (type 5) (result anyref) + global.get $i31 + global.get $b-null + ref.cast_desc (ref (exact $a)) + ) + (func (;88;) (type 5) (result anyref) + global.get $i31-null + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) + (func (;89;) (type 5) (result anyref) + global.get $i31 + global.get $b1-exact + ref.cast_desc (ref (exact $a)) + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast.json new file mode 100644 index 0000000000..ae71abb744 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast.json @@ -0,0 +1,390 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/ref_get_desc.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "ref_get_desc.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 37, + "filename": "ref_get_desc.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 72, + "filename": "ref_get_desc.2.wasm", + "module_type": "binary", + "text": "unknown type" + }, + { + "type": "assert_invalid", + "line": 82, + "filename": "ref_get_desc.3.wasm", + "module_type": "binary", + "text": "type without descriptor" + }, + { + "type": "assert_invalid", + "line": 93, + "filename": "ref_get_desc.4.wasm", + "module_type": "binary", + "text": "type without descriptor" + }, + { + "type": "assert_invalid", + "line": 104, + "filename": "ref_get_desc.5.wasm", + "module_type": "binary", + "text": "type without descriptor" + }, + { + "type": "assert_invalid", + "line": 118, + "filename": "ref_get_desc.6.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 132, + "filename": "ref_get_desc.7.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 146, + "filename": "ref_get_desc.8.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "module", + "line": 159, + "filename": "ref_get_desc.9.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 176, + "filename": "ref_get_desc.10.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 192, + "filename": "ref_get_desc.11.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 208, + "filename": "ref_get_desc.12.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 224, + "filename": "ref_get_desc.13.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 240, + "filename": "ref_get_desc.14.wasm", + "module_type": "binary", + "text": "constant expression required" + }, + { + "type": "module", + "line": 253, + "filename": "ref_get_desc.15.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 293, + "filename": "ref_get_desc.16.wasm", + "module_type": "binary" + }, + { + "type": "assert_trap", + "line": 400, + "action": { + "type": "invoke", + "field": "null", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 401, + "action": { + "type": "invoke", + "field": "null-typed", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 402, + "action": { + "type": "invoke", + "field": "null-global", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 403, + "action": { + "type": "invoke", + "field": "null-exact-global", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 404, + "action": { + "type": "invoke", + "field": "null-call", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 405, + "action": { + "type": "invoke", + "field": "null-exact-call", + "args": [] + }, + "text": "null reference" + }, + { + "type": "assert_trap", + "line": 406, + "action": { + "type": "invoke", + "field": "get-from-param", + "args": [ + { + "type": "nullref" + } + ] + }, + "text": "null reference" + }, + { + "type": "assert_return", + "line": 408, + "action": { + "type": "invoke", + "field": "alloc-0", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 409, + "action": { + "type": "invoke", + "field": "global-1", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 410, + "action": { + "type": "invoke", + "field": "global-2", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "2" + } + ] + }, + { + "type": "assert_return", + "line": 411, + "action": { + "type": "invoke", + "field": "global-3", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "3" + } + ] + }, + { + "type": "assert_return", + "line": 412, + "action": { + "type": "invoke", + "field": "call-4", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "4" + } + ] + }, + { + "type": "assert_return", + "line": 413, + "action": { + "type": "invoke", + "field": "call-5", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "5" + } + ] + }, + { + "type": "assert_return", + "line": 414, + "action": { + "type": "invoke", + "field": "equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 415, + "action": { + "type": "invoke", + "field": "not-equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + }, + { + "type": "assert_return", + "line": 416, + "action": { + "type": "invoke", + "field": "chain-equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "module", + "line": 420, + "filename": "ref_get_desc.17.wasm", + "module_type": "binary" + }, + { + "type": "register", + "line": 437, + "as": "A" + }, + { + "type": "module", + "line": 439, + "filename": "ref_get_desc.18.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 464, + "action": { + "type": "invoke", + "field": "imported-desc-equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 465, + "action": { + "type": "invoke", + "field": "imported-check-equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "1" + } + ] + }, + { + "type": "assert_return", + "line": 466, + "action": { + "type": "invoke", + "field": "imported-check-not-equal", + "args": [] + }, + "expected": [ + { + "type": "i32", + "value": "0" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/0.print new file mode 100644 index 0000000000..b8f7a0ae89 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/0.print @@ -0,0 +1,44 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (param (ref $a)) (result (ref $b)))) + (type (;3;) (func (param (ref null $a)) (result (ref $b)))) + (type (;4;) (func (param (ref (exact $a))) (result (ref (exact $b))))) + (type (;5;) (func (param (ref null (exact $a))) (result (ref (exact $b))))) + (type (;6;) (func (result (ref (exact $b))))) + (type (;7;) (func (result (ref $b)))) + (func (;0;) (type 2) (param (ref $a)) (result (ref $b)) + local.get 0 + ref.get_desc $a + ) + (func (;1;) (type 3) (param (ref null $a)) (result (ref $b)) + local.get 0 + ref.get_desc $a + ) + (func (;2;) (type 4) (param (ref (exact $a))) (result (ref (exact $b))) + local.get 0 + ref.get_desc $a + ) + (func (;3;) (type 5) (param (ref null (exact $a))) (result (ref (exact $b))) + local.get 0 + ref.get_desc $a + ) + (func (;4;) (type 6) (result (ref (exact $b))) + unreachable + ref.get_desc $a + ) + (func (;5;) (type 6) (result (ref (exact $b))) + ref.null none + ref.get_desc $a + ) + (func (;6;) (type 6) (result (ref (exact $b))) + ref.null (exact $a) + ref.get_desc $a + ) + (func (;7;) (type 7) (result (ref $b)) + ref.null $a + ref.get_desc $a + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/1.print new file mode 100644 index 0000000000..35cdd27978 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/1.print @@ -0,0 +1,45 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (descriptor $c) (struct)) + (type $c (;2;) (describes $b) (struct)) + ) + (type (;3;) (func (param (ref $b)) (result (ref $c)))) + (type (;4;) (func (param (ref null $b)) (result (ref $c)))) + (type (;5;) (func (param (ref (exact $b))) (result (ref (exact $c))))) + (type (;6;) (func (param (ref null (exact $b))) (result (ref (exact $c))))) + (type (;7;) (func (result (ref (exact $c))))) + (type (;8;) (func (result (ref $c)))) + (func (;0;) (type 3) (param (ref $b)) (result (ref $c)) + local.get 0 + ref.get_desc $b + ) + (func (;1;) (type 4) (param (ref null $b)) (result (ref $c)) + local.get 0 + ref.get_desc $b + ) + (func (;2;) (type 5) (param (ref (exact $b))) (result (ref (exact $c))) + local.get 0 + ref.get_desc $b + ) + (func (;3;) (type 6) (param (ref null (exact $b))) (result (ref (exact $c))) + local.get 0 + ref.get_desc $b + ) + (func (;4;) (type 7) (result (ref (exact $c))) + unreachable + ref.get_desc $b + ) + (func (;5;) (type 7) (result (ref (exact $c))) + ref.null none + ref.get_desc $b + ) + (func (;6;) (type 7) (result (ref (exact $c))) + ref.null (exact $b) + ref.get_desc $b + ) + (func (;7;) (type 8) (result (ref $c)) + ref.null $b + ref.get_desc $b + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/15.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/15.print new file mode 100644 index 0000000000..e7ce1ef776 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/15.print @@ -0,0 +1,11 @@ +(module + (rec + (type (;0;) (descriptor 1) (struct)) + (type (;1;) (describes 0) (struct)) + ) + (type (;2;) (func (param (ref null 0)) (result (ref 1)))) + (func (;0;) (type 2) (param (ref null 0)) (result (ref 1)) + local.get 0 + ref.get_desc 0 + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/16.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/16.print new file mode 100644 index 0000000000..664213e625 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/16.print @@ -0,0 +1,152 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct (field i32))) + ) + (rec + (type $one (;2;) (descriptor $two) (struct)) + (type $two (;3;) (describes $one) (descriptor $three) (struct)) + (type $three (;4;) (describes $two) (struct)) + ) + (type (;5;) (func (result (ref null $a)))) + (type (;6;) (func (result (ref null (exact $a))))) + (type (;7;) (func (param i32) (result (ref (exact $a))))) + (type (;8;) (func (param (ref (exact $b))) (result (ref (exact $a))))) + (type (;9;) (func (result anyref))) + (type (;10;) (func (param (ref null $a)) (result anyref))) + (type (;11;) (func (result i32))) + (global $b1 (;0;) (ref (exact $b)) i32.const 1 struct.new $b) + (global $b2 (;1;) (ref (exact $b)) i32.const 2 struct.new $b) + (global $a1 (;2;) (ref null $a) global.get $b1 struct.new $a) + (global $a2 (;3;) (ref null (exact $a)) global.get $b2 struct.new $a) + (global $a3 (;4;) (ref (exact $a)) i32.const 3 struct.new $b struct.new $a) + (global $null (;5;) (ref null $a) ref.null none) + (global $null-exact (;6;) (ref null (exact $a)) ref.null (exact $a)) + (export "null" (func 4)) + (export "null-typed" (func 5)) + (export "null-global" (func 6)) + (export "null-exact-global" (func 7)) + (export "null-call" (func 8)) + (export "null-exact-call" (func 9)) + (export "get-from-param" (func 10)) + (export "alloc-0" (func 11)) + (export "global-1" (func 12)) + (export "global-2" (func 13)) + (export "global-3" (func 14)) + (export "call-4" (func 15)) + (export "call-5" (func 16)) + (export "equal" (func 17)) + (export "not-equal" (func 18)) + (export "chain-equal" (func 19)) + (func $null (;0;) (type 5) (result (ref null $a)) + ref.null none + ) + (func $null-exact (;1;) (type 6) (result (ref null (exact $a))) + ref.null (exact $a) + ) + (func $alloc-i32 (;2;) (type 7) (param i32) (result (ref (exact $a))) + local.get 0 + struct.new $b + struct.new $a + ) + (func $alloc-desc (;3;) (type 8) (param (ref (exact $b))) (result (ref (exact $a))) + local.get 0 + struct.new $a + ) + (func (;4;) (type 9) (result anyref) + ref.null none + ref.get_desc $a + ) + (func (;5;) (type 9) (result anyref) + ref.null (exact $a) + ref.get_desc $a + ) + (func (;6;) (type 9) (result anyref) + global.get $null + ref.get_desc $a + ) + (func (;7;) (type 9) (result anyref) + global.get $null-exact + ref.get_desc $a + ) + (func (;8;) (type 9) (result anyref) + call $null + ref.get_desc $a + ) + (func (;9;) (type 9) (result anyref) + call $null-exact + ref.get_desc $a + ) + (func (;10;) (type 10) (param (ref null $a)) (result anyref) + local.get 0 + ref.get_desc $a + ) + (func (;11;) (type 11) (result i32) + i32.const 0 + struct.new $b + struct.new $a + ref.get_desc $a + struct.get $b 0 + ) + (func (;12;) (type 11) (result i32) + global.get $a1 + ref.get_desc $a + struct.get $b 0 + ) + (func (;13;) (type 11) (result i32) + global.get $a2 + ref.get_desc $a + struct.get $b 0 + ) + (func (;14;) (type 11) (result i32) + global.get $a3 + ref.get_desc $a + struct.get $b 0 + ) + (func (;15;) (type 11) (result i32) + i32.const 4 + call $alloc-i32 + ref.get_desc $a + struct.get $b 0 + ) + (func (;16;) (type 11) (result i32) + i32.const 5 + struct.new $b + call $alloc-desc + ref.get_desc $a + struct.get $b 0 + ) + (func (;17;) (type 11) (result i32) + (local (ref null (exact $b))) + struct.new_default $b + local.set 0 + local.get 0 + local.get 0 + struct.new $a + ref.get_desc $a + ref.eq + ) + (func (;18;) (type 11) (result i32) + struct.new_default $b + struct.new_default $b + struct.new $a + ref.get_desc $a + ref.eq + ) + (func (;19;) (type 11) (result i32) + (local $three (ref null (exact $three))) (local $two (ref null (exact $two))) (local $one (ref null (exact $one))) + struct.new $three + local.set $three + local.get $three + struct.new $two + local.set $two + local.get $two + struct.new $one + local.set $one + local.get $three + local.get $one + ref.get_desc $one + ref.get_desc $two + ref.eq + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/33.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/33.print new file mode 100644 index 0000000000..1d38245520 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/33.print @@ -0,0 +1,22 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (result (ref null $a)))) + (type (;3;) (func (param (ref null $a)) (result i32))) + (global (;0;) (ref null (exact $b)) struct.new $b) + (export "b" (global 0)) + (export "make-a" (func 0)) + (export "check-eq" (func 1)) + (func (;0;) (type 2) (result (ref null $a)) + global.get 0 + struct.new $a + ) + (func (;1;) (type 3) (param (ref null $a)) (result i32) + local.get 0 + ref.get_desc $a + global.get 0 + ref.eq + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/35.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/35.print new file mode 100644 index 0000000000..d45f8798e3 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/35.print @@ -0,0 +1,32 @@ +(module + (type $other (;0;) (func)) + (rec + (type $a (;1;) (descriptor $b) (struct)) + (type $b (;2;) (describes $a) (struct)) + ) + (type (;3;) (func (result (ref null $a)))) + (type (;4;) (func (param (ref null $a)) (result i32))) + (type (;5;) (func (result i32))) + (import "A" "b" (global $b (;0;) (ref null (exact $b)))) + (import "A" "make-a" (func $make-a (;0;) (type 3))) + (import "A" "check-eq" (func $check-eq (;1;) (type 4))) + (export "imported-desc-equal" (func 2)) + (export "imported-check-equal" (func 3)) + (export "imported-check-not-equal" (func 4)) + (func (;2;) (type 5) (result i32) + call $make-a + ref.get_desc $a + global.get $b + ref.eq + ) + (func (;3;) (type 5) (result i32) + global.get $b + struct.new $a + call $check-eq + ) + (func (;4;) (type 5) (result i32) + struct.new $b + struct.new $a + call $check-eq + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/9.print b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/9.print new file mode 100644 index 0000000000..de0459edfa --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/ref_get_desc.wast/9.print @@ -0,0 +1,18 @@ +(module + (rec + (type $a (;0;) (sub (descriptor $b) (struct))) + (type $b (;1;) (sub (describes $a) (struct))) + (type $c (;2;) (sub $a (descriptor $d) (struct))) + (type $d (;3;) (sub $b (describes $c) (struct))) + ) + (type (;4;) (func (param (ref (exact $c))) (result (ref $b)))) + (type (;5;) (func (param (ref $c)) (result (ref $b)))) + (func (;0;) (type 4) (param (ref (exact $c))) (result (ref $b)) + local.get 0 + ref.get_desc $a + ) + (func (;1;) (type 5) (param (ref $c)) (result (ref $b)) + local.get 0 + ref.get_desc $a + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast.json b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast.json new file mode 100644 index 0000000000..c63a691167 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast.json @@ -0,0 +1,330 @@ +{ + "source_filename": "tests/testsuite/proposals/custom-descriptors/struct_new_desc.wast", + "commands": [ + { + "type": "module", + "line": 3, + "filename": "struct_new_desc.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 89, + "filename": "struct_new_desc.1.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 114, + "filename": "struct_new_desc.2.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 128, + "filename": "struct_new_desc.3.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 143, + "filename": "struct_new_desc.4.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 157, + "filename": "struct_new_desc.5.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 171, + "filename": "struct_new_desc.6.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 185, + "filename": "struct_new_desc.7.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 201, + "filename": "struct_new_desc.8.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 217, + "filename": "struct_new_desc.9.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "assert_invalid", + "line": 233, + "filename": "struct_new_desc.10.wasm", + "module_type": "binary", + "text": "type mismatch" + }, + { + "type": "module", + "line": 248, + "filename": "struct_new_desc.11.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 341, + "action": { + "type": "get", + "field": "b" + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 342, + "action": { + "type": "invoke", + "field": "new-new", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 343, + "action": { + "type": "invoke", + "field": "new-global", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 344, + "action": { + "type": "invoke", + "field": "new-call", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 345, + "action": { + "type": "invoke", + "field": "new-pair", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 346, + "action": { + "type": "invoke", + "field": "new-chain", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 347, + "action": { + "type": "invoke", + "field": "new-null", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 348, + "action": { + "type": "invoke", + "field": "new-null-global", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 349, + "action": { + "type": "invoke", + "field": "new-null-call", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 350, + "action": { + "type": "invoke", + "field": "new-null-pair", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 351, + "action": { + "type": "invoke", + "field": "new-null-chain-1", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 352, + "action": { + "type": "invoke", + "field": "new-null-chain-2", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_uninstantiable", + "line": 355, + "filename": "struct_new_desc.12.wasm", + "module_type": "binary", + "text": "null descriptor reference" + }, + { + "type": "assert_uninstantiable", + "line": 366, + "filename": "struct_new_desc.13.wasm", + "module_type": "binary", + "text": "null descriptor reference" + }, + { + "type": "assert_uninstantiable", + "line": 377, + "filename": "struct_new_desc.14.wasm", + "module_type": "binary", + "text": "null descriptor reference" + }, + { + "type": "module", + "line": 390, + "name": "A", + "filename": "struct_new_desc.15.wasm", + "module_type": "binary" + }, + { + "type": "register", + "line": 409, + "as": "A" + }, + { + "type": "module", + "line": 411, + "name": "B", + "filename": "struct_new_desc.16.wasm", + "module_type": "binary" + }, + { + "type": "assert_return", + "line": 443, + "action": { + "type": "get", + "field": "a" + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 444, + "action": { + "type": "invoke", + "field": "new-global", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_return", + "line": 445, + "action": { + "type": "invoke", + "field": "new-call", + "args": [] + }, + "expected": [ + { + "type": "structref" + } + ] + }, + { + "type": "assert_trap", + "line": 446, + "action": { + "type": "invoke", + "field": "null-global", + "args": [] + }, + "text": "null descriptor reference" + }, + { + "type": "assert_trap", + "line": 447, + "action": { + "type": "invoke", + "field": "null-call", + "args": [] + }, + "text": "null descriptor reference" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/0.print b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/0.print new file mode 100644 index 0000000000..1f14c540d0 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/0.print @@ -0,0 +1,127 @@ +(module + (rec + (type $empty (;0;) (descriptor $empty.desc) (struct)) + (type $one (;1;) (descriptor $one.desc) (struct (field i32))) + (type $pair (;2;) (descriptor $pair.desc) (struct (field i32) (field i64))) + (type $empty.desc (;3;) (describes $empty) (struct)) + (type $one.desc (;4;) (describes $one) (struct)) + (type $pair.desc (;5;) (describes $pair) (struct)) + ) + (type (;6;) (func (param (ref null (exact $empty.desc))) (result (ref (exact $empty))))) + (type (;7;) (func (param (ref (exact $empty.desc))) (result (ref (exact $empty))))) + (type (;8;) (func (result (ref (exact $empty))))) + (type (;9;) (func (param (ref null (exact $one.desc))) (result (ref (exact $one))))) + (type (;10;) (func (param (ref (exact $one.desc))) (result (ref (exact $one))))) + (type (;11;) (func (result (ref (exact $one))))) + (type (;12;) (func (param (ref null (exact $pair.desc))) (result (ref (exact $pair))))) + (type (;13;) (func (param (ref (exact $pair.desc))) (result (ref (exact $pair))))) + (type (;14;) (func (result (ref (exact $pair))))) + (func (;0;) (type 6) (param (ref null (exact $empty.desc))) (result (ref (exact $empty))) + local.get 0 + struct.new $empty + ) + (func (;1;) (type 6) (param (ref null (exact $empty.desc))) (result (ref (exact $empty))) + local.get 0 + struct.new_default $empty + ) + (func (;2;) (type 7) (param (ref (exact $empty.desc))) (result (ref (exact $empty))) + local.get 0 + struct.new $empty + ) + (func (;3;) (type 7) (param (ref (exact $empty.desc))) (result (ref (exact $empty))) + local.get 0 + struct.new_default $empty + ) + (func (;4;) (type 8) (result (ref (exact $empty))) + ref.null none + struct.new $empty + ) + (func (;5;) (type 8) (result (ref (exact $empty))) + ref.null none + struct.new_default $empty + ) + (func (;6;) (type 8) (result (ref (exact $empty))) + unreachable + struct.new $empty + ) + (func (;7;) (type 8) (result (ref (exact $empty))) + unreachable + struct.new_default $empty + ) + (func (;8;) (type 9) (param (ref null (exact $one.desc))) (result (ref (exact $one))) + i32.const 0 + local.get 0 + struct.new $one + ) + (func (;9;) (type 9) (param (ref null (exact $one.desc))) (result (ref (exact $one))) + local.get 0 + struct.new_default $one + ) + (func (;10;) (type 10) (param (ref (exact $one.desc))) (result (ref (exact $one))) + i32.const 0 + local.get 0 + struct.new $one + ) + (func (;11;) (type 10) (param (ref (exact $one.desc))) (result (ref (exact $one))) + local.get 0 + struct.new_default $one + ) + (func (;12;) (type 11) (result (ref (exact $one))) + i32.const 0 + ref.null none + struct.new $one + ) + (func (;13;) (type 11) (result (ref (exact $one))) + ref.null none + struct.new_default $one + ) + (func (;14;) (type 11) (result (ref (exact $one))) + i32.const 0 + unreachable + struct.new $one + ) + (func (;15;) (type 11) (result (ref (exact $one))) + unreachable + struct.new_default $one + ) + (func (;16;) (type 12) (param (ref null (exact $pair.desc))) (result (ref (exact $pair))) + i32.const 1 + i64.const 2 + local.get 0 + struct.new $pair + ) + (func (;17;) (type 12) (param (ref null (exact $pair.desc))) (result (ref (exact $pair))) + local.get 0 + struct.new_default $pair + ) + (func (;18;) (type 13) (param (ref (exact $pair.desc))) (result (ref (exact $pair))) + i32.const 1 + i64.const 2 + local.get 0 + struct.new $pair + ) + (func (;19;) (type 13) (param (ref (exact $pair.desc))) (result (ref (exact $pair))) + local.get 0 + struct.new_default $pair + ) + (func (;20;) (type 14) (result (ref (exact $pair))) + i32.const 1 + i64.const 2 + ref.null none + struct.new $pair + ) + (func (;21;) (type 14) (result (ref (exact $pair))) + ref.null none + struct.new_default $pair + ) + (func (;22;) (type 14) (result (ref (exact $pair))) + i32.const 1 + i64.const 2 + unreachable + struct.new $pair + ) + (func (;23;) (type 14) (result (ref (exact $pair))) + unreachable + struct.new_default $pair + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/1.print b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/1.print new file mode 100644 index 0000000000..60f5199c61 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/1.print @@ -0,0 +1,19 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (descriptor $c) (struct)) + (type $c (;2;) (describes $b) (descriptor $d) (struct)) + (type $d (;3;) (describes $c) (struct)) + ) + (type (;4;) (func (result (ref (exact $a))))) + (global $d (;0;) (ref (exact $d)) struct.new $d) + (global $c (;1;) (ref (exact $c)) global.get $d struct.new $c) + (global $b (;2;) (ref (exact $b)) global.get $c struct.new $b) + (global $a (;3;) (ref (exact $a)) global.get $b struct.new $a) + (func (;0;) (type 4) (result (ref (exact $a))) + struct.new $d + struct.new $c + struct.new $b + struct.new $a + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/11.print b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/11.print new file mode 100644 index 0000000000..f2dfd7c4f6 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/11.print @@ -0,0 +1,92 @@ +(module + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (rec + (type $pair (;2;) (descriptor $pair.desc) (struct (field i32) (field i64))) + (type $pair.desc (;3;) (describes $pair) (struct (field f32))) + ) + (rec + (type $one (;4;) (descriptor $two) (struct)) + (type $two (;5;) (describes $one) (descriptor $three) (struct)) + (type $three (;6;) (describes $two) (struct)) + ) + (type (;7;) (func (result (ref (exact $a))))) + (type (;8;) (func (result (ref null (exact $b))))) + (type (;9;) (func (result (ref (exact $pair))))) + (type (;10;) (func (result (ref (exact $one))))) + (global $b (;0;) (ref null (exact $b)) struct.new $b) + (global $a (;1;) (ref (exact $a)) global.get $b struct.new $a) + (global $null-b (;2;) (ref null (exact $b)) ref.null none) + (export "b" (global $b)) + (export "a" (global $a)) + (export "new-new" (func 0)) + (export "new-global" (func 1)) + (export "new-call" (func 2)) + (export "new-pair" (func 4)) + (export "new-chain" (func 5)) + (export "new-null" (func 6)) + (export "new-null-global" (func 7)) + (export "new-null-call" (func 8)) + (export "new-null-pair" (func 10)) + (export "new-null-chain-1" (func 11)) + (export "new-null-chain-2" (func 12)) + (func (;0;) (type 7) (result (ref (exact $a))) + struct.new $b + struct.new $a + ) + (func (;1;) (type 7) (result (ref (exact $a))) + global.get $b + struct.new $a + ) + (func (;2;) (type 7) (result (ref (exact $a))) + call $new-b + struct.new $a + ) + (func $new-b (;3;) (type 8) (result (ref null (exact $b))) + struct.new $b + ) + (func (;4;) (type 9) (result (ref (exact $pair))) + i32.const 0 + i64.const 1 + f32.const 0x1p+1 (;=2;) + struct.new $pair.desc + struct.new $pair + ) + (func (;5;) (type 10) (result (ref (exact $one))) + struct.new $three + struct.new $two + struct.new $one + ) + (func (;6;) (type 7) (result (ref (exact $a))) + ref.null none + struct.new $a + ) + (func (;7;) (type 7) (result (ref (exact $a))) + global.get $null-b + struct.new $a + ) + (func (;8;) (type 7) (result (ref (exact $a))) + call $null + struct.new $a + ) + (func $null (;9;) (type 8) (result (ref null (exact $b))) + ref.null none + ) + (func (;10;) (type 9) (result (ref (exact $pair))) + i32.const 0 + i64.const 1 + ref.null (exact $pair.desc) + struct.new $pair + ) + (func (;11;) (type 10) (result (ref (exact $one))) + ref.null (exact $two) + struct.new $one + ) + (func (;12;) (type 10) (result (ref (exact $one))) + ref.null (exact $three) + struct.new $two + struct.new $one + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/27.print b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/27.print new file mode 100644 index 0000000000..25b801c952 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/27.print @@ -0,0 +1,19 @@ +(module $A + (rec + (type $a (;0;) (descriptor $b) (struct)) + (type $b (;1;) (describes $a) (struct)) + ) + (type (;2;) (func (result (ref null (exact $b))))) + (global (;0;) (ref null (exact $b)) struct.new $b) + (global (;1;) (ref null (exact $b)) ref.null none) + (export "b" (global 0)) + (export "null-b" (global 1)) + (export "new-b" (func 0)) + (export "new-null-b" (func 1)) + (func (;0;) (type 2) (result (ref null (exact $b))) + struct.new $b + ) + (func (;1;) (type 2) (result (ref null (exact $b))) + ref.null none + ) +) diff --git a/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/29.print b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/29.print new file mode 100644 index 0000000000..56f9814d50 --- /dev/null +++ b/tests/snapshots/testsuite/proposals/custom-descriptors/struct_new_desc.wast/29.print @@ -0,0 +1,35 @@ +(module $B + (type $other (;0;) (func)) + (rec + (type $a (;1;) (descriptor $b) (struct)) + (type $b (;2;) (describes $a) (struct)) + ) + (type (;3;) (func (result (ref null (exact $b))))) + (type (;4;) (func (result (ref (exact $a))))) + (import "A" "b" (global $b (;0;) (ref null (exact $b)))) + (import "A" "null-b" (global $null-b (;1;) (ref null (exact $b)))) + (import "A" "new-b" (func $new-b (;0;) (type 3))) + (import "A" "new-null-b" (func $new-null-b (;1;) (type 3))) + (global (;2;) (ref (exact $a)) global.get $b struct.new $a) + (export "a" (global 2)) + (export "new-global" (func 2)) + (export "new-call" (func 3)) + (export "null-global" (func 4)) + (export "null-call" (func 5)) + (func (;2;) (type 4) (result (ref (exact $a))) + global.get $b + struct.new $a + ) + (func (;3;) (type 4) (result (ref (exact $a))) + call $new-b + struct.new $a + ) + (func (;4;) (type 4) (result (ref (exact $a))) + global.get $null-b + struct.new $a + ) + (func (;5;) (type 4) (result (ref (exact $a))) + call $new-null-b + struct.new $a + ) +) diff --git a/tests/snapshots/testsuite/struct.wast.json b/tests/snapshots/testsuite/struct.wast.json index ac83e37b5c..678dea1b33 100644 --- a/tests/snapshots/testsuite/struct.wast.json +++ b/tests/snapshots/testsuite/struct.wast.json @@ -172,7 +172,7 @@ "line": 133, "filename": "struct.8.wasm", "module_type": "binary", - "text": "field is immutable" + "text": "immutable field" }, { "type": "module", diff --git a/tests/snapshots/testsuite/tag.wast.json b/tests/snapshots/testsuite/tag.wast.json index 495310470e..4be7d999d9 100644 --- a/tests/snapshots/testsuite/tag.wast.json +++ b/tests/snapshots/testsuite/tag.wast.json @@ -54,14 +54,14 @@ "line": 49, "filename": "tag.6.wasm", "module_type": "binary", - "text": "incompatible import" + "text": "incompatible import type" }, { "type": "assert_unlinkable", "line": 60, "filename": "tag.7.wasm", "module_type": "binary", - "text": "incompatible import" + "text": "incompatible import type" } ] } \ No newline at end of file diff --git a/tests/snapshots/testsuite/type-subtyping.wast.json b/tests/snapshots/testsuite/type-subtyping.wast.json index c42252a736..bbbbde6019 100644 --- a/tests/snapshots/testsuite/type-subtyping.wast.json +++ b/tests/snapshots/testsuite/type-subtyping.wast.json @@ -130,7 +130,7 @@ "field": "fail1", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -140,7 +140,7 @@ "field": "fail2", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -150,7 +150,7 @@ "field": "fail3", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -160,7 +160,7 @@ "field": "fail4", "args": [] }, - "text": "cast" + "text": "cast failure" }, { "type": "assert_trap", @@ -170,7 +170,7 @@ "field": "fail5", "args": [] }, - "text": "cast" + "text": "cast failure" }, { "type": "assert_trap", @@ -180,7 +180,7 @@ "field": "fail6", "args": [] }, - "text": "cast" + "text": "cast failure" }, { "type": "module", @@ -196,7 +196,7 @@ "field": "fail1", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -206,7 +206,7 @@ "field": "fail2", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -216,7 +216,7 @@ "field": "fail3", "args": [] }, - "text": "cast" + "text": "cast failure" }, { "type": "assert_trap", @@ -226,7 +226,7 @@ "field": "fail4", "args": [] }, - "text": "cast" + "text": "cast failure" }, { "type": "module", @@ -252,7 +252,7 @@ "field": "fail1", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "assert_trap", @@ -262,7 +262,7 @@ "field": "fail2", "args": [] }, - "text": "indirect call" + "text": "indirect call type mismatch" }, { "type": "module", @@ -610,7 +610,7 @@ "line": 606, "filename": "type-subtyping.42.wasm", "module_type": "binary", - "text": "incompatible import" + "text": "incompatible import type" }, { "type": "module", @@ -696,7 +696,7 @@ "line": 699, "filename": "type-subtyping.52.wasm", "module_type": "binary", - "text": "incompatible import" + "text": "incompatible import type" }, { "type": "module", @@ -714,7 +714,7 @@ "line": 714, "filename": "type-subtyping.54.wasm", "module_type": "binary", - "text": "incompatible import" + "text": "incompatible import type" }, { "type": "assert_invalid", @@ -805,56 +805,56 @@ "line": 828, "filename": "type-subtyping.67.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 836, "filename": "type-subtyping.68.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 844, "filename": "type-subtyping.69.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 852, "filename": "type-subtyping.70.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 860, "filename": "type-subtyping.71.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 868, "filename": "type-subtyping.72.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 876, "filename": "type-subtyping.73.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", "line": 884, "filename": "type-subtyping.74.wasm", "module_type": "binary", - "text": "sub type 1 does not match super type" + "text": "sub type" }, { "type": "assert_invalid", diff --git a/tests/testsuite b/tests/testsuite index 7b59001394..637a6bcc87 160000 --- a/tests/testsuite +++ b/tests/testsuite @@ -1 +1 @@ -Subproject commit 7b59001394c1d9c073ffa3c419df0bd52474bc6d +Subproject commit 637a6bcc87baf238e160f4a98bf7a5ec00e7864c