2008-09-09 20:08:45 +00:00
|
|
|
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef V8_FRAMES_H_
|
|
|
|
#define V8_FRAMES_H_
|
|
|
|
|
2011-05-06 06:50:20 +00:00
|
|
|
#include "allocation.h"
|
2011-03-18 20:35:07 +00:00
|
|
|
#include "handles.h"
|
2011-01-12 14:14:14 +00:00
|
|
|
#include "safepoint-table.h"
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
typedef uint32_t RegList;
|
|
|
|
|
|
|
|
// Get the number of registers in a given register list.
|
|
|
|
int NumRegs(RegList list);
|
|
|
|
|
|
|
|
// Return the code of the n-th saved register available to JavaScript.
|
|
|
|
int JSCallerSavedCode(int n);
|
|
|
|
|
|
|
|
|
|
|
|
// Forward declarations.
|
|
|
|
class StackFrameIterator;
|
|
|
|
class ThreadLocalTop;
|
2011-03-18 20:35:07 +00:00
|
|
|
class Isolate;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
class PcToCodeCache {
|
2010-08-30 08:54:43 +00:00
|
|
|
public:
|
|
|
|
struct PcToCodeCacheEntry {
|
|
|
|
Address pc;
|
|
|
|
Code* code;
|
2011-01-12 14:14:14 +00:00
|
|
|
SafepointEntry safepoint_entry;
|
2010-08-30 08:54:43 +00:00
|
|
|
};
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit PcToCodeCache(Isolate* isolate) : isolate_(isolate) {
|
|
|
|
Flush();
|
2010-08-30 08:54:43 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Code* GcSafeFindCodeForPc(Address pc);
|
|
|
|
Code* GcSafeCastToCode(HeapObject* object, Address pc);
|
2010-08-30 08:54:43 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
void Flush() {
|
2010-08-30 08:54:43 +00:00
|
|
|
memset(&cache_[0], 0, sizeof(cache_));
|
|
|
|
}
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
PcToCodeCacheEntry* GetCacheEntry(Address pc);
|
2010-08-30 08:54:43 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
PcToCodeCacheEntry* cache(int index) { return &cache_[index]; }
|
|
|
|
|
|
|
|
Isolate* isolate_;
|
|
|
|
|
2010-09-20 13:50:27 +00:00
|
|
|
static const int kPcToCodeCacheSize = 1024;
|
2011-03-18 20:35:07 +00:00
|
|
|
PcToCodeCacheEntry cache_[kPcToCodeCacheSize];
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PcToCodeCache);
|
2010-08-30 08:54:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class StackHandler BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
enum State {
|
|
|
|
ENTRY,
|
|
|
|
TRY_CATCH,
|
|
|
|
TRY_FINALLY
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get the address of this stack handler.
|
|
|
|
inline Address address() const;
|
|
|
|
|
|
|
|
// Get the next stack handler in the chain.
|
|
|
|
inline StackHandler* next() const;
|
|
|
|
|
|
|
|
// Tells whether the given address is inside this handler.
|
|
|
|
inline bool includes(Address address) const;
|
|
|
|
|
|
|
|
// Garbage collection support.
|
2010-08-30 08:54:43 +00:00
|
|
|
inline void Iterate(ObjectVisitor* v, Code* holder) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Conversion support.
|
|
|
|
static inline StackHandler* FromAddress(Address address);
|
|
|
|
|
|
|
|
// Testers
|
|
|
|
bool is_entry() { return state() == ENTRY; }
|
|
|
|
bool is_try_catch() { return state() == TRY_CATCH; }
|
|
|
|
bool is_try_finally() { return state() == TRY_FINALLY; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Accessors.
|
|
|
|
inline State state() const;
|
|
|
|
|
2010-08-30 08:54:43 +00:00
|
|
|
inline Address* pc_address() const;
|
2008-08-13 09:32:07 +00:00
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define STACK_FRAME_TYPE_LIST(V) \
|
|
|
|
V(ENTRY, EntryFrame) \
|
|
|
|
V(ENTRY_CONSTRUCT, EntryConstructFrame) \
|
|
|
|
V(EXIT, ExitFrame) \
|
|
|
|
V(JAVA_SCRIPT, JavaScriptFrame) \
|
2010-12-07 11:31:57 +00:00
|
|
|
V(OPTIMIZED, OptimizedFrame) \
|
2008-07-03 15:10:15 +00:00
|
|
|
V(INTERNAL, InternalFrame) \
|
2008-10-10 09:09:38 +00:00
|
|
|
V(CONSTRUCT, ConstructFrame) \
|
2008-07-03 15:10:15 +00:00
|
|
|
V(ARGUMENTS_ADAPTOR, ArgumentsAdaptorFrame)
|
|
|
|
|
|
|
|
|
|
|
|
// Abstract base class for all stack frames.
|
|
|
|
class StackFrame BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
#define DECLARE_TYPE(type, ignore) type,
|
|
|
|
enum Type {
|
|
|
|
NONE = 0,
|
|
|
|
STACK_FRAME_TYPE_LIST(DECLARE_TYPE)
|
2011-05-31 15:21:25 +00:00
|
|
|
NUMBER_OF_TYPES
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
#undef DECLARE_TYPE
|
|
|
|
|
|
|
|
// Opaque data type for identifying stack frames. Used extensively
|
|
|
|
// by the debugger.
|
2010-08-16 17:14:34 +00:00
|
|
|
// ID_MIN_VALUE and ID_MAX_VALUE are specified to ensure that enumeration type
|
|
|
|
// has correct value range (see Issue 830 for more details).
|
|
|
|
enum Id {
|
|
|
|
ID_MIN_VALUE = kMinInt,
|
|
|
|
ID_MAX_VALUE = kMaxInt,
|
|
|
|
NO_ID = 0
|
|
|
|
};
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-05-17 11:11:12 +00:00
|
|
|
// Used to mark the outermost JS entry frame.
|
|
|
|
enum JsFrameMarker {
|
|
|
|
INNER_JSENTRY_FRAME = 0,
|
|
|
|
OUTERMOST_JSENTRY_FRAME = 1
|
|
|
|
};
|
|
|
|
|
2010-09-16 08:51:13 +00:00
|
|
|
struct State {
|
|
|
|
State() : sp(NULL), fp(NULL), pc_address(NULL) { }
|
|
|
|
Address sp;
|
|
|
|
Address fp;
|
|
|
|
Address* pc_address;
|
|
|
|
};
|
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
// Copy constructor; it breaks the connection to host iterator
|
|
|
|
// (as an iterator usually lives on stack).
|
2010-04-06 17:58:28 +00:00
|
|
|
StackFrame(const StackFrame& original) {
|
|
|
|
this->state_ = original.state_;
|
|
|
|
this->iterator_ = NULL;
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
this->isolate_ = original.isolate_;
|
2010-04-06 17:58:28 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Type testers.
|
|
|
|
bool is_entry() const { return type() == ENTRY; }
|
|
|
|
bool is_entry_construct() const { return type() == ENTRY_CONSTRUCT; }
|
|
|
|
bool is_exit() const { return type() == EXIT; }
|
2010-12-07 11:31:57 +00:00
|
|
|
bool is_optimized() const { return type() == OPTIMIZED; }
|
2008-07-03 15:10:15 +00:00
|
|
|
bool is_arguments_adaptor() const { return type() == ARGUMENTS_ADAPTOR; }
|
|
|
|
bool is_internal() const { return type() == INTERNAL; }
|
2008-10-10 09:09:38 +00:00
|
|
|
bool is_construct() const { return type() == CONSTRUCT; }
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual bool is_standard() const { return false; }
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
bool is_java_script() const {
|
|
|
|
Type type = this->type();
|
|
|
|
return (type == JAVA_SCRIPT) || (type == OPTIMIZED);
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Accessors.
|
|
|
|
Address sp() const { return state_.sp; }
|
|
|
|
Address fp() const { return state_.fp; }
|
2009-06-10 15:08:25 +00:00
|
|
|
Address caller_sp() const { return GetCallerStackPointer(); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
Address pc() const { return *pc_address(); }
|
|
|
|
void set_pc(Address pc) { *pc_address() = pc; }
|
|
|
|
|
2010-04-06 17:58:28 +00:00
|
|
|
virtual void SetCallerFp(Address caller_fp) = 0;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
Address* pc_address() const { return state_.pc_address; }
|
|
|
|
|
|
|
|
// Get the id of this stack frame.
|
2009-06-10 15:08:25 +00:00
|
|
|
Id id() const { return static_cast<Id>(OffsetFrom(caller_sp())); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Checks if this frame includes any stack handlers.
|
|
|
|
bool HasHandler() const;
|
|
|
|
|
|
|
|
// Get the type of this frame.
|
|
|
|
virtual Type type() const = 0;
|
|
|
|
|
|
|
|
// Get the code associated with this frame.
|
2010-08-17 11:44:01 +00:00
|
|
|
// This method could be called during marking phase of GC.
|
|
|
|
virtual Code* unchecked_code() const = 0;
|
|
|
|
|
|
|
|
// Get the code associated with this frame.
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
Code* LookupCode() const {
|
|
|
|
return GetContainingCode(isolate(), pc());
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
2010-08-30 08:54:43 +00:00
|
|
|
|
|
|
|
// Get the code object that contains the given pc.
|
2011-03-18 20:35:07 +00:00
|
|
|
static inline Code* GetContainingCode(Isolate* isolate, Address pc);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Get the code object containing the given pc and fill in the
|
|
|
|
// safepoint entry and the number of stack slots. The pc must be at
|
|
|
|
// a safepoint.
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
static Code* GetSafepointData(Isolate* isolate,
|
|
|
|
Address pc,
|
2011-01-12 14:14:14 +00:00
|
|
|
SafepointEntry* safepoint_entry,
|
2010-12-07 11:31:57 +00:00
|
|
|
unsigned* stack_slots);
|
|
|
|
|
2010-08-30 08:54:43 +00:00
|
|
|
virtual void Iterate(ObjectVisitor* v) const = 0;
|
|
|
|
static void IteratePc(ObjectVisitor* v, Address* pc_address, Code* holder);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Printing support.
|
|
|
|
enum PrintMode { OVERVIEW, DETAILS };
|
|
|
|
virtual void Print(StringStream* accumulator,
|
|
|
|
PrintMode mode,
|
|
|
|
int index) const { }
|
|
|
|
|
|
|
|
protected:
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
inline explicit StackFrame(StackFrameIterator* iterator);
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual ~StackFrame() { }
|
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
Isolate* isolate() const { return isolate_; }
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Compute the stack pointer for the calling frame.
|
|
|
|
virtual Address GetCallerStackPointer() const = 0;
|
|
|
|
|
|
|
|
// Printing support.
|
|
|
|
static void PrintIndex(StringStream* accumulator,
|
|
|
|
PrintMode mode,
|
|
|
|
int index);
|
|
|
|
|
|
|
|
// Get the top handler from the current stack iterator.
|
|
|
|
inline StackHandler* top_handler() const;
|
|
|
|
|
|
|
|
// Compute the stack frame type for the given state.
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
static Type ComputeType(Isolate* isolate, State* state);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const StackFrameIterator* iterator_;
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
Isolate* isolate_;
|
2008-09-12 03:29:06 +00:00
|
|
|
State state_;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
// Fill in the state of the calling frame.
|
|
|
|
virtual void ComputeCallerState(State* state) const = 0;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Get the type and the state of the calling frame.
|
2009-03-20 14:49:12 +00:00
|
|
|
virtual Type GetCallerState(State* state) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
static const intptr_t kIsolateTag = 1;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class StackFrameIterator;
|
|
|
|
friend class StackHandlerIterator;
|
2009-03-20 14:49:12 +00:00
|
|
|
friend class SafeStackFrameIterator;
|
2010-09-16 08:51:13 +00:00
|
|
|
|
2010-04-06 17:58:28 +00:00
|
|
|
private:
|
|
|
|
void operator=(const StackFrame& original);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Entry frames are used to enter JavaScript execution from C.
|
|
|
|
class EntryFrame: public StackFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return ENTRY; }
|
|
|
|
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Garbage collection support.
|
|
|
|
virtual void Iterate(ObjectVisitor* v) const;
|
|
|
|
|
|
|
|
static EntryFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_entry());
|
|
|
|
return static_cast<EntryFrame*>(frame);
|
|
|
|
}
|
2010-04-06 17:58:28 +00:00
|
|
|
virtual void SetCallerFp(Address caller_fp);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit EntryFrame(StackFrameIterator* iterator) : StackFrame(iterator) { }
|
|
|
|
|
|
|
|
// The caller stack pointer for entry frames is always zero. The
|
|
|
|
// real information about the caller frame is available through the
|
|
|
|
// link to the top exit frame.
|
|
|
|
virtual Address GetCallerStackPointer() const { return 0; }
|
|
|
|
|
|
|
|
private:
|
2009-03-20 14:49:12 +00:00
|
|
|
virtual void ComputeCallerState(State* state) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual Type GetCallerState(State* state) const;
|
|
|
|
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class EntryConstructFrame: public EntryFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return ENTRY_CONSTRUCT; }
|
|
|
|
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
static EntryConstructFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_entry_construct());
|
|
|
|
return static_cast<EntryConstructFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit EntryConstructFrame(StackFrameIterator* iterator)
|
|
|
|
: EntryFrame(iterator) { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Exit frames are used to exit JavaScript execution and go to C.
|
|
|
|
class ExitFrame: public StackFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return EXIT; }
|
|
|
|
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-11-04 08:51:48 +00:00
|
|
|
Object*& code_slot() const;
|
|
|
|
|
2009-01-15 19:08:34 +00:00
|
|
|
// Garbage collection support.
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual void Iterate(ObjectVisitor* v) const;
|
|
|
|
|
2010-04-06 17:58:28 +00:00
|
|
|
virtual void SetCallerFp(Address caller_fp);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static ExitFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_exit());
|
|
|
|
return static_cast<ExitFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the state and type of an exit frame given a frame
|
|
|
|
// pointer. Used when constructing the first stack frame seen by an
|
|
|
|
// iterator and the frames following entry frames.
|
|
|
|
static Type GetStateForFramePointer(Address fp, State* state);
|
2010-09-16 08:23:34 +00:00
|
|
|
static Address ComputeStackPointer(Address fp);
|
|
|
|
static void FillState(Address fp, Address sp, State* state);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit ExitFrame(StackFrameIterator* iterator) : StackFrame(iterator) { }
|
|
|
|
|
|
|
|
virtual Address GetCallerStackPointer() const;
|
|
|
|
|
|
|
|
private:
|
2009-03-20 14:49:12 +00:00
|
|
|
virtual void ComputeCallerState(State* state) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StandardFrame: public StackFrame {
|
|
|
|
public:
|
|
|
|
// Testers.
|
|
|
|
virtual bool is_standard() const { return true; }
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
inline Object* context() const;
|
|
|
|
|
|
|
|
// Access the expressions in the stack frame including locals.
|
|
|
|
inline Object* GetExpression(int index) const;
|
|
|
|
inline void SetExpression(int index, Object* value);
|
|
|
|
int ComputeExpressionsCount() const;
|
|
|
|
|
2010-04-06 17:58:28 +00:00
|
|
|
virtual void SetCallerFp(Address caller_fp);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static StandardFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_standard());
|
|
|
|
return static_cast<StandardFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit StandardFrame(StackFrameIterator* iterator)
|
|
|
|
: StackFrame(iterator) { }
|
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
virtual void ComputeCallerState(State* state) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
inline Address caller_fp() const;
|
|
|
|
inline Address caller_pc() const;
|
|
|
|
|
|
|
|
// Computes the address of the PC field in the standard frame given
|
|
|
|
// by the provided frame pointer.
|
|
|
|
static inline Address ComputePCAddress(Address fp);
|
|
|
|
|
|
|
|
// Iterate over expression stack including stack handlers, locals,
|
|
|
|
// and parts of the fixed part including context and code fields.
|
|
|
|
void IterateExpressions(ObjectVisitor* v) const;
|
|
|
|
|
|
|
|
// Returns the address of the n'th expression stack element.
|
|
|
|
Address GetExpressionAddress(int n) const;
|
|
|
|
|
|
|
|
// Determines if the n'th expression stack element is in a stack
|
|
|
|
// handler or not. Requires traversing all handlers in this frame.
|
|
|
|
bool IsExpressionInsideHandler(int n) const;
|
|
|
|
|
|
|
|
// Determines if the standard frame for the given frame pointer is
|
|
|
|
// an arguments adaptor frame.
|
|
|
|
static inline bool IsArgumentsAdaptorFrame(Address fp);
|
|
|
|
|
2008-10-10 09:09:38 +00:00
|
|
|
// Determines if the standard frame for the given frame pointer is a
|
|
|
|
// construct frame.
|
|
|
|
static inline bool IsConstructFrame(Address fp);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrame;
|
2010-05-08 06:54:36 +00:00
|
|
|
friend class StackFrameIterator;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
class FrameSummary BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
FrameSummary(Object* receiver,
|
|
|
|
JSFunction* function,
|
|
|
|
Code* code,
|
|
|
|
int offset,
|
|
|
|
bool is_constructor)
|
|
|
|
: receiver_(receiver),
|
|
|
|
function_(function),
|
|
|
|
code_(code),
|
|
|
|
offset_(offset),
|
|
|
|
is_constructor_(is_constructor) { }
|
|
|
|
Handle<Object> receiver() { return receiver_; }
|
|
|
|
Handle<JSFunction> function() { return function_; }
|
|
|
|
Handle<Code> code() { return code_; }
|
2011-04-01 10:30:09 +00:00
|
|
|
Address pc() { return code_->address() + offset_; }
|
2010-12-07 11:31:57 +00:00
|
|
|
int offset() { return offset_; }
|
|
|
|
bool is_constructor() { return is_constructor_; }
|
|
|
|
|
|
|
|
void Print();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Handle<Object> receiver_;
|
|
|
|
Handle<JSFunction> function_;
|
|
|
|
Handle<Code> code_;
|
|
|
|
int offset_;
|
|
|
|
bool is_constructor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class JavaScriptFrame: public StandardFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return JAVA_SCRIPT; }
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
inline Object* function() const;
|
|
|
|
inline Object* receiver() const;
|
|
|
|
inline void set_receiver(Object* value);
|
|
|
|
|
|
|
|
// Access the parameters.
|
2011-04-06 14:23:27 +00:00
|
|
|
inline Address GetParameterSlot(int index) const;
|
|
|
|
inline Object* GetParameter(int index) const;
|
|
|
|
inline int ComputeParametersCount() const {
|
|
|
|
return GetNumberOfIncomingArguments();
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-10-10 09:09:38 +00:00
|
|
|
// Check if this frame is a constructor frame invoked through 'new'.
|
2008-07-03 15:10:15 +00:00
|
|
|
bool IsConstructor() const;
|
|
|
|
|
|
|
|
// Check if this frame has "adapted" arguments in the sense that the
|
|
|
|
// actual passed arguments are available in an arguments adaptor
|
|
|
|
// frame below it on the stack.
|
|
|
|
inline bool has_adapted_arguments() const;
|
|
|
|
|
2009-01-15 19:08:34 +00:00
|
|
|
// Garbage collection support.
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual void Iterate(ObjectVisitor* v) const;
|
|
|
|
|
|
|
|
// Printing support.
|
|
|
|
virtual void Print(StringStream* accumulator,
|
|
|
|
PrintMode mode,
|
|
|
|
int index) const;
|
|
|
|
|
|
|
|
// Determine the code for the frame.
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Return a list with JSFunctions of this frame.
|
|
|
|
virtual void GetFunctions(List<JSFunction*>* functions);
|
|
|
|
|
|
|
|
// Build a list with summaries for this frame including all inlined frames.
|
|
|
|
virtual void Summarize(List<FrameSummary>* frames);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static JavaScriptFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_java_script());
|
|
|
|
return static_cast<JavaScriptFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit JavaScriptFrame(StackFrameIterator* iterator)
|
2010-08-30 08:54:43 +00:00
|
|
|
: StandardFrame(iterator) { }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
virtual Address GetCallerStackPointer() const;
|
|
|
|
|
2011-04-06 14:23:27 +00:00
|
|
|
virtual int GetNumberOfIncomingArguments() const;
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Garbage collection support. Iterates over incoming arguments,
|
|
|
|
// receiver, and any callee-saved registers.
|
|
|
|
void IterateArguments(ObjectVisitor* v) const;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2009-03-20 14:49:12 +00:00
|
|
|
inline Object* function_slot_object() const;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class StackFrameIterator;
|
2010-09-16 08:23:34 +00:00
|
|
|
friend class StackTracer;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
class OptimizedFrame : public JavaScriptFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return OPTIMIZED; }
|
|
|
|
|
|
|
|
// GC support.
|
|
|
|
virtual void Iterate(ObjectVisitor* v) const;
|
|
|
|
|
|
|
|
// Return a list with JSFunctions of this frame.
|
|
|
|
// The functions are ordered bottom-to-top (i.e. functions.last()
|
|
|
|
// is the top-most activation)
|
|
|
|
virtual void GetFunctions(List<JSFunction*>* functions);
|
|
|
|
|
|
|
|
virtual void Summarize(List<FrameSummary>* frames);
|
|
|
|
|
|
|
|
DeoptimizationInputData* GetDeoptimizationData(int* deopt_index);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit OptimizedFrame(StackFrameIterator* iterator)
|
|
|
|
: JavaScriptFrame(iterator) { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Arguments adaptor frames are automatically inserted below
|
|
|
|
// JavaScript frames when the actual number of parameters does not
|
|
|
|
// match the formal number of parameters.
|
|
|
|
class ArgumentsAdaptorFrame: public JavaScriptFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return ARGUMENTS_ADAPTOR; }
|
|
|
|
|
|
|
|
// Determine the code for the frame.
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
static ArgumentsAdaptorFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_arguments_adaptor());
|
|
|
|
return static_cast<ArgumentsAdaptorFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Printing support.
|
|
|
|
virtual void Print(StringStream* accumulator,
|
|
|
|
PrintMode mode,
|
|
|
|
int index) const;
|
|
|
|
protected:
|
|
|
|
explicit ArgumentsAdaptorFrame(StackFrameIterator* iterator)
|
|
|
|
: JavaScriptFrame(iterator) { }
|
|
|
|
|
2011-04-06 14:23:27 +00:00
|
|
|
virtual int GetNumberOfIncomingArguments() const {
|
|
|
|
return Smi::cast(GetExpression(0))->value();
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual Address GetCallerStackPointer() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class InternalFrame: public StandardFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return INTERNAL; }
|
|
|
|
|
2009-01-15 19:08:34 +00:00
|
|
|
// Garbage collection support.
|
2008-07-03 15:10:15 +00:00
|
|
|
virtual void Iterate(ObjectVisitor* v) const;
|
|
|
|
|
|
|
|
// Determine the code for the frame.
|
2010-08-17 11:44:01 +00:00
|
|
|
virtual Code* unchecked_code() const;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
static InternalFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_internal());
|
|
|
|
return static_cast<InternalFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit InternalFrame(StackFrameIterator* iterator)
|
|
|
|
: StandardFrame(iterator) { }
|
|
|
|
|
|
|
|
virtual Address GetCallerStackPointer() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-10 09:09:38 +00:00
|
|
|
// Construct frames are special trampoline frames introduced to handle
|
|
|
|
// function invocations through 'new'.
|
|
|
|
class ConstructFrame: public InternalFrame {
|
|
|
|
public:
|
|
|
|
virtual Type type() const { return CONSTRUCT; }
|
|
|
|
|
|
|
|
static ConstructFrame* cast(StackFrame* frame) {
|
|
|
|
ASSERT(frame->is_construct());
|
|
|
|
return static_cast<ConstructFrame*>(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit ConstructFrame(StackFrameIterator* iterator)
|
|
|
|
: InternalFrame(iterator) { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class StackFrameIterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class StackFrameIterator BASE_EMBEDDED {
|
|
|
|
public:
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
// An iterator that iterates over the current thread's stack,
|
|
|
|
// and uses current isolate.
|
2008-07-03 15:10:15 +00:00
|
|
|
StackFrameIterator();
|
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
// An iterator that iterates over the isolate's current thread's stack,
|
|
|
|
explicit StackFrameIterator(Isolate* isolate);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// An iterator that iterates over a given thread's stack.
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
// An iterator that can start from a given FP address.
|
|
|
|
// If use_top, then work as usual, if fp isn't NULL, use it,
|
|
|
|
// otherwise, do nothing.
|
2011-03-18 20:35:07 +00:00
|
|
|
StackFrameIterator(Isolate* isolate, bool use_top, Address fp, Address sp);
|
2009-03-03 11:56:44 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
StackFrame* frame() const {
|
|
|
|
ASSERT(!done());
|
|
|
|
return frame_;
|
|
|
|
}
|
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
Isolate* isolate() const { return isolate_; }
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
bool done() const { return frame_ == NULL; }
|
2009-03-20 14:49:12 +00:00
|
|
|
void Advance() { (this->*advance_)(); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Go back to the first frame.
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
private:
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
Isolate* isolate_;
|
2008-07-03 15:10:15 +00:00
|
|
|
#define DECLARE_SINGLETON(ignore, type) type type##_;
|
|
|
|
STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
|
|
|
|
#undef DECLARE_SINGLETON
|
|
|
|
StackFrame* frame_;
|
|
|
|
StackHandler* handler_;
|
2008-07-30 08:49:36 +00:00
|
|
|
ThreadLocalTop* thread_;
|
2009-03-20 14:49:12 +00:00
|
|
|
Address fp_;
|
|
|
|
Address sp_;
|
|
|
|
void (StackFrameIterator::*advance_)();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
StackHandler* handler() const {
|
|
|
|
ASSERT(!done());
|
|
|
|
return handler_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the type-specific frame singleton in a given state.
|
|
|
|
StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state);
|
2009-03-20 14:49:12 +00:00
|
|
|
// A helper function, can return a NULL pointer.
|
|
|
|
StackFrame* SingletonFor(StackFrame::Type type);
|
|
|
|
|
|
|
|
void AdvanceWithHandler();
|
|
|
|
void AdvanceWithoutHandler();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
friend class StackFrame;
|
2009-03-20 14:49:12 +00:00
|
|
|
friend class SafeStackFrameIterator;
|
2008-08-28 09:55:41 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Iterator that supports iterating through all JavaScript frames.
|
2009-03-03 11:56:44 +00:00
|
|
|
template<typename Iterator>
|
|
|
|
class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2009-03-03 11:56:44 +00:00
|
|
|
JavaScriptFrameIteratorTemp() { if (!done()) Advance(); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Skip frames until the frame with the given id is reached.
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }
|
|
|
|
|
|
|
|
inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id);
|
2009-03-03 11:56:44 +00:00
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
JavaScriptFrameIteratorTemp(Address fp, Address sp,
|
|
|
|
Address low_bound, Address high_bound) :
|
|
|
|
iterator_(fp, sp, low_bound, high_bound) {
|
|
|
|
if (!done()) Advance();
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
JavaScriptFrameIteratorTemp(Isolate* isolate,
|
|
|
|
Address fp, Address sp,
|
|
|
|
Address low_bound, Address high_bound) :
|
|
|
|
iterator_(isolate, fp, sp, low_bound, high_bound) {
|
|
|
|
if (!done()) Advance();
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
inline JavaScriptFrame* frame() const;
|
|
|
|
|
|
|
|
bool done() const { return iterator_.done(); }
|
|
|
|
void Advance();
|
|
|
|
|
|
|
|
// Advance to the frame holding the arguments for the current
|
|
|
|
// frame. This only affects the current frame if it has adapted
|
|
|
|
// arguments.
|
|
|
|
void AdvanceToArgumentsFrame();
|
|
|
|
|
|
|
|
// Go back to the first frame.
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
private:
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
inline void AdvanceToId(StackFrame::Id id);
|
|
|
|
|
2009-03-03 11:56:44 +00:00
|
|
|
Iterator iterator_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: The stack trace frame iterator is an iterator that only
|
|
|
|
// traverse proper JavaScript frames; that is JavaScript frames that
|
|
|
|
// have proper JavaScript functions. This excludes the problematic
|
|
|
|
// functions in runtime.js.
|
|
|
|
class StackTraceFrameIterator: public JavaScriptFrameIterator {
|
|
|
|
public:
|
|
|
|
StackTraceFrameIterator();
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
explicit StackTraceFrameIterator(Isolate* isolate);
|
2009-03-03 11:56:44 +00:00
|
|
|
void Advance();
|
2010-02-01 10:34:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool IsValidFrame();
|
2009-03-03 11:56:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SafeStackFrameIterator BASE_EMBEDDED {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
SafeStackFrameIterator(Isolate* isolate,
|
|
|
|
Address fp, Address sp,
|
2009-03-20 14:49:12 +00:00
|
|
|
Address low_bound, Address high_bound);
|
2009-03-03 11:56:44 +00:00
|
|
|
|
|
|
|
StackFrame* frame() const {
|
|
|
|
ASSERT(is_working_iterator_);
|
|
|
|
return iterator_.frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool done() const { return iteration_done_ ? true : iterator_.done(); }
|
|
|
|
|
|
|
|
void Advance();
|
|
|
|
void Reset();
|
|
|
|
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
static bool is_active(Isolate* isolate);
|
2010-08-30 08:54:43 +00:00
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
static bool IsWithinBounds(
|
2009-03-03 11:56:44 +00:00
|
|
|
Address low_bound, Address high_bound, Address addr) {
|
|
|
|
return low_bound <= addr && addr <= high_bound;
|
|
|
|
}
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
|
|
|
|
private:
|
2010-09-16 08:23:34 +00:00
|
|
|
class StackAddressValidator {
|
|
|
|
public:
|
|
|
|
StackAddressValidator(Address low_bound, Address high_bound)
|
|
|
|
: low_bound_(low_bound), high_bound_(high_bound) { }
|
|
|
|
bool IsValid(Address addr) const {
|
|
|
|
return IsWithinBounds(low_bound_, high_bound_, addr);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
Address low_bound_;
|
|
|
|
Address high_bound_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ExitFrameValidator {
|
|
|
|
public:
|
|
|
|
explicit ExitFrameValidator(const StackAddressValidator& validator)
|
|
|
|
: validator_(validator) { }
|
|
|
|
ExitFrameValidator(Address low_bound, Address high_bound)
|
|
|
|
: validator_(low_bound, high_bound) { }
|
|
|
|
bool IsValidFP(Address fp);
|
|
|
|
private:
|
|
|
|
StackAddressValidator validator_;
|
|
|
|
};
|
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
bool IsValidStackAddress(Address addr) const {
|
2010-09-16 08:23:34 +00:00
|
|
|
return stack_validator_.IsValid(addr);
|
2009-03-03 11:56:44 +00:00
|
|
|
}
|
2009-04-13 14:42:01 +00:00
|
|
|
bool CanIterateHandles(StackFrame* frame, StackHandler* handler);
|
2009-03-20 14:49:12 +00:00
|
|
|
bool IsValidFrame(StackFrame* frame) const;
|
|
|
|
bool IsValidCaller(StackFrame* frame);
|
2011-03-18 20:35:07 +00:00
|
|
|
static bool IsValidTop(Isolate* isolate,
|
|
|
|
Address low_bound, Address high_bound);
|
2009-03-03 11:56:44 +00:00
|
|
|
|
2010-08-30 08:54:43 +00:00
|
|
|
// This is a nasty hack to make sure the active count is incremented
|
|
|
|
// before the constructor for the embedded iterator is invoked. This
|
|
|
|
// is needed because the constructor will start looking at frames
|
|
|
|
// right away and we need to make sure it doesn't start inspecting
|
|
|
|
// heap objects.
|
|
|
|
class ActiveCountMaintainer BASE_EMBEDDED {
|
|
|
|
public:
|
Simplify isolates access during stack iteration (WAS: Move SafeStackFrameIterator::active_count_...)
While trying to fix Mac and Windows versions for this change:
http://codereview.chromium.org/6771047/, I figured out, that we
already store an isolate in StackFrameIterator, so we can use it in
frame objects, instead of requiring it from caller.
I've changed iterators usage to the following scheme: whenever a
caller maintains an isolate pointer, it just passes it to stack
iterator, and no more worries about passing it to frame content
accessors. If a caller uses current isolate, it can omit passing it
to iterator, in this case, an iterator will use the current isolate,
too.
There was a special case with LiveEdit, which creates
detached copies of frame objects.
R=vitalyr@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6794019
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-04-05 09:01:47 +00:00
|
|
|
explicit ActiveCountMaintainer(Isolate* isolate);
|
|
|
|
~ActiveCountMaintainer();
|
|
|
|
private:
|
|
|
|
Isolate* isolate_;
|
2010-08-30 08:54:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ActiveCountMaintainer maintainer_;
|
2010-09-16 08:23:34 +00:00
|
|
|
StackAddressValidator stack_validator_;
|
2009-03-20 14:49:12 +00:00
|
|
|
const bool is_valid_top_;
|
|
|
|
const bool is_valid_fp_;
|
2009-03-03 11:56:44 +00:00
|
|
|
const bool is_working_iterator_;
|
|
|
|
bool iteration_done_;
|
2008-07-03 15:10:15 +00:00
|
|
|
StackFrameIterator iterator_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-03-03 11:56:44 +00:00
|
|
|
#ifdef ENABLE_LOGGING_AND_PROFILING
|
|
|
|
typedef JavaScriptFrameIteratorTemp<SafeStackFrameIterator>
|
|
|
|
SafeJavaScriptFrameIterator;
|
|
|
|
|
|
|
|
|
|
|
|
class SafeStackTraceFrameIterator: public SafeJavaScriptFrameIterator {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit SafeStackTraceFrameIterator(Isolate* isolate,
|
|
|
|
Address fp, Address sp,
|
2009-03-20 14:49:12 +00:00
|
|
|
Address low_bound, Address high_bound);
|
2009-03-03 11:56:44 +00:00
|
|
|
void Advance();
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class StackFrameLocator BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
// Find the nth JavaScript frame on the stack. The caller must
|
|
|
|
// guarantee that such a frame exists.
|
|
|
|
JavaScriptFrame* FindJavaScriptFrame(int n);
|
|
|
|
|
|
|
|
private:
|
|
|
|
StackFrameIterator iterator_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-04-06 17:58:28 +00:00
|
|
|
// Reads all frames on the current stack and copies them into the current
|
|
|
|
// zone memory.
|
|
|
|
Vector<StackFrame*> CreateStackMap();
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_FRAMES_H_
|