blob: 2c5e571ed7e33864d29888161d3295762b8e6d6e [file] [log] [blame]
whesse@chromium.org4acdc2c2011-08-15 13:01:23 +00001// Copyright 2011 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_FRAMES_H_
29#define V8_FRAMES_H_
30
lrn@chromium.org1c092762011-05-09 09:42:16 +000031#include "allocation.h"
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000032#include "handles.h"
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +000033#include "safepoint-table.h"
34
kasperl@chromium.org71affb52009-05-26 05:44:31 +000035namespace v8 {
36namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000037
38typedef uint32_t RegList;
39
40// Get the number of registers in a given register list.
41int NumRegs(RegList list);
42
43// Return the code of the n-th saved register available to JavaScript.
44int JSCallerSavedCode(int n);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000045
46
47// Forward declarations.
48class StackFrameIterator;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000049class ThreadLocalTop;
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000050class Isolate;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000051
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000052class InnerPointerToCodeCache {
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000053 public:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000054 struct InnerPointerToCodeCacheEntry {
55 Address inner_pointer;
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000056 Code* code;
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +000057 SafepointEntry safepoint_entry;
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000058 };
59
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000060 explicit InnerPointerToCodeCache(Isolate* isolate) : isolate_(isolate) {
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000061 Flush();
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000062 }
63
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000064 Code* GcSafeFindCodeForInnerPointer(Address inner_pointer);
65 Code* GcSafeCastToCode(HeapObject* object, Address inner_pointer);
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000066
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000067 void Flush() {
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000068 memset(&cache_[0], 0, sizeof(cache_));
69 }
70
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000071 InnerPointerToCodeCacheEntry* GetCacheEntry(Address inner_pointer);
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000072
73 private:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000074 InnerPointerToCodeCacheEntry* cache(int index) { return &cache_[index]; }
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000075
76 Isolate* isolate_;
77
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000078 static const int kInnerPointerToCodeCacheSize = 1024;
79 InnerPointerToCodeCacheEntry cache_[kInnerPointerToCodeCacheSize];
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000080
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000081 DISALLOW_COPY_AND_ASSIGN(InnerPointerToCodeCache);
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +000082};
83
84
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000085class StackHandler BASE_EMBEDDED {
86 public:
jkummerow@chromium.org04e4f1e2011-11-14 13:36:17 +000087 enum Kind {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000088 ENTRY,
89 TRY_CATCH,
90 TRY_FINALLY
91 };
92
jkummerow@chromium.org04e4f1e2011-11-14 13:36:17 +000093 static const int kKindWidth = 2;
94 static const int kOffsetWidth = 32 - kKindWidth;
95 class KindField: public BitField<StackHandler::Kind, 0, kKindWidth> {};
96 class OffsetField: public BitField<unsigned, kKindWidth, kOffsetWidth> {};
97
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000098 // Get the address of this stack handler.
99 inline Address address() const;
100
101 // Get the next stack handler in the chain.
102 inline StackHandler* next() const;
103
104 // Tells whether the given address is inside this handler.
105 inline bool includes(Address address) const;
106
107 // Garbage collection support.
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000108 inline void Iterate(ObjectVisitor* v, Code* holder) const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000109
110 // Conversion support.
111 static inline StackHandler* FromAddress(Address address);
112
113 // Testers
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000114 inline bool is_entry() const;
115 inline bool is_try_catch() const;
116 inline bool is_try_finally() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000117
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000118 private:
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000119 // Accessors.
jkummerow@chromium.org04e4f1e2011-11-14 13:36:17 +0000120 inline Kind kind() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000121
whesse@chromium.org4acdc2c2011-08-15 13:01:23 +0000122 inline Object** context_address() const;
jkummerow@chromium.org04e4f1e2011-11-14 13:36:17 +0000123 inline Object** code_address() const;
mads.s.ager31e71382008-08-13 09:32:07 +0000124
125 DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000126};
127
128
129#define STACK_FRAME_TYPE_LIST(V) \
130 V(ENTRY, EntryFrame) \
131 V(ENTRY_CONSTRUCT, EntryConstructFrame) \
132 V(EXIT, ExitFrame) \
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000133 V(JAVA_SCRIPT, JavaScriptFrame) \
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000134 V(OPTIMIZED, OptimizedFrame) \
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000135 V(INTERNAL, InternalFrame) \
ager@chromium.org7c537e22008-10-16 08:43:32 +0000136 V(CONSTRUCT, ConstructFrame) \
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000137 V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame)
138
139
140// Abstract base class for all stack frames.
141class StackFrame BASE_EMBEDDED {
142 public:
143#define DECLARE_TYPE(type, ignore) type,
144 enum Type {
145 NONE = 0,
146 STACK_FRAME_TYPE_LIST(DECLARE_TYPE)
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000147 NUMBER_OF_TYPES,
148 // Used by FrameScope to indicate that the stack frame is constructed
149 // manually and the FrameScope does not need to emit code.
150 MANUAL
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000151 };
152#undef DECLARE_TYPE
153
154 // Opaque data type for identifying stack frames. Used extensively
155 // by the debugger.
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000156 // ID_MIN_VALUE and ID_MAX_VALUE are specified to ensure that enumeration type
157 // has correct value range (see Issue 830 for more details).
158 enum Id {
159 ID_MIN_VALUE = kMinInt,
160 ID_MAX_VALUE = kMaxInt,
161 NO_ID = 0
162 };
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000163
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000164 // Used to mark the outermost JS entry frame.
165 enum JsFrameMarker {
166 INNER_JSENTRY_FRAME = 0,
167 OUTERMOST_JSENTRY_FRAME = 1
168 };
169
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000170 struct State {
171 State() : sp(NULL), fp(NULL), pc_address(NULL) { }
172 Address sp;
173 Address fp;
174 Address* pc_address;
175 };
176
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000177 // Copy constructor; it breaks the connection to host iterator
178 // (as an iterator usually lives on stack).
ager@chromium.org357bf652010-04-12 11:30:10 +0000179 StackFrame(const StackFrame& original) {
180 this->state_ = original.state_;
181 this->iterator_ = NULL;
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000182 this->isolate_ = original.isolate_;
ager@chromium.org357bf652010-04-12 11:30:10 +0000183 }
184
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000185 // Type testers.
186 bool is_entry() const { return type() == ENTRY; }
187 bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; }
188 bool is_exit() const { return type() == EXIT; }
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000189 bool is_optimized() const { return type() == OPTIMIZED; }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000190 bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
191 bool is_internal() const { return type() == INTERNAL; }
ager@chromium.org7c537e22008-10-16 08:43:32 +0000192 bool is_construct() const { return type() == CONSTRUCT; }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000193 virtual bool is_standard() const { return false; }
194
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000195 bool is_java_script() const {
196 Type type = this->type();
197 return (type == JAVA_SCRIPT) || (type == OPTIMIZED);
198 }
199
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000200 // Accessors.
201 Address sp() const { return state_.sp; }
202 Address fp() const { return state_.fp; }
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000203 Address caller_sp() const { return GetCallerStackPointer(); }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000204
205 Address pc() const { return *pc_address(); }
206 void set_pc(Address pc) { *pc_address() = pc; }
207
ager@chromium.org357bf652010-04-12 11:30:10 +0000208 virtual void SetCallerFp(Address caller_fp) = 0;
209
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000210 Address* pc_address() const { return state_.pc_address; }
211
212 // Get the id of this stack frame.
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000213 Id id() const { return static_cast<Id>(OffsetFrom(caller_sp())); }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000214
215 // Checks if this frame includes any stack handlers.
216 bool HasHandler() const;
217
218 // Get the type of this frame.
219 virtual Type type() const = 0;
220
221 // Get the code associated with this frame.
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000222 // This method could be called during marking phase of GC.
223 virtual Code* unchecked_code() const = 0;
224
225 // Get the code associated with this frame.
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000226 inline Code* LookupCode() const;
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000227
228 // Get the code object that contains the given pc.
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000229 static inline Code* GetContainingCode(Isolate* isolate, Address pc);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000230
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000231 // Get the code object containing the given pc and fill in the
232 // safepoint entry and the number of stack slots. The pc must be at
233 // a safepoint.
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000234 static Code* GetSafepointData(Isolate* isolate,
235 Address pc,
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +0000236 SafepointEntry* safepoint_entry,
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000237 unsigned* stack_slots);
238
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000239 virtual void Iterate(ObjectVisitor* v) const = 0;
240 static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000241
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000242
243 // Printing support.
244 enum PrintMode { OVERVIEW, DETAILS };
245 virtual void Print(StringStream* accumulator,
246 PrintMode mode,
247 int index) const { }
248
249 protected:
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000250 inline explicit StackFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000251 virtual ~StackFrame() { }
252
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000253 Isolate* isolate() const { return isolate_; }
254
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000255 // Compute the stack pointer for the calling frame.
256 virtual Address GetCallerStackPointer() const = 0;
257
258 // Printing support.
259 static void PrintIndex(StringStream* accumulator,
260 PrintMode mode,
261 int index);
262
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000263 // Get the top handler from the current stack iterator.
264 inline StackHandler* top_handler() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000265
266 // Compute the stack frame type for the given state.
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000267 static Type ComputeType(Isolate* isolate, State* state);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000268
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000269 private:
270 const StackFrameIterator* iterator_;
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000271 Isolate* isolate_;
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000272 State state_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000273
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000274 // Fill in the state of the calling frame.
275 virtual void ComputeCallerState(State* state) const = 0;
276
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000277 // Get the type and the state of the calling frame.
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000278 virtual Type GetCallerState(State* state) const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000279
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000280 static const intptr_t kIsolateTag = 1;
281
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000282 friend class StackFrameIterator;
283 friend class StackHandlerIterator;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000284 friend class SafeStackFrameIterator;
mads.s.ager31e71382008-08-13 09:32:07 +0000285
ager@chromium.org357bf652010-04-12 11:30:10 +0000286 private:
287 void operator=(const StackFrame& original);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000288};
289
290
291// Entry frames are used to enter JavaScript execution from C.
292class EntryFrame: public StackFrame {
293 public:
294 virtual Type type() const { return ENTRY; }
295
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000296 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000297
298 // Garbage collection support.
299 virtual void Iterate(ObjectVisitor* v) const;
300
301 static EntryFrame* cast(StackFrame* frame) {
302 ASSERT(frame->is_entry());
303 return static_cast<EntryFrame*>(frame);
304 }
ager@chromium.org357bf652010-04-12 11:30:10 +0000305 virtual void SetCallerFp(Address caller_fp);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000306
307 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000308 inline explicit EntryFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000309
310 // The caller stack pointer for entry frames is always zero. The
311 // real information about the caller frame is available through the
312 // link to the top exit frame.
313 virtual Address GetCallerStackPointer() const { return 0; }
314
315 private:
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000316 virtual void ComputeCallerState(State* state) const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000317 virtual Type GetCallerState(State* state) const;
318
319 friend class StackFrameIterator;
320};
321
322
323class EntryConstructFrame: public EntryFrame {
324 public:
325 virtual Type type() const { return ENTRY_CONSTRUCT; }
326
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000327 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000328
329 static EntryConstructFrame* cast(StackFrame* frame) {
330 ASSERT(frame->is_entry_construct());
331 return static_cast<EntryConstructFrame*>(frame);
332 }
333
334 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000335 inline explicit EntryConstructFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000336
337 private:
338 friend class StackFrameIterator;
339};
340
341
342// Exit frames are used to exit JavaScript execution and go to C.
343class ExitFrame: public StackFrame {
344 public:
345 virtual Type type() const { return EXIT; }
346
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000347 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000348
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000349 Object*& code_slot() const;
350
ager@chromium.org32912102009-01-16 10:38:43 +0000351 // Garbage collection support.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000352 virtual void Iterate(ObjectVisitor* v) const;
353
ager@chromium.org357bf652010-04-12 11:30:10 +0000354 virtual void SetCallerFp(Address caller_fp);
355
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000356 static ExitFrame* cast(StackFrame* frame) {
357 ASSERT(frame->is_exit());
358 return static_cast<ExitFrame*>(frame);
359 }
360
361 // Compute the state and type of an exit frame given a frame
362 // pointer. Used when constructing the first stack frame seen by an
363 // iterator and the frames following entry frames.
364 static Type GetStateForFramePointer(Address fp, State* state);
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000365 static Address ComputeStackPointer(Address fp);
366 static void FillState(Address fp, Address sp, State* state);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000367
368 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000369 inline explicit ExitFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000370
371 virtual Address GetCallerStackPointer() const;
372
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000373 private:
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000374 virtual void ComputeCallerState(State* state) const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000375
376 friend class StackFrameIterator;
377};
378
379
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000380class StandardFrame: public StackFrame {
381 public:
382 // Testers.
383 virtual bool is_standard() const { return true; }
384
385 // Accessors.
386 inline Object* context() const;
387
388 // Access the expressions in the stack frame including locals.
389 inline Object* GetExpression(int index) const;
390 inline void SetExpression(int index, Object* value);
391 int ComputeExpressionsCount() const;
ricow@chromium.org4f693d62011-07-04 14:01:31 +0000392 static Object* GetExpression(Address fp, int index);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000393
ager@chromium.org357bf652010-04-12 11:30:10 +0000394 virtual void SetCallerFp(Address caller_fp);
395
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000396 static StandardFrame* cast(StackFrame* frame) {
397 ASSERT(frame->is_standard());
398 return static_cast<StandardFrame*>(frame);
399 }
400
401 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000402 inline explicit StandardFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000403
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000404 virtual void ComputeCallerState(State* state) const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000405
406 // Accessors.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000407 inline Address caller_fp() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000408 inline Address caller_pc() const;
409
410 // Computes the address of the PC field in the standard frame given
411 // by the provided frame pointer.
412 static inline Address ComputePCAddress(Address fp);
413
414 // Iterate over expression stack including stack handlers, locals,
415 // and parts of the fixed part including context and code fields.
416 void IterateExpressions(ObjectVisitor* v) const;
417
418 // Returns the address of the n'th expression stack element.
419 Address GetExpressionAddress(int n) const;
ricow@chromium.org4f693d62011-07-04 14:01:31 +0000420 static Address GetExpressionAddress(Address fp, int n);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000421
422 // Determines if the n'th expression stack element is in a stack
423 // handler or not. Requires traversing all handlers in this frame.
424 bool IsExpressionInsideHandler(int n) const;
425
426 // Determines if the standard frame for the given frame pointer is
427 // an arguments adaptor frame.
428 static inline bool IsArgumentsAdaptorFrame(Address fp);
429
ager@chromium.org7c537e22008-10-16 08:43:32 +0000430 // Determines if the standard frame for the given frame pointer is a
431 // construct frame.
432 static inline bool IsConstructFrame(Address fp);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000433
434 private:
435 friend class StackFrame;
sgjesse@chromium.org720dc0b2010-05-10 09:25:39 +0000436 friend class StackFrameIterator;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000437};
438
439
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000440class FrameSummary BASE_EMBEDDED {
441 public:
442 FrameSummary(Object* receiver,
443 JSFunction* function,
444 Code* code,
445 int offset,
446 bool is_constructor)
447 : receiver_(receiver),
448 function_(function),
449 code_(code),
450 offset_(offset),
451 is_constructor_(is_constructor) { }
452 Handle<Object> receiver() { return receiver_; }
453 Handle<JSFunction> function() { return function_; }
454 Handle<Code> code() { return code_; }
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000455 Address pc() { return code_->address() + offset_; }
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000456 int offset() { return offset_; }
457 bool is_constructor() { return is_constructor_; }
458
459 void Print();
460
461 private:
462 Handle<Object> receiver_;
463 Handle<JSFunction> function_;
464 Handle<Code> code_;
465 int offset_;
466 bool is_constructor_;
467};
468
469
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000470class JavaScriptFrame: public StandardFrame {
471 public:
472 virtual Type type() const { return JAVA_SCRIPT; }
473
474 // Accessors.
475 inline Object* function() const;
476 inline Object* receiver() const;
477 inline void set_receiver(Object* value);
478
479 // Access the parameters.
karlklose@chromium.org44bc7082011-04-11 12:33:05 +0000480 inline Address GetParameterSlot(int index) const;
481 inline Object* GetParameter(int index) const;
482 inline int ComputeParametersCount() const {
483 return GetNumberOfIncomingArguments();
484 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000485
ager@chromium.org7c537e22008-10-16 08:43:32 +0000486 // Check if this frame is a constructor frame invoked through 'new'.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000487 bool IsConstructor() const;
488
489 // Check if this frame has "adapted" arguments in the sense that the
490 // actual passed arguments are available in an arguments adaptor
491 // frame below it on the stack.
492 inline bool has_adapted_arguments() const;
ricow@chromium.org4f693d62011-07-04 14:01:31 +0000493 int GetArgumentsLength() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000494
ager@chromium.org32912102009-01-16 10:38:43 +0000495 // Garbage collection support.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000496 virtual void Iterate(ObjectVisitor* v) const;
497
498 // Printing support.
499 virtual void Print(StringStream* accumulator,
500 PrintMode mode,
501 int index) const;
502
503 // Determine the code for the frame.
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000504 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000505
ricow@chromium.org4f693d62011-07-04 14:01:31 +0000506 // Returns the levels of inlining for this frame.
507 virtual int GetInlineCount() { return 1; }
508
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000509 // Return a list with JSFunctions of this frame.
510 virtual void GetFunctions(List<JSFunction*>* functions);
511
512 // Build a list with summaries for this frame including all inlined frames.
513 virtual void Summarize(List<FrameSummary>* frames);
514
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000515 static JavaScriptFrame* cast(StackFrame* frame) {
516 ASSERT(frame->is_java_script());
517 return static_cast<JavaScriptFrame*>(frame);
518 }
519
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000520 static void PrintTop(FILE* file, bool print_args, bool print_line_number);
521
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000522 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000523 inline explicit JavaScriptFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000524
525 virtual Address GetCallerStackPointer() const;
526
karlklose@chromium.org44bc7082011-04-11 12:33:05 +0000527 virtual int GetNumberOfIncomingArguments() const;
528
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000529 // Garbage collection support. Iterates over incoming arguments,
530 // receiver, and any callee-saved registers.
531 void IterateArguments(ObjectVisitor* v) const;
532
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000533 private:
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000534 inline Object* function_slot_object() const;
535
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000536 friend class StackFrameIterator;
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000537 friend class StackTracer;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000538};
539
540
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000541class OptimizedFrame : public JavaScriptFrame {
542 public:
543 virtual Type type() const { return OPTIMIZED; }
544
545 // GC support.
546 virtual void Iterate(ObjectVisitor* v) const;
547
ricow@chromium.org4f693d62011-07-04 14:01:31 +0000548 virtual int GetInlineCount();
549
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000550 // Return a list with JSFunctions of this frame.
551 // The functions are ordered bottom-to-top (i.e. functions.last()
552 // is the top-most activation)
553 virtual void GetFunctions(List<JSFunction*>* functions);
554
555 virtual void Summarize(List<FrameSummary>* frames);
556
557 DeoptimizationInputData* GetDeoptimizationData(int* deopt_index);
558
559 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000560 inline explicit OptimizedFrame(StackFrameIterator* iterator);
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000561
562 private:
563 friend class StackFrameIterator;
564};
565
566
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000567// Arguments adaptor frames are automatically inserted below
568// JavaScript frames when the actual number of parameters does not
569// match the formal number of parameters.
570class ArgumentsAdaptorFrame: public JavaScriptFrame {
571 public:
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000572 virtual Type type() const { return ARGUMENTS_ADAPTOR; }
573
574 // Determine the code for the frame.
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000575 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000576
577 static ArgumentsAdaptorFrame* cast(StackFrame* frame) {
578 ASSERT(frame->is_arguments_adaptor());
579 return static_cast<ArgumentsAdaptorFrame*>(frame);
580 }
581
582 // Printing support.
583 virtual void Print(StringStream* accumulator,
584 PrintMode mode,
585 int index) const;
kmillikin@chromium.org83e16822011-09-13 08:21:47 +0000586
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000587 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000588 inline explicit ArgumentsAdaptorFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000589
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000590 virtual int GetNumberOfIncomingArguments() const;
karlklose@chromium.org44bc7082011-04-11 12:33:05 +0000591
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000592 virtual Address GetCallerStackPointer() const;
593
594 private:
595 friend class StackFrameIterator;
596};
597
598
599class InternalFrame: public StandardFrame {
600 public:
601 virtual Type type() const { return INTERNAL; }
602
ager@chromium.org32912102009-01-16 10:38:43 +0000603 // Garbage collection support.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000604 virtual void Iterate(ObjectVisitor* v) const;
605
606 // Determine the code for the frame.
ricow@chromium.org0b9f8502010-08-18 07:45:01 +0000607 virtual Code* unchecked_code() const;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000608
609 static InternalFrame* cast(StackFrame* frame) {
610 ASSERT(frame->is_internal());
611 return static_cast<InternalFrame*>(frame);
612 }
613
614 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000615 inline explicit InternalFrame(StackFrameIterator* iterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000616
617 virtual Address GetCallerStackPointer() const;
618
619 private:
620 friend class StackFrameIterator;
621};
622
623
ager@chromium.org7c537e22008-10-16 08:43:32 +0000624// Construct frames are special trampoline frames introduced to handle
625// function invocations through 'new'.
626class ConstructFrame: public InternalFrame {
627 public:
628 virtual Type type() const { return CONSTRUCT; }
629
630 static ConstructFrame* cast(StackFrame* frame) {
631 ASSERT(frame->is_construct());
632 return static_cast<ConstructFrame*>(frame);
633 }
634
635 protected:
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000636 inline explicit ConstructFrame(StackFrameIterator* iterator);
ager@chromium.org7c537e22008-10-16 08:43:32 +0000637
638 private:
639 friend class StackFrameIterator;
640};
641
642
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000643class StackFrameIterator BASE_EMBEDDED {
644 public:
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000645 // An iterator that iterates over the current thread's stack,
646 // and uses current isolate.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000647 StackFrameIterator();
648
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000649 // An iterator that iterates over the isolate's current thread's stack,
650 explicit StackFrameIterator(Isolate* isolate);
651
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000652 // An iterator that iterates over a given thread's stack.
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000653 StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000654
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000655 // An iterator that can start from a given FP address.
656 // If use_top, then work as usual, if fp isn't NULL, use it,
657 // otherwise, do nothing.
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000658 StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000659
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000660 StackFrame* frame() const {
661 ASSERT(!done());
662 return frame_;
663 }
664
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000665 Isolate* isolate() const { return isolate_; }
666
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000667 bool done() const { return frame_ == NULL; }
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000668 void Advance() { (this->*advance_)(); }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000669
670 // Go back to the first frame.
671 void Reset();
672
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000673 private:
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000674 Isolate* isolate_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000675#define DECLARE_SINGLETON(ignore, type) type type##_;
676 STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
677#undef DECLARE_SINGLETON
678 StackFrame* frame_;
679 StackHandler* handler_;
kasper.lund7276f142008-07-30 08:49:36 +0000680 ThreadLocalTop* thread_;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000681 Address fp_;
682 Address sp_;
683 void (StackFrameIterator::*advance_)();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000684
685 StackHandler* handler() const {
686 ASSERT(!done());
687 return handler_;
688 }
689
690 // Get the type-specific frame singleton in a given state.
691 StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state);
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000692 // A helper function, can return a NULL pointer.
693 StackFrame* SingletonFor(StackFrame::Type type);
694
695 void AdvanceWithHandler();
696 void AdvanceWithoutHandler();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000697
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000698 friend class StackFrame;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000699 friend class SafeStackFrameIterator;
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000700 DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000701};
702
703
704// Iterator that supports iterating through all JavaScript frames.
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000705template<typename Iterator>
706class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000707 public:
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000708 JavaScriptFrameIteratorTemp() { if (!done()) Advance(); }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000709
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000710 inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000711
rossberg@chromium.orgb4b2aa62011-10-13 09:49:59 +0000712 inline JavaScriptFrameIteratorTemp(Isolate* isolate, ThreadLocalTop* top);
713
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000714 // Skip frames until the frame with the given id is reached.
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000715 explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }
716
717 inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000718
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000719 JavaScriptFrameIteratorTemp(Address fp,
720 Address sp,
721 Address low_bound,
722 Address high_bound) :
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000723 iterator_(fp, sp, low_bound, high_bound) {
724 if (!done()) Advance();
725 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000726
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000727 JavaScriptFrameIteratorTemp(Isolate* isolate,
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000728 Address fp,
729 Address sp,
730 Address low_bound,
731 Address high_bound) :
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000732 iterator_(isolate, fp, sp, low_bound, high_bound) {
733 if (!done()) Advance();
734 }
735
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000736 inline JavaScriptFrame* frame() const;
737
738 bool done() const { return iterator_.done(); }
739 void Advance();
740
741 // Advance to the frame holding the arguments for the current
742 // frame. This only affects the current frame if it has adapted
743 // arguments.
744 void AdvanceToArgumentsFrame();
745
746 // Go back to the first frame.
747 void Reset();
748
749 private:
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000750 inline void AdvanceToId(StackFrame::Id id);
751
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000752 Iterator iterator_;
753};
754
755
756typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
757
758
759// NOTE: The stack trace frame iterator is an iterator that only
760// traverse proper JavaScript frames; that is JavaScript frames that
761// have proper JavaScript functions. This excludes the problematic
762// functions in runtime.js.
763class StackTraceFrameIterator: public JavaScriptFrameIterator {
764 public:
765 StackTraceFrameIterator();
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000766 explicit StackTraceFrameIterator(Isolate* isolate);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000767 void Advance();
sgjesse@chromium.orgb302e562010-02-03 11:26:59 +0000768
769 private:
770 bool IsValidFrame();
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000771};
772
773
774class SafeStackFrameIterator BASE_EMBEDDED {
775 public:
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000776 SafeStackFrameIterator(Isolate* isolate,
777 Address fp, Address sp,
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000778 Address low_bound, Address high_bound);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000779
780 StackFrame* frame() const {
781 ASSERT(is_working_iterator_);
782 return iterator_.frame();
783 }
784
785 bool done() const { return iteration_done_ ? true : iterator_.done(); }
786
787 void Advance();
788 void Reset();
789
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000790 static bool is_active(Isolate* isolate);
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000791
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000792 static bool IsWithinBounds(
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000793 Address low_bound, Address high_bound, Address addr) {
794 return low_bound <= addr && addr <= high_bound;
795 }
sgjesse@chromium.orgb302e562010-02-03 11:26:59 +0000796
797 private:
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000798 class StackAddressValidator {
799 public:
800 StackAddressValidator(Address low_bound, Address high_bound)
801 : low_bound_(low_bound), high_bound_(high_bound) { }
802 bool IsValid(Address addr) const {
803 return IsWithinBounds(low_bound_, high_bound_, addr);
804 }
805 private:
806 Address low_bound_;
807 Address high_bound_;
808 };
809
810 class ExitFrameValidator {
811 public:
812 explicit ExitFrameValidator(const StackAddressValidator& validator)
813 : validator_(validator) { }
814 ExitFrameValidator(Address low_bound, Address high_bound)
815 : validator_(low_bound, high_bound) { }
816 bool IsValidFP(Address fp);
817 private:
818 StackAddressValidator validator_;
819 };
820
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000821 bool IsValidStackAddress(Address addr) const {
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000822 return stack_validator_.IsValid(addr);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000823 }
kasperl@chromium.orgd1e3e722009-04-14 13:38:25 +0000824 bool CanIterateHandles(StackFrame* frame, StackHandler* handler);
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000825 bool IsValidFrame(StackFrame* frame) const;
826 bool IsValidCaller(StackFrame* frame);
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000827 static bool IsValidTop(Isolate* isolate,
828 Address low_bound, Address high_bound);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000829
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000830 // This is a nasty hack to make sure the active count is incremented
831 // before the constructor for the embedded iterator is invoked. This
832 // is needed because the constructor will start looking at frames
833 // right away and we need to make sure it doesn't start inspecting
834 // heap objects.
835 class ActiveCountMaintainer BASE_EMBEDDED {
836 public:
vegorov@chromium.org74f333b2011-04-06 11:17:46 +0000837 explicit ActiveCountMaintainer(Isolate* isolate);
838 ~ActiveCountMaintainer();
839 private:
840 Isolate* isolate_;
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000841 };
842
843 ActiveCountMaintainer maintainer_;
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000844 StackAddressValidator stack_validator_;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000845 const bool is_valid_top_;
846 const bool is_valid_fp_;
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000847 const bool is_working_iterator_;
848 bool iteration_done_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000849 StackFrameIterator iterator_;
850};
851
852
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000853typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator>
854 SafeJavaScriptFrameIterator;
855
856
857class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator {
858 public:
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000859 explicit SafeStackTraceFrameIterator(Isolate* isolate,
860 Address fp, Address sp,
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000861 Address low_bound, Address high_bound);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000862 void Advance();
863};
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000864
865
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000866class StackFrameLocator BASE_EMBEDDED {
867 public:
868 // Find the nth JavaScript frame on the stack. The caller must
869 // guarantee that such a frame exists.
870 JavaScriptFrame* FindJavaScriptFrame(int n);
871
872 private:
873 StackFrameIterator iterator_;
874};
875
876
ager@chromium.org357bf652010-04-12 11:30:10 +0000877// Reads all frames on the current stack and copies them into the current
878// zone memory.
879Vector<StackFrame*> CreateStackMap();
880
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000881} } // namespace v8::internal
882
883#endif // V8_FRAMES_H_