| 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" |
| 11 | 11 |
| 12 #if defined(TARGET_ARCH_IA32) | 12 #if defined(TARGET_ARCH_IA32) |
| 13 #include "vm/stack_frame_ia32.h" | 13 #include "vm/stack_frame_ia32.h" |
| 14 #elif defined(TARGET_ARCH_X64) | 14 #elif defined(TARGET_ARCH_X64) |
| 15 #include "vm/stack_frame_x64.h" | 15 #include "vm/stack_frame_x64.h" |
| 16 #elif defined(TARGET_ARCH_ARM) | 16 #elif defined(TARGET_ARCH_ARM) |
| 17 #include "vm/stack_frame_arm.h" | 17 #include "vm/stack_frame_arm.h" |
| 18 #elif defined(TARGET_ARCH_ARM64) | 18 #elif defined(TARGET_ARCH_ARM64) |
| 19 #include "vm/stack_frame_arm64.h" | 19 #include "vm/stack_frame_arm64.h" |
| 20 #elif defined(TARGET_ARCH_MIPS) | 20 #elif defined(TARGET_ARCH_MIPS) |
| 21 #include "vm/stack_frame_mips.h" | 21 #include "vm/stack_frame_mips.h" |
| 22 #elif defined(TARGET_ARCH_DBC) |
| 23 #include "vm/stack_frame_dbc.h" |
| 22 #else | 24 #else |
| 23 #error Unknown architecture. | 25 #error Unknown architecture. |
| 24 #endif | 26 #endif |
| 25 | 27 |
| 26 namespace dart { | 28 namespace dart { |
| 27 | 29 |
| 28 // Forward declarations. | 30 // Forward declarations. |
| 29 class ObjectPointerVisitor; | 31 class ObjectPointerVisitor; |
| 30 class RawContext; | 32 class RawContext; |
| 31 | 33 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 | 44 |
| 43 // The pool pointer is not implemented on all architectures. | 45 // The pool pointer is not implemented on all architectures. |
| 44 static int SavedCallerPpSlotFromFp() { | 46 static int SavedCallerPpSlotFromFp() { |
| 45 if (kSavedCallerPpSlotFromFp != kSavedCallerFpSlotFromFp) { | 47 if (kSavedCallerPpSlotFromFp != kSavedCallerFpSlotFromFp) { |
| 46 return kSavedCallerPpSlotFromFp; | 48 return kSavedCallerPpSlotFromFp; |
| 47 } | 49 } |
| 48 UNREACHABLE(); | 50 UNREACHABLE(); |
| 49 return 0; | 51 return 0; |
| 50 } | 52 } |
| 51 | 53 |
| 54 #if !defined(TARGET_ARCH_DBC) |
| 52 void set_pc(uword value) { | 55 void set_pc(uword value) { |
| 53 *reinterpret_cast<uword*>(sp() + (kSavedPcSlotFromSp * kWordSize)) = value; | 56 *reinterpret_cast<uword*>(sp() + (kSavedPcSlotFromSp * kWordSize)) = value; |
| 54 } | 57 } |
| 55 | 58 |
| 56 void set_pc_marker(RawCode* code) { | 59 void set_pc_marker(RawCode* code) { |
| 57 *reinterpret_cast<RawCode**>(fp() + (kPcMarkerSlotFromFp * kWordSize)) = | 60 *reinterpret_cast<RawCode**>(fp() + (kPcMarkerSlotFromFp * kWordSize)) = |
| 58 code; | 61 code; |
| 59 } | 62 } |
| 63 #endif |
| 60 | 64 |
| 61 // Visit objects in the frame. | 65 // Visit objects in the frame. |
| 62 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); | 66 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 63 | 67 |
| 64 const char* ToCString() const; | 68 const char* ToCString() const; |
| 65 | 69 |
| 66 // Check validity of a frame, used for assertion purposes. | 70 // Check validity of a frame, used for assertion purposes. |
| 67 virtual bool IsValid() const; | 71 virtual bool IsValid() const; |
| 68 | 72 |
| 69 // Frame type. | 73 // Frame type. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 Isolate* isolate() const { return thread_->isolate(); } | 98 Isolate* isolate() const { return thread_->isolate(); } |
| 95 | 99 |
| 96 Thread* thread() const { return thread_; } | 100 Thread* thread() const { return thread_; } |
| 97 | 101 |
| 98 private: | 102 private: |
| 99 RawCode* GetCodeObject() const; | 103 RawCode* GetCodeObject() const; |
| 100 | 104 |
| 101 uword GetCallerSp() const { | 105 uword GetCallerSp() const { |
| 102 return fp() + (kCallerSpSlotFromFp * kWordSize); | 106 return fp() + (kCallerSpSlotFromFp * kWordSize); |
| 103 } | 107 } |
| 108 |
| 104 uword GetCallerFp() const { | 109 uword GetCallerFp() const { |
| 105 return *(reinterpret_cast<uword*>( | 110 return *(reinterpret_cast<uword*>( |
| 106 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); | 111 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); |
| 107 } | 112 } |
| 113 |
| 108 uword GetCallerPc() const { | 114 uword GetCallerPc() const { |
| 109 return *(reinterpret_cast<uword*>( | 115 return *(reinterpret_cast<uword*>( |
| 110 fp() + (kSavedCallerPcSlotFromFp * kWordSize))); | 116 fp() + (kSavedCallerPcSlotFromFp * kWordSize))); |
| 111 } | 117 } |
| 112 | 118 |
| 113 uword fp_; | 119 uword fp_; |
| 114 uword sp_; | 120 uword sp_; |
| 115 uword pc_; | 121 uword pc_; |
| 116 Thread* thread_; | 122 Thread* thread_; |
| 117 | 123 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 static const bool kValidateFrames = true; | 187 static const bool kValidateFrames = true; |
| 182 static const bool kDontValidateFrames = false; | 188 static const bool kDontValidateFrames = false; |
| 183 | 189 |
| 184 // Iterators for iterating over all frames from the last ExitFrame to the | 190 // Iterators for iterating over all frames from the last ExitFrame to the |
| 185 // first EntryFrame. | 191 // first EntryFrame. |
| 186 StackFrameIterator(bool validate, | 192 StackFrameIterator(bool validate, |
| 187 Thread* thread = Thread::Current()); | 193 Thread* thread = Thread::Current()); |
| 188 StackFrameIterator(uword last_fp, bool validate, | 194 StackFrameIterator(uword last_fp, bool validate, |
| 189 Thread* thread = Thread::Current()); | 195 Thread* thread = Thread::Current()); |
| 190 | 196 |
| 197 #if !defined(TARGET_ARCH_DBC) |
| 191 // Iterator for iterating over all frames from the current frame (given by its | 198 // Iterator for iterating over all frames from the current frame (given by its |
| 192 // fp, sp, and pc) to the first EntryFrame. | 199 // fp, sp, and pc) to the first EntryFrame. |
| 193 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, | 200 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, |
| 194 Thread* thread = Thread::Current()); | 201 Thread* thread = Thread::Current()); |
| 202 #endif |
| 195 | 203 |
| 196 // Checks if a next frame exists. | 204 // Checks if a next frame exists. |
| 197 bool HasNextFrame() const { return frames_.fp_ != 0; } | 205 bool HasNextFrame() const { return frames_.fp_ != 0; } |
| 198 | 206 |
| 199 // Get next frame. | 207 // Get next frame. |
| 200 StackFrame* NextFrame(); | 208 StackFrame* NextFrame(); |
| 201 | 209 |
| 202 bool validate() const { return validate_; } | 210 bool validate() const { return validate_; } |
| 203 | 211 |
| 204 private: | 212 private: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // it is only allowed on Windows- where it is needed for the profiler. | 273 // it is only allowed on Windows- where it is needed for the profiler. |
| 266 // It is the responsibility of users of DartFrameIterator to ensure that the | 274 // It is the responsibility of users of DartFrameIterator to ensure that the |
| 267 // isolate given is not running concurrently on another thread. | 275 // isolate given is not running concurrently on another thread. |
| 268 class DartFrameIterator : public ValueObject { | 276 class DartFrameIterator : public ValueObject { |
| 269 public: | 277 public: |
| 270 explicit DartFrameIterator(Thread* thread = Thread::Current()) | 278 explicit DartFrameIterator(Thread* thread = Thread::Current()) |
| 271 : frames_(StackFrameIterator::kDontValidateFrames, thread) { } | 279 : frames_(StackFrameIterator::kDontValidateFrames, thread) { } |
| 272 DartFrameIterator(uword last_fp, | 280 DartFrameIterator(uword last_fp, |
| 273 Thread* thread = Thread::Current()) | 281 Thread* thread = Thread::Current()) |
| 274 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, thread) { } | 282 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, thread) { } |
| 283 |
| 284 #if !defined(TARGET_ARCH_DBC) |
| 275 DartFrameIterator(uword fp, | 285 DartFrameIterator(uword fp, |
| 276 uword sp, | 286 uword sp, |
| 277 uword pc, | 287 uword pc, |
| 278 Thread* thread = Thread::Current()) | 288 Thread* thread = Thread::Current()) |
| 279 : frames_(fp, sp, pc, | 289 : frames_(fp, sp, pc, |
| 280 StackFrameIterator::kDontValidateFrames, thread) { | 290 StackFrameIterator::kDontValidateFrames, thread) { |
| 281 } | 291 } |
| 292 #endif |
| 293 |
| 282 // Get next dart frame. | 294 // Get next dart frame. |
| 283 StackFrame* NextFrame() { | 295 StackFrame* NextFrame() { |
| 284 StackFrame* frame = frames_.NextFrame(); | 296 StackFrame* frame = frames_.NextFrame(); |
| 285 while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { | 297 while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { |
| 286 frame = frames_.NextFrame(); | 298 frame = frames_.NextFrame(); |
| 287 } | 299 } |
| 288 return frame; | 300 return frame; |
| 289 } | 301 } |
| 290 | 302 |
| 291 private: | 303 private: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 Code& code_; | 341 Code& code_; |
| 330 TypedData& deopt_info_; | 342 TypedData& deopt_info_; |
| 331 Function& function_; | 343 Function& function_; |
| 332 uword pc_; | 344 uword pc_; |
| 333 GrowableArray<DeoptInstr*> deopt_instructions_; | 345 GrowableArray<DeoptInstr*> deopt_instructions_; |
| 334 ObjectPool& object_table_; | 346 ObjectPool& object_table_; |
| 335 | 347 |
| 336 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); | 348 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); |
| 337 }; | 349 }; |
| 338 | 350 |
| 351 #if !defined(TARGET_ARCH_DBC) |
| 352 DART_FORCE_INLINE static uword LocalVarAddress(uword fp, intptr_t index) { |
| 353 return fp + ((kFirstLocalSlotFromFp - index) * kWordSize); |
| 354 } |
| 355 |
| 356 |
| 357 DART_FORCE_INLINE static uword ParamAddress(uword fp, intptr_t reverse_index) { |
| 358 return fp + (kParamEndSlotFromFp * kWordSize) + (reverse_index * kWordSize); |
| 359 } |
| 360 |
| 361 |
| 362 DART_FORCE_INLINE static bool IsCalleeFrameOf(uword fp, uword other_fp) { |
| 363 return other_fp < fp; |
| 364 } |
| 365 #endif |
| 366 |
| 339 } // namespace dart | 367 } // namespace dart |
| 340 | 368 |
| 341 #endif // VM_STACK_FRAME_H_ | 369 #endif // VM_STACK_FRAME_H_ |
| OLD | NEW |