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 V8_TRAP_HANDLER_H_ | 5 #ifndef V8_TRAP_HANDLER_H_ |
6 #define V8_TRAP_HANDLER_H_ | 6 #define V8_TRAP_HANDLER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 #include <stdlib.h> |
| 10 |
| 11 #include "src/base/build_config.h" |
| 12 |
8 namespace v8 { | 13 namespace v8 { |
9 namespace internal { | 14 namespace internal { |
10 namespace trap_handler { | 15 namespace trap_handler { |
11 | 16 |
| 17 // TODO(eholk): Support trap handlers on other platforms. |
| 18 #if V8_TARGET_ARCH_X64 && V8_OS_LINUX |
| 19 #define V8_TRAP_HANDLER_SUPPORTED 1 |
| 20 const bool kTrapHandlerSupported = true; |
| 21 #else |
| 22 #define V8_TRAP_HANDLER_SUPPORTED 0 |
| 23 const bool kTrapHandlerSupported = false; |
| 24 #endif |
| 25 |
12 struct ProtectedInstructionData { | 26 struct ProtectedInstructionData { |
13 // The offset of this instruction from the start of its code object. | 27 // The offset of this instruction from the start of its code object. |
14 intptr_t instr_offset; | 28 intptr_t instr_offset; |
15 | 29 |
16 // The offset of the landing pad from the start of its code object. | 30 // The offset of the landing pad from the start of its code object. |
17 // | 31 // |
18 // TODO(eholk): Using a single landing pad and store parameters here. | 32 // TODO(eholk): Using a single landing pad and store parameters here. |
19 intptr_t landing_offset; | 33 intptr_t landing_offset; |
20 }; | 34 }; |
21 | 35 |
| 36 /// Adjusts the base code pointer. |
| 37 void UpdateCodePointer(int index, void* base); |
| 38 |
| 39 /// Adds the handler data to the place where the signal handler will find it. |
| 40 /// |
| 41 /// This returns a number that can be used to identify the handler data to |
| 42 /// UpdateCodePointer and ReleaseHandlerData, or -1 on failure. |
| 43 int RegisterHandlerData(void* base, size_t size, |
| 44 size_t num_protected_instructions, |
| 45 ProtectedInstructionData* protected_instructions); |
| 46 |
| 47 /// Removes the data from the master list and frees any memory, if necessary. |
| 48 void ReleaseHandlerData(int index); |
| 49 |
| 50 void SetThreadInWasm(); |
| 51 void ClearThreadInWasm(); |
| 52 |
| 53 bool IsThreadInWasm(); |
| 54 |
| 55 bool EnableTrapHandler(); |
| 56 bool RegisterDefaultSignalHandler(); |
| 57 bool TryHandleFault(void* source_instruction, void* target_data, |
| 58 void** return_address); |
| 59 |
22 } // namespace trap_handler | 60 } // namespace trap_handler |
23 } // namespace internal | 61 } // namespace internal |
24 } // namespace v8 | 62 } // namespace v8 |
25 | 63 |
26 #endif // V8_TRAP_HANDLER_H_ | 64 #endif // V8_TRAP_HANDLER_H_ |
OLD | NEW |