| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <setjmp.h> | 8 #include <setjmp.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 if (!interpret()) { | 713 if (!interpret()) { |
| 714 wrapper_.Init<ReturnType, ParamTypes...>(functions_[0]->descriptor()); | 714 wrapper_.Init<ReturnType, ParamTypes...>(functions_[0]->descriptor()); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 ReturnType Call(ParamTypes... p) { | 718 ReturnType Call(ParamTypes... p) { |
| 719 DCHECK(compiled_); | 719 DCHECK(compiled_); |
| 720 if (interpret()) return CallInterpreter(p...); | 720 if (interpret()) return CallInterpreter(p...); |
| 721 | 721 |
| 722 // Use setjmp/longjmp to deal with traps in WebAssembly code. | 722 // Use setjmp/longjmp to deal with traps in WebAssembly code. |
| 723 // Make the return value volatile, to give defined semantics if accessed | |
| 724 // after setjmp. | |
| 725 ReturnType return_value = static_cast<ReturnType>(0xdeadbeefdeadbeef); | 723 ReturnType return_value = static_cast<ReturnType>(0xdeadbeefdeadbeef); |
| 726 static int setjmp_ret; | 724 static int setjmp_ret; |
| 727 setjmp_ret = setjmp(WasmRunnerBase::jump_buffer); | 725 setjmp_ret = setjmp(WasmRunnerBase::jump_buffer); |
| 728 // setjmp returns 0 on the first return, 1 (passed to longjmp) after trap. | 726 // setjmp returns 0 on the first return, 1 (passed to longjmp) after trap. |
| 729 if (setjmp_ret == 0) { | 727 if (setjmp_ret == 0) { |
| 730 DoCall(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); | 728 DoCall(static_cast<void*>(&p)..., static_cast<void*>(&return_value)); |
| 731 } | 729 } |
| 732 return return_value; | 730 return return_value; |
| 733 } | 731 } |
| 734 | 732 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 void RunWasm_##name(WasmExecutionMode execution_mode) | 794 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 797 | 795 |
| 798 #define WASM_EXEC_COMPILED_TEST(name) \ | 796 #define WASM_EXEC_COMPILED_TEST(name) \ |
| 799 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 797 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 800 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 798 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 801 void RunWasm_##name(WasmExecutionMode execution_mode) | 799 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 802 | 800 |
| 803 } // namespace | 801 } // namespace |
| 804 | 802 |
| 805 #endif | 803 #endif |
| OLD | NEW |