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
2 changes: 2 additions & 0 deletions src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ struct TypeBuilder {
ForwardChildReference,
// A continuation reference that does not refer to a function type.
InvalidFuncType,
// A shared type with shared-everything disabled.
InvalidSharedType,
// A non-shared field of a shared heap type.
InvalidUnsharedField,
// A describes clause on a non-struct type.
Expand Down
5 changes: 5 additions & 0 deletions src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,8 @@ std::ostream& operator<<(std::ostream& os, TypeBuilder::ErrorReason reason) {
return os << "Heap type has an undeclared child";
case TypeBuilder::ErrorReason::InvalidFuncType:
return os << "Continuation has invalid function type";
case TypeBuilder::ErrorReason::InvalidSharedType:
return os << "Shared types require shared-everything";
case TypeBuilder::ErrorReason::InvalidUnsharedField:
return os << "Heap type has an invalid unshared field";
case TypeBuilder::ErrorReason::NonStructDescribes:
Expand Down Expand Up @@ -2470,6 +2472,9 @@ validateType(HeapTypeInfo& info,
}
}
if (info.share == Shared) {
if (!features.hasSharedEverything()) {
return TypeBuilder::ErrorReason::InvalidSharedType;
}
if (info.described && info.described->share != Shared) {
return TypeBuilder::ErrorReason::InvalidUnsharedDescribes;
}
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/print-explicit-typeuse.wast
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-opt %s --no-validation -S -o - | filecheck %s
;; RUN: wasm-opt %s --enable-shared-everything --no-validation -S -o - | filecheck %s

;; Check that we print explicit type uses for function signatures when the
;; function type uses non-MVP features, whether or not those features are
Expand Down
29 changes: 0 additions & 29 deletions test/lit/passes/gto-jsinterop.wast
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,6 @@
)
)

(module
(rec
;; CHECK: (rec
;; CHECK-NEXT: (type $struct (descriptor $desc) (struct))
(type $struct (descriptor $desc) (struct))
;; Maybe we will support shared prototypes someday.
;; CHECK: (type $desc (describes $struct) (struct (field (ref null (shared extern)))))
(type $desc (describes $struct) (struct (field (ref null (shared extern)))))
)

;; CHECK: (type $2 (func))

;; CHECK: (func $externalize (type $2)
;; CHECK-NEXT: (local $struct (ref null $struct))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (extern.convert_any
;; CHECK-NEXT: (local.get $struct)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $externalize
(local $struct (ref null $struct))
(drop
(extern.convert_any
(local.get $struct)
)
)
)
)

(module
(rec
Expand Down
34 changes: 34 additions & 0 deletions test/lit/passes/gto-shared-jsinterop.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: foreach %s %t wasm-opt -all --closed-world --gto --preserve-type-order -S -o - | filecheck %s

(module
(rec
;; CHECK: (rec
;; CHECK-NEXT: (type $struct (descriptor $desc) (struct))
(type $struct (descriptor $desc) (struct))
;; Maybe we will support shared prototypes someday. The shared externref
;; should not be optimized out.
;; CHECK: (type $desc (describes $struct) (struct (field (ref null (shared extern)))))
(type $desc (describes $struct) (struct (field (ref null (shared extern)))))
)

;; CHECK: (type $2 (func))

;; CHECK: (func $externalize (type $2)
;; CHECK-NEXT: (local $struct (ref null $struct))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (extern.convert_any
;; CHECK-NEXT: (local.get $struct)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $externalize
(local $struct (ref null $struct))
(drop
(extern.convert_any
(local.get $struct)
)
)
)
)
2 changes: 1 addition & 1 deletion test/lit/validation/shared-struct.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; RUN: not wasm-opt %s 2>&1 | filecheck %s --check-prefix NO-SHARED
;; RUN: wasm-opt %s --enable-reference-types --enable-gc --enable-shared-everything -o - -S | filecheck %s --check-prefix SHARED

;; NO-SHARED: global type requires additional features [--enable-reference-types --enable-gc --enable-shared-everything]
;; NO-SHARED: invalid type: Shared types require shared-everything
;; SHARED: (type $t (shared (struct)))

(module
Expand Down
Loading