OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 inline void set_pc(Address value); | 86 inline void set_pc(Address value); |
87 | 87 |
88 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); |
89 }; | 89 }; |
90 | 90 |
91 | 91 |
92 #define STACK_FRAME_TYPE_LIST(V) \ | 92 #define STACK_FRAME_TYPE_LIST(V) \ |
93 V(ENTRY, EntryFrame) \ | 93 V(ENTRY, EntryFrame) \ |
94 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ | 94 V(ENTRY_CONSTRUCT, EntryConstructFrame) \ |
95 V(EXIT, ExitFrame) \ | 95 V(EXIT, ExitFrame) \ |
96 V(EXIT_DEBUG, ExitDebugFrame) \ | |
97 V(JAVA_SCRIPT, JavaScriptFrame) \ | 96 V(JAVA_SCRIPT, JavaScriptFrame) \ |
98 V(INTERNAL, InternalFrame) \ | 97 V(INTERNAL, InternalFrame) \ |
99 V(CONSTRUCT, ConstructFrame) \ | 98 V(CONSTRUCT, ConstructFrame) \ |
100 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) | 99 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame) |
101 | 100 |
102 | 101 |
103 // Abstract base class for all stack frames. | 102 // Abstract base class for all stack frames. |
104 class StackFrame BASE_EMBEDDED { | 103 class StackFrame BASE_EMBEDDED { |
105 public: | 104 public: |
106 #define DECLARE_TYPE(type, ignore) type, | 105 #define DECLARE_TYPE(type, ignore) type, |
107 enum Type { | 106 enum Type { |
108 NONE = 0, | 107 NONE = 0, |
109 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) | 108 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) |
110 NUMBER_OF_TYPES | 109 NUMBER_OF_TYPES |
111 }; | 110 }; |
112 #undef DECLARE_TYPE | 111 #undef DECLARE_TYPE |
113 | 112 |
114 // Opaque data type for identifying stack frames. Used extensively | 113 // Opaque data type for identifying stack frames. Used extensively |
115 // by the debugger. | 114 // by the debugger. |
116 enum Id { NO_ID = 0 }; | 115 enum Id { NO_ID = 0 }; |
117 | 116 |
118 // Type testers. | 117 // Type testers. |
119 bool is_entry() const { return type() == ENTRY; } | 118 bool is_entry() const { return type() == ENTRY; } |
120 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 119 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
121 bool is_exit() const { return type() == EXIT; } | 120 bool is_exit() const { return type() == EXIT; } |
122 bool is_exit_debug() const { return type() == EXIT_DEBUG; } | |
123 bool is_java_script() const { return type() == JAVA_SCRIPT; } | 121 bool is_java_script() const { return type() == JAVA_SCRIPT; } |
124 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 122 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
125 bool is_internal() const { return type() == INTERNAL; } | 123 bool is_internal() const { return type() == INTERNAL; } |
126 bool is_construct() const { return type() == CONSTRUCT; } | 124 bool is_construct() const { return type() == CONSTRUCT; } |
127 virtual bool is_standard() const { return false; } | 125 virtual bool is_standard() const { return false; } |
128 | 126 |
129 // Accessors. | 127 // Accessors. |
130 Address sp() const { return state_.sp; } | 128 Address sp() const { return state_.sp; } |
131 Address fp() const { return state_.fp; } | 129 Address fp() const { return state_.fp; } |
132 Address caller_sp() const { return GetCallerStackPointer(); } | 130 Address caller_sp() const { return GetCallerStackPointer(); } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 : EntryFrame(iterator) { } | 251 : EntryFrame(iterator) { } |
254 | 252 |
255 private: | 253 private: |
256 friend class StackFrameIterator; | 254 friend class StackFrameIterator; |
257 }; | 255 }; |
258 | 256 |
259 | 257 |
260 // Exit frames are used to exit JavaScript execution and go to C. | 258 // Exit frames are used to exit JavaScript execution and go to C. |
261 class ExitFrame: public StackFrame { | 259 class ExitFrame: public StackFrame { |
262 public: | 260 public: |
| 261 enum Mode { MODE_NORMAL, MODE_DEBUG }; |
263 virtual Type type() const { return EXIT; } | 262 virtual Type type() const { return EXIT; } |
264 | 263 |
265 virtual Code* code() const; | 264 virtual Code* code() const; |
266 | 265 |
| 266 Object*& code_slot() const; |
| 267 |
267 // Garbage collection support. | 268 // Garbage collection support. |
268 virtual void Iterate(ObjectVisitor* v) const; | 269 virtual void Iterate(ObjectVisitor* v) const; |
269 | 270 |
270 static ExitFrame* cast(StackFrame* frame) { | 271 static ExitFrame* cast(StackFrame* frame) { |
271 ASSERT(frame->is_exit()); | 272 ASSERT(frame->is_exit()); |
272 return static_cast<ExitFrame*>(frame); | 273 return static_cast<ExitFrame*>(frame); |
273 } | 274 } |
274 | 275 |
275 // Compute the state and type of an exit frame given a frame | 276 // Compute the state and type of an exit frame given a frame |
276 // pointer. Used when constructing the first stack frame seen by an | 277 // pointer. Used when constructing the first stack frame seen by an |
277 // iterator and the frames following entry frames. | 278 // iterator and the frames following entry frames. |
278 static Type GetStateForFramePointer(Address fp, State* state); | 279 static Type GetStateForFramePointer(Address fp, State* state); |
279 | 280 |
280 protected: | 281 protected: |
281 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } | 282 explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } |
282 | 283 |
283 virtual Address GetCallerStackPointer() const; | 284 virtual Address GetCallerStackPointer() const; |
284 | 285 |
285 private: | 286 private: |
286 virtual void ComputeCallerState(State* state) const; | 287 virtual void ComputeCallerState(State* state) const; |
287 | 288 |
288 friend class StackFrameIterator; | 289 friend class StackFrameIterator; |
289 }; | 290 }; |
290 | 291 |
291 | 292 |
292 class ExitDebugFrame: public ExitFrame { | |
293 public: | |
294 virtual Type type() const { return EXIT_DEBUG; } | |
295 | |
296 virtual Code* code() const; | |
297 | |
298 static ExitDebugFrame* cast(StackFrame* frame) { | |
299 ASSERT(frame->is_exit_debug()); | |
300 return static_cast<ExitDebugFrame*>(frame); | |
301 } | |
302 | |
303 protected: | |
304 explicit ExitDebugFrame(StackFrameIterator* iterator) | |
305 : ExitFrame(iterator) { } | |
306 | |
307 private: | |
308 friend class StackFrameIterator; | |
309 }; | |
310 | |
311 | |
312 class StandardFrame: public StackFrame { | 293 class StandardFrame: public StackFrame { |
313 public: | 294 public: |
314 // Testers. | 295 // Testers. |
315 virtual bool is_standard() const { return true; } | 296 virtual bool is_standard() const { return true; } |
316 | 297 |
317 // Accessors. | 298 // Accessors. |
318 inline Object* context() const; | 299 inline Object* context() const; |
319 | 300 |
320 // Access the expressions in the stack frame including locals. | 301 // Access the expressions in the stack frame including locals. |
321 inline Object* GetExpression(int index) const; | 302 inline Object* GetExpression(int index) const; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 JavaScriptFrame* FindJavaScriptFrame(int n); | 650 JavaScriptFrame* FindJavaScriptFrame(int n); |
670 | 651 |
671 private: | 652 private: |
672 StackFrameIterator iterator_; | 653 StackFrameIterator iterator_; |
673 }; | 654 }; |
674 | 655 |
675 | 656 |
676 } } // namespace v8::internal | 657 } } // namespace v8::internal |
677 | 658 |
678 #endif // V8_FRAMES_H_ | 659 #endif // V8_FRAMES_H_ |
OLD | NEW |