Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/parser/parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3091,34 +3091,30 @@ template<typename Ctx> Result<> comptype(Ctx& ctx) {
return ctx.in.err("expected type description");
}

// describedcomptype ::= '(' 'descriptor' typeidx ct:comptype ')'
// | ct:comptype
// describedcomptype ::= '(' 'descriptor' typeidx ')' comptype
// | comptype
template<typename Ctx> Result<> describedcomptype(Ctx& ctx) {
if (ctx.in.takeSExprStart("descriptor"sv)) {
auto x = typeidx(ctx);
CHECK_ERR(x);
ctx.setDescriptor(*x);
CHECK_ERR(comptype(ctx));
auto d = typeidx(ctx);
CHECK_ERR(d);
if (!ctx.in.takeRParen()) {
return ctx.in.err("expected end of described type");
return ctx.in.err("expected end of descriptor");
}
return Ok{};
ctx.setDescriptor(*d);
}
return comptype(ctx);
}

// describingcomptype ::= '(' 'describes' typeidx ct:describedcomptype ')'
// | ct: describedcomptype
// describingcomptype ::= '(' 'describes' typeidx ')' describedcomptype
// | describedcomptype
template<typename Ctx> Result<> describingcomptype(Ctx& ctx) {
if (ctx.in.takeSExprStart("describes"sv)) {
auto x = typeidx(ctx);
CHECK_ERR(x);
ctx.setDescribes(*x);
CHECK_ERR(describedcomptype(ctx));
auto d = typeidx(ctx);
CHECK_ERR(d);
if (!ctx.in.takeRParen()) {
return ctx.in.err("expected end of describing type");
return ctx.in.err("expected end of describes");
}
return Ok{};
ctx.setDescribes(*d);
}
return describedcomptype(ctx);
}
Expand Down
10 changes: 2 additions & 8 deletions src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,12 +1823,12 @@ std::ostream& TypePrinter::print(HeapType type) {
if (auto desc = type.getDescribedType()) {
os << "(describes ";
printHeapTypeName(*desc);
os << ' ';
os << ") ";
}
if (auto desc = type.getDescriptorType()) {
os << "(descriptor ";
printHeapTypeName(*desc);
os << ' ';
os << ") ";
}
switch (type.getKind()) {
case HeapTypeKind::Func:
Expand All @@ -1846,12 +1846,6 @@ std::ostream& TypePrinter::print(HeapType type) {
case HeapTypeKind::Basic:
WASM_UNREACHABLE("unexpected kind");
}
if (type.getDescriptorType()) {
os << ')';
}
if (type.getDescribedType()) {
os << ')';
}
if (type.isShared()) {
os << ')';
}
Expand Down
56 changes: 28 additions & 28 deletions test/lit/basic/custom-descriptors.wast
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
(module
(rec
;; CHECK-TEXT: (rec
;; CHECK-TEXT-NEXT: (type $described (descriptor $middle (struct)))
;; CHECK-TEXT-NEXT: (type $described (descriptor $middle) (struct))
;; CHECK-BIN: (rec
;; CHECK-BIN-NEXT: (type $described (descriptor $middle (struct)))
(type $described (descriptor $middle (struct)))
;; CHECK-TEXT: (type $middle (describes $described (descriptor $describing (struct))))
;; CHECK-BIN: (type $middle (describes $described (descriptor $describing (struct))))
(type $middle (describes $described (descriptor $describing (struct))))
;; CHECK-TEXT: (type $describing (describes $middle (struct)))
;; CHECK-BIN: (type $describing (describes $middle (struct)))
(type $describing (describes $middle (struct)))
;; CHECK-BIN-NEXT: (type $described (descriptor $middle) (struct))
(type $described (descriptor $middle) (struct))
;; CHECK-TEXT: (type $middle (describes $described) (descriptor $describing) (struct))
;; CHECK-BIN: (type $middle (describes $described) (descriptor $describing) (struct))
(type $middle (describes $described) (descriptor $describing) (struct))
;; CHECK-TEXT: (type $describing (describes $middle) (struct))
;; CHECK-BIN: (type $describing (describes $middle) (struct))
(type $describing (describes $middle) (struct))
)

(rec
;; CHECK-TEXT: (type $3 (func (param anyref) (result anyref)))

;; CHECK-TEXT: (rec
;; CHECK-TEXT-NEXT: (type $pair (descriptor $pair.desc (struct (field i32) (field i64))))
;; CHECK-TEXT-NEXT: (type $pair (descriptor $pair.desc) (struct (field i32) (field i64)))
;; CHECK-BIN: (type $3 (func (param anyref) (result anyref)))

;; CHECK-BIN: (rec
;; CHECK-BIN-NEXT: (type $pair (descriptor $pair.desc (struct (field i32) (field i64))))
(type $pair (descriptor $pair.desc (struct (field i32 i64))))
;; CHECK-TEXT: (type $pair.desc (describes $pair (struct)))
;; CHECK-BIN: (type $pair.desc (describes $pair (struct)))
(type $pair.desc (describes $pair (struct)))
;; CHECK-BIN-NEXT: (type $pair (descriptor $pair.desc) (struct (field i32) (field i64)))
(type $pair (descriptor $pair.desc) (struct (field i32 i64)))
;; CHECK-TEXT: (type $pair.desc (describes $pair) (struct))
;; CHECK-BIN: (type $pair.desc (describes $pair) (struct))
(type $pair.desc (describes $pair) (struct))
)

(rec
Expand All @@ -58,7 +58,7 @@
;; CHECK-TEXT: (type $13 (func (result (ref (exact $pair)))))

;; CHECK-TEXT: (rec
;; CHECK-TEXT-NEXT: (type $shared-described (shared (descriptor $shared-describing (struct))))
;; CHECK-TEXT-NEXT: (type $shared-described (shared (descriptor $shared-describing) (struct)))
;; CHECK-BIN: (type $6 (func))

;; CHECK-BIN: (type $7 (func (param anyref (ref null $describing))))
Expand All @@ -76,11 +76,11 @@
;; CHECK-BIN: (type $13 (func (result (ref (exact $pair)))))

;; CHECK-BIN: (rec
;; CHECK-BIN-NEXT: (type $shared-described (shared (descriptor $shared-describing (struct))))
(type $shared-described (shared (descriptor $shared-describing (struct))))
;; CHECK-TEXT: (type $shared-describing (shared (describes $shared-described (struct))))
;; CHECK-BIN: (type $shared-describing (shared (describes $shared-described (struct))))
(type $shared-describing (shared (describes $shared-described (struct))))
;; CHECK-BIN-NEXT: (type $shared-described (shared (descriptor $shared-describing) (struct)))
(type $shared-described (shared (descriptor $shared-describing) (struct)))
;; CHECK-TEXT: (type $shared-describing (shared (describes $shared-described) (struct)))
;; CHECK-BIN: (type $shared-describing (shared (describes $shared-described) (struct)))
(type $shared-describing (shared (describes $shared-described) (struct)))
)


Expand Down Expand Up @@ -685,18 +685,18 @@

)
;; CHECK-BIN-NODEBUG: (rec
;; CHECK-BIN-NODEBUG-NEXT: (type $0 (descriptor $1 (struct)))
;; CHECK-BIN-NODEBUG-NEXT: (type $0 (descriptor $1) (struct))

;; CHECK-BIN-NODEBUG: (type $1 (describes $0 (descriptor $2 (struct))))
;; CHECK-BIN-NODEBUG: (type $1 (describes $0) (descriptor $2) (struct))

;; CHECK-BIN-NODEBUG: (type $2 (describes $1 (struct)))
;; CHECK-BIN-NODEBUG: (type $2 (describes $1) (struct))

;; CHECK-BIN-NODEBUG: (type $3 (func (param anyref) (result anyref)))

;; CHECK-BIN-NODEBUG: (rec
;; CHECK-BIN-NODEBUG-NEXT: (type $4 (descriptor $5 (struct (field i32) (field i64))))
;; CHECK-BIN-NODEBUG-NEXT: (type $4 (descriptor $5) (struct (field i32) (field i64)))

;; CHECK-BIN-NODEBUG: (type $5 (describes $4 (struct)))
;; CHECK-BIN-NODEBUG: (type $5 (describes $4) (struct))

;; CHECK-BIN-NODEBUG: (type $6 (func))

Expand All @@ -715,9 +715,9 @@
;; CHECK-BIN-NODEBUG: (type $13 (func (result (ref (exact $4)))))

;; CHECK-BIN-NODEBUG: (rec
;; CHECK-BIN-NODEBUG-NEXT: (type $14 (shared (descriptor $15 (struct))))
;; CHECK-BIN-NODEBUG-NEXT: (type $14 (shared (descriptor $15) (struct)))

;; CHECK-BIN-NODEBUG: (type $15 (shared (describes $14 (struct))))
;; CHECK-BIN-NODEBUG: (type $15 (shared (describes $14) (struct)))

;; CHECK-BIN-NODEBUG: (type $16 (func (param (ref null $0) (ref null (exact $1)))))

Expand Down
8 changes: 4 additions & 4 deletions test/lit/ctor-eval/gc-desc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
(module
(rec
;; CHECK: (rec
;; CHECK-NEXT: (type $struct (sub (descriptor $desc (struct))))
(type $struct (sub (descriptor $desc (struct))))
;; CHECK: (type $desc (describes $struct (struct)))
(type $desc (describes $struct (struct)))
;; CHECK-NEXT: (type $struct (sub (descriptor $desc) (struct)))
(type $struct (sub (descriptor $desc) (struct)))
;; CHECK: (type $desc (describes $struct) (struct))
(type $desc (describes $struct) (struct))
)
;; CHECK: (type $2 (func))

Expand Down
12 changes: 6 additions & 6 deletions test/lit/fuzz-types.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
;; CHECK-NEXT: (type $4 (sub (array (ref null $9))))
;; CHECK-NEXT: (type $5 (sub final $0 (shared (array i8))))
;; CHECK-NEXT: (type $6 (sub $2 (shared (func (param i64 (ref null (shared eq)) i64) (result (ref $8))))))
;; CHECK-NEXT: (type $7 (sub (shared (descriptor $9 (struct (field (ref null $7)) (field (mut i64)) (field (mut i8)) (field i32) (field (mut i32)))))))
;; CHECK-NEXT: (type $7 (sub (shared (descriptor $9) (struct (field (ref null $7)) (field (mut i64)) (field (mut i8)) (field i32) (field (mut i32))))))
;; CHECK-NEXT: (type $8 (sub $2 (shared (func (param i64 (ref null $0) i64) (result (ref $8))))))
;; CHECK-NEXT: (type $9 (shared (describes $7 (descriptor $12 (struct (field i32) (field (mut (ref $8))) (field f64))))))
;; CHECK-NEXT: (type $9 (shared (describes $7) (descriptor $12) (struct (field i32) (field (mut (ref $8))) (field f64))))
;; CHECK-NEXT: (type $10 (sub (array (mut externref))))
;; CHECK-NEXT: (type $11 (sub $4 (array (ref $9))))
;; CHECK-NEXT: (type $12 (sub (shared (describes $9 (struct (field (mut f64)) (field (mut i32)) (field (mut f64)))))))
;; CHECK-NEXT: (type $12 (sub (shared (describes $9) (struct (field (mut f64)) (field (mut i32)) (field (mut f64))))))
;; CHECK-NEXT: )
;; CHECK-NEXT: (rec
;; CHECK-NEXT: (type $13 (sub (struct (field (mut i16)) (field i64) (field (mut (ref (shared func)))))))
Expand All @@ -42,12 +42,12 @@
;; CHECK-NEXT: (type $4 (sub (array (ref null $9))))
;; CHECK-NEXT: (type $5 (sub final $0 (shared (array i8))))
;; CHECK-NEXT: (type $6 (sub $2 (shared (func (param i64 (ref null (shared eq)) i64) (result (ref $8))))))
;; CHECK-NEXT: (type $7 (sub (shared (descriptor $9 (struct (field (ref null $7)) (field (mut i64)) (field (mut i8)) (field i32) (field (mut i32)))))))
;; CHECK-NEXT: (type $7 (sub (shared (descriptor $9) (struct (field (ref null $7)) (field (mut i64)) (field (mut i8)) (field i32) (field (mut i32))))))
;; CHECK-NEXT: (type $8 (sub $2 (shared (func (param i64 (ref null $0) i64) (result (ref $8))))))
;; CHECK-NEXT: (type $9 (shared (describes $7 (descriptor $12 (struct (field i32) (field (mut (ref $8))) (field f64))))))
;; CHECK-NEXT: (type $9 (shared (describes $7) (descriptor $12) (struct (field i32) (field (mut (ref $8))) (field f64))))
;; CHECK-NEXT: (type $10 (sub (array (mut externref))))
;; CHECK-NEXT: (type $11 (sub $4 (array (ref $9))))
;; CHECK-NEXT: (type $12 (sub (shared (describes $9 (struct (field (mut f64)) (field (mut i32)) (field (mut f64)))))))
;; CHECK-NEXT: (type $12 (sub (shared (describes $9) (struct (field (mut f64)) (field (mut i32)) (field (mut f64))))))
;; CHECK-NEXT: )
;; CHECK-NEXT: (rec
;; CHECK-NEXT: (type $13 (sub (struct (field (mut i16)) (field i64) (field (mut (ref (shared func)))))))
Expand Down
Loading
Loading