Simplify isolates access during stack iteration (WAS: Move...

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
parent 101413a0
...@@ -603,7 +603,7 @@ MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) { ...@@ -603,7 +603,7 @@ MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) {
// Find the top invocation of the function by traversing frames. // Find the top invocation of the function by traversing frames.
List<JSFunction*> functions(2); List<JSFunction*> functions(2);
for (JavaScriptFrameIterator it; !it.done(); it.Advance()) { for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
frame->GetFunctions(&functions); frame->GetFunctions(&functions);
for (int i = functions.length() - 1; i >= 0; i--) { for (int i = functions.length() - 1; i >= 0; i--) {
...@@ -692,7 +692,7 @@ MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) { ...@@ -692,7 +692,7 @@ MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) {
Handle<JSFunction> function(holder, isolate); Handle<JSFunction> function(holder, isolate);
List<JSFunction*> functions(2); List<JSFunction*> functions(2);
for (JavaScriptFrameIterator it; !it.done(); it.Advance()) { for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
frame->GetFunctions(&functions); frame->GetFunctions(&functions);
for (int i = functions.length() - 1; i >= 0; i--) { for (int i = functions.length() - 1; i >= 0; i--) {
......
...@@ -367,11 +367,11 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { ...@@ -367,11 +367,11 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
// For eval scripts add information on the function from which eval was // For eval scripts add information on the function from which eval was
// called. // called.
if (info->is_eval()) { if (info->is_eval()) {
StackTraceFrameIterator it; StackTraceFrameIterator it(isolate);
if (!it.done()) { if (!it.done()) {
script->set_eval_from_shared( script->set_eval_from_shared(
JSFunction::cast(it.frame()->function())->shared()); JSFunction::cast(it.frame()->function())->shared());
Code* code = it.frame()->LookupCode(isolate); Code* code = it.frame()->LookupCode();
int offset = static_cast<int>( int offset = static_cast<int>(
it.frame()->pc() - code->instruction_start()); it.frame()->pc() - code->instruction_start());
script->set_eval_from_instructions_offset(Smi::FromInt(offset)); script->set_eval_from_instructions_offset(Smi::FromInt(offset));
......
...@@ -184,12 +184,13 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent( ...@@ -184,12 +184,13 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent(
void ProfilerEventsProcessor::AddCurrentStack() { void ProfilerEventsProcessor::AddCurrentStack() {
TickSampleEventRecord record; TickSampleEventRecord record;
TickSample* sample = &record.sample; TickSample* sample = &record.sample;
sample->state = Isolate::Current()->current_vm_state(); Isolate* isolate = Isolate::Current();
sample->state = isolate->current_vm_state();
sample->pc = reinterpret_cast<Address>(sample); // Not NULL. sample->pc = reinterpret_cast<Address>(sample); // Not NULL.
sample->tos = NULL; sample->tos = NULL;
sample->has_external_callback = false; sample->has_external_callback = false;
sample->frames_count = 0; sample->frames_count = 0;
for (StackTraceFrameIterator it; for (StackTraceFrameIterator it(isolate);
!it.done() && sample->frames_count < TickSample::kMaxFramesCount; !it.done() && sample->frames_count < TickSample::kMaxFramesCount;
it.Advance()) { it.Advance()) {
sample->stack[sample->frames_count++] = it.frame()->pc(); sample->stack[sample->frames_count++] = it.frame()->pc();
......
...@@ -925,7 +925,7 @@ Object* Debug::Break(Arguments args) { ...@@ -925,7 +925,7 @@ Object* Debug::Break(Arguments args) {
thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED;
// Get the top-most JavaScript frame. // Get the top-most JavaScript frame.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate_);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
// Just continue if breaks are disabled or debugger cannot be loaded. // Just continue if breaks are disabled or debugger cannot be loaded.
...@@ -1224,7 +1224,7 @@ void Debug::FloodHandlerWithOneShot() { ...@@ -1224,7 +1224,7 @@ void Debug::FloodHandlerWithOneShot() {
// If there is no JavaScript stack don't do anything. // If there is no JavaScript stack don't do anything.
return; return;
} }
for (JavaScriptFrameIterator it(id); !it.done(); it.Advance()) { for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
if (frame->HasHandler()) { if (frame->HasHandler()) {
Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo> shared =
...@@ -1280,7 +1280,7 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { ...@@ -1280,7 +1280,7 @@ void Debug::PrepareStep(StepAction step_action, int step_count) {
// If there is no JavaScript stack don't do anything. // If there is no JavaScript stack don't do anything.
return; return;
} }
JavaScriptFrameIterator frames_it(id); JavaScriptFrameIterator frames_it(isolate_, id);
JavaScriptFrame* frame = frames_it.frame(); JavaScriptFrame* frame = frames_it.frame();
// First of all ensure there is one-shot break points in the top handler // First of all ensure there is one-shot break points in the top handler
...@@ -1777,7 +1777,7 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { ...@@ -1777,7 +1777,7 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
Handle<Code> original_code(debug_info->original_code()); Handle<Code> original_code(debug_info->original_code());
#ifdef DEBUG #ifdef DEBUG
// Get the code which is actually executing. // Get the code which is actually executing.
Handle<Code> frame_code(frame->LookupCode(isolate_)); Handle<Code> frame_code(frame->LookupCode());
ASSERT(frame_code.is_identical_to(code)); ASSERT(frame_code.is_identical_to(code));
#endif #endif
...@@ -1859,7 +1859,7 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) { ...@@ -1859,7 +1859,7 @@ bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
Handle<Code> code(debug_info->code()); Handle<Code> code(debug_info->code());
#ifdef DEBUG #ifdef DEBUG
// Get the code which is actually executing. // Get the code which is actually executing.
Handle<Code> frame_code(frame->LookupCode(Isolate::Current())); Handle<Code> frame_code(frame->LookupCode());
ASSERT(frame_code.is_identical_to(code)); ASSERT(frame_code.is_identical_to(code));
#endif #endif
......
...@@ -863,6 +863,7 @@ class EnterDebugger BASE_EMBEDDED { ...@@ -863,6 +863,7 @@ class EnterDebugger BASE_EMBEDDED {
EnterDebugger() EnterDebugger()
: isolate_(Isolate::Current()), : isolate_(Isolate::Current()),
prev_(isolate_->debug()->debugger_entry()), prev_(isolate_->debug()->debugger_entry()),
it_(isolate_),
has_js_frames_(!it_.done()), has_js_frames_(!it_.done()),
save_(isolate_) { save_(isolate_) {
Debug* debug = isolate_->debug(); Debug* debug = isolate_->debug();
......
...@@ -711,7 +711,7 @@ Object* Execution::DebugBreakHelper() { ...@@ -711,7 +711,7 @@ Object* Execution::DebugBreakHelper() {
} }
{ {
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
ASSERT(!it.done()); ASSERT(!it.done());
Object* fun = it.frame()->function(); Object* fun = it.frame()->function();
if (fun && fun->IsJSFunction()) { if (fun && fun->IsJSFunction()) {
......
...@@ -88,6 +88,11 @@ inline Address* StackHandler::pc_address() const { ...@@ -88,6 +88,11 @@ inline Address* StackHandler::pc_address() const {
} }
inline StackFrame::StackFrame(StackFrameIterator* iterator)
: iterator_(iterator), isolate_(iterator_->isolate()) {
}
inline StackHandler* StackFrame::top_handler() const { inline StackHandler* StackFrame::top_handler() const {
return iterator_->handler(); return iterator_->handler();
} }
...@@ -167,6 +172,13 @@ inline Object* JavaScriptFrame::function() const { ...@@ -167,6 +172,13 @@ inline Object* JavaScriptFrame::function() const {
} }
template<typename Iterator>
inline JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp(
Isolate* isolate)
: iterator_(isolate) {
if (!done()) Advance();
}
template<typename Iterator> template<typename Iterator>
inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const { inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const {
// TODO(1233797): The frame hierarchy needs to change. It's // TODO(1233797): The frame hierarchy needs to change. It's
...@@ -181,11 +193,9 @@ inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const { ...@@ -181,11 +193,9 @@ inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const {
template<typename Iterator> template<typename Iterator>
JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp( JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp(
StackFrame::Id id) { Isolate* isolate, StackFrame::Id id)
while (!done()) { : iterator_(isolate) {
Advance(); AdvanceToId(id);
if (frame()->id() == id) return;
}
} }
...@@ -205,6 +215,15 @@ void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToArgumentsFrame() { ...@@ -205,6 +215,15 @@ void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToArgumentsFrame() {
} }
template<typename Iterator>
void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToId(StackFrame::Id id) {
while (!done()) {
Advance();
if (frame()->id() == id) return;
}
}
template<typename Iterator> template<typename Iterator>
void JavaScriptFrameIteratorTemp<Iterator>::Reset() { void JavaScriptFrameIteratorTemp<Iterator>::Reset() {
iterator_.Reset(); iterator_.Reset();
......
This diff is collapsed.
...@@ -158,10 +158,12 @@ class StackFrame BASE_EMBEDDED { ...@@ -158,10 +158,12 @@ class StackFrame BASE_EMBEDDED {
Address* pc_address; Address* pc_address;
}; };
// Copy constructor; it breaks the connection to host iterator. // Copy constructor; it breaks the connection to host iterator
// (as an iterator usually lives on stack).
StackFrame(const StackFrame& original) { StackFrame(const StackFrame& original) {
this->state_ = original.state_; this->state_ = original.state_;
this->iterator_ = NULL; this->iterator_ = NULL;
this->isolate_ = original.isolate_;
} }
// Type testers. // Type testers.
...@@ -205,8 +207,8 @@ class StackFrame BASE_EMBEDDED { ...@@ -205,8 +207,8 @@ class StackFrame BASE_EMBEDDED {
virtual Code* unchecked_code() const = 0; virtual Code* unchecked_code() const = 0;
// Get the code associated with this frame. // Get the code associated with this frame.
Code* LookupCode(Isolate* isolate) const { Code* LookupCode() const {
return GetContainingCode(isolate, pc()); return GetContainingCode(isolate(), pc());
} }
// Get the code object that contains the given pc. // Get the code object that contains the given pc.
...@@ -215,7 +217,8 @@ class StackFrame BASE_EMBEDDED { ...@@ -215,7 +217,8 @@ class StackFrame BASE_EMBEDDED {
// Get the code object containing the given pc and fill in the // 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 // safepoint entry and the number of stack slots. The pc must be at
// a safepoint. // a safepoint.
static Code* GetSafepointData(Address pc, static Code* GetSafepointData(Isolate* isolate,
Address pc,
SafepointEntry* safepoint_entry, SafepointEntry* safepoint_entry,
unsigned* stack_slots); unsigned* stack_slots);
...@@ -230,9 +233,11 @@ class StackFrame BASE_EMBEDDED { ...@@ -230,9 +233,11 @@ class StackFrame BASE_EMBEDDED {
int index) const { } int index) const { }
protected: protected:
explicit StackFrame(StackFrameIterator* iterator) : iterator_(iterator) { } inline explicit StackFrame(StackFrameIterator* iterator);
virtual ~StackFrame() { } virtual ~StackFrame() { }
Isolate* isolate() const { return isolate_; }
// Compute the stack pointer for the calling frame. // Compute the stack pointer for the calling frame.
virtual Address GetCallerStackPointer() const = 0; virtual Address GetCallerStackPointer() const = 0;
...@@ -245,10 +250,11 @@ class StackFrame BASE_EMBEDDED { ...@@ -245,10 +250,11 @@ class StackFrame BASE_EMBEDDED {
inline StackHandler* top_handler() const; inline StackHandler* top_handler() const;
// Compute the stack frame type for the given state. // Compute the stack frame type for the given state.
static Type ComputeType(State* state); static Type ComputeType(Isolate* isolate, State* state);
private: private:
const StackFrameIterator* iterator_; const StackFrameIterator* iterator_;
Isolate* isolate_;
State state_; State state_;
// Fill in the state of the calling frame. // Fill in the state of the calling frame.
...@@ -257,6 +263,8 @@ class StackFrame BASE_EMBEDDED { ...@@ -257,6 +263,8 @@ class StackFrame BASE_EMBEDDED {
// Get the type and the state of the calling frame. // Get the type and the state of the calling frame.
virtual Type GetCallerState(State* state) const; virtual Type GetCallerState(State* state) const;
static const intptr_t kIsolateTag = 1;
friend class StackFrameIterator; friend class StackFrameIterator;
friend class StackHandlerIterator; friend class StackHandlerIterator;
friend class SafeStackFrameIterator; friend class SafeStackFrameIterator;
...@@ -609,11 +617,15 @@ class ConstructFrame: public InternalFrame { ...@@ -609,11 +617,15 @@ class ConstructFrame: public InternalFrame {
class StackFrameIterator BASE_EMBEDDED { class StackFrameIterator BASE_EMBEDDED {
public: public:
// An iterator that iterates over the current thread's stack. // An iterator that iterates over the current thread's stack,
// and uses current isolate.
StackFrameIterator(); StackFrameIterator();
// An iterator that iterates over the isolate's current thread's stack,
explicit StackFrameIterator(Isolate* isolate);
// An iterator that iterates over a given thread's stack. // An iterator that iterates over a given thread's stack.
explicit StackFrameIterator(ThreadLocalTop* thread); StackFrameIterator(Isolate* isolate, ThreadLocalTop* t);
// An iterator that can start from a given FP address. // An iterator that can start from a given FP address.
// If use_top, then work as usual, if fp isn't NULL, use it, // If use_top, then work as usual, if fp isn't NULL, use it,
...@@ -625,6 +637,8 @@ class StackFrameIterator BASE_EMBEDDED { ...@@ -625,6 +637,8 @@ class StackFrameIterator BASE_EMBEDDED {
return frame_; return frame_;
} }
Isolate* isolate() const { return isolate_; }
bool done() const { return frame_ == NULL; } bool done() const { return frame_ == NULL; }
void Advance() { (this->*advance_)(); } void Advance() { (this->*advance_)(); }
...@@ -632,6 +646,7 @@ class StackFrameIterator BASE_EMBEDDED { ...@@ -632,6 +646,7 @@ class StackFrameIterator BASE_EMBEDDED {
void Reset(); void Reset();
private: private:
Isolate* isolate_;
#define DECLARE_SINGLETON(ignore, type) type type##_; #define DECLARE_SINGLETON(ignore, type) type type##_;
STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON) STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
#undef DECLARE_SINGLETON #undef DECLARE_SINGLETON
...@@ -667,13 +682,12 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED { ...@@ -667,13 +682,12 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
public: public:
JavaScriptFrameIteratorTemp() { if (!done()) Advance(); } JavaScriptFrameIteratorTemp() { if (!done()) Advance(); }
explicit JavaScriptFrameIteratorTemp(ThreadLocalTop* thread) : inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);
iterator_(thread) {
if (!done()) Advance();
}
// Skip frames until the frame with the given id is reached. // Skip frames until the frame with the given id is reached.
explicit JavaScriptFrameIteratorTemp(StackFrame::Id id); explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }
inline JavaScriptFrameIteratorTemp(Isolate* isolate, StackFrame::Id id);
JavaScriptFrameIteratorTemp(Address fp, Address sp, JavaScriptFrameIteratorTemp(Address fp, Address sp,
Address low_bound, Address high_bound) : Address low_bound, Address high_bound) :
...@@ -702,6 +716,8 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED { ...@@ -702,6 +716,8 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED {
void Reset(); void Reset();
private: private:
inline void AdvanceToId(StackFrame::Id id);
Iterator iterator_; Iterator iterator_;
}; };
...@@ -716,6 +732,7 @@ typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator; ...@@ -716,6 +732,7 @@ typedef JavaScriptFrameIteratorTemp<StackFrameIterator> JavaScriptFrameIterator;
class StackTraceFrameIterator: public JavaScriptFrameIterator { class StackTraceFrameIterator: public JavaScriptFrameIterator {
public: public:
StackTraceFrameIterator(); StackTraceFrameIterator();
explicit StackTraceFrameIterator(Isolate* isolate);
void Advance(); void Advance();
private: private:
...@@ -739,7 +756,7 @@ class SafeStackFrameIterator BASE_EMBEDDED { ...@@ -739,7 +756,7 @@ class SafeStackFrameIterator BASE_EMBEDDED {
void Advance(); void Advance();
void Reset(); void Reset();
static bool is_active() { return active_count_ > 0; } static bool is_active(Isolate* isolate);
static bool IsWithinBounds( static bool IsWithinBounds(
Address low_bound, Address high_bound, Address addr) { Address low_bound, Address high_bound, Address addr) {
...@@ -786,13 +803,13 @@ class SafeStackFrameIterator BASE_EMBEDDED { ...@@ -786,13 +803,13 @@ class SafeStackFrameIterator BASE_EMBEDDED {
// heap objects. // heap objects.
class ActiveCountMaintainer BASE_EMBEDDED { class ActiveCountMaintainer BASE_EMBEDDED {
public: public:
ActiveCountMaintainer() { active_count_++; } explicit ActiveCountMaintainer(Isolate* isolate);
~ActiveCountMaintainer() { active_count_--; } ~ActiveCountMaintainer();
private:
Isolate* isolate_;
}; };
ActiveCountMaintainer maintainer_; ActiveCountMaintainer maintainer_;
// TODO(isolates): this is dangerous.
static int active_count_;
StackAddressValidator stack_validator_; StackAddressValidator stack_validator_;
const bool is_valid_top_; const bool is_valid_top_;
const bool is_valid_fp_; const bool is_valid_fp_;
......
...@@ -316,6 +316,8 @@ typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache; ...@@ -316,6 +316,8 @@ typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
/* AstNode state. */ \ /* AstNode state. */ \
V(unsigned, ast_node_id, 0) \ V(unsigned, ast_node_id, 0) \
V(unsigned, ast_node_count, 0) \ V(unsigned, ast_node_count, 0) \
/* SafeStackFrameIterator activations count. */ \
V(int, safe_stack_iterator_counter, 0) \
ISOLATE_PLATFORM_INIT_LIST(V) \ ISOLATE_PLATFORM_INIT_LIST(V) \
ISOLATE_LOGGING_INIT_LIST(V) \ ISOLATE_LOGGING_INIT_LIST(V) \
ISOLATE_DEBUGGER_INIT_LIST(V) ISOLATE_DEBUGGER_INIT_LIST(V)
...@@ -1142,7 +1144,7 @@ class SaveContext BASE_EMBEDDED { ...@@ -1142,7 +1144,7 @@ class SaveContext BASE_EMBEDDED {
isolate->set_save_context(this); isolate->set_save_context(this);
// If there is no JS frame under the current C frame, use the value 0. // If there is no JS frame under the current C frame, use the value 0.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
js_sp_ = it.done() ? 0 : it.frame()->sp(); js_sp_ = it.done() ? 0 : it.frame()->sp();
} }
......
...@@ -1396,17 +1396,18 @@ static const char* DropFrames(Vector<StackFrame*> frames, ...@@ -1396,17 +1396,18 @@ static const char* DropFrames(Vector<StackFrame*> frames,
ASSERT(bottom_js_frame->is_java_script()); ASSERT(bottom_js_frame->is_java_script());
// Check the nature of the top frame. // Check the nature of the top frame.
Code* pre_top_frame_code = pre_top_frame->LookupCode(Isolate::Current()); Isolate* isolate = Isolate::Current();
Code* pre_top_frame_code = pre_top_frame->LookupCode();
if (pre_top_frame_code->is_inline_cache_stub() && if (pre_top_frame_code->is_inline_cache_stub() &&
pre_top_frame_code->ic_state() == DEBUG_BREAK) { pre_top_frame_code->ic_state() == DEBUG_BREAK) {
// OK, we can drop inline cache calls. // OK, we can drop inline cache calls.
*mode = Debug::FRAME_DROPPED_IN_IC_CALL; *mode = Debug::FRAME_DROPPED_IN_IC_CALL;
} else if (pre_top_frame_code == } else if (pre_top_frame_code ==
Isolate::Current()->debug()->debug_break_slot()) { isolate->debug()->debug_break_slot()) {
// OK, we can drop debug break slot. // OK, we can drop debug break slot.
*mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL; *mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL;
} else if (pre_top_frame_code == } else if (pre_top_frame_code ==
Isolate::Current()->builtins()->builtin( isolate->builtins()->builtin(
Builtins::kFrameDropper_LiveEdit)) { Builtins::kFrameDropper_LiveEdit)) {
// OK, we can drop our own code. // OK, we can drop our own code.
*mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL; *mode = Debug::FRAME_DROPPED_IN_DIRECT_CALL;
...@@ -1570,8 +1571,8 @@ class InactiveThreadActivationsChecker : public ThreadVisitor { ...@@ -1570,8 +1571,8 @@ class InactiveThreadActivationsChecker : public ThreadVisitor {
: shared_info_array_(shared_info_array), result_(result), : shared_info_array_(shared_info_array), result_(result),
has_blocked_functions_(false) { has_blocked_functions_(false) {
} }
void VisitThread(ThreadLocalTop* top) { void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
for (StackFrameIterator it(top); !it.done(); it.Advance()) { for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) {
has_blocked_functions_ |= CheckActivation( has_blocked_functions_ |= CheckActivation(
shared_info_array_, result_, it.frame(), shared_info_array_, result_, it.frame(),
LiveEdit::FUNCTION_BLOCKED_ON_OTHER_STACK); LiveEdit::FUNCTION_BLOCKED_ON_OTHER_STACK);
......
...@@ -191,7 +191,7 @@ void StackTracer::Trace(Isolate* isolate, TickSample* sample) { ...@@ -191,7 +191,7 @@ void StackTracer::Trace(Isolate* isolate, TickSample* sample) {
// //
class Ticker: public Sampler { class Ticker: public Sampler {
public: public:
explicit Ticker(Isolate* isolate, int interval): Ticker(Isolate* isolate, int interval):
Sampler(isolate, interval), Sampler(isolate, interval),
window_(NULL), window_(NULL),
profiler_(NULL) {} profiler_(NULL) {}
......
...@@ -890,8 +890,8 @@ class CodeMarkingVisitor : public ThreadVisitor { ...@@ -890,8 +890,8 @@ class CodeMarkingVisitor : public ThreadVisitor {
explicit CodeMarkingVisitor(MarkCompactCollector* collector) explicit CodeMarkingVisitor(MarkCompactCollector* collector)
: collector_(collector) {} : collector_(collector) {}
void VisitThread(ThreadLocalTop* top) { void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
for (StackFrameIterator it(top); !it.done(); it.Advance()) { for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) {
collector_->MarkObject(it.frame()->unchecked_code()); collector_->MarkObject(it.frame()->unchecked_code());
} }
} }
......
...@@ -258,7 +258,7 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -258,7 +258,7 @@ void RuntimeProfiler::OptimizeNow() {
JSFunction* samples[kSamplerFrameCount]; JSFunction* samples[kSamplerFrameCount];
int sample_count = 0; int sample_count = 0;
int frame_count = 0; int frame_count = 0;
for (JavaScriptFrameIterator it; for (JavaScriptFrameIterator it(isolate_);
frame_count++ < kSamplerFrameCount && !it.done(); frame_count++ < kSamplerFrameCount && !it.done();
it.Advance()) { it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
......
...@@ -681,7 +681,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenPrototype) { ...@@ -681,7 +681,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenPrototype) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) { RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) {
NoHandleAllocation ha; NoHandleAllocation ha;
ASSERT(args.length() == 0); ASSERT(args.length() == 0);
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
return isolate->heap()->ToBoolean(it.frame()->IsConstructor()); return isolate->heap()->ToBoolean(it.frame()->IsConstructor());
} }
...@@ -4484,7 +4484,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { ...@@ -4484,7 +4484,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
ASSERT(args.length() == 1); ASSERT(args.length() == 1);
// Compute the frame holding the arguments. // Compute the frame holding the arguments.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
it.AdvanceToArgumentsFrame(); it.AdvanceToArgumentsFrame();
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
...@@ -7323,7 +7323,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { ...@@ -7323,7 +7323,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
ASSERT(isolate->heap()->IsAllocationAllowed()); ASSERT(isolate->heap()->IsAllocationAllowed());
int frames = deoptimizer->output_count(); int frames = deoptimizer->output_count();
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = NULL; JavaScriptFrame* frame = NULL;
for (int i = 0; i < frames; i++) { for (int i = 0; i < frames; i++) {
if (i != 0) it.Advance(); if (i != 0) it.Advance();
...@@ -7425,7 +7425,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { ...@@ -7425,7 +7425,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
// indirectly recursive and (b) an optimized invocation has been // indirectly recursive and (b) an optimized invocation has been
// deoptimized so that we are currently in an unoptimized activation. // deoptimized so that we are currently in an unoptimized activation.
// Check for optimized activations of this function. // Check for optimized activations of this function.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
while (succeeded && !it.done()) { while (succeeded && !it.done()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
succeeded = !frame->is_optimized() || frame->function() != *function; succeeded = !frame->is_optimized() || frame->function() != *function;
...@@ -7437,10 +7437,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { ...@@ -7437,10 +7437,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
if (succeeded) { if (succeeded) {
// The top JS function is this one, the PC is somewhere in the // The top JS function is this one, the PC is somewhere in the
// unoptimized code. // unoptimized code.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
ASSERT(frame->function() == *function); ASSERT(frame->function() == *function);
ASSERT(frame->LookupCode(isolate) == *unoptimized); ASSERT(frame->LookupCode() == *unoptimized);
ASSERT(unoptimized->contains(frame->pc())); ASSERT(unoptimized->contains(frame->pc()));
// Use linear search of the unoptimized code's stack check table to find // Use linear search of the unoptimized code's stack check table to find
...@@ -8001,7 +8001,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { ...@@ -8001,7 +8001,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) {
if (args[0]->IsString()) { if (args[0]->IsString()) {
// If we have a string, assume it's a code "marker" // If we have a string, assume it's a code "marker"
// and print some interesting cpu debugging info. // and print some interesting cpu debugging info.
JavaScriptFrameIterator it; JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
PrintF("fp = %p, sp = %p, caller_sp = %p: ", PrintF("fp = %p, sp = %p, caller_sp = %p: ",
frame->fp(), frame->sp(), frame->caller_sp()); frame->fp(), frame->sp(), frame->caller_sp());
...@@ -9337,7 +9337,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) { ...@@ -9337,7 +9337,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) {
// If there is no JavaScript stack frame count is 0. // If there is no JavaScript stack frame count is 0.
return Smi::FromInt(0); return Smi::FromInt(0);
} }
for (JavaScriptFrameIterator it(id); !it.done(); it.Advance()) n++; for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) n++;
return Smi::FromInt(n); return Smi::FromInt(n);
} }
...@@ -9390,7 +9390,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { ...@@ -9390,7 +9390,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
return heap->undefined_value(); return heap->undefined_value();
} }
int count = 0; int count = 0;
JavaScriptFrameIterator it(id); JavaScriptFrameIterator it(isolate, id);
for (; !it.done(); it.Advance()) { for (; !it.done(); it.Advance()) {
if (count == index) break; if (count == index) break;
count++; count++;
...@@ -9398,7 +9398,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { ...@@ -9398,7 +9398,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
if (it.done()) return heap->undefined_value(); if (it.done()) return heap->undefined_value();
bool is_optimized_frame = bool is_optimized_frame =
it.frame()->LookupCode(isolate)->kind() == Code::OPTIMIZED_FUNCTION; it.frame()->LookupCode()->kind() == Code::OPTIMIZED_FUNCTION;
// Traverse the saved contexts chain to find the active context for the // Traverse the saved contexts chain to find the active context for the
// selected frame. // selected frame.
...@@ -9413,7 +9413,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { ...@@ -9413,7 +9413,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
// Find source position. // Find source position.
int position = int position =
it.frame()->LookupCode(isolate)->SourcePosition(it.frame()->pc()); it.frame()->LookupCode()->SourcePosition(it.frame()->pc());
// Check for constructor frame. // Check for constructor frame.
bool constructor = it.frame()->IsConstructor(); bool constructor = it.frame()->IsConstructor();
...@@ -9475,7 +9475,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { ...@@ -9475,7 +9475,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
// to the frame information. // to the frame information.
Handle<Object> return_value = isolate->factory()->undefined_value(); Handle<Object> return_value = isolate->factory()->undefined_value();
if (at_return) { if (at_return) {
StackFrameIterator it2; StackFrameIterator it2(isolate);
Address internal_frame_sp = NULL; Address internal_frame_sp = NULL;
while (!it2.done()) { while (!it2.done()) {
if (it2.frame()->is_internal()) { if (it2.frame()->is_internal()) {
...@@ -10008,7 +10008,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { ...@@ -10008,7 +10008,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) {
// Get the frame where the debugging is performed. // Get the frame where the debugging is performed.
StackFrame::Id id = UnwrapFrameId(wrapped_id); StackFrame::Id id = UnwrapFrameId(wrapped_id);
JavaScriptFrameIterator it(id); JavaScriptFrameIterator it(isolate, id);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
// Count the visible scopes. // Count the visible scopes.
...@@ -10048,7 +10048,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { ...@@ -10048,7 +10048,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) {
// Get the frame where the debugging is performed. // Get the frame where the debugging is performed.
StackFrame::Id id = UnwrapFrameId(wrapped_id); StackFrame::Id id = UnwrapFrameId(wrapped_id);
JavaScriptFrameIterator frame_it(id); JavaScriptFrameIterator frame_it(isolate, id);
JavaScriptFrame* frame = frame_it.frame(); JavaScriptFrame* frame = frame_it.frame();
// Find the requested scope. // Find the requested scope.
...@@ -10536,7 +10536,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { ...@@ -10536,7 +10536,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) {
// Get the frame where the debugging is performed. // Get the frame where the debugging is performed.
StackFrame::Id id = UnwrapFrameId(wrapped_id); StackFrame::Id id = UnwrapFrameId(wrapped_id);
JavaScriptFrameIterator it(id); JavaScriptFrameIterator it(isolate, id);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
Handle<JSFunction> function(JSFunction::cast(frame->function())); Handle<JSFunction> function(JSFunction::cast(frame->function()));
Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info());
...@@ -11604,7 +11604,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { ...@@ -11604,7 +11604,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) {
Handle<FixedArray> elements = Handle<FixedArray> elements =
factory->NewFixedArrayWithHoles(initial_size * 4); factory->NewFixedArrayWithHoles(initial_size * 4);
StackFrameIterator iter; StackFrameIterator iter(isolate);
// If the caller parameter is a function we skip frames until we're // If the caller parameter is a function we skip frames until we're
// under it before starting to collect. // under it before starting to collect.
bool seen_caller = !caller->IsJSFunction(); bool seen_caller = !caller->IsJSFunction();
......
...@@ -89,13 +89,13 @@ char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) { ...@@ -89,13 +89,13 @@ char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) {
void Isolate::IterateThread(ThreadVisitor* v) { void Isolate::IterateThread(ThreadVisitor* v) {
v->VisitThread(thread_local_top()); v->VisitThread(this, thread_local_top());
} }
void Isolate::IterateThread(ThreadVisitor* v, char* t) { void Isolate::IterateThread(ThreadVisitor* v, char* t) {
ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t); ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t);
v->VisitThread(thread); v->VisitThread(this, thread);
} }
...@@ -125,7 +125,7 @@ void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { ...@@ -125,7 +125,7 @@ void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
} }
// Iterate over pointers on native execution stack. // Iterate over pointers on native execution stack.
for (StackFrameIterator it(thread); !it.done(); it.Advance()) { for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) {
it.frame()->Iterate(v); it.frame()->Iterate(v);
} }
} }
...@@ -204,7 +204,7 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace( ...@@ -204,7 +204,7 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
Handle<String> constructor_key = Handle<String> constructor_key =
factory()->LookupAsciiSymbol("isConstructor"); factory()->LookupAsciiSymbol("isConstructor");
StackTraceFrameIterator it; StackTraceFrameIterator it(this);
int frames_seen = 0; int frames_seen = 0;
while (!it.done() && (frames_seen < limit)) { while (!it.done() && (frames_seen < limit)) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
...@@ -584,12 +584,12 @@ Failure* Isolate::PromoteScheduledException() { ...@@ -584,12 +584,12 @@ Failure* Isolate::PromoteScheduledException() {
void Isolate::PrintCurrentStackTrace(FILE* out) { void Isolate::PrintCurrentStackTrace(FILE* out) {
StackTraceFrameIterator it; StackTraceFrameIterator it(this);
while (!it.done()) { while (!it.done()) {
HandleScope scope; HandleScope scope;
// Find code position if recorded in relocation info. // Find code position if recorded in relocation info.
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
int pos = frame->LookupCode(this)->SourcePosition(frame->pc()); int pos = frame->LookupCode()->SourcePosition(frame->pc());
Handle<Object> pos_obj(Smi::FromInt(pos)); Handle<Object> pos_obj(Smi::FromInt(pos));
// Fetch function and receiver. // Fetch function and receiver.
Handle<JSFunction> fun(JSFunction::cast(frame->function())); Handle<JSFunction> fun(JSFunction::cast(frame->function()));
...@@ -613,14 +613,14 @@ void Isolate::PrintCurrentStackTrace(FILE* out) { ...@@ -613,14 +613,14 @@ void Isolate::PrintCurrentStackTrace(FILE* out) {
void Isolate::ComputeLocation(MessageLocation* target) { void Isolate::ComputeLocation(MessageLocation* target) {
*target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
StackTraceFrameIterator it; StackTraceFrameIterator it(this);
if (!it.done()) { if (!it.done()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* fun = JSFunction::cast(frame->function()); JSFunction* fun = JSFunction::cast(frame->function());
Object* script = fun->shared()->script(); Object* script = fun->shared()->script();
if (script->IsScript() && if (script->IsScript() &&
!(Script::cast(script)->source()->IsUndefined())) { !(Script::cast(script)->source()->IsUndefined())) {
int pos = frame->LookupCode(this)->SourcePosition(frame->pc()); int pos = frame->LookupCode()->SourcePosition(frame->pc());
// Compute the location from the function and the reloc info. // Compute the location from the function and the reloc info.
Handle<Script> casted_script(Script::cast(script)); Handle<Script> casted_script(Script::cast(script));
*target = MessageLocation(casted_script, pos, pos + 1); *target = MessageLocation(casted_script, pos, pos + 1);
......
...@@ -78,7 +78,7 @@ class ThreadLocalTop; ...@@ -78,7 +78,7 @@ class ThreadLocalTop;
class ThreadVisitor { class ThreadVisitor {
public: public:
// ThreadLocalTop may be only available during this call. // ThreadLocalTop may be only available during this call.
virtual void VisitThread(ThreadLocalTop* top) = 0; virtual void VisitThread(Isolate* isolate, ThreadLocalTop* top) = 0;
protected: protected:
virtual ~ThreadVisitor() {} virtual ~ThreadVisitor() {}
......
...@@ -397,7 +397,7 @@ static v8::Handle<Value> StackCheck(Local<String> name, ...@@ -397,7 +397,7 @@ static v8::Handle<Value> StackCheck(Local<String> name,
for (int i = 0; !iter.done(); i++) { for (int i = 0; !iter.done(); i++) {
i::StackFrame* frame = iter.frame(); i::StackFrame* frame = iter.frame();
CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT)); CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT));
i::Code* code = frame->LookupCode(i::Isolate::Current()); i::Code* code = frame->LookupCode();
CHECK(code->IsCode()); CHECK(code->IsCode());
i::Address pc = frame->pc(); i::Address pc = frame->pc();
CHECK(code->contains(pc)); CHECK(code->contains(pc));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment