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 <signal.h> | |
9 #include <stdint.h> | |
10 #include <stdlib.h> | |
11 #include <ucontext.h> | |
12 | |
13 #include "src/base/build_config.h" | |
14 | |
8 namespace v8 { | 15 namespace v8 { |
9 namespace internal { | 16 namespace internal { |
10 namespace trap_handler { | 17 namespace trap_handler { |
11 | 18 |
19 // TODO(eholk): Support trap handlers on other platforms. | |
20 #if V8_TARGET_ARCH_X64 && V8_OS_LINUX | |
21 #define V8_TRAP_HANDLER_SUPPORTED 1 | |
22 const bool kTrapHandlerSupported = true; | |
23 #else | |
24 #define V8_TRAP_HANDLER_SUPPORTED 0 | |
25 const bool kTrapHandlerSupported = false; | |
26 #endif | |
27 | |
12 struct ProtectedInstructionData { | 28 struct ProtectedInstructionData { |
13 // The offset of this instruction from the start of its code object. | 29 // The offset of this instruction from the start of its code object. |
14 intptr_t instr_offset; | 30 intptr_t instr_offset; |
15 | 31 |
16 // The offset of the landing pad from the start of its code object. | 32 // The offset of the landing pad from the start of its code object. |
17 // | 33 // |
18 // TODO(eholk): Using a single landing pad and store parameters here. | 34 // TODO(eholk): Using a single landing pad and store parameters here. |
19 intptr_t landing_offset; | 35 intptr_t landing_offset; |
20 }; | 36 }; |
21 | 37 |
38 /// Adjusts the base code pointer. | |
39 void UpdateCodePointer(int index, void* base); | |
40 | |
41 /// Adds the handler data to the place where the signal handler will find it. | |
42 /// | |
43 /// This returns a number that can be used to identify the handler data to | |
44 /// UpdateCodePointer and ReleaseHandlerData, or -1 on failure. | |
45 int RegisterHandlerData(void* base, size_t size, | |
46 size_t num_protected_instructions, | |
47 ProtectedInstructionData* protected_instructions); | |
48 | |
49 /// Removes the data from the master list and frees any memory, if necessary. | |
50 void ReleaseHandlerData(int index); | |
51 | |
52 void SetThreadInWasm(); | |
53 void ClearThreadInWasm(); | |
54 | |
55 bool IsThreadInWasm(); | |
56 | |
57 bool EnableTrapHandler(); | |
Mark Mentovai
2017/02/09 17:39:41
It sounds like this should be called ShouldEnableT
Eric Holk
2017/02/15 02:02:45
Agreed. I'll go with ShouldEnableTrapHandler.
Don
| |
58 bool RegisterDefaultSignalHandler(); | |
Mark Mentovai
2017/02/09 17:39:41
I find it a little weird that this function and th
Eric Holk
2017/02/15 02:02:45
The original idea was that trap-handler.h provided
| |
59 | |
60 #if V8_OS_LINUX | |
61 bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); | |
62 #endif // V8_OS_LINUX | |
63 | |
22 } // namespace trap_handler | 64 } // namespace trap_handler |
23 } // namespace internal | 65 } // namespace internal |
24 } // namespace v8 | 66 } // namespace v8 |
25 | 67 |
26 #endif // V8_TRAP_HANDLER_H_ | 68 #endif // V8_TRAP_HANDLER_H_ |
OLD | NEW |