Chromium Code Reviews| Index: test/cctest/wasm/wasm-run-utils.h |
| diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h |
| index 7eef59c515ed1965adf63edc0d002bbe781be612..4b882f4a5b5c433b44494c64be1fdc74372878a2 100644 |
| --- a/test/cctest/wasm/wasm-run-utils.h |
| +++ b/test/cctest/wasm/wasm-run-utils.h |
| @@ -743,7 +743,7 @@ class WasmRunnerBase : public HandleAndZoneScope { |
| public: |
| // This field has to be static. Otherwise, gcc complains about the using in |
|
Clemens Hammacher
2017/02/08 22:13:20
Can you fix this typo ("using" should be "use" IMO
ahaas
2017/02/09 16:59:37
Done.
|
| // the lambda context below. |
| - static jmp_buf jump_buffer; |
| + static bool trap_happened; |
| }; |
| template <typename ReturnType, typename... ParamTypes> |
| @@ -764,13 +764,23 @@ class WasmRunner : public WasmRunnerBase { |
| // Use setjmp/longjmp to deal with traps in WebAssembly code. |
|
Clemens Hammacher
2017/02/08 22:13:20
This comment is obsolete now.
ahaas
2017/02/09 16:59:37
Done.
|
| ReturnType return_value = static_cast<ReturnType>(0xdeadbeefdeadbeef); |
| - static int setjmp_ret; |
| - setjmp_ret = setjmp(WasmRunnerBase::jump_buffer); |
| - // setjmp returns 0 on the first return, 1 (passed to longjmp) after trap. |
| - if (setjmp_ret == 0) { |
| - DoCall(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); |
| - } |
| - return return_value; |
| + WasmRunnerBase::trap_happened = false; |
| + auto trap_callback = []() -> void { |
| + WasmRunnerBase::trap_happened = true; |
| + set_trap_callback_for_testing(nullptr); |
| + }; |
| + set_trap_callback_for_testing(trap_callback); |
| + |
| + wrapper_.SetInnerCode( |
| + module_.GetFunctionCode(functions_[0]->function_index())); |
| + CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), |
| + wrapper_.GetWrapperCode(), wrapper_.signature()); |
| + int32_t result = runner.Call(static_cast<void*>(&p)..., |
| + static_cast<void*>(&return_value)); |
| + CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); |
| + return WasmRunnerBase::trap_happened |
| + ? static_cast<ReturnType>(0xdeadbeefdeadbeef) |
| + : return_value; |
| } |
| ReturnType CallInterpreter(ParamTypes... p) { |
| @@ -791,30 +801,10 @@ class WasmRunner : public WasmRunnerBase { |
| return ReturnType{0}; |
| } |
| } |
| - |
| - private: |
| - // Don't inline this function. The setjmp above should be followed immediately |
| - // by a call. |
| - template <typename... Ptrs> |
| - V8_NOINLINE void DoCall(Ptrs... ptrs) { |
| - auto trap_callback = []() -> void { |
| - set_trap_callback_for_testing(nullptr); |
| - longjmp(WasmRunnerBase::jump_buffer, 1); |
| - }; |
| - set_trap_callback_for_testing(trap_callback); |
| - |
| - wrapper_.SetInnerCode( |
| - module_.GetFunctionCode(functions_[0]->function_index())); |
| - CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), |
| - wrapper_.GetWrapperCode(), wrapper_.signature()); |
| - int32_t result = runner.Call(ptrs...); |
| - // If we arrive here, no trap happened. |
| - CHECK_EQ(WASM_WRAPPER_RETURN_VALUE, result); |
| - } |
| }; |
| // Declare static variable. |
| -jmp_buf WasmRunnerBase::jump_buffer; |
| +bool WasmRunnerBase::trap_happened; |
| // A macro to define tests that run in different engine configurations. |
| #define WASM_EXEC_TEST(name) \ |