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 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 | 22 |
23 bool StackFrame::IsStubFrame() const { | 23 bool StackFrame::IsStubFrame() const { |
24 ASSERT(!(IsEntryFrame() || IsExitFrame())); | 24 ASSERT(!(IsEntryFrame() || IsExitFrame())); |
25 #if !defined(TARGET_OS_WINDOWS) | 25 #if !defined(TARGET_OS_WINDOWS) |
26 // On Windows, the profiler calls this from a separate thread where | 26 // On Windows, the profiler calls this from a separate thread where |
27 // Thread::Current() is NULL, so we cannot create a NoSafepointScope. | 27 // Thread::Current() is NULL, so we cannot create a NoSafepointScope. |
28 NoSafepointScope no_safepoint; | 28 NoSafepointScope no_safepoint; |
29 #endif | 29 #endif |
30 RawCode* code = GetCodeObject(); | 30 RawCode* code = GetCodeObject(); |
31 ASSERT(code != Object::null()); | |
31 const intptr_t cid = code->ptr()->owner_->GetClassId(); | 32 const intptr_t cid = code->ptr()->owner_->GetClassId(); |
32 ASSERT(cid == kNullCid || cid == kClassCid || cid == kFunctionCid); | 33 ASSERT(cid == kNullCid || cid == kClassCid || cid == kFunctionCid); |
33 return cid == kNullCid || cid == kClassCid; | 34 return cid == kNullCid || cid == kClassCid; |
34 } | 35 } |
35 | 36 |
36 | 37 |
37 const char* StackFrame::ToCString() const { | 38 const char* StackFrame::ToCString() const { |
38 ASSERT(thread_ == Thread::Current()); | 39 ASSERT(thread_ == Thread::Current()); |
39 Zone* zone = Thread::Current()->zone(); | 40 Zone* zone = Thread::Current()->zone(); |
40 if (IsDartFrame()) { | 41 if (IsDartFrame()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 if (!code.IsNull()) { | 94 if (!code.IsNull()) { |
94 // Visit the code object. | 95 // Visit the code object. |
95 RawObject* raw_code = code.raw(); | 96 RawObject* raw_code = code.raw(); |
96 visitor->VisitPointer(&raw_code); | 97 visitor->VisitPointer(&raw_code); |
97 | 98 |
98 // Optimized frames have a stack map. We need to visit the frame based | 99 // Optimized frames have a stack map. We need to visit the frame based |
99 // on the stack map. | 100 // on the stack map. |
100 Array maps; | 101 Array maps; |
101 maps = Array::null(); | 102 maps = Array::null(); |
102 Stackmap map; | 103 Stackmap map; |
103 const uword entry = reinterpret_cast<uword>(code.instructions()->ptr()) + | 104 const uword entry = code.EntryPoint(); |
104 Instructions::HeaderSize(); | |
105 map = code.GetStackmap(pc() - entry, &maps, &map); | 105 map = code.GetStackmap(pc() - entry, &maps, &map); |
106 if (!map.IsNull()) { | 106 if (!map.IsNull()) { |
107 RawObject** first = reinterpret_cast<RawObject**>(sp()); | 107 RawObject** first = reinterpret_cast<RawObject**>(sp()); |
108 RawObject** last = reinterpret_cast<RawObject**>( | 108 RawObject** last = reinterpret_cast<RawObject**>( |
109 fp() + (kFirstLocalSlotFromFp * kWordSize)); | 109 fp() + (kFirstLocalSlotFromFp * kWordSize)); |
110 | 110 |
111 // A stack map is present in the code object, use the stack map to | 111 // A stack map is present in the code object, use the stack map to |
112 // visit frame slots which are marked as having objects. | 112 // visit frame slots which are marked as having objects. |
113 // | 113 // |
114 // The layout of the frame is (lower addresses to the right): | 114 // The layout of the frame is (lower addresses to the right): |
(...skipping 28 matching lines...) Expand all Loading... | |
143 visitor->VisitPointers(first, last); | 143 visitor->VisitPointers(first, last); |
144 | 144 |
145 // Now visit other slots which might be part of the calling convention. | 145 // Now visit other slots which might be part of the calling convention. |
146 first = reinterpret_cast<RawObject**>( | 146 first = reinterpret_cast<RawObject**>( |
147 fp() + ((kFirstLocalSlotFromFp + 1) * kWordSize)); | 147 fp() + ((kFirstLocalSlotFromFp + 1) * kWordSize)); |
148 last = reinterpret_cast<RawObject**>( | 148 last = reinterpret_cast<RawObject**>( |
149 fp() + (kFirstObjectSlotFromFp * kWordSize)); | 149 fp() + (kFirstObjectSlotFromFp * kWordSize)); |
150 visitor->VisitPointers(first, last); | 150 visitor->VisitPointers(first, last); |
151 return; | 151 return; |
152 } | 152 } |
153 | |
154 // No stack map, fall through. | |
153 } | 155 } |
154 // For normal unoptimized Dart frames and Stub frames each slot | 156 // For normal unoptimized Dart frames and Stub frames each slot |
155 // between the first and last included are tagged objects. | 157 // between the first and last included are tagged objects. |
156 RawObject** first = reinterpret_cast<RawObject**>(sp()); | 158 RawObject** first = reinterpret_cast<RawObject**>(sp()); |
157 RawObject** last = reinterpret_cast<RawObject**>( | 159 RawObject** last = reinterpret_cast<RawObject**>( |
158 fp() + (kFirstObjectSlotFromFp * kWordSize)); | 160 fp() + (kFirstObjectSlotFromFp * kWordSize)); |
159 visitor->VisitPointers(first, last); | 161 visitor->VisitPointers(first, last); |
160 } | 162 } |
161 | 163 |
162 | 164 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 current_frame_ = NULL; // No more frames. | 375 current_frame_ = NULL; // No more frames. |
374 return current_frame_; | 376 return current_frame_; |
375 } | 377 } |
376 ASSERT(current_frame_->IsExitFrame() || | 378 ASSERT(current_frame_->IsExitFrame() || |
377 current_frame_->IsDartFrame(validate_) || | 379 current_frame_->IsDartFrame(validate_) || |
378 current_frame_->IsStubFrame()); | 380 current_frame_->IsStubFrame()); |
379 | 381 |
380 // Consume dart/stub frames using StackFrameIterator::FrameSetIterator | 382 // Consume dart/stub frames using StackFrameIterator::FrameSetIterator |
381 // until we are out of dart/stub frames at which point we return the | 383 // until we are out of dart/stub frames at which point we return the |
382 // corresponding entry frame for that set of dart/stub frames. | 384 // corresponding entry frame for that set of dart/stub frames. |
383 current_frame_ = | 385 if (frames_.HasNext()) { |
384 (frames_.HasNext()) ? frames_.NextFrame(validate_) : NextEntryFrame(); | 386 current_frame_ = frames_.NextFrame(validate_); |
Florian Schneider
2016/03/28 22:15:47
What's wrong with using the conditional expression
rmacnak
2016/03/28 23:56:45
Nothing, I had print here debugger earlier. Undone
| |
387 } else { | |
388 current_frame_ = NextEntryFrame(); | |
389 } | |
385 return current_frame_; | 390 return current_frame_; |
386 } | 391 } |
387 | 392 |
388 | 393 |
389 StackFrame* StackFrameIterator::FrameSetIterator::NextFrame(bool validate) { | 394 StackFrame* StackFrameIterator::FrameSetIterator::NextFrame(bool validate) { |
390 StackFrame* frame; | 395 StackFrame* frame; |
391 ASSERT(HasNext()); | 396 ASSERT(HasNext()); |
392 frame = &stack_frame_; | 397 frame = &stack_frame_; |
393 frame->sp_ = sp_; | 398 frame->sp_ = sp_; |
394 frame->fp_ = fp_; | 399 frame->fp_ = fp_; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 495 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
491 return (index - num_materializations_); | 496 return (index - num_materializations_); |
492 } | 497 } |
493 } | 498 } |
494 UNREACHABLE(); | 499 UNREACHABLE(); |
495 return 0; | 500 return 0; |
496 } | 501 } |
497 | 502 |
498 | 503 |
499 } // namespace dart | 504 } // namespace dart |
OLD | NEW |