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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 Isolate* isolate() const { return thread_->isolate(); } | 96 Isolate* isolate() const { return thread_->isolate(); } |
95 | 97 |
96 Thread* thread() const { return thread_; } | 98 Thread* thread() const { return thread_; } |
97 | 99 |
98 private: | 100 private: |
99 RawCode* GetCodeObject() const; | 101 RawCode* GetCodeObject() const; |
100 | 102 |
101 uword GetCallerSp() const { | 103 uword GetCallerSp() const { |
102 return fp() + (kCallerSpSlotFromFp * kWordSize); | 104 return fp() + (kCallerSpSlotFromFp * kWordSize); |
103 } | 105 } |
| 106 |
104 uword GetCallerFp() const { | 107 uword GetCallerFp() const { |
105 return *(reinterpret_cast<uword*>( | 108 return *(reinterpret_cast<uword*>( |
106 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); | 109 fp() + (kSavedCallerFpSlotFromFp * kWordSize))); |
107 } | 110 } |
| 111 |
108 uword GetCallerPc() const { | 112 uword GetCallerPc() const { |
109 return *(reinterpret_cast<uword*>( | 113 return *(reinterpret_cast<uword*>( |
110 fp() + (kSavedCallerPcSlotFromFp * kWordSize))); | 114 fp() + (kSavedCallerPcSlotFromFp * kWordSize))); |
111 } | 115 } |
112 | 116 |
113 uword fp_; | 117 uword fp_; |
114 uword sp_; | 118 uword sp_; |
115 uword pc_; | 119 uword pc_; |
116 Thread* thread_; | 120 Thread* thread_; |
117 | 121 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 static const bool kValidateFrames = true; | 185 static const bool kValidateFrames = true; |
182 static const bool kDontValidateFrames = false; | 186 static const bool kDontValidateFrames = false; |
183 | 187 |
184 // Iterators for iterating over all frames from the last ExitFrame to the | 188 // Iterators for iterating over all frames from the last ExitFrame to the |
185 // first EntryFrame. | 189 // first EntryFrame. |
186 StackFrameIterator(bool validate, | 190 StackFrameIterator(bool validate, |
187 Thread* thread = Thread::Current()); | 191 Thread* thread = Thread::Current()); |
188 StackFrameIterator(uword last_fp, bool validate, | 192 StackFrameIterator(uword last_fp, bool validate, |
189 Thread* thread = Thread::Current()); | 193 Thread* thread = Thread::Current()); |
190 | 194 |
| 195 #if !defined(TARGET_ARCH_DBC) |
191 // Iterator for iterating over all frames from the current frame (given by its | 196 // Iterator for iterating over all frames from the current frame (given by its |
192 // fp, sp, and pc) to the first EntryFrame. | 197 // fp, sp, and pc) to the first EntryFrame. |
193 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, | 198 StackFrameIterator(uword fp, uword sp, uword pc, bool validate, |
194 Thread* thread = Thread::Current()); | 199 Thread* thread = Thread::Current()); |
| 200 #endif |
195 | 201 |
196 // Checks if a next frame exists. | 202 // Checks if a next frame exists. |
197 bool HasNextFrame() const { return frames_.fp_ != 0; } | 203 bool HasNextFrame() const { return frames_.fp_ != 0; } |
198 | 204 |
199 // Get next frame. | 205 // Get next frame. |
200 StackFrame* NextFrame(); | 206 StackFrame* NextFrame(); |
201 | 207 |
202 bool validate() const { return validate_; } | 208 bool validate() const { return validate_; } |
203 | 209 |
204 private: | 210 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. | 271 // 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 | 272 // It is the responsibility of users of DartFrameIterator to ensure that the |
267 // isolate given is not running concurrently on another thread. | 273 // isolate given is not running concurrently on another thread. |
268 class DartFrameIterator : public ValueObject { | 274 class DartFrameIterator : public ValueObject { |
269 public: | 275 public: |
270 explicit DartFrameIterator(Thread* thread = Thread::Current()) | 276 explicit DartFrameIterator(Thread* thread = Thread::Current()) |
271 : frames_(StackFrameIterator::kDontValidateFrames, thread) { } | 277 : frames_(StackFrameIterator::kDontValidateFrames, thread) { } |
272 DartFrameIterator(uword last_fp, | 278 DartFrameIterator(uword last_fp, |
273 Thread* thread = Thread::Current()) | 279 Thread* thread = Thread::Current()) |
274 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, thread) { } | 280 : frames_(last_fp, StackFrameIterator::kDontValidateFrames, thread) { } |
| 281 |
| 282 #if !defined(TARGET_ARCH_DBC) |
275 DartFrameIterator(uword fp, | 283 DartFrameIterator(uword fp, |
276 uword sp, | 284 uword sp, |
277 uword pc, | 285 uword pc, |
278 Thread* thread = Thread::Current()) | 286 Thread* thread = Thread::Current()) |
279 : frames_(fp, sp, pc, | 287 : frames_(fp, sp, pc, |
280 StackFrameIterator::kDontValidateFrames, thread) { | 288 StackFrameIterator::kDontValidateFrames, thread) { |
281 } | 289 } |
| 290 #endif |
| 291 |
282 // Get next dart frame. | 292 // Get next dart frame. |
283 StackFrame* NextFrame() { | 293 StackFrame* NextFrame() { |
284 StackFrame* frame = frames_.NextFrame(); | 294 StackFrame* frame = frames_.NextFrame(); |
285 while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { | 295 while (frame != NULL && !frame->IsDartFrame(frames_.validate())) { |
286 frame = frames_.NextFrame(); | 296 frame = frames_.NextFrame(); |
287 } | 297 } |
288 return frame; | 298 return frame; |
289 } | 299 } |
290 | 300 |
291 private: | 301 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 Code& code_; | 339 Code& code_; |
330 TypedData& deopt_info_; | 340 TypedData& deopt_info_; |
331 Function& function_; | 341 Function& function_; |
332 uword pc_; | 342 uword pc_; |
333 GrowableArray<DeoptInstr*> deopt_instructions_; | 343 GrowableArray<DeoptInstr*> deopt_instructions_; |
334 ObjectPool& object_table_; | 344 ObjectPool& object_table_; |
335 | 345 |
336 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); | 346 DISALLOW_COPY_AND_ASSIGN(InlinedFunctionsIterator); |
337 }; | 347 }; |
338 | 348 |
| 349 #if !defined(TARGET_ARCH_DBC) |
| 350 DART_FORCE_INLINE static uword LocalVarAddress(uword fp, intptr_t index) { |
| 351 return fp + (index * kWordSize); |
| 352 } |
| 353 |
| 354 |
| 355 DART_FORCE_INLINE static uword ParamAddress(uword fp, intptr_t reverse_index) { |
| 356 return fp + (kParamEndSlotFromFp * kWordSize) + (reverse_index * kWordSize); |
| 357 } |
| 358 |
| 359 |
| 360 DART_FORCE_INLINE static bool IsCalleeFrameOf(uword fp, uword other_fp) { |
| 361 return other_fp < fp; |
| 362 } |
| 363 |
| 364 // Value for stack limit that is used to cause an interrupt. |
| 365 // Note that on DBC stack is growing upwards so interrupt limit is 0 unlike |
| 366 // on all other architectures. |
| 367 static const uword kInterruptStackLimit = ~static_cast<uword>(0); |
| 368 #endif |
| 369 |
339 } // namespace dart | 370 } // namespace dart |
340 | 371 |
341 #endif // VM_STACK_FRAME_H_ | 372 #endif // VM_STACK_FRAME_H_ |
OLD | NEW |