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..aaa00cdc20f661f30a685acccaadc19ba0a1a211 100644 |
--- a/src/trap-handler/trap-handler.h |
+++ b/src/trap-handler/trap-handler.h |
@@ -5,10 +5,26 @@ |
#ifndef V8_TRAP_HANDLER_H_ |
#define V8_TRAP_HANDLER_H_ |
+#include <signal.h> |
+#include <stdint.h> |
+#include <stdlib.h> |
+#include <ucontext.h> |
+ |
+#include "src/base/build_config.h" |
+ |
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; |
+#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 +35,32 @@ struct ProtectedInstructionData { |
intptr_t landing_offset; |
}; |
+/// Adjusts the base code pointer. |
+void UpdateCodePointer(int index, void* base); |
+ |
+/// 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(); |
+ |
+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
|
+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
|
+ |
+#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 |