| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_STACK_FRAME_H_ | 5 #ifndef VM_STACK_FRAME_H_ |
| 6 #define VM_STACK_FRAME_H_ | 6 #define VM_STACK_FRAME_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/stub_code.h" | 10 #include "vm/stub_code.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 uword sp() const { return sp_; } | 24 uword sp() const { return sp_; } |
| 25 uword fp() const { return fp_; } | 25 uword fp() const { return fp_; } |
| 26 uword pc() const { | 26 uword pc() const { |
| 27 return *reinterpret_cast<uword*>(sp_ + PcAddressOffsetFromSp()); | 27 return *reinterpret_cast<uword*>(sp_ + PcAddressOffsetFromSp()); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void set_pc(uword value) { | 30 void set_pc(uword value) { |
| 31 *reinterpret_cast<uword*>(sp_ + PcAddressOffsetFromSp()) = value; | 31 *reinterpret_cast<uword*>(sp_ + PcAddressOffsetFromSp()) = value; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void SetEntrypointMarker(uword value) { |
| 35 ASSERT(!(IsStubFrame() || IsEntryFrame() || IsExitFrame())); |
| 36 *reinterpret_cast<uword*>(fp_ - kWordSize) = value; |
| 37 } |
| 38 |
| 34 // Visit objects in the frame. | 39 // Visit objects in the frame. |
| 35 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); | 40 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 36 | 41 |
| 37 // Print a frame. | 42 // Print a frame. |
| 38 virtual void Print() const; | 43 virtual void Print() const; |
| 39 | 44 |
| 40 // Check validity of a frame, used for assertion purposes. | 45 // Check validity of a frame, used for assertion purposes. |
| 41 virtual bool IsValid() const; | 46 virtual bool IsValid() const; |
| 42 | 47 |
| 43 // Frame type. | 48 // Frame type. |
| 44 virtual bool IsDartFrame() const { | 49 virtual bool IsDartFrame() const { |
| 45 ASSERT(IsValid()); | 50 ASSERT(IsValid()); |
| 46 return !(IsStubFrame() || IsEntryFrame() || IsExitFrame()); | 51 return !(IsEntryFrame() || IsExitFrame() || IsStubFrame()); |
| 47 } | 52 } |
| 48 virtual bool IsStubFrame() const; | 53 virtual bool IsStubFrame() const; |
| 49 virtual bool IsEntryFrame() const { return false; } | 54 virtual bool IsEntryFrame() const { return false; } |
| 50 virtual bool IsExitFrame() const { return false; } | 55 virtual bool IsExitFrame() const { return false; } |
| 51 | 56 |
| 52 RawFunction* LookupDartFunction() const; | 57 RawFunction* LookupDartFunction() const; |
| 53 RawCode* LookupDartCode() const; | 58 RawCode* LookupDartCode() const; |
| 54 bool FindExceptionHandler(uword* handler_pc) const; | 59 bool FindExceptionHandler(uword* handler_pc) const; |
| 55 | 60 |
| 56 // Find code object corresponding to pc (only frames running dart code or | |
| 57 // stub code will have a code object associated with them). | |
| 58 static RawCode* LookupCode(Isolate* isolate, uword pc); | |
| 59 | |
| 60 protected: | 61 protected: |
| 61 StackFrame() : fp_(0), sp_(0) { } | 62 StackFrame() : fp_(0), sp_(0) { } |
| 62 | 63 |
| 63 // Name of the frame, used for generic frame printing functionality. | 64 // Name of the frame, used for generic frame printing functionality. |
| 64 virtual const char* GetName() const { return IsStubFrame()? "stub" : "dart"; } | 65 virtual const char* GetName() const { return IsStubFrame()? "stub" : "dart"; } |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 // An object finder visitor interface. | 68 RawCode* GetCodeObject() const; |
| 68 class FindRawCodeVisitor : public FindObjectVisitor { | |
| 69 public: | |
| 70 explicit FindRawCodeVisitor(uword pc) : pc_(pc) { } | |
| 71 virtual ~FindRawCodeVisitor() { } | |
| 72 | |
| 73 // Check if object matches find condition. | |
| 74 virtual bool FindObject(RawObject* obj); | |
| 75 | |
| 76 private: | |
| 77 uword pc_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor); | |
| 80 }; | |
| 81 | 69 |
| 82 // Target specific implementations for locating pc and caller fp/sp values. | 70 // Target specific implementations for locating pc and caller fp/sp values. |
| 83 static intptr_t PcAddressOffsetFromSp(); | 71 static intptr_t PcAddressOffsetFromSp(); |
| 84 uword GetCallerSp() const; | 72 uword GetCallerSp() const; |
| 85 uword GetCallerFp() const; | 73 uword GetCallerFp() const; |
| 86 | 74 |
| 87 uword fp_; | 75 uword fp_; |
| 88 uword sp_; | 76 uword sp_; |
| 89 | 77 |
| 90 // The iterators FrameSetIterator and StackFrameIterator set the private | 78 // The iterators FrameSetIterator and StackFrameIterator set the private |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 216 |
| 229 private: | 217 private: |
| 230 StackFrameIterator frames_; | 218 StackFrameIterator frames_; |
| 231 | 219 |
| 232 DISALLOW_COPY_AND_ASSIGN(DartFrameIterator); | 220 DISALLOW_COPY_AND_ASSIGN(DartFrameIterator); |
| 233 }; | 221 }; |
| 234 | 222 |
| 235 } // namespace dart | 223 } // namespace dart |
| 236 | 224 |
| 237 #endif // VM_STACK_FRAME_H_ | 225 #endif // VM_STACK_FRAME_H_ |
| OLD | NEW |