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