Simplify stack unwinding logic
This commit is contained in:
parent
49feb09bf8
commit
470f1e550e
|
@ -84,7 +84,7 @@ function resumeCount() {
|
||||||
for (;; stageNum++) {
|
for (;; stageNum++) {
|
||||||
let isDone = wasm['count_one_stage_' + numbers](state, opts);
|
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
|
// This stage caused a stack unwind in get_user_input so ignore the result
|
||||||
// We will resume execution when a userInput message is received
|
// We will resume execution when a userInput message is received
|
||||||
return;
|
return;
|
||||||
|
@ -102,7 +102,6 @@ function resumeCount() {
|
||||||
postMessage({'type': 'finalResultSummary', 'summary': wasm['final_result_summary_' + numbers](state, opts)});
|
postMessage({'type': 'finalResultSummary', 'summary': wasm['final_result_summary_' + numbers](state, opts)});
|
||||||
}
|
}
|
||||||
|
|
||||||
var unwindingStack = false;
|
|
||||||
var userInputBuffer = null;
|
var userInputBuffer = null;
|
||||||
|
|
||||||
function get_user_input(message) {
|
function get_user_input(message) {
|
||||||
|
@ -111,13 +110,11 @@ function get_user_input(message) {
|
||||||
|
|
||||||
// Record the current state of the stack
|
// Record the current state of the stack
|
||||||
wasmRaw.asyncify_start_unwind(DATA_ADDR);
|
wasmRaw.asyncify_start_unwind(DATA_ADDR);
|
||||||
unwindingStack = true;
|
|
||||||
|
|
||||||
// No further WebAssembly will be executed and control will return to resumeCount
|
// No further WebAssembly will be executed and control will return to resumeCount
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
// We have reached the point the stack was originally unwound, so resume normal execution
|
// We have reached the point the stack was originally unwound, so resume normal execution
|
||||||
unwindingStack = false;
|
|
||||||
wasmRaw.asyncify_stop_rewind();
|
wasmRaw.asyncify_stop_rewind();
|
||||||
|
|
||||||
// Return the correct result to WebAssembly
|
// Return the correct result to WebAssembly
|
||||||
|
|
Loading…
Reference in New Issue