diff --git a/src/ir/possible-constant.h b/src/ir/possible-constant.h index a75dd76299a..21422a3e880 100644 --- a/src/ir/possible-constant.h +++ b/src/ir/possible-constant.h @@ -120,8 +120,12 @@ struct PossibleConstantValues { value = val.and_(Literal(uint32_t(0xffff))); } break; + case Field::WaitQueue: + WASM_UNREACHABLE("not implemented"); + break; case Field::not_packed: WASM_UNREACHABLE("unexpected packed type"); + break; } } diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 3978afff45d..c865272349b 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -149,6 +149,7 @@ struct NullTypeParserCtx { StorageT makeI8() { return Ok{}; } StorageT makeI16() { return Ok{}; } + StorageT makeWaitQueue() { return Ok{}; } StorageT makeStorageType(TypeT) { return Ok{}; } FieldT makeFieldType(StorageT, Mutability) { return Ok{}; } @@ -308,6 +309,7 @@ template struct TypeParserCtx { StorageT makeI8() { return Field(Field::i8, Immutable); } StorageT makeI16() { return Field(Field::i16, Immutable); } + StorageT makeWaitQueue() { return Field(Field::WaitQueue, Immutable); } StorageT makeStorageType(TypeT type) { return Field(type, Immutable); } FieldT makeFieldType(FieldT field, Mutability mutability) { diff --git a/src/parser/parsers.h b/src/parser/parsers.h index d606563f1c1..2a3a5ec5a4e 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -717,6 +717,10 @@ template Result storagetype(Ctx& ctx) { if (ctx.in.takeKeyword("i16"sv)) { return ctx.makeI16(); } + if (ctx.in.takeKeyword("waitqueue"sv)) { + return ctx.makeWaitQueue(); + } + auto type = valtype(ctx); CHECK_ERR(type); return ctx.makeStorageType(*type); diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 3bd3199b67a..fc37c0662a4 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -369,8 +369,9 @@ enum EncodedType { f64 = -0x4, // 0x7c v128 = -0x5, // 0x7b // packed types - i8 = -0x8, // 0x78 - i16 = -0x9, // 0x77 + i8 = -0x8, // 0x78 + i16 = -0x9, // 0x77 + waitQueue = -0x24, // 0x5c // reference types nullfuncref = -0xd, // 0x73 nullexternref = -0xe, // 0x72 diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 20578e03089..c2dff5ea34b 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -2752,6 +2752,10 @@ class ExpressionRunner : public OverriddenVisitor { memcpy(&i, p, sizeof(i)); return truncateForPacking(Literal(int32_t(i)), field); } + case Field::WaitQueue: { + WASM_UNREACHABLE("waitqueue not implemented"); + break; + } } WASM_UNREACHABLE("unexpected type"); } diff --git a/src/wasm-type.h b/src/wasm-type.h index 2364641a17c..ef892d92d41 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -701,6 +701,7 @@ struct Field { not_packed, i8, i16, + WaitQueue, } packedType; // applicable iff type=i32 Mutability mutable_; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 85768b55fbc..633e6261278 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1996,6 +1996,8 @@ void WasmBinaryWriter::writeField(const Field& field) { o << S32LEB(BinaryConsts::EncodedType::i8); } else if (field.packedType == Field::i16) { o << S32LEB(BinaryConsts::EncodedType::i16); + } else if (field.packedType == Field::WaitQueue) { + o << S32LEB(BinaryConsts::EncodedType::waitQueue); } else { WASM_UNREACHABLE("invalid packed type"); } @@ -2717,6 +2719,10 @@ void WasmBinaryReader::readTypes() { auto mutable_ = readMutability(); return Field(Field::i16, mutable_); } + if (typeCode == BinaryConsts::EncodedType::waitQueue) { + auto mutable_ = readMutability(); + return Field(Field::WaitQueue, mutable_); + } // It's a regular wasm value. auto type = makeType(typeCode); auto mutable_ = readMutability(); diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 83c58593010..a5f585a9277 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1483,6 +1483,9 @@ unsigned Field::getByteSize() const { return 2; case Field::PackedType::not_packed: return 4; + case Field::PackedType::WaitQueue: + WASM_UNREACHABLE("waitqueue not implemented"); + break; } WASM_UNREACHABLE("impossible packed type"); } @@ -1874,6 +1877,8 @@ std::ostream& TypePrinter::print(const Field& field) { os << "i8"; } else if (packedType == Field::PackedType::i16) { os << "i16"; + } else if (packedType == Field::PackedType::WaitQueue) { + os << "waitqueue"; } else { WASM_UNREACHABLE("unexpected packed type"); } diff --git a/test/lit/waitqueue.wast b/test/lit/waitqueue.wast new file mode 100644 index 00000000000..1a3e9726674 --- /dev/null +++ b/test/lit/waitqueue.wast @@ -0,0 +1,9 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s -all --roundtrip -S -o - | filecheck %s --check-prefix=RTRIP +(module + ;; RTRIP: (type $t (struct (field waitqueue))) + (type $t (struct (field waitqueue))) + + ;; use $t so roundtripping doesn't drop the definition + (global (ref null $t) (ref.null $t)) +)