diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/literal.cpp | 10 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 3 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 8 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 2 |
5 files changed, 25 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 3d7303e23..48b58c3ca 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -137,6 +137,7 @@ void Literal::getBits(uint8_t (&buf)[16]) const { case Type::v128: memcpy(buf, &v128, sizeof(v128)); break; + case Type::except_ref: // except_ref type is opaque case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -271,6 +272,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { o << "i32x4 "; literal.printVec128(o, literal.getv128()); break; + case Type::except_ref: // except_ref type is opaque case Type::unreachable: WASM_UNREACHABLE(); } @@ -473,6 +475,7 @@ Literal Literal::eqz() const { case Type::f64: return eq(Literal(double(0))); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -491,6 +494,7 @@ Literal Literal::neg() const { case Type::f64: return Literal(int64_t(i64 ^ 0x8000000000000000ULL)).castToF64(); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -509,6 +513,7 @@ Literal Literal::abs() const { case Type::f64: return Literal(int64_t(i64 & 0x7fffffffffffffffULL)).castToF64(); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -610,6 +615,7 @@ Literal Literal::add(const Literal& other) const { case Type::f64: return Literal(getf64() + other.getf64()); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -628,6 +634,7 @@ Literal Literal::sub(const Literal& other) const { case Type::f64: return Literal(getf64() - other.getf64()); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -717,6 +724,7 @@ Literal Literal::mul(const Literal& other) const { case Type::f64: return Literal(getf64() * other.getf64()); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -934,6 +942,7 @@ Literal Literal::eq(const Literal& other) const { case Type::f64: return Literal(getf64() == other.getf64()); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -952,6 +961,7 @@ Literal Literal::ne(const Literal& other) const { case Type::f64: return Literal(getf64() != other.getf64()); case Type::v128: + case Type::except_ref: case Type::none: case Type::unreachable: WASM_UNREACHABLE(); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index a29665a15..484bfb49c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1056,6 +1056,8 @@ Type WasmBinaryBuilder::getType() { return f64; case BinaryConsts::EncodedType::v128: return v128; + case BinaryConsts::EncodedType::except_ref: + return except_ref; default: { throwError("invalid wasm type: " + std::to_string(type)); } } WASM_UNREACHABLE(); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index a869aa08a..4eaf54eff 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -790,6 +790,9 @@ Type SExpressionWasmBuilder::stringToType(const char* str, return v128; } } + if (strncmp(str, "except_ref", 10) == 0 && (prefix || str[10] == 0)) { + return except_ref; + } if (allowError) { return none; } diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 449dff4db..091d851f6 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -36,6 +36,8 @@ const char* printType(Type type) { return "f64"; case Type::v128: return "v128"; + case Type::except_ref: + return "except_ref"; case Type::unreachable: return "unreachable"; } @@ -54,6 +56,7 @@ unsigned getTypeSize(Type type) { return 8; case Type::v128: return 16; + case Type::except_ref: // except_ref type is opaque case Type::none: case Type::unreachable: WASM_UNREACHABLE(); @@ -110,4 +113,9 @@ bool isFloatType(Type type) { bool isVectorType(Type type) { return type == v128; } +bool isReferenceType(Type type) { + // TODO Add other reference types later + return type == except_ref; +} + } // namespace wasm diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index b84105c8d..7467f1f15 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -1053,6 +1053,7 @@ void FunctionValidator::validateMemBytes(uint8_t bytes, shouldBeEqual( bytes, uint8_t(16), curr, "expected v128 operation to touch 16 bytes"); break; + case except_ref: // except_ref cannot be stored in memory case none: WASM_UNREACHABLE(); case unreachable: @@ -1616,6 +1617,7 @@ void FunctionValidator::validateAlignment( case v128: case unreachable: break; + case except_ref: // except_ref cannot be stored in memory case none: WASM_UNREACHABLE(); } |