diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/subtypes.h | 1 | ||||
-rw-r--r-- | src/tools/fuzzing.h | 7 | ||||
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 3 | ||||
-rw-r--r-- | src/wasm-type.h | 5 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 41 |
5 files changed, 47 insertions, 10 deletions
diff --git a/src/ir/subtypes.h b/src/ir/subtypes.h index 7cc633a75..488bb8310 100644 --- a/src/ir/subtypes.h +++ b/src/ir/subtypes.h @@ -122,7 +122,6 @@ struct SubTypes { } // Add the max depths of basic types. - // TODO: update when we get structtype for (auto type : types) { HeapType basic; if (type.isStruct()) { diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index e29a6ddaf..a40a76106 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -25,8 +25,6 @@ high chance for set at start of loop high chance of a tee in that case => loop var */ -// TODO Generate exception handling instructions - #include "ir/branch-utils.h" #include "ir/memory-utils.h" #include "ir/struct-utils.h" @@ -399,8 +397,3 @@ private: }; } // namespace wasm - -// XXX Switch class has a condition?! is it real? should the node type be the -// value type if it exists?! - -// TODO copy an existing function and replace just one node in it diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 2e4d460f7..bdaf71e83 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -765,8 +765,7 @@ void TranslateToFuzzReader::recombine(Function* func) { while (1) { ret.push_back(Type(heapType, nullability)); - // TODO: handle basic supertypes too - auto super = heapType.getDeclaredSuperType(); + auto super = heapType.getSuperType(); if (!super) { break; } diff --git a/src/wasm-type.h b/src/wasm-type.h index bc6b25b34..23ceb9143 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -372,6 +372,11 @@ public: // module) nominal supertype, return it, else an empty optional. std::optional<HeapType> getDeclaredSuperType() const; + // As |getDeclaredSuperType|, but also handles basic types, that is, if the + // super is a basic type, then we return it here. Declared types are returned + // as well, just like |getDeclaredSuperType|. + std::optional<HeapType> getSuperType() const; + // Return the depth of this heap type in the nominal type hierarchy, i.e. the // number of supertypes in its supertype chain. size_t getDepth() const; diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 1b8d7d0f1..68d7f732b 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1219,6 +1219,47 @@ std::optional<HeapType> HeapType::getDeclaredSuperType() const { return {}; } +std::optional<HeapType> HeapType::getSuperType() const { + auto ret = getDeclaredSuperType(); + if (ret) { + return ret; + } + + // There may be a basic supertype. + if (isBasic()) { + switch (getBasic()) { + case ext: + case noext: + case func: + case nofunc: + case any: + case none: + case string: + case stringview_wtf8: + case stringview_wtf16: + case stringview_iter: + return {}; + case eq: + return any; + case i31: + case struct_: + case array: + return eq; + } + } + + auto* info = getHeapTypeInfo(*this); + switch (info->kind) { + case HeapTypeInfo::SignatureKind: + return func; + case HeapTypeInfo::StructKind: + return struct_; + case HeapTypeInfo::ArrayKind: + return array; + } + WASM_UNREACHABLE("unexpected kind"); +} + size_t HeapType::getDepth() const { size_t depth = 0; std::optional<HeapType> super; |