From 3f4d3b3eff5d8112a9da3674a5f5eea696ca3c7d Mon Sep 17 00:00:00 2001
From: Alon Zakai <azakai@google.com>
Date: Thu, 21 Jan 2021 22:09:47 +0000
Subject: [GC] Add dataref type (#3500)

This is not 100% of everything, but is enough to get tests passing, which
includes full binary and text format support, getting all switches to compile
without error, and some additions to InstrumentLocals.
---
 src/wasm/wasm-binary.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'src/wasm/wasm-binary.cpp')

diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index eea0a9c21..62c8a6cb3 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1057,6 +1057,9 @@ void WasmBinaryWriter::writeType(Type type) {
     case Type::i31ref:
       ret = BinaryConsts::EncodedType::i31ref;
       break;
+    case Type::dataref:
+      ret = BinaryConsts::EncodedType::dataref;
+      break;
     default:
       WASM_UNREACHABLE("unexpected type");
   }
@@ -1089,6 +1092,9 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
       case HeapType::i31:
         ret = BinaryConsts::EncodedHeapType::i31;
         break;
+      case HeapType::data:
+        ret = BinaryConsts::EncodedHeapType::data;
+        break;
     }
   } else {
     WASM_UNREACHABLE("TODO: compound GC types");
@@ -1415,6 +1421,9 @@ Type WasmBinaryBuilder::getType(int initial) {
     case BinaryConsts::EncodedType::nonnullable:
       // FIXME: for now, force all inputs to be nullable
       return Type(getHeapType(), Nullable);
+    case BinaryConsts::EncodedType::dataref:
+      // FIXME: for now, force all inputs to be nullable
+      return Type(HeapType::BasicHeapType::data, Nullable);
     case BinaryConsts::EncodedType::i31ref:
       // FIXME: for now, force all inputs to be nullable
       return Type(HeapType::BasicHeapType::i31, Nullable);
@@ -1456,6 +1465,8 @@ HeapType WasmBinaryBuilder::getHeapType() {
       return HeapType::eq;
     case BinaryConsts::EncodedHeapType::i31:
       return HeapType::i31;
+    case BinaryConsts::EncodedHeapType::data:
+      return HeapType::data;
     default:
       throwError("invalid wasm heap type: " + std::to_string(type));
   }
-- 
cgit v1.2.3