OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/stack_frame.h" | 5 #include "vm/stack_frame.h" |
6 | 6 |
7 #include "platform/memory_sanitizer.h" | 7 #include "platform/memory_sanitizer.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/deopt_instructions.h" | 9 #include "vm/deopt_instructions.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 bool StackFrame::FindExceptionHandler(Isolate* isolate, | 202 bool StackFrame::FindExceptionHandler(Isolate* isolate, |
203 uword* handler_pc, | 203 uword* handler_pc, |
204 bool* needs_stacktrace, | 204 bool* needs_stacktrace, |
205 bool* has_catch_all) const { | 205 bool* has_catch_all) const { |
206 REUSABLE_CODE_HANDLESCOPE(isolate); | 206 REUSABLE_CODE_HANDLESCOPE(isolate); |
207 Code& code = reused_code_handle.Handle(); | 207 Code& code = reused_code_handle.Handle(); |
208 code = LookupDartCode(); | 208 code = LookupDartCode(); |
209 if (code.IsNull()) { | 209 if (code.IsNull()) { |
210 return false; // Stub frames do not have exception handlers. | 210 return false; // Stub frames do not have exception handlers. |
211 } | 211 } |
| 212 uword pc_offset = pc() - code.EntryPoint(); |
212 | 213 |
213 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(isolate); | 214 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(isolate); |
214 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); | 215 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); |
215 handlers = code.exception_handlers(); | 216 handlers = code.exception_handlers(); |
216 if (handlers.num_entries() == 0) { | 217 if (handlers.num_entries() == 0) { |
217 return false; | 218 return false; |
218 } | 219 } |
219 | 220 |
220 // Find pc descriptor for the current pc. | 221 // Find pc descriptor for the current pc. |
221 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); | 222 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); |
222 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); | 223 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); |
223 descriptors = code.pc_descriptors(); | 224 descriptors = code.pc_descriptors(); |
224 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 225 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
225 while (iter.MoveNext()) { | 226 while (iter.MoveNext()) { |
226 const intptr_t current_try_index = iter.TryIndex(); | 227 const intptr_t current_try_index = iter.TryIndex(); |
227 if ((iter.Pc() == pc()) && (current_try_index != -1)) { | 228 if ((iter.PcOffset() == pc_offset) && (current_try_index != -1)) { |
228 RawExceptionHandlers::HandlerInfo handler_info; | 229 RawExceptionHandlers::HandlerInfo handler_info; |
229 handlers.GetHandlerInfo(current_try_index, &handler_info); | 230 handlers.GetHandlerInfo(current_try_index, &handler_info); |
230 *handler_pc = handler_info.handler_pc; | 231 *handler_pc = handler_info.handler_pc; |
231 *needs_stacktrace = handler_info.needs_stacktrace; | 232 *needs_stacktrace = handler_info.needs_stacktrace; |
232 *has_catch_all = handler_info.has_catch_all; | 233 *has_catch_all = handler_info.has_catch_all; |
233 return true; | 234 return true; |
234 } | 235 } |
235 } | 236 } |
236 return false; | 237 return false; |
237 } | 238 } |
238 | 239 |
239 | 240 |
240 intptr_t StackFrame::GetTokenPos() const { | 241 intptr_t StackFrame::GetTokenPos() const { |
241 const Code& code = Code::Handle(LookupDartCode()); | 242 const Code& code = Code::Handle(LookupDartCode()); |
242 if (code.IsNull()) { | 243 if (code.IsNull()) { |
243 return -1; // Stub frames do not have token_pos. | 244 return -1; // Stub frames do not have token_pos. |
244 } | 245 } |
| 246 uword pc_offset = pc() - code.EntryPoint(); |
245 const PcDescriptors& descriptors = | 247 const PcDescriptors& descriptors = |
246 PcDescriptors::Handle(code.pc_descriptors()); | 248 PcDescriptors::Handle(code.pc_descriptors()); |
247 ASSERT(!descriptors.IsNull()); | 249 ASSERT(!descriptors.IsNull()); |
248 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 250 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
249 while (iter.MoveNext()) { | 251 while (iter.MoveNext()) { |
250 if (iter.Pc() == pc()) { | 252 if (iter.PcOffset() == pc_offset) { |
251 return iter.TokenPos(); | 253 return iter.TokenPos(); |
252 } | 254 } |
253 } | 255 } |
254 return -1; | 256 return -1; |
255 } | 257 } |
256 | 258 |
257 | 259 |
258 | 260 |
259 bool StackFrame::IsValid() const { | 261 bool StackFrame::IsValid() const { |
260 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { | 262 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 492 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
491 return (index - num_materializations_); | 493 return (index - num_materializations_); |
492 } | 494 } |
493 } | 495 } |
494 UNREACHABLE(); | 496 UNREACHABLE(); |
495 return 0; | 497 return 0; |
496 } | 498 } |
497 | 499 |
498 | 500 |
499 } // namespace dart | 501 } // namespace dart |
OLD | NEW |