| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Visit objects in the frame. | 56 // Visit objects in the frame. |
| 57 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); | 57 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 58 | 58 |
| 59 const char* ToCString() const; | 59 const char* ToCString() const; |
| 60 | 60 |
| 61 // Check validity of a frame, used for assertion purposes. | 61 // Check validity of a frame, used for assertion purposes. |
| 62 virtual bool IsValid() const; | 62 virtual bool IsValid() const; |
| 63 | 63 |
| 64 // Frame type. | 64 // Frame type. |
| 65 virtual bool IsDartFrame() const { | 65 virtual bool IsDartFrame(bool validate = true) const { |
| 66 ASSERT(IsValid()); | 66 ASSERT(!validate || IsValid()); |
| 67 return !(IsEntryFrame() || IsExitFrame() || IsStubFrame()); | 67 return !(IsEntryFrame() || IsExitFrame() || IsStubFrame()); |
| 68 } | 68 } |
| 69 virtual bool IsStubFrame() const; | 69 virtual bool IsStubFrame() const; |
| 70 virtual bool IsEntryFrame() const { return false; } | 70 virtual bool IsEntryFrame() const { return false; } |
| 71 virtual bool IsExitFrame() const { return false; } | 71 virtual bool IsExitFrame() const { return false; } |
| 72 | 72 |
| 73 RawFunction* LookupDartFunction() const; | 73 RawFunction* LookupDartFunction() const; |
| 74 RawCode* LookupDartCode() const; | 74 RawCode* LookupDartCode() const; |
| 75 bool FindExceptionHandler(Isolate* isolate, | 75 bool FindExceptionHandler(Isolate* isolate, |
| 76 uword* handler_pc, | 76 uword* handler_pc, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 friend class StackFrameIterator; | 114 friend class StackFrameIterator; |
| 115 DISALLOW_COPY_AND_ASSIGN(StackFrame); | 115 DISALLOW_COPY_AND_ASSIGN(StackFrame); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 | 118 |
| 119 // Exit frame is used to mark the transition from dart code into dart VM | 119 // Exit frame is used to mark the transition from dart code into dart VM |
| 120 // runtime code. | 120 // runtime code. |
| 121 class ExitFrame : public StackFrame { | 121 class ExitFrame : public StackFrame { |
| 122 public: | 122 public: |
| 123 bool IsValid() const { return sp() == 0; } | 123 bool IsValid() const { return sp() == 0; } |
| 124 bool IsDartFrame() const { return false; } | 124 bool IsDartFrame(bool validate = true) const { return false; } |
| 125 bool IsStubFrame() const { return false; } | 125 bool IsStubFrame() const { return false; } |
| 126 bool IsExitFrame() const { return true; } | 126 bool IsExitFrame() const { return true; } |
| 127 | 127 |
| 128 // Visit objects in the frame. | 128 // Visit objects in the frame. |
| 129 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); | 129 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 130 | 130 |
| 131 protected: | 131 protected: |
| 132 virtual const char* GetName() const { return "exit"; } | 132 virtual const char* GetName() const { return "exit"; } |
| 133 | 133 |
| 134 private: | 134 private: |
| 135 explicit ExitFrame(Isolate* isolate) : StackFrame(isolate) { } | 135 explicit ExitFrame(Isolate* isolate) : StackFrame(isolate) { } |
| 136 | 136 |
| 137 friend class StackFrameIterator; | 137 friend class StackFrameIterator; |
| 138 DISALLOW_COPY_AND_ASSIGN(ExitFrame); | 138 DISALLOW_COPY_AND_ASSIGN(ExitFrame); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 | 141 |
| 142 // Entry Frame is used to mark the transition from dart VM runtime code into | 142 // Entry Frame is used to mark the transition from dart VM runtime code into |
| 143 // dart code. | 143 // dart code. |
| 144 class EntryFrame : public StackFrame { | 144 class EntryFrame : public StackFrame { |
| 145 public: | 145 public: |
| 146 bool IsValid() const { | 146 bool IsValid() const { |
| 147 return StubCode::InInvocationStubForIsolate(isolate(), pc()); | 147 return StubCode::InInvocationStubForIsolate(isolate(), pc()); |
| 148 } | 148 } |
| 149 bool IsDartFrame() const { return false; } | 149 bool IsDartFrame(bool validate = true) const { return false; } |
| 150 bool IsStubFrame() const { return false; } | 150 bool IsStubFrame() const { return false; } |
| 151 bool IsEntryFrame() const { return true; } | 151 bool IsEntryFrame() const { return true; } |
| 152 | 152 |
| 153 RawContext* SavedContext() const; | 153 RawContext* SavedContext() const; |
| 154 | 154 |
| 155 // Visit objects in the frame. | 155 // Visit objects in the frame. |
| 156 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); | 156 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 157 | 157 |
| 158 protected: | 158 protected: |
| 159 virtual const char* GetName() const { return "entry"; } | 159 virtual const char* GetName() const { return "entry"; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 187 // fp, sp, and pc) to the first EntryFrame. | 187 // fp, sp, and pc) to the first EntryFrame. |
| 188 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, | 188 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, |
| 189 Isolate* isolate = Isolate::Current()); | 189 Isolate* isolate = Isolate::Current()); |
| 190 | 190 |
| 191 // Checks if a next frame exists. | 191 // Checks if a next frame exists. |
| 192 bool HasNextFrame() const { return frames_.fp_ != 0; } | 192 bool HasNextFrame() const { return frames_.fp_ != 0; } |
| 193 | 193 |
| 194 // Get next frame. | 194 // Get next frame. |
| 195 StackFrame* NextFrame(); | 195 StackFrame* NextFrame(); |
| 196 | 196 |
| 197 bool validate() const { return validate_; } |
| 198 |
| 197 private: | 199 private: |
| 198 // Iterator for iterating over the set of frames (dart or stub) which exist | 200 // Iterator for iterating over the set of frames (dart or stub) which exist |
| 199 // in one EntryFrame and ExitFrame block. | 201 // in one EntryFrame and ExitFrame block. |
| 200 class FrameSetIterator : public ValueObject { | 202 class FrameSetIterator : public ValueObject { |
| 201 public: | 203 public: |
| 202 // Checks if a next non entry/exit frame exists in the set. | 204 // Checks if a next non entry/exit frame exists in the set. |
| 203 bool HasNext() const { | 205 bool HasNext() const { |
| 204 if (fp_ == 0) { | 206 if (fp_ == 0) { |
| 205 return false; | 207 return false; |
| 206 } | 208 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, isolate) { } | 269 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, isolate) { } |
| 268 DartFrameIterator(uword fp, | 270 DartFrameIterator(uword fp, |
| 269 uword sp, | 271 uword sp, |
| 270 uword pc, | 272 uword pc, |
| 271 Isolate* isolate = Isolate::Current()) | 273 Isolate* isolate = Isolate::Current()) |
| 272 : frames_(fp, sp, pc, StackFrameIterator::kDontValidateFrames, isolate) { | 274 : frames_(fp, sp, pc, StackFrameIterator::kDontValidateFrames, isolate) { |
| 273 } | 275 } |
| 274 // Get next dart frame. | 276 // Get next dart frame. |
| 275 StackFrame* NextFrame() { | 277 StackFrame* NextFrame() { |
| 276 StackFrame* frame = frames_.NextFrame(); | 278 StackFrame* frame = frames_.NextFrame(); |
| 277 while (frame != NULL && !frame->IsDartFrame()) { | 279 while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { |
| 278 frame = frames_.NextFrame(); | 280 frame = frames_.NextFrame(); |
| 279 } | 281 } |
| 280 return frame; | 282 return frame; |
| 281 } | 283 } |
| 282 | 284 |
| 283 private: | 285 private: |
| 284 StackFrameIterator frames_; | 286 StackFrameIterator frames_; |
| 285 | 287 |
| 286 DISALLOW_COPY_AND_ASSIGN(DartFrameIterator); | 288 DISALLOW_COPY_AND_ASSIGN(DartFrameIterator); |
| 287 }; | 289 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 uword pc_; | 326 uword pc_; |
| 325 GrowableArray<DeoptInstr*> deopt_instructions_; | 327 GrowableArray<DeoptInstr*> deopt_instructions_; |
| 326 Array& object_table_; | 328 Array& object_table_; |
| 327 | 329 |
| 328 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); | 330 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); |
| 329 }; | 331 }; |
| 330 | 332 |
| 331 } // namespace dart | 333 } // namespace dart |
| 332 | 334 |
| 333 #endif // VM_STACK_FRAME_H_ | 335 #endif // VM_STACK_FRAME_H_ |
| OLD | NEW |