Merge SafeStackTraceFrameIterator into SafeStackFrameIterator
authoryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 25 Jun 2013 07:14:06 +0000 (07:14 +0000)
committeryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 25 Jun 2013 07:14:06 +0000 (07:14 +0000)
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

src/frames-inl.h
src/frames.cc
src/frames.h
src/profile-generator.cc
src/sampler.cc

index cf31a48..c22a018 100644 (file)
@@ -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
   // problematic that we can't use the safe-cast operator to cast to
   // the JavaScript frame type, because we may encounter arguments
index 5ea0fd8..3cf02f4 100644 (file)
@@ -291,6 +291,7 @@ SafeStackFrameIterator::SafeStackFrameIterator(
     is_valid_fp_(IsWithinBounds(low_bound, high_bound, fp)),
     iteration_done_(!is_valid_top_ && !is_valid_fp_),
     iterator_(isolate, is_valid_top_, is_valid_fp_ ? fp : NULL, sp) {
+  if (!done()) Advance();
 }
 
 bool SafeStackFrameIterator::is_active(Isolate* isolate) {
@@ -308,7 +309,7 @@ bool SafeStackFrameIterator::IsValidTop(Isolate* isolate,
 }
 
 
-void SafeStackFrameIterator::Advance() {
+void SafeStackFrameIterator::AdvanceOneFrame() {
   ASSERT(!done());
   StackFrame* last_frame = iterator_.frame();
   Address last_sp = last_frame->sp(), last_fp = last_frame->fp();
@@ -366,26 +367,18 @@ bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) {
 }
 
 
-// -------------------------------------------------------------------------
-
-
-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() {
+void SafeStackFrameIterator::Advance() {
   while (true) {
-    iterator_.Advance();
-    if (iterator_.done()) return;
+    AdvanceOneFrame();
+    if (done()) return;
     if (iterator_.frame()->is_java_script()) return;
   }
 }
 
 
+// -------------------------------------------------------------------------
+
+
 Code* StackFrame::GetSafepointData(Isolate* isolate,
                                    Address inner_pointer,
                                    SafepointEntry* safepoint_entry,
index 5c3acf2..1a78d09 100644 (file)
@@ -874,18 +874,16 @@ class SafeStackFrameIterator BASE_EMBEDDED {
                          Address fp, Address sp,
                          Address low_bound, Address high_bound);
 
-  StackFrame* frame() const {
-    ASSERT(!iteration_done_);
-    return iterator_.frame();
-  }
+  inline JavaScriptFrame* frame() const;
 
   bool done() const { return iteration_done_ || iterator_.done(); }
-
   void Advance();
 
   static bool is_active(Isolate* isolate);
 
  private:
+  void AdvanceOneFrame();
+
   static bool IsWithinBounds(
       Address low_bound, Address high_bound, Address addr) {
     return low_bound <= addr && addr <= high_bound;
@@ -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 {
  public:
   explicit StackFrameLocator(Isolate* isolate) : iterator_(isolate) {}
index d15c400..7461462 100644 (file)
@@ -910,7 +910,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
     Address 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
-    // 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
     // frame. Check for this case and just skip such samples.
     if (pc_entry) {
index 96b20f0..6d97110 100644 (file)
@@ -636,7 +636,7 @@ DISABLE_ASAN void TickSample::Trace(Isolate* isolate) {
     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;
   while (!it.done() && i < TickSample::kMaxFramesCount) {
     stack[i++] = it.frame()->pc();