diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing.h | 84 |
1 files changed, 49 insertions, 35 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 208bc3983..4150ac725 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -827,7 +827,8 @@ private: // Fix up changes that may have broken validation - types are correct in our // modding, but not necessarily labels. void fixLabels(Function* func) { - struct Fixer : public ControlFlowWalker<Fixer> { + struct Fixer + : public ControlFlowWalker<Fixer, UnifiedExpressionVisitor<Fixer>> { Module& wasm; TranslateToFuzzReader& parent; @@ -837,36 +838,42 @@ private: // Track seen names to find duplication, which is invalid. std::set<Name> seen; - void visitBlock(Block* curr) { - if (curr->name.is()) { - if (seen.count(curr->name)) { - replace(); - } else { - seen.insert(curr->name); - } - } - } + void visitExpression(Expression* curr) { + // Note all scope names, and fix up all uses. - void visitLoop(Loop* curr) { - if (curr->name.is()) { - if (seen.count(curr->name)) { - replace(); - } else { - seen.insert(curr->name); - } - } - } +#define DELEGATE_ID curr->_id - void visitSwitch(Switch* curr) { - for (auto name : curr->targets) { - if (replaceIfInvalid(name)) { - return; - } - } - replaceIfInvalid(curr->default_); - } +#define DELEGATE_START(id) \ + auto* cast = curr->cast<id>(); \ + WASM_UNUSED(cast); + +#define DELEGATE_GET_FIELD(id, name) cast->name - void visitBreak(Break* curr) { replaceIfInvalid(curr->name); } +#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, name) \ + if (cast->name.is()) { \ + if (seen.count(cast->name)) { \ + replace(); \ + } else { \ + seen.insert(cast->name); \ + } \ + } + +#define DELEGATE_FIELD_SCOPE_NAME_USE(id, name) replaceIfInvalid(cast->name); + +#define DELEGATE_FIELD_CHILD(id, name) +#define DELEGATE_FIELD_OPTIONAL_CHILD(id, name) +#define DELEGATE_FIELD_INT(id, name) +#define DELEGATE_FIELD_INT_ARRAY(id, name) +#define DELEGATE_FIELD_LITERAL(id, name) +#define DELEGATE_FIELD_NAME(id, name) +#define DELEGATE_FIELD_NAME_VECTOR(id, name) +#define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, name) +#define DELEGATE_FIELD_SIGNATURE(id, name) +#define DELEGATE_FIELD_TYPE(id, name) +#define DELEGATE_FIELD_ADDRESS(id, name) + +#include "wasm-delegations-fields.h" + } bool replaceIfInvalid(Name target) { if (!hasBreakTarget(target)) { @@ -1098,7 +1105,7 @@ private: &Self::makeSelect) .add(FeatureSet::Multivalue, &Self::makeTupleExtract); } - if (type.isSingle() && !type.isRef()) { + if (type.isSingle() && !type.isRef() && !type.isRtt()) { options.add(FeatureSet::MVP, {&Self::makeLoad, Important}); options.add(FeatureSet::SIMD, &Self::makeSIMD); } @@ -2093,6 +2100,15 @@ private: builder.makeUnreachable())); return builder.makeRefFunc(func->name, type); } + if (type.isRtt()) { + Expression* ret = builder.makeRttCanon(type.getHeapType()); + if (type.getRtt().hasDepth()) { + for (Index i = 0; i < type.getRtt().depth; i++) { + ret = builder.makeRttSub(type.getHeapType(), ret); + } + } + return ret; + } if (type.isTuple()) { std::vector<Expression*> operands; for (const auto& t : type) { @@ -2119,11 +2135,10 @@ private: // give up return makeTrivial(type); } - // There's no unary ops for reference types - if (type.isRef()) { + // There are no unary ops for reference or RTT types. + if (type.isRef() || type.isRtt()) { return makeTrivial(type); } - switch (type.getBasic()) { case Type::i32: { auto singleConcreteType = getSingleConcreteType(); @@ -2345,11 +2360,10 @@ private: // give up return makeTrivial(type); } - // There's no binary ops for reference types - if (type.isRef()) { + // There are no binary ops for reference or RTT types. + if (type.isRef() || type.isRtt()) { return makeTrivial(type); } - switch (type.getBasic()) { case Type::i32: { switch (upTo(4)) { |