Chromium Code Reviews| Index: vm/stack_frame.cc |
| =================================================================== |
| --- vm/stack_frame.cc (revision 7576) |
| +++ vm/stack_frame.cc (working copy) |
| @@ -4,6 +4,7 @@ |
| #include "vm/stack_frame.h" |
| +#include "vm/assembler_macros.h" |
| #include "vm/isolate.h" |
| #include "vm/object.h" |
| #include "vm/object_store.h" |
| @@ -14,19 +15,11 @@ |
| namespace dart { |
| -bool StackFrame::FindRawCodeVisitor::FindObject(RawObject* obj) { |
| - return RawInstructions::ContainsPC(obj, pc_); |
| -} |
| - |
| bool StackFrame::IsStubFrame() const { |
| - if (Dart::vm_isolate()->heap()->StubCodeContains(pc())) { |
| - return true; // Common stub code is generated in the VM heap. |
| - } |
| - if (Isolate::Current()->heap()->StubCodeContains(pc())) { |
| - return true; // Common stub code is generated in the VM heap. |
| - } |
| - return false; |
| + ASSERT(!(IsEntryFrame() || IsExitFrame())); |
| + uword saved_pc = *(reinterpret_cast<uword*>(fp() - kWordSize)); |
| + return (saved_pc == 0); |
| } |
| @@ -35,24 +28,6 @@ |
| } |
| -RawCode* StackFrame::LookupCode(Isolate* isolate, uword pc) { |
| - // TODO(asiva): Need to add a data structure for storing a (pc, code |
| - // object) map in order to do a quick lookup and avoid having to |
| - // traverse the code heap. |
| - ASSERT(isolate != NULL); |
| - // We add a no gc scope to ensure that the code below does not trigger |
| - // a GC as we are handling raw object references here. It is possible |
| - // that the code is called while a GC is in progress, that is ok. |
| - NoGCScope no_gc; |
| - FindRawCodeVisitor visitor(pc); |
| - RawInstructions* instr = isolate->heap()->FindObjectInCodeSpace(&visitor); |
| - if (instr != Instructions::null()) { |
| - return instr->ptr()->code_; |
| - } |
| - return Code::null(); |
| -} |
| - |
| - |
| void ExitFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| // There are no objects to visit in this frame. |
| } |
| @@ -103,8 +78,9 @@ |
| // frame relies on tagged pointers and hence we visit each entry |
| // on the frame between SP and FP. |
| ASSERT(visitor != NULL); |
| - visitor->VisitPointers(reinterpret_cast<RawObject**>(sp()), |
| - reinterpret_cast<RawObject**>(fp() - kWordSize)); |
| + RawObject** start = reinterpret_cast<RawObject**>(sp()); |
| + RawObject** end = reinterpret_cast<RawObject**>(fp() - (2 * kWordSize)); |
|
regis
2012/05/14 17:33:10
Use defined constant instead of 2.
siva
2012/05/15 23:52:39
Done.
|
| + visitor->VisitPointers(start, end); |
| } |
| @@ -122,10 +98,25 @@ |
| // a GC as we are handling raw object references here. It is possible |
| // that the code is called while a GC is in progress, that is ok. |
| NoGCScope no_gc; |
| - Isolate* isolate = Isolate::Current(); |
| - RawCode* code = StackFrame::LookupCode(isolate, pc()); |
| - if ((code != Code::null()) && (code->ptr()->function_ != Function::null())) { |
| - return code; |
| + RawCode* code = GetCodeObject(); |
| + ASSERT(code == Code::null() || code->ptr()->function_ != Function::null()); |
| + return code; |
| +} |
| + |
| + |
| +RawCode* StackFrame::GetCodeObject() const { |
| + // We add a no gc scope to ensure that the code below does not trigger |
| + // a GC as we are handling raw object references here. It is possible |
| + // that the code is called while a GC is in progress, that is ok. |
| + NoGCScope no_gc; |
| + uword saved_pc = *(reinterpret_cast<uword*>(fp() - kWordSize)); |
| + if (saved_pc != 0) { |
| + uword entry_point = |
| + (saved_pc - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint); |
| + RawInstructions* instr = Instructions::FromEntryPoint(entry_point); |
| + if (instr != Instructions::null()) { |
| + return instr->ptr()->code_; |
| + } |
| } |
| return Code::null(); |
| } |
| @@ -168,7 +159,7 @@ |
| if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { |
| return true; |
| } |
| - return (StackFrame::LookupCode(Isolate::Current(), pc()) != Code::null()); |
| + return (LookupDartCode() != Code::null()); |
| } |