Index: src/gdb-jit.h |
=================================================================== |
--- src/gdb-jit.h (revision 6445) |
+++ src/gdb-jit.h (working copy) |
@@ -128,9 +128,107 @@ |
#define GDBJIT(action) GDBJITInterface::action |
+#ifdef V8_TARGET_ARCH_X64 |
+ |
+// This is currently only available (needed?) for AMD64. |
+class UnwindInfoInterface { |
+ public: |
+ |
+ // An architecture dependent enum containing the various _states_ the program |
+ // is in at various instructions. This information is used to generate the |
+ // instructions for the CFI table. If UnwindInfoInterface is extended to other |
+ // architectures, this will need to be selectively defined using #if ... |
+ // #endif blocks. |
+ enum UnwindInfoState { |
+ UNWIND_STATE_AFTER_RBP_PUSH, |
+ UNWIND_STATE_AFTER_RBP_SET, |
+ UNWIND_STATE_AFTER_RBP_POP, |
+ UNWIND_STATE_AFTER_RETURN, |
+ UNWIND_STATE_MAX |
+ }; |
+ |
+ struct UnwindInformation { |
+ uintptr_t state_offsets_[UNWIND_STATE_MAX]; |
+ uintptr_t begin_; |
+ }; |
+ |
+ UnwindInfoInterface(); |
+ ~UnwindInfoInterface(); |
+ |
+ static void SetStatePosition(uintptr_t pc, UnwindInfoState state); |
+ static void SetStartAddress(uintptr_t pc); |
+ |
+ // Unwind information emitted for the JS entry and exit stubs are accurate |
+ // only at the call-sites. This is done since the more granular approach |
+ // (which is used for regular compiled functions) will probably require |
+ // considerable change to the internals. Since people are unlikely to step |
+ // through the generated stubs, this is unlikely to be a problem. |
+ // It is because of this reason, only the start and the end addresses for |
+ // code stubs are required. This function does all the work - there is no |
+ // need to create a dummy instance of this class for the mechanism to work |
+ // correctly. |
+ static void SetCodeStub(uintptr_t begin, uintptr_t length); |
+ |
+ private: |
+ |
+ struct UnwindInformationList { |
+ UnwindInformation data_; |
+ UnwindInformationList *next_; |
+ }; |
+ |
+ static UnwindInformationList *info_; |
+}; |
+ |
+ |
+#define SET_UNWIND_INFO(stage, pc) \ |
+ UnwindInfoInterface::SetStatePosition(pc, UnwindInfoInterface::stage) |
+ |
+#define SET_UNWIND_INFO_START_ADDRESS(pc) \ |
+ UnwindInfoInterface::SetStartAddress(pc) |
+ |
+#define SET_UNWIND_INFO_STUB(begin, len) \ |
+ UnwindInfoInterface::SetCodeStub(begin, len) |
+ |
+ |
+inline void UnwindInfoInterface::SetStatePosition( |
+ uintptr_t pc, UnwindInfoInterface::UnwindInfoState state) { |
+ ASSERT(info_); |
+ info_->data_.state_offsets_[state] = pc; |
+ if (state) |
+ ASSERT(info_->data_.state_offsets_[state-1] < pc); |
+} |
+ |
+ |
+inline void UnwindInfoInterface::SetStartAddress(uintptr_t pc) { |
+ ASSERT(info_); |
+ info_->data_.begin_ = pc; |
+} |
+ |
+ |
+inline UnwindInfoInterface::UnwindInfoInterface() { |
+ UnwindInformationList *ulist = new UnwindInformationList(); |
+ ulist->next_ = info_; |
+ info_ = ulist; |
+} |
+ |
+ |
+#else // V8_TARGET_ARCH_X64 |
+ |
+ |
+#define SET_UNWIND_INFO(stage, pc) ((void) 0) |
+#define SET_UNWIND_INFO_START_ADDRESS(pc) ((void) 0) |
+#define SET_UNWIND_INFO_STUB(begin, len) ((void) 0) |
+ |
+ |
+#endif // V8_TARGET_ARCH_X64 |
+ |
+ |
} } // namespace v8::internal |
#else |
#define GDBJIT(action) ((void) 0) |
+#define SET_UNWIND_INFO(stage, pc) ((void) 0) |
+#define SET_UNWIND_INFO_START_ADDRESS(pc) ((void) 0) |
+#define SET_UNWIND_INFO_STUB(begin, len) |
#endif |
#endif |