summaryrefslogtreecommitdiff
path: root/src/wasm-type.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-08 18:55:20 -0800
committerGitHub <noreply@github.com>2020-12-08 18:55:20 -0800
commit63a042e3a94df7ba3a5c9dde03990a9813fdc366 (patch)
tree50c05727ce20615f4d0c0206e62dcd56c246766f /src/wasm-type.h
parent2a0059dec2fe01dcf1358e0120c32aadd2d765b6 (diff)
downloadbinaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.gz
binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.bz2
binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.zip
[GC] Add basic RTT support (#3432)
This adds rtt.canon and rtt.sub together with RTT type support that is necessary for them. Together this lets us test roundtripping the instructions and types. Also fixes a missing traversal over globals in collectHeapTypes, which the example from the GC docs requires, as the RTTs are in globals there. This does not yet add full interpreter support and other things. It disables initial contents on GC in the fuzzer, to avoid the fuzzer breaking. Renames the binary ID for exnref, which is being removed from the spec, and which overlaps with the binary ID for rtt.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r--src/wasm-type.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h
index 0e159b3a9..f600f2e79 100644
--- a/src/wasm-type.h
+++ b/src/wasm-type.h
@@ -177,6 +177,8 @@ public:
// Gets the heap type corresponding to this type
HeapType getHeapType() const;
+ const struct Rtt& getRtt() const;
+
// Returns a number type based on its size in bytes and whether it is a float
// type.
static Type get(unsigned byteSize, bool float_);
@@ -430,14 +432,20 @@ struct Array {
};
struct Rtt {
+ enum {
+ // An Rtt can have no depth specified
+ NoDepth = -1
+ };
uint32_t depth;
HeapType heapType;
+ Rtt(HeapType heapType) : depth(NoDepth), heapType(heapType) {}
Rtt(uint32_t depth, HeapType heapType) : depth(depth), heapType(heapType) {}
bool operator==(const Rtt& other) const {
return depth == other.depth && heapType == other.heapType;
}
bool operator!=(const Rtt& other) const { return !(*this == other); }
bool operator<(const Rtt& other) const;
+ bool hasDepth() { return depth != uint32_t(NoDepth); }
std::string toString() const;
};