diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-09 03:40:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 03:40:09 +0200 |
commit | 916ce6f1a9f7c85102a8c69f593b301c8df5d19d (patch) | |
tree | 93b22be9f2c0718248528d140b05221cb6878600 /src/wasm/wasm-binary.cpp | |
parent | 0fdcf5b51a0c8c379b2d3ad8262aa22bb234f0e9 (diff) | |
download | binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.gz binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.bz2 binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.zip |
Update reference types (#3084)
Align with the current state of the reference types proposal:
* Remove `nullref`
* Remove `externref` and `funcref` subtyping
* A `Literal` of a nullable reference type can now represent `null` (previously was type `nullref`)
* Update the tests and temporarily comment out those tests relying on subtyping
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index ae10687fb..b78d6b86b 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1136,8 +1136,6 @@ Type WasmBinaryBuilder::getType() { return Type::funcref; case BinaryConsts::EncodedType::externref: return Type::externref; - case BinaryConsts::EncodedType::nullref: - return Type::nullref; case BinaryConsts::EncodedType::exnref: return Type::exnref; default: @@ -1146,6 +1144,28 @@ Type WasmBinaryBuilder::getType() { WASM_UNREACHABLE("unexpeced type"); } +HeapType WasmBinaryBuilder::getHeapType() { + int type = getS32LEB(); // TODO: Actually encoded as s33 + // Single heap types are negative; heap type indices are non-negative + if (type >= 0) { + if (size_t(type) >= signatures.size()) { + throwError("invalid signature index: " + std::to_string(type)); + } + return HeapType(signatures[type]); + } + switch (type) { + case BinaryConsts::EncodedHeapType::func: + return HeapType::FuncKind; + case BinaryConsts::EncodedHeapType::extern_: + return HeapType::ExternKind; + case BinaryConsts::EncodedHeapType::exn: + return HeapType::ExnKind; + default: + throwError("invalid wasm heap type: " + std::to_string(type)); + } + WASM_UNREACHABLE("unexpeced type"); +} + Type WasmBinaryBuilder::getConcreteType() { auto type = getType(); if (!type.isConcrete()) { @@ -4689,7 +4709,7 @@ void WasmBinaryBuilder::visitDrop(Drop* curr) { void WasmBinaryBuilder::visitRefNull(RefNull* curr) { BYN_TRACE("zz node: RefNull\n"); - curr->finalize(); + curr->finalize(getHeapType()); } void WasmBinaryBuilder::visitRefIsNull(RefIsNull* curr) { |