Bug 719878 - AllFramesIter does not find all frames when the current segment contains only a native call (r=sfink)
authorLuke Wagner <luke@mozilla.com>
Fri, 20 Jan 2012 16:00:26 -0800
changeset 85015 b881c5526ed2264bc4a585a9488e41c1457134df
parent 85014 b7684cc4cb7818c61bf1a5cd5090e3669d8b256a
child 85016 a862ba2711fdba6e316f060ccb3b2c5d6f8b3a69
child 85040 099ec081e8aa1a92cfbbd0f6d007b3900e02ea53
push id5124
push userlwagner@mozilla.com
push dateSat, 21 Jan 2012 00:05:07 +0000
treeherdermozilla-inbound@b881c5526ed2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs719878
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 719878 - AllFramesIter does not find all frames when the current segment contains only a native call (r=sfink)
js/src/vm/Stack.cpp
js/src/vm/Stack.h
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -1117,27 +1117,32 @@ StackIter::operator==(const StackIter &r
               (!isScript() && nativeArgs().base() == rhs.nativeArgs().base()))));
 }
 
 /*****************************************************************************/
 
 AllFramesIter::AllFramesIter(StackSpace &space)
   : seg_(space.seg_),
     fp_(seg_ ? seg_->maybefp() : NULL)
-{}
+{
+    settle();
+}
 
 AllFramesIter&
 AllFramesIter::operator++()
 {
     JS_ASSERT(!done());
     fp_ = fp_->prev();
-    if (!seg_->contains(fp_)) {
-        seg_ = seg_->prevInMemory();
-        while (seg_) {
-            fp_ = seg_->maybefp();
-            if (fp_)
-                return *this;
-            seg_ = seg_->prevInMemory();
-        }
-        JS_ASSERT(!fp_);
-    }
+    settle();
     return *this;
 }
+
+void
+AllFramesIter::settle()
+{
+    while (seg_ && (!fp_ || !seg_->contains(fp_))) {
+        seg_ = seg_->prevInMemory();
+        fp_ = seg_ ? seg_->maybefp() : NULL;
+    }
+
+    JS_ASSERT(!!seg_ == !!fp_);
+    JS_ASSERT_IF(fp_, seg_->contains(fp_));
+}
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1571,15 +1571,16 @@ class AllFramesIter
     AllFramesIter(StackSpace &space);
 
     bool done() const { return fp_ == NULL; }
     AllFramesIter& operator++();
 
     StackFrame *fp() const { return fp_; }
 
   private:
+    void settle();
     StackSegment *seg_;
     StackFrame *fp_;
 };
 
 }  /* namespace js */
 
 #endif /* Stack_h__ */