summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-04-07 12:25:49 -0700
committerGitHub <noreply@github.com>2023-04-07 12:25:49 -0700
commit642d663d50ee90b19ef4d0c2e92f30585799d8b1 (patch)
treeb4955aec1f1105998f134b5a41e02e2f7b267abc
parente54fdf9dac415bd44268e72a2b836534ad4dc1b6 (diff)
downloadbinaryen-642d663d50ee90b19ef4d0c2e92f30585799d8b1.tar.gz
binaryen-642d663d50ee90b19ef4d0c2e92f30585799d8b1.tar.bz2
binaryen-642d663d50ee90b19ef4d0c2e92f30585799d8b1.zip
[NFC] Use the new getField() in the heap type fuzzer (#5643)
-rw-r--r--src/tools/fuzzing/heap-types.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/tools/fuzzing/heap-types.cpp b/src/tools/fuzzing/heap-types.cpp
index 7fa0cd338..24054572d 100644
--- a/src/tools/fuzzing/heap-types.cpp
+++ b/src/tools/fuzzing/heap-types.cpp
@@ -16,6 +16,7 @@
#include <variant>
+#include "ir/gc-type-utils.h"
#include "ir/subtypes.h"
#include "support/insert_ordered.h"
#include "tools/fuzzing/heap-types.h"
@@ -700,7 +701,7 @@ struct Inhabitator {
Inhabitator(const std::vector<HeapType>& types)
: types(types), subtypes(types) {}
- Variance getVariance(FieldPos field);
+ Variance getVariance(FieldPos fieldPos);
void markNullable(FieldPos field);
void markBottomRefsNullable();
void markExternRefsNullable();
@@ -709,24 +710,16 @@ struct Inhabitator {
std::vector<HeapType> build();
};
-Inhabitator::Variance Inhabitator::getVariance(FieldPos field) {
- auto [type, idx] = field;
+Inhabitator::Variance Inhabitator::getVariance(FieldPos fieldPos) {
+ auto [type, idx] = fieldPos;
assert(!type.isBasic() && !type.isSignature());
- if (type.isStruct()) {
- if (type.getStruct().fields[idx].mutable_ == Mutable) {
- return Invariant;
- } else {
- return Covariant;
- }
- }
- if (type.isArray()) {
- if (type.getArray().element.mutable_ == Mutable) {
- return Invariant;
- } else {
- return Covariant;
- }
+ auto field = GCTypeUtils::getField(type, idx);
+ assert(field);
+ if (field->mutable_ == Mutable) {
+ return Invariant;
+ } else {
+ return Covariant;
}
- WASM_UNREACHABLE("unexpected kind");
}
void Inhabitator::markNullable(FieldPos field) {