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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (!code.IsNull()) { | 101 if (!code.IsNull()) { |
102 // Visit the code object. | 102 // Visit the code object. |
103 RawObject* raw_code = code.raw(); | 103 RawObject* raw_code = code.raw(); |
104 visitor->VisitPointer(&raw_code); | 104 visitor->VisitPointer(&raw_code); |
105 | 105 |
106 // Optimized frames have a stack map. We need to visit the frame based | 106 // Optimized frames have a stack map. We need to visit the frame based |
107 // on the stack map. | 107 // on the stack map. |
108 Array maps; | 108 Array maps; |
109 maps = Array::null(); | 109 maps = Array::null(); |
110 Stackmap map; | 110 Stackmap map; |
111 const uword entry = reinterpret_cast<uword>(code.instructions()->ptr()) + | 111 const uword start = Instructions::PayloadStart(code.instructions()); |
112 Instructions::HeaderSize(); | 112 map = code.GetStackmap(pc() - start, &maps, &map); |
113 map = code.GetStackmap(pc() - entry, &maps, &map); | |
114 if (!map.IsNull()) { | 113 if (!map.IsNull()) { |
115 #if !defined(TARGET_ARCH_DBC) | 114 #if !defined(TARGET_ARCH_DBC) |
116 RawObject** first = reinterpret_cast<RawObject**>(sp()); | 115 RawObject** first = reinterpret_cast<RawObject**>(sp()); |
117 RawObject** last = reinterpret_cast<RawObject**>( | 116 RawObject** last = reinterpret_cast<RawObject**>( |
118 fp() + (kFirstLocalSlotFromFp * kWordSize)); | 117 fp() + (kFirstLocalSlotFromFp * kWordSize)); |
119 | 118 |
120 // A stack map is present in the code object, use the stack map to | 119 // A stack map is present in the code object, use the stack map to |
121 // visit frame slots which are marked as having objects. | 120 // visit frame slots which are marked as having objects. |
122 // | 121 // |
123 // The layout of the frame is (lower addresses to the right): | 122 // The layout of the frame is (lower addresses to the right): |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 bool StackFrame::FindExceptionHandler(Thread* thread, | 252 bool StackFrame::FindExceptionHandler(Thread* thread, |
254 uword* handler_pc, | 253 uword* handler_pc, |
255 bool* needs_stacktrace, | 254 bool* needs_stacktrace, |
256 bool* has_catch_all) const { | 255 bool* has_catch_all) const { |
257 REUSABLE_CODE_HANDLESCOPE(thread); | 256 REUSABLE_CODE_HANDLESCOPE(thread); |
258 Code& code = reused_code_handle.Handle(); | 257 Code& code = reused_code_handle.Handle(); |
259 code = LookupDartCode(); | 258 code = LookupDartCode(); |
260 if (code.IsNull()) { | 259 if (code.IsNull()) { |
261 return false; // Stub frames do not have exception handlers. | 260 return false; // Stub frames do not have exception handlers. |
262 } | 261 } |
263 uword pc_offset = pc() - code.EntryPoint(); | 262 uword pc_offset = pc() - code.PayloadStart(); |
264 | 263 |
265 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(thread); | 264 REUSABLE_EXCEPTION_HANDLERS_HANDLESCOPE(thread); |
266 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); | 265 ExceptionHandlers& handlers = reused_exception_handlers_handle.Handle(); |
267 handlers = code.exception_handlers(); | 266 handlers = code.exception_handlers(); |
268 if (handlers.num_entries() == 0) { | 267 if (handlers.num_entries() == 0) { |
269 return false; | 268 return false; |
270 } | 269 } |
271 | 270 |
272 // Find pc descriptor for the current pc. | 271 // Find pc descriptor for the current pc. |
273 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(thread); | 272 REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(thread); |
274 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); | 273 PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); |
275 descriptors = code.pc_descriptors(); | 274 descriptors = code.pc_descriptors(); |
276 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 275 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
277 while (iter.MoveNext()) { | 276 while (iter.MoveNext()) { |
278 const intptr_t current_try_index = iter.TryIndex(); | 277 const intptr_t current_try_index = iter.TryIndex(); |
279 if ((iter.PcOffset() == pc_offset) && (current_try_index != -1)) { | 278 if ((iter.PcOffset() == pc_offset) && (current_try_index != -1)) { |
280 RawExceptionHandlers::HandlerInfo handler_info; | 279 RawExceptionHandlers::HandlerInfo handler_info; |
281 handlers.GetHandlerInfo(current_try_index, &handler_info); | 280 handlers.GetHandlerInfo(current_try_index, &handler_info); |
282 *handler_pc = code.EntryPoint() + handler_info.handler_pc_offset; | 281 *handler_pc = code.PayloadStart() + handler_info.handler_pc_offset; |
283 *needs_stacktrace = handler_info.needs_stacktrace; | 282 *needs_stacktrace = handler_info.needs_stacktrace; |
284 *has_catch_all = handler_info.has_catch_all; | 283 *has_catch_all = handler_info.has_catch_all; |
285 return true; | 284 return true; |
286 } | 285 } |
287 } | 286 } |
288 return false; | 287 return false; |
289 } | 288 } |
290 | 289 |
291 | 290 |
292 TokenPosition StackFrame::GetTokenPos() const { | 291 TokenPosition StackFrame::GetTokenPos() const { |
293 const Code& code = Code::Handle(LookupDartCode()); | 292 const Code& code = Code::Handle(LookupDartCode()); |
294 if (code.IsNull()) { | 293 if (code.IsNull()) { |
295 return TokenPosition::kNoSource; // Stub frames do not have token_pos. | 294 return TokenPosition::kNoSource; // Stub frames do not have token_pos. |
296 } | 295 } |
297 uword pc_offset = pc() - code.EntryPoint(); | 296 uword pc_offset = pc() - code.PayloadStart(); |
298 const PcDescriptors& descriptors = | 297 const PcDescriptors& descriptors = |
299 PcDescriptors::Handle(code.pc_descriptors()); | 298 PcDescriptors::Handle(code.pc_descriptors()); |
300 ASSERT(!descriptors.IsNull()); | 299 ASSERT(!descriptors.IsNull()); |
301 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 300 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
302 while (iter.MoveNext()) { | 301 while (iter.MoveNext()) { |
303 if (iter.PcOffset() == pc_offset) { | 302 if (iter.PcOffset() == pc_offset) { |
304 return TokenPosition(iter.TokenPos()); | 303 return TokenPosition(iter.TokenPos()); |
305 } | 304 } |
306 } | 305 } |
307 return TokenPosition::kNoSource; | 306 return TokenPosition::kNoSource; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 return (index - num_materializations_); | 560 return (index - num_materializations_); |
562 #endif | 561 #endif |
563 } | 562 } |
564 } | 563 } |
565 UNREACHABLE(); | 564 UNREACHABLE(); |
566 return 0; | 565 return 0; |
567 } | 566 } |
568 | 567 |
569 | 568 |
570 } // namespace dart | 569 } // namespace dart |
OLD | NEW |