diff --git a/scripts/test/fuzzing.py b/scripts/test/fuzzing.py index bc0d206ea76..7f8897835ea 100644 --- a/scripts/test/fuzzing.py +++ b/scripts/test/fuzzing.py @@ -116,6 +116,8 @@ 'vacuum-removable-if-unused.wast', 'vacuum-removable-if-unused-func.wast', 'strip-toolchain-annotations-func.wast', + # Not fully implemented. + 'waitqueue.wast', ] diff --git a/src/ir/possible-constant.h b/src/ir/possible-constant.h index a75dd76299a..95acb6f9bca 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("waitqueue 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 5ab172224e9..3bd58aa3100 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 125040aa2d2..52a6ad9dfeb 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 b7165de5307..f4a164f9802 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 23077d236a9..95aad7ba501 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2008,6 +2008,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"); } @@ -2733,6 +2735,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 4f229ab2b92..71c5a3ed1cb 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1485,6 +1485,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"); } @@ -1876,6 +1879,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)) +)