summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-19 08:48:06 +0200
committerGitHub <noreply@github.com>2020-09-19 08:48:06 +0200
commite35cdb97adf6eb2ade2be7734d1c6c397d440dc1 (patch)
tree7a740e6fc54d286a05ca3e746ae1e7f3c4b783a8 /src/wasm-binary.h
parente308db569ab2582d3b0ea9accdbaa3b27abdb044 (diff)
downloadbinaryen-e35cdb97adf6eb2ade2be7734d1c6c397d440dc1.tar.gz
binaryen-e35cdb97adf6eb2ade2be7734d1c6c397d440dc1.tar.bz2
binaryen-e35cdb97adf6eb2ade2be7734d1c6c397d440dc1.zip
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.
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h18
1 files changed, 17 insertions, 1 deletions
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
}