Skip to content

Fix ExpressionRunner issues found by the fuzzer #2790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 23, 2020
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: 1 addition & 1 deletion src/passes/Precompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PrecomputingExpressionRunner
if (iter != getValues.end()) {
auto values = iter->second;
if (values.isConcrete()) {
return Flow(std::move(values));
return Flow(values);
}
}
return ExpressionRunner<PrecomputingExpressionRunner>::visitLocalGet(curr);
Expand Down
33 changes: 17 additions & 16 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
// Check if a constant value has been set in the context of this runner.
auto iter = localValues.find(curr->index);
if (iter != localValues.end()) {
return Flow(std::move(iter->second));
return Flow(iter->second);
}
return Flow(NONCONSTANT_FLOW);
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
// Check if a constant value has been set in the context of this runner.
auto iter = globalValues.find(curr->name);
if (iter != globalValues.end()) {
return Flow(std::move(iter->second));
return Flow(iter->second);
}
return Flow(NONCONSTANT_FLOW);
}
Expand Down Expand Up @@ -1327,13 +1327,13 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
auto argFlow = visit(curr->operands[i]);
if (!argFlow.breaking()) {
assert(argFlow.values.isConcrete());
localValues[i] = std::move(argFlow.values);
localValues[i] = argFlow.values;
}
}
auto retFlow = visit(func->body);
localValues = std::move(prevLocalValues);
localValues = prevLocalValues;
if (retFlow.breakTo == RETURN_FLOW) {
return Flow(std::move(retFlow.values));
return Flow(retFlow.values);
} else if (!retFlow.breaking()) {
return retFlow;
}
Expand All @@ -1343,7 +1343,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
return Flow(NONCONSTANT_FLOW);
}

Flow visitCallIndirect(CallIndirect*) {
Flow visitCallIndirect(CallIndirect* curr) {
NOTE_ENTER("CallIndirect");
return Flow(NONCONSTANT_FLOW);
}
Expand Down Expand Up @@ -1375,39 +1375,39 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
NOTE_ENTER("MemoryFill");
return Flow(NONCONSTANT_FLOW);
}
Flow visitAtomicRMW(AtomicRMW*) {
Flow visitAtomicRMW(AtomicRMW* curr) {
NOTE_ENTER("AtomicRMW");
return Flow(NONCONSTANT_FLOW);
}
Flow visitAtomicCmpxchg(AtomicCmpxchg*) {
Flow visitAtomicCmpxchg(AtomicCmpxchg* curr) {
NOTE_ENTER("AtomicCmpxchg");
return Flow(NONCONSTANT_FLOW);
}
Flow visitAtomicWait(AtomicWait*) {
Flow visitAtomicWait(AtomicWait* curr) {
NOTE_ENTER("AtomicWait");
return Flow(NONCONSTANT_FLOW);
}
Flow visitAtomicNotify(AtomicNotify*) {
Flow visitAtomicNotify(AtomicNotify* curr) {
NOTE_ENTER("AtomicNotify");
return Flow(NONCONSTANT_FLOW);
}
Flow visitSIMDLoad(SIMDLoad*) {
Flow visitSIMDLoad(SIMDLoad* curr) {
NOTE_ENTER("SIMDLoad");
return Flow(NONCONSTANT_FLOW);
}
Flow visitSIMDLoadSplat(SIMDLoad*) {
Flow visitSIMDLoadSplat(SIMDLoad* curr) {
NOTE_ENTER("SIMDLoadSplat");
return Flow(NONCONSTANT_FLOW);
}
Flow visitSIMDLoadExtend(SIMDLoad*) {
Flow visitSIMDLoadExtend(SIMDLoad* curr) {
NOTE_ENTER("SIMDLoadExtend");
return Flow(NONCONSTANT_FLOW);
}
Flow visitPush(Push*) {
Flow visitPush(Push* curr) {
NOTE_ENTER("Push");
return Flow(NONCONSTANT_FLOW);
}
Flow visitPop(Pop*) {
Flow visitPop(Pop* curr) {
NOTE_ENTER("Pop");
return Flow(NONCONSTANT_FLOW);
}
Expand Down Expand Up @@ -2470,7 +2470,8 @@ template<typename GlobalManager, typename SubType> class ModuleInstanceBase {
functionStack.pop_back();
}
#ifdef WASM_INTERPRETER_DEBUG
std::cout << "exiting " << function->name << " with " << ret << '\n';
std::cout << "exiting " << function->name << " with " << flow.values
<< '\n';
#endif
return flow.values;
}
Expand Down
4 changes: 4 additions & 0 deletions src/wasm-printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ inline std::ostream& operator<<(std::ostream& o, wasm::Expression& expression) {
return wasm::WasmPrinter::printExpression(&expression, o);
}

inline std::ostream& operator<<(std::ostream& o, wasm::Expression* expression) {
return wasm::WasmPrinter::printExpression(expression, o);
}

inline std::ostream& operator<<(std::ostream& o, wasm::StackInst& inst) {
return wasm::WasmPrinter::printStackInst(&inst, o);
}
Expand Down