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" |
11 #include "vm/object.h" | 11 #include "vm/object.h" |
12 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
13 #include "vm/os.h" | 13 #include "vm/os.h" |
14 #include "vm/parser.h" | 14 #include "vm/parser.h" |
15 #include "vm/raw_object.h" | 15 #include "vm/raw_object.h" |
16 #include "vm/reusable_handles.h" | 16 #include "vm/reusable_handles.h" |
17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
18 #include "vm/visitor.h" | 18 #include "vm/visitor.h" |
19 | 19 |
20 namespace dart { | 20 namespace dart { |
21 | 21 |
22 | 22 |
23 bool StackFrame::IsStubFrame() const { | 23 bool StackFrame::IsStubFrame() const { |
24 ASSERT(!(IsEntryFrame() || IsExitFrame())); | 24 ASSERT(!(IsEntryFrame() || IsExitFrame())); |
25 uword saved_pc = | 25 return (LookupDartCode() == Code::null()); |
26 *(reinterpret_cast<uword*>(fp() + (kPcMarkerSlotFromFp * kWordSize))); | |
27 return (saved_pc == 0); | |
28 } | 26 } |
29 | 27 |
30 | 28 |
31 const char* StackFrame::ToCString() const { | 29 const char* StackFrame::ToCString() const { |
32 ASSERT(isolate_ == Isolate::Current()); | 30 ASSERT(isolate_ == Isolate::Current()); |
33 Zone* zone = Thread::Current()->zone(); | 31 Zone* zone = Thread::Current()->zone(); |
34 if (IsDartFrame()) { | 32 if (IsDartFrame()) { |
35 const Code& code = Code::Handle(LookupDartCode()); | 33 const Code& code = Code::Handle(LookupDartCode()); |
36 ASSERT(!code.IsNull()); | 34 ASSERT(!code.IsNull()); |
37 const Object& owner = Object::Handle(code.owner()); | 35 const Object& owner = Object::Handle(code.owner()); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 166 } |
169 | 167 |
170 | 168 |
171 RawCode* StackFrame::LookupDartCode() const { | 169 RawCode* StackFrame::LookupDartCode() const { |
172 ASSERT(isolate_ == Isolate::Current()); | 170 ASSERT(isolate_ == Isolate::Current()); |
173 // We add a no gc scope to ensure that the code below does not trigger | 171 // We add a no gc scope to ensure that the code below does not trigger |
174 // a GC as we are handling raw object references here. It is possible | 172 // a GC as we are handling raw object references here. It is possible |
175 // that the code is called while a GC is in progress, that is ok. | 173 // that the code is called while a GC is in progress, that is ok. |
176 NoSafepointScope no_safepoint; | 174 NoSafepointScope no_safepoint; |
177 RawCode* code = GetCodeObject(); | 175 RawCode* code = GetCodeObject(); |
178 ASSERT(code == Code::null() || code->ptr()->owner_ != Function::null()); | 176 if ((code != Code::null()) && |
179 return code; | 177 (code->ptr()->owner_->GetClassId() == kFunctionCid)) { |
| 178 return code; |
| 179 } |
| 180 return Code::null(); |
180 } | 181 } |
181 | 182 |
182 | 183 |
183 RawCode* StackFrame::GetCodeObject() const { | 184 RawCode* StackFrame::GetCodeObject() const { |
184 // We add a no gc scope to ensure that the code below does not trigger | 185 // We add a no gc scope to ensure that the code below does not trigger |
185 // a GC as we are handling raw object references here. It is possible | 186 // a GC as we are handling raw object references here. It is possible |
186 // that the code is called while a GC is in progress, that is ok. | 187 // that the code is called while a GC is in progress, that is ok. |
187 NoSafepointScope no_safepoint; | 188 NoSafepointScope no_safepoint; |
188 const uword pc_marker = | 189 const uword pc_marker = |
189 *(reinterpret_cast<uword*>(fp() + (kPcMarkerSlotFromFp * kWordSize))); | 190 *(reinterpret_cast<uword*>(fp() + (kPcMarkerSlotFromFp * kWordSize))); |
190 if (pc_marker != 0) { | 191 if (pc_marker != 0) { |
191 const uword entry_point = | 192 ASSERT(reinterpret_cast<RawObject*>(pc_marker)->GetClassId() == kCodeCid); |
192 (pc_marker - Assembler::EntryPointToPcMarkerOffset()); | 193 return reinterpret_cast<RawCode*>(pc_marker); |
193 RawInstructions* instr = Instructions::FromEntryPoint(entry_point); | |
194 if (instr != Instructions::null()) { | |
195 return instr->ptr()->code_; | |
196 } | |
197 } | 194 } |
198 return Code::null(); | 195 return Code::null(); |
199 } | 196 } |
200 | 197 |
201 | 198 |
202 bool StackFrame::FindExceptionHandler(Isolate* isolate, | 199 bool StackFrame::FindExceptionHandler(Isolate* isolate, |
203 uword* handler_pc, | 200 uword* handler_pc, |
204 bool* needs_stacktrace, | 201 bool* needs_stacktrace, |
205 bool* has_catch_all) const { | 202 bool* has_catch_all) const { |
206 REUSABLE_CODE_HANDLESCOPE(isolate); | 203 REUSABLE_CODE_HANDLESCOPE(isolate); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 489 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
493 return (index - num_materializations_); | 490 return (index - num_materializations_); |
494 } | 491 } |
495 } | 492 } |
496 UNREACHABLE(); | 493 UNREACHABLE(); |
497 return 0; | 494 return 0; |
498 } | 495 } |
499 | 496 |
500 | 497 |
501 } // namespace dart | 498 } // namespace dart |
OLD | NEW |