diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-23 16:10:35 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-23 16:10:35 -0700 |
commit | 359c895db53b99fd176aac926914ecebcb4ddd93 (patch) | |
tree | 48cbe7e6e0e6af110cd5bac26df8f87fc6f09a0d /src/wasm-interpreter.h | |
parent | a67434f2dd05f7590c2b7ab18b6bf9d6215f79f2 (diff) | |
parent | 85959a42f97857491bac46a25e9634029f6eb3b4 (diff) | |
download | binaryen-359c895db53b99fd176aac926914ecebcb4ddd93.tar.gz binaryen-359c895db53b99fd176aac926914ecebcb4ddd93.tar.bz2 binaryen-359c895db53b99fd176aac926914ecebcb4ddd93.zip |
Merge pull request #275 from WebAssembly/closure-fix
Test suite corner case fixes
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r-- | src/wasm-interpreter.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index e9ced6b6f..f1b9fc8f9 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -116,6 +116,15 @@ public: return callFunction(export_->value, arguments); } + std::string printFunctionStack() { + std::string ret = "/== (binaryen interpreter stack trace)\n"; + for (int i = int(functionStack.size()) - 1; i >= 0; i--) { + ret += std::string("|: ") + functionStack[i].str + "\n"; + } + ret += std::string("\\==\n"); + return ret; + } + private: size_t callDepth = 0; @@ -124,6 +133,10 @@ private: int indent = 0; #endif + // Function stack. We maintain this explicitly to allow printing of + // stack traces. + std::vector<Name> functionStack; + // // Calls a function. This can be used both internally (calls from // the interpreter to another method), or when you want to call into @@ -656,6 +669,7 @@ private: if (callDepth > maxCallDepth) externalInterface->trap("stack limit"); callDepth++; + functionStack.push_back(name); Function *function = wasm.functionsMap[name]; assert(function); @@ -671,6 +685,8 @@ private: if (function->result == none) ret = Literal(); assert(function->result == ret.type); callDepth--; + assert(functionStack.back() == name); + functionStack.pop_back(); #ifdef WASM_INTERPRETER_DEBUG std::cout << "exiting " << function->name << " with " << ret << '\n'; #endif |