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 <signal.h> | |
| 9 #include <stdint.h> | |
| 10 #include <stdlib.h> | |
| 11 | |
| 12 #include "src/base/build_config.h" | |
| 13 #include "src/globals.h" | |
| 14 | |
| 15 #if V8_OS_LINUX | |
| 16 #include <ucontext.h> | |
| 17 #endif | |
| 18 | |
| 8 namespace v8 { | 19 namespace v8 { |
| 9 namespace internal { | 20 namespace internal { |
| 10 namespace trap_handler { | 21 namespace trap_handler { |
| 11 | 22 |
| 23 // TODO(eholk): Support trap handlers on other platforms. | |
| 24 #if V8_TARGET_ARCH_X64 && V8_OS_LINUX | |
| 25 #define V8_TRAP_HANDLER_SUPPORTED 1 | |
| 26 const bool kTrapHandlerSupported = true; | |
|
titzer
2017/02/20 09:50:08
why not just move this down to:
const bool kTrapH
Eric Holk
2017/02/23 02:16:57
Originally I thought there was some good reason fo
| |
| 27 #else | |
| 28 #define V8_TRAP_HANDLER_SUPPORTED 0 | |
| 29 const bool kTrapHandlerSupported = false; | |
| 30 #endif | |
| 31 | |
| 12 struct ProtectedInstructionData { | 32 struct ProtectedInstructionData { |
| 13 // The offset of this instruction from the start of its code object. | 33 // The offset of this instruction from the start of its code object. |
| 14 intptr_t instr_offset; | 34 intptr_t instr_offset; |
| 15 | 35 |
| 16 // The offset of the landing pad from the start of its code object. | 36 // The offset of the landing pad from the start of its code object. |
| 17 // | 37 // |
| 18 // TODO(eholk): Using a single landing pad and store parameters here. | 38 // TODO(eholk): Using a single landing pad and store parameters here. |
| 19 intptr_t landing_offset; | 39 intptr_t landing_offset; |
| 20 }; | 40 }; |
| 21 | 41 |
| 42 /// Adjusts the base code pointer. | |
| 43 void UpdateCodePointer(int index, void* base); | |
|
titzer
2017/02/20 09:50:08
We could use a more specific name here, because it
Eric Holk
2017/02/23 02:16:57
How about UpdateHandlerDataCodePointer?
Done.
| |
| 44 | |
| 45 /// Adds the handler data to the place where the signal handler will find it. | |
| 46 /// | |
| 47 /// This returns a number that can be used to identify the handler data to | |
| 48 /// UpdateCodePointer and ReleaseHandlerData, or -1 on failure. | |
| 49 int RegisterHandlerData(void* base, size_t size, | |
| 50 size_t num_protected_instructions, | |
| 51 ProtectedInstructionData* protected_instructions); | |
| 52 | |
| 53 /// Removes the data from the master list and frees any memory, if necessary. | |
| 54 void ReleaseHandlerData(int index); | |
| 55 | |
| 56 void SetThreadInWasm(); | |
| 57 void ClearThreadInWasm(); | |
| 58 | |
| 59 bool IsThreadInWasm(); | |
| 60 | |
| 61 V8_EXPORT_PRIVATE bool ShouldEnableTrapHandler(); | |
|
titzer
2017/02/20 09:50:08
Uses of this method read kinda funny. Maybe
UseTr
Eric Holk
2017/02/23 02:16:57
I went with UseTrapHandler.
Done.
| |
| 62 bool RegisterDefaultSignalHandler(); | |
| 63 | |
| 64 #if V8_OS_LINUX | |
| 65 bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); | |
| 66 #endif // V8_OS_LINUX | |
| 67 | |
| 22 } // namespace trap_handler | 68 } // namespace trap_handler |
| 23 } // namespace internal | 69 } // namespace internal |
| 24 } // namespace v8 | 70 } // namespace v8 |
| 25 | 71 |
| 26 #endif // V8_TRAP_HANDLER_H_ | 72 #endif // V8_TRAP_HANDLER_H_ |
| OLD | NEW |