Commit ebdf62c2 authored by yurys@chromium.org's avatar yurys@chromium.org

Merge SafeStackTraceFrameIterator into SafeStackFrameIterator

SafeStackFrameIterator was used solely to implement SafeStackTraceFrameIterator. This CL simply merges them and updates usage of SafeStackTraceFrameIterator to use SafeStackFrameIterator (a bit shorter name).

BUG=None
R=loislo@chromium.org, svenpanne@chromium.org

Review URL: https://codereview.chromium.org/17579005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15305 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 63eff64f
...@@ -324,7 +324,8 @@ inline JavaScriptFrame* JavaScriptFrameIterator::frame() const { ...@@ -324,7 +324,8 @@ inline JavaScriptFrame* JavaScriptFrameIterator::frame() const {
} }
inline JavaScriptFrame* SafeStackTraceFrameIterator::frame() const { inline JavaScriptFrame* SafeStackFrameIterator::frame() const {
ASSERT(!iteration_done_);
// TODO(1233797): The frame hierarchy needs to change. It's // TODO(1233797): The frame hierarchy needs to change. It's
// problematic that we can't use the safe-cast operator to cast to // problematic that we can't use the safe-cast operator to cast to
// the JavaScript frame type, because we may encounter arguments // the JavaScript frame type, because we may encounter arguments
......
...@@ -291,6 +291,7 @@ SafeStackFrameIterator::SafeStackFrameIterator( ...@@ -291,6 +291,7 @@ SafeStackFrameIterator::SafeStackFrameIterator(
is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)), is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
iteration_done_(!is_valid_top_ && !is_valid_fp_), iteration_done_(!is_valid_top_ && !is_valid_fp_),
iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) { iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) {
if (!done()) Advance();
} }
bool SafeStackFrameIterator::is_active(Isolate* isolate) { bool SafeStackFrameIterator::is_active(Isolate* isolate) {
...@@ -308,7 +309,7 @@ bool SafeStackFrameIterator::IsValidTop(Isolate* isolate, ...@@ -308,7 +309,7 @@ bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
} }
void SafeStackFrameIterator::Advance() { void SafeStackFrameIterator::AdvanceOneFrame() {
ASSERT(!done()); ASSERT(!done());
StackFrame* last_frame = iterator_.frame(); StackFrame* last_frame = iterator_.frame();
Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); Address last_sp = last_frame->sp(), last_fp = last_frame->fp();
...@@ -366,26 +367,18 @@ bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { ...@@ -366,26 +367,18 @@ bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) {
} }
// ------------------------------------------------------------------------- void SafeStackFrameIterator::Advance() {
SafeStackTraceFrameIterator::SafeStackTraceFrameIterator(
Isolate* isolate,
Address fp, Address sp, Address low_bound, Address high_bound)
: iterator_(isolate, fp, sp, low_bound, high_bound) {
if (!done()) Advance();
}
void SafeStackTraceFrameIterator::Advance() {
while (true) { while (true) {
iterator_.Advance(); AdvanceOneFrame();
if (iterator_.done()) return; if (done()) return;
if (iterator_.frame()->is_java_script()) return; if (iterator_.frame()->is_java_script()) return;
} }
} }
// -------------------------------------------------------------------------
Code* StackFrame::GetSafepointData(Isolate* isolate, Code* StackFrame::GetSafepointData(Isolate* isolate,
Address inner_pointer, Address inner_pointer,
SafepointEntry* safepoint_entry, SafepointEntry* safepoint_entry,
......
...@@ -874,18 +874,16 @@ class SafeStackFrameIterator BASE_EMBEDDED { ...@@ -874,18 +874,16 @@ class SafeStackFrameIterator BASE_EMBEDDED {
Address fp, Address sp, Address fp, Address sp,
Address low_bound, Address high_bound); Address low_bound, Address high_bound);
StackFrame* frame() const { inline JavaScriptFrame* frame() const;
ASSERT(!iteration_done_);
return iterator_.frame();
}
bool done() const { return iteration_done_ || iterator_.done(); } bool done() const { return iteration_done_ || iterator_.done(); }
void Advance(); void Advance();
static bool is_active(Isolate* isolate); static bool is_active(Isolate* isolate);
private: private:
void AdvanceOneFrame();
static bool IsWithinBounds( static bool IsWithinBounds(
Address low_bound, Address high_bound, Address addr) { Address low_bound, Address high_bound, Address addr) {
return low_bound <= addr && addr <= high_bound; return low_bound <= addr && addr <= high_bound;
...@@ -945,24 +943,6 @@ class SafeStackFrameIterator BASE_EMBEDDED { ...@@ -945,24 +943,6 @@ class SafeStackFrameIterator BASE_EMBEDDED {
}; };
class SafeStackTraceFrameIterator BASE_EMBEDDED {
public:
SafeStackTraceFrameIterator(Isolate* isolate,
Address fp,
Address sp,
Address low_bound,
Address high_bound);
inline JavaScriptFrame* frame() const;
bool done() const { return iterator_.done(); }
void Advance();
private:
SafeStackFrameIterator iterator_;
};
class StackFrameLocator BASE_EMBEDDED { class StackFrameLocator BASE_EMBEDDED {
public: public:
explicit StackFrameLocator(Isolate* isolate) : iterator_(isolate) {} explicit StackFrameLocator(Isolate* isolate) : iterator_(isolate) {}
......
...@@ -910,7 +910,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) { ...@@ -910,7 +910,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
Address start; Address start;
CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start); CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start);
// If pc is in the function code before it set up stack frame or after the // If pc is in the function code before it set up stack frame or after the
// frame was destroyed SafeStackTraceFrameIterator incorrectly thinks that // frame was destroyed SafeStackFrameIterator incorrectly thinks that
// ebp contains return address of the current function and skips caller's // ebp contains return address of the current function and skips caller's
// frame. Check for this case and just skip such samples. // frame. Check for this case and just skip such samples.
if (pc_entry) { if (pc_entry) {
......
...@@ -636,7 +636,7 @@ DISABLE_ASAN void TickSample::Trace(Isolate* isolate) { ...@@ -636,7 +636,7 @@ DISABLE_ASAN void TickSample::Trace(Isolate* isolate) {
has_external_callback = false; has_external_callback = false;
} }
SafeStackTraceFrameIterator it(isolate, fp, sp, sp, js_entry_sp); SafeStackFrameIterator it(isolate, fp, sp, sp, js_entry_sp);
int i = 0; int i = 0;
while (!it.done() && i < TickSample::kMaxFramesCount) { while (!it.done() && i < TickSample::kMaxFramesCount) {
stack[i++] = it.frame()->pc(); stack[i++] = it.frame()->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