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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 NONE = 0, | 107 NONE = 0, |
108 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) | 108 STACK_FRAME_TYPE_LIST(DECLARE_TYPE) |
109 NUMBER_OF_TYPES | 109 NUMBER_OF_TYPES |
110 }; | 110 }; |
111 #undef DECLARE_TYPE | 111 #undef DECLARE_TYPE |
112 | 112 |
113 // Opaque data type for identifying stack frames. Used extensively | 113 // Opaque data type for identifying stack frames. Used extensively |
114 // by the debugger. | 114 // by the debugger. |
115 enum Id { NO_ID = 0 }; | 115 enum Id { NO_ID = 0 }; |
116 | 116 |
| 117 // Copy constructor; it breaks the connection to host iterator. |
| 118 StackFrame(const StackFrame& original) { |
| 119 this->state_ = original.state_; |
| 120 this->iterator_ = NULL; |
| 121 } |
| 122 |
117 // Type testers. | 123 // Type testers. |
118 bool is_entry() const { return type() == ENTRY; } | 124 bool is_entry() const { return type() == ENTRY; } |
119 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } | 125 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; } |
120 bool is_exit() const { return type() == EXIT; } | 126 bool is_exit() const { return type() == EXIT; } |
121 bool is_java_script() const { return type() == JAVA_SCRIPT; } | 127 bool is_java_script() const { return type() == JAVA_SCRIPT; } |
122 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } | 128 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; } |
123 bool is_internal() const { return type() == INTERNAL; } | 129 bool is_internal() const { return type() == INTERNAL; } |
124 bool is_construct() const { return type() == CONSTRUCT; } | 130 bool is_construct() const { return type() == CONSTRUCT; } |
125 virtual bool is_standard() const { return false; } | 131 virtual bool is_standard() const { return false; } |
126 | 132 |
127 // Accessors. | 133 // Accessors. |
128 Address sp() const { return state_.sp; } | 134 Address sp() const { return state_.sp; } |
129 Address fp() const { return state_.fp; } | 135 Address fp() const { return state_.fp; } |
130 Address caller_sp() const { return GetCallerStackPointer(); } | 136 Address caller_sp() const { return GetCallerStackPointer(); } |
131 | 137 |
132 Address pc() const { return *pc_address(); } | 138 Address pc() const { return *pc_address(); } |
133 void set_pc(Address pc) { *pc_address() = pc; } | 139 void set_pc(Address pc) { *pc_address() = pc; } |
134 | 140 |
| 141 virtual void SetCallerFp(Address caller_fp) = 0; |
| 142 |
135 Address* pc_address() const { return state_.pc_address; } | 143 Address* pc_address() const { return state_.pc_address; } |
136 | 144 |
137 // Get the id of this stack frame. | 145 // Get the id of this stack frame. |
138 Id id() const { return static_cast<Id>(OffsetFrom(caller_sp())); } | 146 Id id() const { return static_cast<Id>(OffsetFrom(caller_sp())); } |
139 | 147 |
140 // Checks if this frame includes any stack handlers. | 148 // Checks if this frame includes any stack handlers. |
141 bool HasHandler() const; | 149 bool HasHandler() const; |
142 | 150 |
143 // Get the type of this frame. | 151 // Get the type of this frame. |
144 virtual Type type() const = 0; | 152 virtual Type type() const = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 virtual Type GetCallerState(State* state) const; | 201 virtual Type GetCallerState(State* state) const; |
194 | 202 |
195 // Cooking/uncooking support. | 203 // Cooking/uncooking support. |
196 void Cook(); | 204 void Cook(); |
197 void Uncook(); | 205 void Uncook(); |
198 | 206 |
199 friend class StackFrameIterator; | 207 friend class StackFrameIterator; |
200 friend class StackHandlerIterator; | 208 friend class StackHandlerIterator; |
201 friend class SafeStackFrameIterator; | 209 friend class SafeStackFrameIterator; |
202 | 210 |
203 DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrame); | 211 private: |
| 212 void operator=(const StackFrame& original); |
204 }; | 213 }; |
205 | 214 |
206 | 215 |
207 // Entry frames are used to enter JavaScript execution from C. | 216 // Entry frames are used to enter JavaScript execution from C. |
208 class EntryFrame: public StackFrame { | 217 class EntryFrame: public StackFrame { |
209 public: | 218 public: |
210 virtual Type type() const { return ENTRY; } | 219 virtual Type type() const { return ENTRY; } |
211 | 220 |
212 virtual Code* code() const; | 221 virtual Code* code() const; |
213 | 222 |
214 // Garbage collection support. | 223 // Garbage collection support. |
215 virtual void Iterate(ObjectVisitor* v) const; | 224 virtual void Iterate(ObjectVisitor* v) const; |
216 | 225 |
217 static EntryFrame* cast(StackFrame* frame) { | 226 static EntryFrame* cast(StackFrame* frame) { |
218 ASSERT(frame->is_entry()); | 227 ASSERT(frame->is_entry()); |
219 return static_cast<EntryFrame*>(frame); | 228 return static_cast<EntryFrame*>(frame); |
220 } | 229 } |
| 230 virtual void SetCallerFp(Address caller_fp); |
221 | 231 |
222 protected: | 232 protected: |
223 explicit EntryFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } | 233 explicit EntryFrame(StackFrameIterator* iterator) : StackFrame(iterator) { } |
224 | 234 |
225 // The caller stack pointer for entry frames is always zero. The | 235 // The caller stack pointer for entry frames is always zero. The |
226 // real information about the caller frame is available through the | 236 // real information about the caller frame is available through the |
227 // link to the top exit frame. | 237 // link to the top exit frame. |
228 virtual Address GetCallerStackPointer() const { return 0; } | 238 virtual Address GetCallerStackPointer() const { return 0; } |
229 | 239 |
230 private: | 240 private: |
(...skipping 30 matching lines...) Expand all Loading... |
261 enum Mode { MODE_NORMAL, MODE_DEBUG }; | 271 enum Mode { MODE_NORMAL, MODE_DEBUG }; |
262 virtual Type type() const { return EXIT; } | 272 virtual Type type() const { return EXIT; } |
263 | 273 |
264 virtual Code* code() const; | 274 virtual Code* code() const; |
265 | 275 |
266 Object*& code_slot() const; | 276 Object*& code_slot() const; |
267 | 277 |
268 // Garbage collection support. | 278 // Garbage collection support. |
269 virtual void Iterate(ObjectVisitor* v) const; | 279 virtual void Iterate(ObjectVisitor* v) const; |
270 | 280 |
| 281 virtual void SetCallerFp(Address caller_fp); |
| 282 |
271 static ExitFrame* cast(StackFrame* frame) { | 283 static ExitFrame* cast(StackFrame* frame) { |
272 ASSERT(frame->is_exit()); | 284 ASSERT(frame->is_exit()); |
273 return static_cast<ExitFrame*>(frame); | 285 return static_cast<ExitFrame*>(frame); |
274 } | 286 } |
275 | 287 |
276 // Compute the state and type of an exit frame given a frame | 288 // Compute the state and type of an exit frame given a frame |
277 // pointer. Used when constructing the first stack frame seen by an | 289 // pointer. Used when constructing the first stack frame seen by an |
278 // iterator and the frames following entry frames. | 290 // iterator and the frames following entry frames. |
279 static Type GetStateForFramePointer(Address fp, State* state); | 291 static Type GetStateForFramePointer(Address fp, State* state); |
280 | 292 |
(...skipping 15 matching lines...) Expand all Loading... |
296 virtual bool is_standard() const { return true; } | 308 virtual bool is_standard() const { return true; } |
297 | 309 |
298 // Accessors. | 310 // Accessors. |
299 inline Object* context() const; | 311 inline Object* context() const; |
300 | 312 |
301 // Access the expressions in the stack frame including locals. | 313 // Access the expressions in the stack frame including locals. |
302 inline Object* GetExpression(int index) const; | 314 inline Object* GetExpression(int index) const; |
303 inline void SetExpression(int index, Object* value); | 315 inline void SetExpression(int index, Object* value); |
304 int ComputeExpressionsCount() const; | 316 int ComputeExpressionsCount() const; |
305 | 317 |
| 318 virtual void SetCallerFp(Address caller_fp); |
| 319 |
306 static StandardFrame* cast(StackFrame* frame) { | 320 static StandardFrame* cast(StackFrame* frame) { |
307 ASSERT(frame->is_standard()); | 321 ASSERT(frame->is_standard()); |
308 return static_cast<StandardFrame*>(frame); | 322 return static_cast<StandardFrame*>(frame); |
309 } | 323 } |
310 | 324 |
311 protected: | 325 protected: |
312 explicit StandardFrame(StackFrameIterator* iterator) | 326 explicit StandardFrame(StackFrameIterator* iterator) |
313 : StackFrame(iterator) { } | 327 : StackFrame(iterator) { } |
314 | 328 |
315 virtual void ComputeCallerState(State* state) const; | 329 virtual void ComputeCallerState(State* state) const; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 public: | 665 public: |
652 // Find the nth JavaScript frame on the stack. The caller must | 666 // Find the nth JavaScript frame on the stack. The caller must |
653 // guarantee that such a frame exists. | 667 // guarantee that such a frame exists. |
654 JavaScriptFrame* FindJavaScriptFrame(int n); | 668 JavaScriptFrame* FindJavaScriptFrame(int n); |
655 | 669 |
656 private: | 670 private: |
657 StackFrameIterator iterator_; | 671 StackFrameIterator iterator_; |
658 }; | 672 }; |
659 | 673 |
660 | 674 |
| 675 // Reads all frames on the current stack and copies them into the current |
| 676 // zone memory. |
| 677 Vector<StackFrame*> CreateStackMap(); |
| 678 |
661 } } // namespace v8::internal | 679 } } // namespace v8::internal |
662 | 680 |
663 #endif // V8_FRAMES_H_ | 681 #endif // V8_FRAMES_H_ |
OLD | NEW |