diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-07-23 17:12:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-23 17:12:22 -0700 |
commit | a2741b360b444a26cd87327a3d60a601bb33119f (patch) | |
tree | e7ea331a4236f33c4f8e28b8ef30a8a09ab29740 /src/wasm-interpreter.h | |
parent | 0beba8aad60e4bdadcd3fc3e5126e7befb7b7994 (diff) | |
download | binaryen-a2741b360b444a26cd87327a3d60a601bb33119f.tar.gz binaryen-a2741b360b444a26cd87327a3d60a601bb33119f.tar.bz2 binaryen-a2741b360b444a26cd87327a3d60a601bb33119f.zip |
Finalize tail call support (#2246)
Adds tail call support to fuzzer and makes small changes to handle return calls in multiple utilities and passes. Makes larger changes to DAE and inlining passes to properly handle tail calls.
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r-- | src/wasm-interpreter.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 42e904fd3..f683f9b38 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1435,6 +1435,15 @@ private: #ifdef WASM_INTERPRETER_DEBUG std::cout << "(returned to " << scope.function->name << ")\n"; #endif + // TODO: make this a proper tail call (return first) + if (curr->isReturn) { + Const c; + c.value = ret.value; + c.finalize(); + Return return_; + return_.value = &c; + return this->visit(&return_); + } return ret; } Flow visitCallIndirect(CallIndirect* curr) { @@ -1449,8 +1458,19 @@ private: return target; } Index index = target.value.geti32(); - return instance.externalInterface->callTable( - index, arguments, curr->type, *instance.self()); + Type type = curr->isReturn ? scope.function->result : curr->type; + Flow ret = instance.externalInterface->callTable( + index, arguments, type, *instance.self()); + // TODO: make this a proper tail call (return first) + if (curr->isReturn) { + Const c; + c.value = ret.value; + c.finalize(); + Return return_; + return_.value = &c; + return this->visit(&return_); + } + return ret; } Flow visitLocalGet(LocalGet* curr) { |