summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp15
-rw-r--r--src/wasm/wasm-s-parser.cpp10
-rw-r--r--src/wasm/wasm-stack.cpp9
-rw-r--r--src/wasm/wasm.cpp6
4 files changed, 33 insertions, 7 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index b3f085b36..fc14510e9 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -3046,6 +3046,12 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) {
if (maybeVisitArrayLen(curr, opcode)) {
break;
}
+ if (opcode == BinaryConsts::RefIsFunc ||
+ opcode == BinaryConsts::RefIsData ||
+ opcode == BinaryConsts::RefIsI31) {
+ visitRefIs((curr = allocator.alloc<RefIs>())->cast<RefIs>(), opcode);
+ break;
+ }
throwError("invalid code after GC prefix: " + std::to_string(opcode));
break;
}
@@ -5534,6 +5540,15 @@ void WasmBinaryBuilder::visitRefIs(RefIs* curr, uint8_t code) {
case BinaryConsts::RefIsNull:
curr->op = RefIsNull;
break;
+ case BinaryConsts::RefIsFunc:
+ curr->op = RefIsFunc;
+ break;
+ case BinaryConsts::RefIsData:
+ curr->op = RefIsData;
+ break;
+ case BinaryConsts::RefIsI31:
+ curr->op = RefIsI31;
+ break;
default:
WASM_UNREACHABLE("invalid code for ref.is_*");
}
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index b2212db18..b9927cbc7 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -51,7 +51,7 @@ int unhex(char c) {
namespace wasm {
static Name STRUCT("struct"), FIELD("field"), ARRAY("array"), I8("i8"),
- I16("i16"), RTT("rtt"), REF_IS_NULL("ref.is_null");
+ I16("i16"), RTT("rtt");
static Address getAddress(const Element* s) { return atoll(s->c_str()); }
@@ -1922,13 +1922,9 @@ Expression* SExpressionWasmBuilder::makeRefNull(Element& s) {
return ret;
}
-Expression* SExpressionWasmBuilder::makeRefIs(Element& s) {
+Expression* SExpressionWasmBuilder::makeRefIs(Element& s, RefIsOp op) {
auto ret = allocator.alloc<RefIs>();
- if (*s[0] == REF_IS_NULL) {
- ret->op = RefIsNull;
- } else {
- WASM_UNREACHABLE("unimplemented ref.is_*");
- }
+ ret->op = op;
ret->value = parseExpression(s[1]);
ret->finalize();
return ret;
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 7b902ad67..5609dbb0e 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -1869,6 +1869,15 @@ void BinaryInstWriter::visitRefIs(RefIs* curr) {
case RefIsNull:
o << int8_t(BinaryConsts::RefIsNull);
break;
+ case RefIsFunc:
+ o << int8_t(BinaryConsts::GCPrefix) << int8_t(BinaryConsts::RefIsFunc);
+ break;
+ case RefIsData:
+ o << int8_t(BinaryConsts::GCPrefix) << int8_t(BinaryConsts::RefIsData);
+ break;
+ case RefIsI31:
+ o << int8_t(BinaryConsts::GCPrefix) << int8_t(BinaryConsts::RefIsI31);
+ break;
default:
WASM_UNREACHABLE("unimplemented ref.is_*");
}
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index f2f08033e..cd1fb716c 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -192,6 +192,12 @@ const char* getExpressionName(Expression* curr) {
switch (curr->cast<RefIs>()->op) {
case RefIsNull:
return "ref.is_null";
+ case RefIsFunc:
+ return "ref.is_func";
+ case RefIsData:
+ return "ref.is_data";
+ case RefIsI31:
+ return "ref.is_i31";
default:
WASM_UNREACHABLE("unimplemented ref.is_*");
}