Skip to content

Commit

Permalink
WIP: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Guryanov committed Jun 22, 2023
1 parent 3282bfe commit 50dc3a6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/passes/Asyncify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@
// calls, so that you know when to start an asynchronous operation and
// when to propagate results back.
//
// * asyncify_get_catch_counter(): call this to get the current value of the
// internal "__asyncify_catch_counter" variable (only when assertions
// or ignore mode are enabled).
//
// These four functions are exported so that you can call them from the
// outside. If you want to manage things from inside the wasm, then you
// couldn't have called them before they were created by this pass. To work
Expand Down Expand Up @@ -251,8 +247,9 @@
//
// --pass-arg=asyncify-ignore-unwind-from-catch
//
// This enables extra check before unwind, if it called from within catch
// block then it silently ignored (-fwasm-exceptions support)
// This enables additional check to be performed before unwinding. In
// cases where the unwind operation is triggered from the catch block,
// it will be silently ignored (-fwasm-exceptions support)
//
// --pass-arg=asyncify-verbose
//
Expand Down Expand Up @@ -1154,15 +1151,17 @@ struct AsyncifyFlow : public Pass {
} else if (doesCall(curr)) {
results.push_back(makeCallSupport(curr));
continue;
} else if (auto* iTry = curr->dynCast<Try>()) {
} else if (auto* try_ = curr->dynCast<Try>()) {
if (item.phase == Work::Scan) {
work.push_back(Work{curr, Work::Finish});
work.push_back(Work{iTry->body, Work::Scan});
work.push_back(Work{try_->body, Work::Scan});
// catchBodies are ignored because we assume that pause/resume will
// not happen inside them
continue;
}
iTry->body = results.back();
try_->body = results.back();
results.pop_back();
results.push_back(iTry);
results.push_back(try_);
continue;
}
// We must handle all control flow above, and all things that can change
Expand Down Expand Up @@ -1244,7 +1243,7 @@ struct AsyncifyFlow : public Pass {
}
};

// Add catch block counters to verify that unwind is not called from catch block
// Add catch block counters to verify that unwind is not called from catch block.
struct AsyncifyAddCatchCounters : public Pass {
bool isFunctionParallel() override { return true; }

Expand All @@ -1269,7 +1268,7 @@ struct AsyncifyAddCatchCounters : public Pass {
makeBinary(SubInt32,
makeGlobalGet(ASYNCIFY_CATCH_COUNTER, Type::i32),
makeConst(int32_t(amount))));
};
}
};
CountersBuilder builder(*module_);
BranchUtils::BranchTargets branchTargets(func->body);
Expand Down

0 comments on commit 50dc3a6

Please sign in to comment.