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 "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/deopt_instructions.h" | 8 #include "vm/deopt_instructions.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); | 217 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); |
218 handlers = code.exception_handlers(); | 218 handlers = code.exception_handlers(); |
219 if (handlers.Length() == 0) { | 219 if (handlers.Length() == 0) { |
220 return false; | 220 return false; |
221 } | 221 } |
222 | 222 |
223 // Find pc descriptor for the current pc. | 223 // Find pc descriptor for the current pc. |
224 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); | 224 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); |
225 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); | 225 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); |
226 descriptors = code.pc_descriptors(); | 226 descriptors = code.pc_descriptors(); |
227 const intptr_t len = descriptors.Length(); | 227 PcDescriptors::Iterator iter(descriptors); |
228 for (intptr_t i = 0; i < len; i++) { | 228 while (iter.HasNext()) { |
229 if ((static_cast<uword>(descriptors.PC(i)) == pc()) && | 229 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
230 (descriptors.TryIndex(i) != -1)) { | 230 if ((rec.pc == pc()) && (rec.try_index != -1)) { |
231 const intptr_t try_index = descriptors.TryIndex(i); | 231 const intptr_t try_index = rec.try_index; |
232 RawExceptionHandlers::HandlerInfo handler_info; | 232 RawExceptionHandlers::HandlerInfo handler_info; |
233 handlers.GetHandlerInfo(try_index, &handler_info); | 233 handlers.GetHandlerInfo(try_index, &handler_info); |
234 *handler_pc = handler_info.handler_pc; | 234 *handler_pc = handler_info.handler_pc; |
235 *needs_stacktrace = handler_info.needs_stacktrace; | 235 *needs_stacktrace = handler_info.needs_stacktrace; |
236 *has_catch_all = handler_info.has_catch_all; | 236 *has_catch_all = handler_info.has_catch_all; |
237 return true; | 237 return true; |
238 } | 238 } |
239 } | 239 } |
240 return false; | 240 return false; |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 intptr_t StackFrame::GetTokenPos() const { | 244 intptr_t StackFrame::GetTokenPos() const { |
245 const Code& code = Code::Handle(LookupDartCode()); | 245 const Code& code = Code::Handle(LookupDartCode()); |
246 if (code.IsNull()) { | 246 if (code.IsNull()) { |
247 return -1; // Stub frames do not have token_pos. | 247 return -1; // Stub frames do not have token_pos. |
248 } | 248 } |
249 const PcDescriptors& descriptors = | 249 const PcDescriptors& descriptors = |
250 PcDescriptors::Handle(code.pc_descriptors()); | 250 PcDescriptors::Handle(code.pc_descriptors()); |
251 ASSERT(!descriptors.IsNull()); | 251 ASSERT(!descriptors.IsNull()); |
252 for (int i = 0; i < descriptors.Length(); i++) { | 252 PcDescriptors::Iterator iter(descriptors); |
253 if (static_cast<uword>(descriptors.PC(i)) == pc()) { | 253 while (iter.HasNext()) { |
254 return descriptors.TokenPos(i); | 254 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
| 255 if (rec.pc == pc()) { |
| 256 return rec.token_pos; |
255 } | 257 } |
256 } | 258 } |
257 return -1; | 259 return -1; |
258 } | 260 } |
259 | 261 |
260 | 262 |
261 | 263 |
262 bool StackFrame::IsValid() const { | 264 bool StackFrame::IsValid() const { |
263 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { | 265 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { |
264 return true; | 266 return true; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 484 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
483 return (index - num_materializations_); | 485 return (index - num_materializations_); |
484 } | 486 } |
485 } | 487 } |
486 UNREACHABLE(); | 488 UNREACHABLE(); |
487 return 0; | 489 return 0; |
488 } | 490 } |
489 | 491 |
490 | 492 |
491 } // namespace dart | 493 } // namespace dart |
OLD | NEW |