| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 | 30 |
| 31 // Generic stack frame. | 31 // Generic stack frame. |
| 32 class StackFrame : public ValueObject { | 32 class StackFrame : public ValueObject { |
| 33 public: | 33 public: |
| 34 virtual ~StackFrame() { } | 34 virtual ~StackFrame() { } |
| 35 | 35 |
| 36 // Accessors to get the pc, sp and fp of a frame. | 36 // Accessors to get the pc, sp and fp of a frame. |
| 37 uword sp() const { return sp_; } | 37 uword sp() const { return sp_; } |
| 38 uword fp() const { return fp_; } | 38 uword fp() const { return fp_; } |
| 39 uword pc() const { | 39 uword pc() const { return pc_; } |
| 40 return *reinterpret_cast<uword*>(sp_ + (kSavedPcSlotFromSp * kWordSize)); | |
| 41 } | |
| 42 | 40 |
| 43 // The pool pointer is not implemented on all architectures. | 41 // The pool pointer is not implemented on all architectures. |
| 44 static int SavedCallerPpSlotFromFp() { | 42 static int SavedCallerPpSlotFromFp() { |
| 45 if (kSavedCallerPpSlotFromFp != kSavedCallerFpSlotFromFp) { | 43 if (kSavedCallerPpSlotFromFp != kSavedCallerFpSlotFromFp) { |
| 46 return kSavedCallerPpSlotFromFp; | 44 return kSavedCallerPpSlotFromFp; |
| 47 } | 45 } |
| 48 UNREACHABLE(); | 46 UNREACHABLE(); |
| 49 return 0; | 47 return 0; |
| 50 } | 48 } |
| 51 | 49 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 72 virtual bool IsExitFrame() const { return false; } | 70 virtual bool IsExitFrame() const { return false; } |
| 73 | 71 |
| 74 RawFunction* LookupDartFunction() const; | 72 RawFunction* LookupDartFunction() const; |
| 75 RawCode* LookupDartCode() const; | 73 RawCode* LookupDartCode() const; |
| 76 bool FindExceptionHandler(uword* handler_pc) const; | 74 bool FindExceptionHandler(uword* handler_pc) const; |
| 77 // Returns token_pos of the pc(), or -1 if none exists. | 75 // Returns token_pos of the pc(), or -1 if none exists. |
| 78 intptr_t GetTokenPos() const; | 76 intptr_t GetTokenPos() const; |
| 79 | 77 |
| 80 | 78 |
| 81 protected: | 79 protected: |
| 82 StackFrame() : fp_(0), sp_(0) { } | 80 StackFrame() : fp_(0), sp_(0), pc_(0) { } |
| 83 | 81 |
| 84 // Name of the frame, used for generic frame printing functionality. | 82 // Name of the frame, used for generic frame printing functionality. |
| 85 virtual const char* GetName() const { return IsStubFrame()? "stub" : "dart"; } | 83 virtual const char* GetName() const { return IsStubFrame()? "stub" : "dart"; } |
| 86 | 84 |
| 87 private: | 85 private: |
| 88 RawCode* GetCodeObject() const; | 86 RawCode* GetCodeObject() const; |
| 89 | 87 |
| 90 uword GetCallerSp() const { | 88 uword GetCallerSp() const { |
| 91 return fp() + (kCallerSpSlotFromFp * kWordSize); | 89 return fp() + (kCallerSpSlotFromFp * kWordSize); |
| 92 } | 90 } |
| 93 uword GetCallerFp() const { | 91 uword GetCallerFp() const { |
| 94 return *(reinterpret_cast<uword*>( | 92 return *(reinterpret_cast<uword*>( |
| 95 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); | 93 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); |
| 96 } | 94 } |
| 95 uword GetCallerPc() const { |
| 96 return *(reinterpret_cast<uword*>( |
| 97 fp() + (kSavedCallerPcSlotFromFp * kWordSize))); |
| 98 } |
| 97 | 99 |
| 98 uword fp_; | 100 uword fp_; |
| 99 uword sp_; | 101 uword sp_; |
| 102 uword pc_; |
| 100 | 103 |
| 101 // The iterators FrameSetIterator and StackFrameIterator set the private | 104 // The iterators FrameSetIterator and StackFrameIterator set the private |
| 102 // fields fp_ and sp_ when they return the respective frame objects. | 105 // fields fp_ and sp_ when they return the respective frame objects. |
| 103 friend class FrameSetIterator; | 106 friend class FrameSetIterator; |
| 104 friend class StackFrameIterator; | 107 friend class StackFrameIterator; |
| 105 DISALLOW_COPY_AND_ASSIGN(StackFrame); | 108 DISALLOW_COPY_AND_ASSIGN(StackFrame); |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 | 111 |
| 109 // Exit frame is used to mark the transition from dart code into dart VM | 112 // Exit frame is used to mark the transition from dart code into dart VM |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 virtual const char* GetName() const { return "entry"; } | 150 virtual const char* GetName() const { return "entry"; } |
| 148 | 151 |
| 149 private: | 152 private: |
| 150 EntryFrame() { } | 153 EntryFrame() { } |
| 151 | 154 |
| 152 friend class StackFrameIterator; | 155 friend class StackFrameIterator; |
| 153 DISALLOW_COPY_AND_ASSIGN(EntryFrame); | 156 DISALLOW_COPY_AND_ASSIGN(EntryFrame); |
| 154 }; | 157 }; |
| 155 | 158 |
| 156 | 159 |
| 157 // Iterator for iterating over all frames from the last ExitFrame to the | |
| 158 // first EntryFrame. | |
| 159 class StackFrameIterator : public ValueObject { | 160 class StackFrameIterator : public ValueObject { |
| 160 public: | 161 public: |
| 161 static const bool kValidateFrames = true; | 162 static const bool kValidateFrames = true; |
| 162 static const bool kDontValidateFrames = false; | 163 static const bool kDontValidateFrames = false; |
| 163 | 164 |
| 165 // Iterators for iterating over all frames from the last ExitFrame to the |
| 166 // first EntryFrame. |
| 164 explicit StackFrameIterator(bool validate); | 167 explicit StackFrameIterator(bool validate); |
| 165 StackFrameIterator(uword last_fp, bool validate); | 168 StackFrameIterator(uword last_fp, bool validate); |
| 166 | 169 |
| 170 // Iterator for iterating over all frames from the current frame (given by its |
| 171 // fp, sp, and pc) to the first EntryFrame. |
| 172 StackFrameIterator(uword fp, uword sp, uword pc, bool validate); |
| 173 |
| 167 // Checks if a next frame exists. | 174 // Checks if a next frame exists. |
| 168 bool HasNextFrame() const { return frames_.fp_ != 0; } | 175 bool HasNextFrame() const { return frames_.fp_ != 0; } |
| 169 | 176 |
| 170 // Get next frame. | 177 // Get next frame. |
| 171 StackFrame* NextFrame(); | 178 StackFrame* NextFrame(); |
| 172 | 179 |
| 173 private: | 180 private: |
| 174 // Iterator for iterating over the set of frames (dart or stub) which exist | 181 // Iterator for iterating over the set of frames (dart or stub) which exist |
| 175 // in one EntryFrame and ExitFrame block. | 182 // in one EntryFrame and ExitFrame block. |
| 176 class FrameSetIterator : public ValueObject { | 183 class FrameSetIterator : public ValueObject { |
| 177 public: | 184 public: |
| 178 // Checks if a next non entry/exit frame exists in the set. | 185 // Checks if a next non entry/exit frame exists in the set. |
| 179 bool HasNext() const { | 186 bool HasNext() const { |
| 180 if (fp_ == 0) { | 187 if (fp_ == 0) { |
| 181 return false; | 188 return false; |
| 182 } | 189 } |
| 183 const uword pc = *(reinterpret_cast<uword*>( | 190 const uword pc = *(reinterpret_cast<uword*>( |
| 184 sp_ + (kSavedPcSlotFromSp * kWordSize))); | 191 sp_ + (kSavedPcSlotFromSp * kWordSize))); |
| 185 return !StubCode::InInvocationStub(pc); | 192 return !StubCode::InInvocationStub(pc); |
| 186 } | 193 } |
| 187 | 194 |
| 188 // Get next non entry/exit frame in the set (assumes a next frame exists). | 195 // Get next non entry/exit frame in the set (assumes a next frame exists). |
| 189 StackFrame* NextFrame(bool validate); | 196 StackFrame* NextFrame(bool validate); |
| 190 | 197 |
| 191 private: | 198 private: |
| 192 FrameSetIterator() : fp_(0), sp_(0), stack_frame_() { } | 199 FrameSetIterator() : fp_(0), sp_(0), pc_(0), stack_frame_() { } |
| 193 | 200 |
| 194 uword fp_; | 201 uword fp_; |
| 195 uword sp_; | 202 uword sp_; |
| 203 uword pc_; |
| 196 StackFrame stack_frame_; // Singleton frame returned by NextFrame(). | 204 StackFrame stack_frame_; // Singleton frame returned by NextFrame(). |
| 197 | 205 |
| 198 friend class StackFrameIterator; | 206 friend class StackFrameIterator; |
| 199 DISALLOW_COPY_AND_ASSIGN(FrameSetIterator); | 207 DISALLOW_COPY_AND_ASSIGN(FrameSetIterator); |
| 200 }; | 208 }; |
| 201 | 209 |
| 202 // Get next exit frame. | 210 // Get next exit frame. |
| 203 ExitFrame* NextExitFrame(); | 211 ExitFrame* NextExitFrame(); |
| 204 | 212 |
| 205 // Get next entry frame. | 213 // Get next entry frame. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 GrowableArray<DeoptInstr*> deopt_instructions_; | 290 GrowableArray<DeoptInstr*> deopt_instructions_; |
| 283 Array& object_table_; | 291 Array& object_table_; |
| 284 | 292 |
| 285 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); | 293 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); |
| 286 }; | 294 }; |
| 287 | 295 |
| 288 } // namespace dart | 296 } // namespace dart |
| 289 | 297 |
| 290 #endif // VM_STACK_FRAME_H_ | 298 #endif // VM_STACK_FRAME_H_ |
| 291 | 299 |
| OLD | NEW |