| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 bool StackFrame::FindExceptionHandler(Thread* thread, | 250 bool StackFrame::FindExceptionHandler(Thread* thread, |
| 251 uword* handler_pc, | 251 uword* handler_pc, |
| 252 bool* needs_stacktrace, | 252 bool* needs_stacktrace, |
| 253 bool* has_catch_all) const { | 253 bool* has_catch_all) const { |
| 254 REUSABLE_CODE_HANDLESCOPE(thread); | 254 REUSABLE_CODE_HANDLESCOPE(thread); |
| 255 Code& code = reused_code_handle.Handle(); | 255 Code& code = reused_code_handle.Handle(); |
| 256 code = LookupDartCode(); | 256 code = LookupDartCode(); |
| 257 if (code.IsNull()) { | 257 if (code.IsNull()) { |
| 258 return false; // Stub frames do not have exception handlers. | 258 return false; // Stub frames do not have exception handlers. |
| 259 } | 259 } |
| 260 HandlerInfoCache* cache = thread->isolate()->handler_info_cache(); |
| 261 ExceptionHandlerInfo* info = cache->Lookup(pc()); |
| 262 if (info != NULL) { |
| 263 *handler_pc = code.PayloadStart() + info->handler_pc_offset; |
| 264 *needs_stacktrace = info->needs_stacktrace; |
| 265 *has_catch_all = info->has_catch_all; |
| 266 return true; |
| 267 } |
| 260 uword pc_offset = pc() - code.PayloadStart(); | 268 uword pc_offset = pc() - code.PayloadStart(); |
| 261 | 269 |
| 262 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(thread); | 270 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(thread); |
| 263 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); | 271 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); |
| 264 handlers = code.exception_handlers(); | 272 handlers = code.exception_handlers(); |
| 265 if (handlers.num_entries() == 0) { | 273 if (handlers.num_entries() == 0) { |
| 266 return false; | 274 return false; |
| 267 } | 275 } |
| 268 | 276 |
| 269 // Find pc descriptor for the current pc. | 277 // Find pc descriptor for the current pc. |
| 270 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(thread); | 278 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(thread); |
| 271 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); | 279 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); |
| 272 descriptors = code.pc_descriptors(); | 280 descriptors = code.pc_descriptors(); |
| 273 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 281 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
| 274 while (iter.MoveNext()) { | 282 while (iter.MoveNext()) { |
| 275 const intptr_t current_try_index = iter.TryIndex(); | 283 const intptr_t current_try_index = iter.TryIndex(); |
| 276 if ((iter.PcOffset() == pc_offset) && (current_try_index != -1)) { | 284 if ((iter.PcOffset() == pc_offset) && (current_try_index != -1)) { |
| 277 RawExceptionHandlers::HandlerInfo handler_info; | 285 ExceptionHandlerInfo handler_info; |
| 278 handlers.GetHandlerInfo(current_try_index, &handler_info); | 286 handlers.GetHandlerInfo(current_try_index, &handler_info); |
| 279 *handler_pc = code.PayloadStart() + handler_info.handler_pc_offset; | 287 *handler_pc = code.PayloadStart() + handler_info.handler_pc_offset; |
| 280 *needs_stacktrace = handler_info.needs_stacktrace; | 288 *needs_stacktrace = handler_info.needs_stacktrace; |
| 281 *has_catch_all = handler_info.has_catch_all; | 289 *has_catch_all = handler_info.has_catch_all; |
| 290 cache->Insert(pc(), handler_info); |
| 282 return true; | 291 return true; |
| 283 } | 292 } |
| 284 } | 293 } |
| 285 return false; | 294 return false; |
| 286 } | 295 } |
| 287 | 296 |
| 288 | 297 |
| 289 TokenPosition StackFrame::GetTokenPos() const { | 298 TokenPosition StackFrame::GetTokenPos() const { |
| 290 const Code& code = Code::Handle(LookupDartCode()); | 299 const Code& code = Code::Handle(LookupDartCode()); |
| 291 if (code.IsNull()) { | 300 if (code.IsNull()) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 StackFrameIterator frames(StackFrameIterator::kValidateFrames); | 581 StackFrameIterator frames(StackFrameIterator::kValidateFrames); |
| 573 StackFrame* frame = frames.NextFrame(); | 582 StackFrame* frame = frames.NextFrame(); |
| 574 while (frame != NULL) { | 583 while (frame != NULL) { |
| 575 frame = frames.NextFrame(); | 584 frame = frames.NextFrame(); |
| 576 } | 585 } |
| 577 } | 586 } |
| 578 #endif | 587 #endif |
| 579 | 588 |
| 580 | 589 |
| 581 } // namespace dart | 590 } // namespace dart |
| OLD | NEW |