Simplify stack unwinding logic

This commit is contained in:
RunasSudo 2021-07-28 16:03:34 +10:00
parent 49feb09bf8
commit 470f1e550e
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 1 additions and 4 deletions

View File

@ -84,7 +84,7 @@ function resumeCount() {
for (;; stageNum++) {
let isDone = wasm['count_one_stage_' + numbers](state, opts);
if (unwindingStack) {
if (wasmRaw.asyncify_get_state() !== 0) {
// This stage caused a stack unwind in get_user_input so ignore the result
// We will resume execution when a userInput message is received
return;
@ -102,7 +102,6 @@ function resumeCount() {
postMessage({'type': 'finalResultSummary', 'summary': wasm['final_result_summary_' + numbers](state, opts)});
}
var unwindingStack = false;
var userInputBuffer = null;
function get_user_input(message) {
@ -111,13 +110,11 @@ function get_user_input(message) {
// Record the current state of the stack
wasmRaw.asyncify_start_unwind(DATA_ADDR);
unwindingStack = true;
// No further WebAssembly will be executed and control will return to resumeCount
return null;
} else {
// We have reached the point the stack was originally unwound, so resume normal execution
unwindingStack = false;
wasmRaw.asyncify_stop_rewind();
// Return the correct result to WebAssembly