- Revision
- 153825
- Author
- [email protected]
- Date
- 2013-08-08 09:57:07 -0700 (Thu, 08 Aug 2013)
Log Message
Restoring use of StackIterator instead of Interpreter::getStacktrace().
https://bugs.webkit.org/show_bug.cgi?id=119575.
Reviewed by Oliver Hunt.
Source/_javascript_Core:
* 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):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (153824 => 153825)
--- trunk/Source/_javascript_Core/ChangeLog 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-08-08 16:57:07 UTC (rev 153825)
@@ -1,5 +1,27 @@
2013-08-08 Mark Lam <[email protected]>
+ Restoring use of StackIterator instead of Interpreter::getStacktrace().
+ https://bugs.webkit.org/show_bug.cgi?id=119575.
+
+ Reviewed by Oliver Hunt.
+
+ * 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:
+
+2013-08-08 Mark Lam <[email protected]>
+
Moved ErrorConstructor and NativeErrorConstructor helper functions into
the Interpreter class.
https://bugs.webkit.org/show_bug.cgi?id=119576.
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.h (153824 => 153825)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.h 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.h 2013-08-08 16:57:07 UTC (rev 153825)
@@ -233,8 +233,6 @@
JS_EXPORT_PRIVATE void dumpCallFrame(CallFrame*);
- JS_EXPORT_PRIVATE void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
-
private:
enum ExecutionFlag { Normal, InitializeAndReturn };
@@ -242,6 +240,7 @@
void endRepeatCall(CallFrameClosure&);
JSValue execute(CallFrameClosure&);
+ void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
NEVER_INLINE bool unwindCallFrame(StackIterator&, JSValue);
void dumpRegisters(CallFrame*);
Modified: trunk/Source/_javascript_Core/interpreter/StackIterator.cpp (153824 => 153825)
--- trunk/Source/_javascript_Core/interpreter/StackIterator.cpp 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/_javascript_Core/interpreter/StackIterator.cpp 2013-08-08 16:57:07 UTC (rev 153825)
@@ -34,14 +34,34 @@
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()
{
Frame* frame = m_frame;
@@ -51,8 +71,16 @@
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)
{
ASSERT(functionObj);
Modified: trunk/Source/_javascript_Core/interpreter/StackIteratorPrivate.h (153824 => 153825)
--- trunk/Source/_javascript_Core/interpreter/StackIteratorPrivate.h 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/_javascript_Core/interpreter/StackIteratorPrivate.h 2013-08-08 16:57:07 UTC (rev 153825)
@@ -39,6 +39,8 @@
class Frame;
typedef bool (*FrameFilter)(Frame*);
+ JS_EXPORT_PRIVATE size_t numberOfFrames();
+
Frame& operator*() { return *m_frame; }
ALWAYS_INLINE Frame* operator->() { return m_frame; }
@@ -51,8 +53,12 @@
JS_EXPORT_PRIVATE StackIterator(CallFrame* startFrame, FrameFilter = 0);
static Frame* end() { return 0; }
+ void gotoFrameAtIndex(size_t frameIndex);
JS_EXPORT_PRIVATE void gotoNextFrame();
+ void resetIterator();
+ CallFrame* m_startFrame;
+ size_t m_frameIndex;
Frame* m_frame;
FrameFilter m_filter;
Modified: trunk/Source/WebCore/ChangeLog (153824 => 153825)
--- trunk/Source/WebCore/ChangeLog 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/WebCore/ChangeLog 2013-08-08 16:57:07 UTC (rev 153825)
@@ -1,3 +1,15 @@
+2013-08-08 Mark Lam <[email protected]>
+
+ Restoring use of StackIterator instead of Interpreter::getStacktrace().
+ https://bugs.webkit.org/show_bug.cgi?id=119575.
+
+ Reviewed by Oliver Hunt.
+
+ No new tests.
+
+ * bindings/js/ScriptCallStackFactory.cpp:
+ (WebCore::createScriptCallStack):
+
2013-08-08 Zalan Bujtas <[email protected]>
REGRESSION (r121551) Incorrect handling of invalid media query list.
Modified: trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp (153824 => 153825)
--- trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp 2013-08-08 16:55:05 UTC (rev 153824)
+++ trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp 2013-08-08 16:57:07 UTC (rev 153825)
@@ -78,22 +78,22 @@
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
{
Vector<ScriptCallFrame> frames;
- Vector<StackFrame> stackTrace;
- exec->vm().interpreter->getStackTrace(stackTrace, maxStackSize + 1);
- for (size_t i = stackTrace.size() == 1 ? 0 : 1; i < stackTrace.size(); i++) {
+ ASSERT(exec);
+ CallFrame* frame = exec->vm().topCallFrame;
+ StackIterator iter = frame->begin();
+ if (iter.numberOfFrames() > 1)
+ ++iter;
+ for (; iter != frame->end() && maxStackSize--; ++iter) {
// This early exit is necessary to maintain our old behaviour
// but the stack trace we produce now is complete and handles all
// ways in which code may be running
- if (!stackTrace[i].callee && frames.size())
+ if (!iter->callee() && frames.size())
break;
-
- String functionName = stackTrace[i].friendlyFunctionName(exec);
unsigned line;
unsigned column;
- stackTrace[i].computeLineAndColumn(line, column);
- frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, line, column));
+ iter->computeLineAndColumn(line, column);
+ frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), line, column));
}
-
return ScriptCallStack::create(frames);
}