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