Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/passes/Asyncify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ static const Name START_UNWIND = "start_unwind";
static const Name STOP_UNWIND = "stop_unwind";
static const Name START_REWIND = "start_rewind";
static const Name STOP_REWIND = "stop_rewind";
static const Name GET_STATE = "get_state";
static const Name ASYNCIFY_GET_CALL_INDEX = "__asyncify_get_call_index";
static const Name ASYNCIFY_CHECK_CALL_INDEX = "__asyncify_check_call_index";

Expand Down Expand Up @@ -582,6 +583,8 @@ class ModuleAnalyzer {
renamings[func->name] = ASYNCIFY_START_REWIND;
} else if (func->base == STOP_REWIND) {
renamings[func->name] = ASYNCIFY_STOP_REWIND;
} else if (func->base == GET_STATE) {
renamings[func->name] = ASYNCIFY_GET_STATE;
} else {
Fatal() << "call to unidenfied asyncify import: " << func->base;
}
Expand Down Expand Up @@ -637,6 +640,8 @@ class ModuleAnalyzer {
} else if (target->base == STOP_REWIND) {
info.canChangeState = true;
info.isTopMostRuntime = true;
} else if (target->base == GET_STATE) {
info.canChangeState = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong - it will undo a previous true, forgetting that another call can change the state.

That is, these flags start as false, and should only ever change to true.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense; this branch is necessary though to prevent falling through to the unreachable, so I’ll add a condition to the outer scope.

} else {
WASM_UNREACHABLE("call to unidenfied asyncify import");
}
Expand Down
Loading