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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); | 212 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); |
213 handlers = code.exception_handlers(); | 213 handlers = code.exception_handlers(); |
214 if (handlers.Length() == 0) { | 214 if (handlers.Length() == 0) { |
215 return false; | 215 return false; |
216 } | 216 } |
217 | 217 |
218 // Find pc descriptor for the current pc. | 218 // Find pc descriptor for the current pc. |
219 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); | 219 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); |
220 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); | 220 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); |
221 descriptors = code.pc_descriptors(); | 221 descriptors = code.pc_descriptors(); |
222 const intptr_t len = descriptors.Length(); | 222 PcDescriptors::Iterator iter(descriptors); |
223 for (intptr_t i = 0; i < len; i++) { | 223 while (iter.HasNext()) { |
224 if ((static_cast<uword>(descriptors.PC(i)) == pc()) && | 224 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
225 (descriptors.TryIndex(i) != -1)) { | 225 if ((rec.pc == pc()) && (rec.try_index != -1)) { |
226 const intptr_t try_index = descriptors.TryIndex(i); | 226 const intptr_t try_index = rec.try_index; |
227 RawExceptionHandlers::HandlerInfo handler_info; | 227 RawExceptionHandlers::HandlerInfo handler_info; |
228 handlers.GetHandlerInfo(try_index, &handler_info); | 228 handlers.GetHandlerInfo(try_index, &handler_info); |
229 *handler_pc = handler_info.handler_pc; | 229 *handler_pc = handler_info.handler_pc; |
230 *needs_stacktrace = handler_info.needs_stacktrace; | 230 *needs_stacktrace = handler_info.needs_stacktrace; |
231 *has_catch_all = handler_info.has_catch_all; | 231 *has_catch_all = handler_info.has_catch_all; |
232 return true; | 232 return true; |
233 } | 233 } |
234 } | 234 } |
235 return false; | 235 return false; |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 intptr_t StackFrame::GetTokenPos() const { | 239 intptr_t StackFrame::GetTokenPos() const { |
240 const Code& code = Code::Handle(LookupDartCode()); | 240 const Code& code = Code::Handle(LookupDartCode()); |
241 if (code.IsNull()) { | 241 if (code.IsNull()) { |
242 return -1; // Stub frames do not have token_pos. | 242 return -1; // Stub frames do not have token_pos. |
243 } | 243 } |
244 const PcDescriptors& descriptors = | 244 const PcDescriptors& descriptors = |
245 PcDescriptors::Handle(code.pc_descriptors()); | 245 PcDescriptors::Handle(code.pc_descriptors()); |
246 ASSERT(!descriptors.IsNull()); | 246 ASSERT(!descriptors.IsNull()); |
247 for (int i = 0; i < descriptors.Length(); i++) { | 247 PcDescriptors::Iterator iter(descriptors); |
248 if (static_cast<uword>(descriptors.PC(i)) == pc()) { | 248 while (iter.HasNext()) { |
249 return descriptors.TokenPos(i); | 249 const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); |
| 250 if (rec.pc == pc()) { |
| 251 return rec.token_pos; |
250 } | 252 } |
251 } | 253 } |
252 return -1; | 254 return -1; |
253 } | 255 } |
254 | 256 |
255 | 257 |
256 | 258 |
257 bool StackFrame::IsValid() const { | 259 bool StackFrame::IsValid() const { |
258 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { | 260 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { |
259 return true; | 261 return true; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 458 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
457 return (index - num_materializations_); | 459 return (index - num_materializations_); |
458 } | 460 } |
459 } | 461 } |
460 UNREACHABLE(); | 462 UNREACHABLE(); |
461 return 0; | 463 return 0; |
462 } | 464 } |
463 | 465 |
464 | 466 |
465 } // namespace dart | 467 } // namespace dart |
OLD | NEW |