Changeset 153825 in webkit
- Timestamp:
- Aug 8, 2013, 9:57:07 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r153823 r153825 1 2013-08-08 Mark Lam <mark.lam@apple.com> 2 3 Restoring use of StackIterator instead of Interpreter::getStacktrace(). 4 https://bugs.webkit.org/show_bug.cgi?id=119575. 5 6 Reviewed by Oliver Hunt. 7 8 * interpreter/Interpreter.h: 9 - Made getStackTrace() private. 10 * interpreter/StackIterator.cpp: 11 (JSC::StackIterator::StackIterator): 12 (JSC::StackIterator::numberOfFrames): 13 - Computes the number of frames by iterating through the whole stack 14 from the starting frame. The iterator will save its current frame 15 position before counting the frames, and then restoring it after 16 the counting. 17 (JSC::StackIterator::gotoFrameAtIndex): 18 (JSC::StackIterator::gotoNextFrame): 19 (JSC::StackIterator::resetIterator): 20 - Points the iterator to the starting frame. 21 * interpreter/StackIteratorPrivate.h: 22 1 23 2013-08-08 Mark Lam <mark.lam@apple.com> 2 24 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r153823 r153825 234 234 JS_EXPORT_PRIVATE void dumpCallFrame(CallFrame*); 235 235 236 JS_EXPORT_PRIVATE void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());237 238 236 private: 239 237 enum ExecutionFlag { Normal, InitializeAndReturn }; … … 243 241 JSValue execute(CallFrameClosure&); 244 242 243 void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max()); 245 244 NEVER_INLINE bool unwindCallFrame(StackIterator&, JSValue); 246 245 -
trunk/Source/JavaScriptCore/interpreter/StackIterator.cpp
r153329 r153825 35 35 namespace JSC { 36 36 37 StackIterator::StackIterator(CallFrame* frame, StackIterator::FrameFilter filter) 38 : m_filter(filter) 39 { 40 ASSERT(frame); 41 m_frame = Frame::create(frame); 42 m_frame = m_frame->logicalFrame(); 37 StackIterator::StackIterator(CallFrame* startFrame, StackIterator::FrameFilter filter) 38 : m_startFrame(startFrame) 39 , m_filter(filter) 40 { 41 ASSERT(startFrame); 42 resetIterator(); 43 } 44 45 size_t StackIterator::numberOfFrames() 46 { 47 int savedFrameIndex = m_frameIndex; 48 resetIterator(); 49 while (m_frame) 50 gotoNextFrame(); 51 size_t numberOfFrames = m_frameIndex; 52 53 resetIterator(); 54 gotoFrameAtIndex(savedFrameIndex); 55 56 return numberOfFrames; 57 } 58 59 void StackIterator::gotoFrameAtIndex(size_t index) 60 { 61 while (m_frame && (m_frameIndex != index)) 62 gotoNextFrame(); 43 63 } 44 64 … … 52 72 } 53 73 m_frame = frame; 74 m_frameIndex++; 75 } 76 77 void StackIterator::resetIterator() 78 { 79 m_frameIndex = 0; 80 m_frame = Frame::create(m_startFrame); 81 m_frame = m_frame->logicalFrame(); 54 82 } 55 83 -
trunk/Source/JavaScriptCore/interpreter/StackIteratorPrivate.h
r153299 r153825 40 40 typedef bool (*FrameFilter)(Frame*); 41 41 42 JS_EXPORT_PRIVATE size_t numberOfFrames(); 43 42 44 Frame& operator*() { return *m_frame; } 43 45 ALWAYS_INLINE Frame* operator->() { return m_frame; } … … 52 54 53 55 static Frame* end() { return 0; } 56 void gotoFrameAtIndex(size_t frameIndex); 54 57 JS_EXPORT_PRIVATE void gotoNextFrame(); 58 void resetIterator(); 55 59 60 CallFrame* m_startFrame; 61 size_t m_frameIndex; 56 62 Frame* m_frame; 57 63 FrameFilter m_filter; -
trunk/Source/WebCore/ChangeLog
r153822 r153825 1 2013-08-08 Mark Lam <mark.lam@apple.com> 2 3 Restoring use of StackIterator instead of Interpreter::getStacktrace(). 4 https://bugs.webkit.org/show_bug.cgi?id=119575. 5 6 Reviewed by Oliver Hunt. 7 8 No new tests. 9 10 * bindings/js/ScriptCallStackFactory.cpp: 11 (WebCore::createScriptCallStack): 12 1 13 2013-08-08 Zalan Bujtas <zalan@apple.com> 2 14 -
trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp
r153383 r153825 79 79 { 80 80 Vector<ScriptCallFrame> frames; 81 Vector<StackFrame> stackTrace; 82 exec->vm().interpreter->getStackTrace(stackTrace, maxStackSize + 1); 83 for (size_t i = stackTrace.size() == 1 ? 0 : 1; i < stackTrace.size(); i++) { 81 ASSERT(exec); 82 CallFrame* frame = exec->vm().topCallFrame; 83 StackIterator iter = frame->begin(); 84 if (iter.numberOfFrames() > 1) 85 ++iter; 86 for (; iter != frame->end() && maxStackSize--; ++iter) { 84 87 // This early exit is necessary to maintain our old behaviour 85 88 // but the stack trace we produce now is complete and handles all 86 89 // ways in which code may be running 87 if (! stackTrace[i].callee&& frames.size())90 if (!iter->callee() && frames.size()) 88 91 break; 89 90 String functionName = stackTrace[i].friendlyFunctionName(exec);91 92 unsigned line; 92 93 unsigned column; 93 stackTrace[i].computeLineAndColumn(line, column);94 frames.append(ScriptCallFrame( functionName, stackTrace[i].sourceURL, line, column));94 iter->computeLineAndColumn(line, column); 95 frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), line, column)); 95 96 } 96 97 97 return ScriptCallStack::create(frames); 98 98 }
Note:
See TracChangeset
for help on using the changeset viewer.