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 @@ -928,6 +928,8 @@ struct TypeBuilder {
InvalidSharedType,
// A string type with strings disabled.
InvalidStringType,
// A SIMD type with SIMD disabled.
InvalidSIMDType,
// 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 @@ -1468,6 +1468,8 @@ std::ostream& operator<<(std::ostream& os,
return os << "Shared types require shared-everything";
case TypeBuilder::ErrorReasonKind::InvalidStringType:
return os << "String types require strings feature";
case TypeBuilder::ErrorReasonKind::InvalidSIMDType:
return os << "SIMD types require SIMD feature";
case TypeBuilder::ErrorReasonKind::InvalidUnsharedField:
return os << "Heap type has an invalid unshared field";
case TypeBuilder::ErrorReasonKind::NonStructDescribes:
Expand Down Expand Up @@ -2387,6 +2389,9 @@ bool isValidSupertype(const HeapTypeInfo& sub, const HeapTypeInfo& super) {

std::optional<TypeBuilder::ErrorReason>
validateType(Type type, FeatureSet feats, bool isShared) {
if (type == Type::v128 && !feats.hasSIMD()) {
return TypeBuilder::ErrorReasonKind::InvalidSIMDType;
}
if (type.isRef()) {
auto heapType = type.getHeapType();
if (isShared && !heapType.isShared()) {
Expand Down
2 changes: 1 addition & 1 deletion test/lit/validation/ref-func-simd.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; A function type that uses a SIMD type requires the SIMD feature.
;; RUN: not wasm-opt --enable-reference-types %s 2>&1 | filecheck %s

;; CHECK: all used types should be allowed
;; CHECK: invalid type: SIMD types require SIMD feature

(module
(type $simd-user (func (param v128)))
Expand Down
2 changes: 1 addition & 1 deletion test/lit/validation/ref-gc-simd.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; A gc type that uses a SIMD type requires the SIMD feature.
;; RUN: not wasm-opt --enable-reference-types --enable-gc %s 2>&1 | filecheck %s

;; CHECK: all used types should be allowed
;; CHECK: invalid type: SIMD types require SIMD feature

(module
(type $simd-user (struct (field v128)))
Expand Down
Loading