Chromium Code Reviews| 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 int32_t instr_offset; | 28 int32_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 int32_t landing_offset; | 33 int32_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 int RegisterHandlerData(void* base, size_t size, | |
|
Mark Seaborn
2017/01/24 07:14:40
Can you add a comment saying what this returns?
Eric Holk
2017/01/26 01:33:37
Done.
| |
| 41 size_t num_protected_instructions, | |
| 42 ProtectedInstructionData* protected_instructions); | |
| 43 | |
| 44 /// Removes the data from the master list and frees any memory, if necessary. | |
| 45 void ReleaseHandlerData(int index); | |
| 46 | |
| 47 void SetThreadInWasm(); | |
| 48 void ClearThreadInWasm(); | |
| 49 | |
| 50 bool IsThreadInWasm(); | |
| 51 | |
| 52 bool EnableTrapHandler(); | |
| 53 bool RegisterDefaultSignalHandler(); | |
| 54 bool TryHandleFault(void* source_instruction, void* target_data, | |
| 55 void** return_address); | |
| 56 | |
| 22 } // namespace trap_handler | 57 } // namespace trap_handler |
| 23 } // namespace internal | 58 } // namespace internal |
| 24 } // namespace v8 | 59 } // namespace v8 |
| 25 | 60 |
| 26 #endif // V8_TRAP_HANDLER_H_ | 61 #endif // V8_TRAP_HANDLER_H_ |
| OLD | NEW |