Skip to content

Commit 50dc3a6

Browse files
author
Alexander Guryanov
committed
WIP: refactoring
1 parent 3282bfe commit 50dc3a6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/passes/Asyncify.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@
170170
// calls, so that you know when to start an asynchronous operation and
171171
// when to propagate results back.
172172
//
173-
// * asyncify_get_catch_counter(): call this to get the current value of the
174-
// internal "__asyncify_catch_counter" variable (only when assertions
175-
// or ignore mode are enabled).
176-
//
177173
// These four functions are exported so that you can call them from the
178174
// outside. If you want to manage things from inside the wasm, then you
179175
// couldn't have called them before they were created by this pass. To work
@@ -251,8 +247,9 @@
251247
//
252248
// --pass-arg=asyncify-ignore-unwind-from-catch
253249
//
254-
// This enables extra check before unwind, if it called from within catch
255-
// block then it silently ignored (-fwasm-exceptions support)
250+
// This enables additional check to be performed before unwinding. In
251+
// cases where the unwind operation is triggered from the catch block,
252+
// it will be silently ignored (-fwasm-exceptions support)
256253
//
257254
// --pass-arg=asyncify-verbose
258255
//
@@ -1154,15 +1151,17 @@ struct AsyncifyFlow : public Pass {
11541151
} else if (doesCall(curr)) {
11551152
results.push_back(makeCallSupport(curr));
11561153
continue;
1157-
} else if (auto* iTry = curr->dynCast<Try>()) {
1154+
} else if (auto* try_ = curr->dynCast<Try>()) {
11581155
if (item.phase == Work::Scan) {
11591156
work.push_back(Work{curr, Work::Finish});
1160-
work.push_back(Work{iTry->body, Work::Scan});
1157+
work.push_back(Work{try_->body, Work::Scan});
1158+
// catchBodies are ignored because we assume that pause/resume will
1159+
// not happen inside them
11611160
continue;
11621161
}
1163-
iTry->body = results.back();
1162+
try_->body = results.back();
11641163
results.pop_back();
1165-
results.push_back(iTry);
1164+
results.push_back(try_);
11661165
continue;
11671166
}
11681167
// We must handle all control flow above, and all things that can change
@@ -1244,7 +1243,7 @@ struct AsyncifyFlow : public Pass {
12441243
}
12451244
};
12461245

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

@@ -1269,7 +1268,7 @@ struct AsyncifyAddCatchCounters : public Pass {
12691268
makeBinary(SubInt32,
12701269
makeGlobalGet(ASYNCIFY_CATCH_COUNTER, Type::i32),
12711270
makeConst(int32_t(amount))));
1272-
};
1271+
}
12731272
};
12741273
CountersBuilder builder(*module_);
12751274
BranchUtils::BranchTargets branchTargets(func->body);

0 commit comments

Comments
 (0)