diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-19 08:48:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 08:48:06 +0200 |
commit | e35cdb97adf6eb2ade2be7734d1c6c397d440dc1 (patch) | |
tree | 7a740e6fc54d286a05ca3e746ae1e7f3c4b783a8 /src/wasm/literal.cpp | |
parent | e308db569ab2582d3b0ea9accdbaa3b27abdb044 (diff) | |
download | binaryen-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/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 39a4cea3c..4a89b5cd1 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -70,7 +70,10 @@ Literal::Literal(const Literal& other) : type(other.type) { break; case Type::externref: case Type::anyref: + case Type::eqref: break; // null + case Type::i31ref: + WASM_UNREACHABLE("TODO: i31ref"); case Type::funcref: case Type::exnref: case Type::unreachable: @@ -223,10 +226,11 @@ void Literal::getBits(uint8_t (&buf)[16]) const { case Type::externref: case Type::exnref: case Type::anyref: - if (isNull()) { - break; - } - // falls through + case Type::eqref: + assert(isNull() && "unexpected non-null reference type literal"); + break; + case Type::i31ref: + WASM_UNREACHABLE("TODO: i31ref"); case Type::none: case Type::unreachable: WASM_UNREACHABLE("invalid type"); @@ -379,6 +383,10 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { o << "funcref(" << literal.getFunc() << ")"; } break; + case Type::externref: + assert(literal.isNull() && "unexpected non-null externref literal"); + o << "externref(null)"; + break; case Type::exnref: if (literal.isNull()) { o << "exnref(null)"; @@ -387,13 +395,15 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { } break; case Type::anyref: - assert(literal.isNull() && "TODO: non-null anyref values"); + assert(literal.isNull() && "unexpected non-null anyref literal"); o << "anyref(null)"; break; - case Type::externref: - assert(literal.isNull() && "TODO: non-null externref values"); - o << "externref(null)"; + case Type::eqref: + assert(literal.isNull() && "unexpected non-null eqref literal"); + o << "eqref(null)"; break; + case Type::i31ref: + WASM_UNREACHABLE("TODO: i31ref"); case Type::unreachable: WASM_UNREACHABLE("invalid type"); } @@ -619,6 +629,8 @@ Literal Literal::eqz() const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -641,6 +653,8 @@ Literal Literal::neg() const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -663,6 +677,8 @@ Literal Literal::abs() const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -768,6 +784,8 @@ Literal Literal::add(const Literal& other) const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -790,6 +808,8 @@ Literal Literal::sub(const Literal& other) const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -908,6 +928,8 @@ Literal Literal::mul(const Literal& other) const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1154,6 +1176,8 @@ Literal Literal::eq(const Literal& other) const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); @@ -1176,6 +1200,8 @@ Literal Literal::ne(const Literal& other) const { case Type::externref: case Type::exnref: case Type::anyref: + case Type::eqref: + case Type::i31ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE("unexpected type"); |