From e35cdb97adf6eb2ade2be7734d1c6c397d440dc1 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Sat, 19 Sep 2020 08:48:06 +0200 Subject: GC: Integrate eqref and i31ref types (#3141) Adds the `eqref` and `i31ref` types to their respective code locations. Implements what can be implemented trivially and otherwise traps with a TODO for now. Integration of `eqref` is mostly complete due to it being nullable, just like `anyref`, but `i31ref` needs to remain disabled in the fuzzer because we are lacking the functionality to create trivial `i31ref` values, i.e. `(i31.new (i32.const 0))`, which is left for follow-ups to implement. --- src/wasm-binary.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/wasm-binary.h') diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 7666fa842..39980ee04 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -346,6 +346,10 @@ enum EncodedType { externref = -0x11, // 0x6f // any reference type anyref = -0x12, // 0x6e + // comparable reference type + eqref = -0x13, // 0x6d + // integer reference type + i31ref = -0x16, // 0x6a // exception reference type exnref = -0x18, // 0x68 // func_type form @@ -358,6 +362,8 @@ enum EncodedHeapType { func = -0x10, // 0x70 extern_ = -0x11, // 0x6f any = -0x12, // 0x6e + eq = -0x13, // 0x6d + i31 = -0x17, // 0x69, != i31ref exn = -0x18, // 0x68 }; @@ -981,6 +987,12 @@ inline S32LEB binaryType(Type type) { case Type::anyref: ret = BinaryConsts::EncodedType::anyref; break; + case Type::eqref: + ret = BinaryConsts::EncodedType::eqref; + break; + case Type::i31ref: + ret = BinaryConsts::EncodedType::i31ref; + break; case Type::unreachable: WASM_UNREACHABLE("unexpected type"); } @@ -1003,11 +1015,15 @@ inline S32LEB binaryHeapType(HeapType type) { ret = BinaryConsts::EncodedHeapType::any; break; case HeapType::EqKind: + ret = BinaryConsts::EncodedHeapType::eq; + break; case HeapType::I31Kind: + ret = BinaryConsts::EncodedHeapType::i31; + break; case HeapType::SignatureKind: case HeapType::StructKind: case HeapType::ArrayKind: - WASM_UNREACHABLE("TODO: GC types"); + WASM_UNREACHABLE("TODO: compound GC types"); } return S32LEB(ret); // TODO: Actually encoded as s33 } -- cgit v1.2.3