Chromium Code Reviews| Index: src/trap-handler/trap-handler.h |
| diff --git a/src/trap-handler/trap-handler.h b/src/trap-handler/trap-handler.h |
| index e6dd9bdca463c456af0b4fa75972e8facbc11cee..be28c678a9df08292af4658181dfee74a503e1b7 100644 |
| --- a/src/trap-handler/trap-handler.h |
| +++ b/src/trap-handler/trap-handler.h |
| @@ -5,10 +5,30 @@ |
| #ifndef V8_TRAP_HANDLER_H_ |
| #define V8_TRAP_HANDLER_H_ |
| +#include <signal.h> |
| +#include <stdint.h> |
| +#include <stdlib.h> |
| + |
| +#include "src/base/build_config.h" |
| +#include "src/globals.h" |
| + |
| +#if V8_OS_LINUX |
| +#include <ucontext.h> |
| +#endif |
| + |
| namespace v8 { |
| namespace internal { |
| namespace trap_handler { |
| +// TODO(eholk): Support trap handlers on other platforms. |
| +#if V8_TARGET_ARCH_X64 && V8_OS_LINUX |
| +#define V8_TRAP_HANDLER_SUPPORTED 1 |
| +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
|
| +#else |
| +#define V8_TRAP_HANDLER_SUPPORTED 0 |
| +const bool kTrapHandlerSupported = false; |
| +#endif |
| + |
| struct ProtectedInstructionData { |
| // The offset of this instruction from the start of its code object. |
| intptr_t instr_offset; |
| @@ -19,6 +39,32 @@ struct ProtectedInstructionData { |
| intptr_t landing_offset; |
| }; |
| +/// Adjusts the base code pointer. |
| +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.
|
| + |
| +/// Adds the handler data to the place where the signal handler will find it. |
| +/// |
| +/// This returns a number that can be used to identify the handler data to |
| +/// UpdateCodePointer and ReleaseHandlerData, or -1 on failure. |
| +int RegisterHandlerData(void* base, size_t size, |
| + size_t num_protected_instructions, |
| + ProtectedInstructionData* protected_instructions); |
| + |
| +/// Removes the data from the master list and frees any memory, if necessary. |
| +void ReleaseHandlerData(int index); |
| + |
| +void SetThreadInWasm(); |
| +void ClearThreadInWasm(); |
| + |
| +bool IsThreadInWasm(); |
| + |
| +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.
|
| +bool RegisterDefaultSignalHandler(); |
| + |
| +#if V8_OS_LINUX |
| +bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); |
| +#endif // V8_OS_LINUX |
| + |
| } // namespace trap_handler |
| } // namespace internal |
| } // namespace v8 |