Restoring use of StackIterator instead of Interpreter::getStacktrace().
https://bugs.webkit.org/show_bug.cgi?id=119575.

Reviewed by Oliver Hunt.

Source/JavaScriptCore: 

* interpreter/Interpreter.h:
- Made getStackTrace() private.
* interpreter/StackIterator.cpp:
(JSC::StackIterator::StackIterator):
(JSC::StackIterator::numberOfFrames):
- Computes the number of frames by iterating through the whole stack
  from the starting frame. The iterator will save its current frame
  position before counting the frames, and then restoring it after
  the counting.
(JSC::StackIterator::gotoFrameAtIndex):
(JSC::StackIterator::gotoNextFrame):
(JSC::StackIterator::resetIterator):
- Points the iterator to the starting frame.
* interpreter/StackIteratorPrivate.h:

Source/WebCore: 

No new tests.

* bindings/js/ScriptCallStackFactory.cpp:
(WebCore::createScriptCallStack):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/interpreter/StackIterator.cpp b/Source/JavaScriptCore/interpreter/StackIterator.cpp
index 72c5210..9d8490e 100644
--- a/Source/JavaScriptCore/interpreter/StackIterator.cpp
+++ b/Source/JavaScriptCore/interpreter/StackIterator.cpp
@@ -34,12 +34,32 @@
 
 namespace JSC {
 
-StackIterator::StackIterator(CallFrame* frame, StackIterator::FrameFilter filter)
-    : m_filter(filter)
+StackIterator::StackIterator(CallFrame* startFrame, StackIterator::FrameFilter filter)
+    : m_startFrame(startFrame)
+    , m_filter(filter)
 {
-    ASSERT(frame);
-    m_frame = Frame::create(frame);
-    m_frame = m_frame->logicalFrame();
+    ASSERT(startFrame);
+    resetIterator();
+}
+
+size_t StackIterator::numberOfFrames()
+{
+    int savedFrameIndex = m_frameIndex;
+    resetIterator();
+    while (m_frame)
+        gotoNextFrame();
+    size_t numberOfFrames = m_frameIndex;
+
+    resetIterator();
+    gotoFrameAtIndex(savedFrameIndex);
+
+    return numberOfFrames;
+}
+
+void StackIterator::gotoFrameAtIndex(size_t index)
+{
+    while (m_frame && (m_frameIndex != index))
+        gotoNextFrame();
 }
 
 void StackIterator::gotoNextFrame()
@@ -51,6 +71,14 @@
             break;
     }
     m_frame = frame;
+    m_frameIndex++;
+}
+
+void StackIterator::resetIterator()
+{
+    m_frameIndex = 0;
+    m_frame = Frame::create(m_startFrame);
+    m_frame = m_frame->logicalFrame();
 }
 
 void StackIterator::find(JSFunction* functionObj)