OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 static void AddCode(CodeTag tag, Code* code); | 122 static void AddCode(CodeTag tag, Code* code); |
123 | 123 |
124 static void RemoveCode(Code* code); | 124 static void RemoveCode(Code* code); |
125 | 125 |
126 static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info); | 126 static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info); |
127 }; | 127 }; |
128 | 128 |
129 #define GDBJIT(action) GDBJITInterface::action | 129 #define GDBJIT(action) GDBJITInterface::action |
130 | 130 |
| 131 #ifdef V8_TARGET_ARCH_X64 |
| 132 |
| 133 // This is currently only available (needed?) for AMD64. |
| 134 class UnwindInfoInterface { |
| 135 public: |
| 136 |
| 137 // An architecture dependent enum containing the various _states_ the program |
| 138 // is in at various instructions. This information is used to generate the |
| 139 // instructions for the CFI table. If UnwindInfoInterface is extended to other |
| 140 // architectures, this will need to be selectively defined using #if ... |
| 141 // #endif blocks. |
| 142 enum UnwindInfoState { |
| 143 UNWIND_STATE_AFTER_RBP_PUSH, |
| 144 UNWIND_STATE_AFTER_RBP_SET, |
| 145 UNWIND_STATE_AFTER_RBP_POP, |
| 146 UNWIND_STATE_AFTER_RETURN, |
| 147 UNWIND_STATE_MAX |
| 148 }; |
| 149 |
| 150 struct UnwindInformation { |
| 151 uintptr_t state_offsets_[UNWIND_STATE_MAX]; |
| 152 uintptr_t begin_; |
| 153 }; |
| 154 |
| 155 UnwindInfoInterface(); |
| 156 ~UnwindInfoInterface(); |
| 157 |
| 158 static void SetStatePosition(uintptr_t pc, UnwindInfoState state); |
| 159 static void SetStartAddress(uintptr_t pc); |
| 160 |
| 161 // Unwind information emitted for the JS entry and exit stubs are accurate |
| 162 // only at the call-sites. This is done since the more granular approach |
| 163 // (which is used for regular compiled functions) will probably require |
| 164 // considerable change to the internals. Since people are unlikely to step |
| 165 // through the generated stubs, this is unlikely to be a problem. |
| 166 // It is because of this reason, only the start and the end addresses for |
| 167 // code stubs are required. This function does all the work - there is no |
| 168 // need to create a dummy instance of this class for the mechanism to work |
| 169 // correctly. |
| 170 static void SetCodeStub(uintptr_t begin, uintptr_t length); |
| 171 |
| 172 private: |
| 173 |
| 174 struct UnwindInformationList { |
| 175 UnwindInformation data_; |
| 176 UnwindInformationList *next_; |
| 177 }; |
| 178 |
| 179 static UnwindInformationList *info_; |
| 180 }; |
| 181 |
| 182 |
| 183 #define SET_UNWIND_INFO(stage, pc) \ |
| 184 UnwindInfoInterface::SetStatePosition(pc, UnwindInfoInterface::stage) |
| 185 |
| 186 #define SET_UNWIND_INFO_START_ADDRESS(pc) \ |
| 187 UnwindInfoInterface::SetStartAddress(pc) |
| 188 |
| 189 #define SET_UNWIND_INFO_STUB(begin, len) \ |
| 190 UnwindInfoInterface::SetCodeStub(begin, len) |
| 191 |
| 192 |
| 193 inline void UnwindInfoInterface::SetStatePosition( |
| 194 uintptr_t pc, UnwindInfoInterface::UnwindInfoState state) { |
| 195 ASSERT(info_); |
| 196 info_->data_.state_offsets_[state] = pc; |
| 197 if (state) |
| 198 ASSERT(info_->data_.state_offsets_[state-1] < pc); |
| 199 } |
| 200 |
| 201 |
| 202 inline void UnwindInfoInterface::SetStartAddress(uintptr_t pc) { |
| 203 ASSERT(info_); |
| 204 info_->data_.begin_ = pc; |
| 205 } |
| 206 |
| 207 |
| 208 inline UnwindInfoInterface::UnwindInfoInterface() { |
| 209 UnwindInformationList *ulist = new UnwindInformationList(); |
| 210 ulist->next_ = info_; |
| 211 info_ = ulist; |
| 212 } |
| 213 |
| 214 |
| 215 #else // V8_TARGET_ARCH_X64 |
| 216 |
| 217 |
| 218 #define SET_UNWIND_INFO(stage, pc) ((void) 0) |
| 219 #define SET_UNWIND_INFO_START_ADDRESS(pc) ((void) 0) |
| 220 #define SET_UNWIND_INFO_STUB(begin, len) ((void) 0) |
| 221 |
| 222 |
| 223 #endif // V8_TARGET_ARCH_X64 |
| 224 |
| 225 |
131 } } // namespace v8::internal | 226 } } // namespace v8::internal |
132 #else | 227 #else |
133 #define GDBJIT(action) ((void) 0) | 228 #define GDBJIT(action) ((void) 0) |
| 229 #define SET_UNWIND_INFO(stage, pc) ((void) 0) |
| 230 #define SET_UNWIND_INFO_START_ADDRESS(pc) ((void) 0) |
| 231 #define SET_UNWIND_INFO_STUB(begin, len) |
134 #endif | 232 #endif |
135 | 233 |
136 #endif | 234 #endif |
OLD | NEW |