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 86260 b881c5526ed2264bc4a585a9488e41c1457134df
parent 86259 b7684cc4cb7818c61bf1a5cd5090e3669d8b256a
child 86261 099ec081e8aa1a92cfbbd0f6d007b3900e02ea53
child 86276 a862ba2711fdba6e316f060ccb3b2c5d6f8b3a69
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs719878
milestone12.0a1
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__ */