<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201641] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201641">201641</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-06-03 07:53:16 -0700 (Fri, 03 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up how StackVisitor dumps its frames.
https://bugs.webkit.org/show_bug.cgi?id=158316

Reviewed by Keith Miller.

Source/JavaScriptCore:

1. Updated to do dumping to a PrintStream.
2. Added support for printing a prefix for each frame.
   This is currently used by JSDollarVMPrototype to print frame numbers.
3. Fix the incrementing of the frame index in StackVisitor.
   It was initialized but never incremented before when iterating the frames.

* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::gotoNextFrame):
(JSC::StackVisitor::Frame::codeType):
(JSC::StackVisitor::Frame::functionName):
(JSC::StackVisitor::Frame::sourceURL):
(JSC::StackVisitor::Frame::toString):
(JSC::StackVisitor::Frame::createArguments):
(JSC::StackVisitor::Frame::computeLineAndColumn):
(JSC::StackVisitor::Frame::retrieveExpressionInfo):
(JSC::StackVisitor::Frame::setToEnd):
(JSC::StackVisitor::Frame::dump):
(JSC::StackVisitor::Indent::dump):
(JSC::printIndents): Deleted.
(JSC::log): Deleted.
(JSC::logF): Deleted.
(JSC::StackVisitor::Frame::print): Deleted.
* interpreter/StackVisitor.h:
(JSC::StackVisitor::Indent::Indent):
(JSC::StackVisitor::Indent::operator++):
(JSC::StackVisitor::Indent::operator--):
(JSC::StackVisitor::Frame::isJSFrame):
(JSC::StackVisitor::Frame::isInlinedFrame):
(JSC::StackVisitor::Frame::vmEntryFrame):
(JSC::StackVisitor::Frame::callFrame):
(JSC::StackVisitor::Frame::Frame):
(JSC::StackVisitor::Frame::~Frame):
* tools/JSDollarVMPrototype.cpp:
(JSC::PrintFrameFunctor::operator()):

Source/WTF:

Added an Indenter class what works with dataLog.

* WTF.xcodeproj/project.pbxproj:
* wtf/Indenter.h: Added.
(WTF::Indenter::Indenter):
(WTF::Indenter::dump):
(WTF::Indenter::operator++):
(WTF::Indenter::operator--):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterStackVisitorcpp">trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterStackVisitorh">trunk/Source/JavaScriptCore/interpreter/StackVisitor.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretoolsJSDollarVMPrototypecpp">trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfIndenterh">trunk/Source/WTF/wtf/Indenter.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-06-03  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Clean up how StackVisitor dumps its frames.
+        https://bugs.webkit.org/show_bug.cgi?id=158316
+
+        Reviewed by Keith Miller.
+
+        1. Updated to do dumping to a PrintStream.
+        2. Added support for printing a prefix for each frame.
+           This is currently used by JSDollarVMPrototype to print frame numbers.
+        3. Fix the incrementing of the frame index in StackVisitor.
+           It was initialized but never incremented before when iterating the frames.
+
+        * interpreter/StackVisitor.cpp:
+        (JSC::StackVisitor::gotoNextFrame):
+        (JSC::StackVisitor::Frame::codeType):
+        (JSC::StackVisitor::Frame::functionName):
+        (JSC::StackVisitor::Frame::sourceURL):
+        (JSC::StackVisitor::Frame::toString):
+        (JSC::StackVisitor::Frame::createArguments):
+        (JSC::StackVisitor::Frame::computeLineAndColumn):
+        (JSC::StackVisitor::Frame::retrieveExpressionInfo):
+        (JSC::StackVisitor::Frame::setToEnd):
+        (JSC::StackVisitor::Frame::dump):
+        (JSC::StackVisitor::Indent::dump):
+        (JSC::printIndents): Deleted.
+        (JSC::log): Deleted.
+        (JSC::logF): Deleted.
+        (JSC::StackVisitor::Frame::print): Deleted.
+        * interpreter/StackVisitor.h:
+        (JSC::StackVisitor::Indent::Indent):
+        (JSC::StackVisitor::Indent::operator++):
+        (JSC::StackVisitor::Indent::operator--):
+        (JSC::StackVisitor::Frame::isJSFrame):
+        (JSC::StackVisitor::Frame::isInlinedFrame):
+        (JSC::StackVisitor::Frame::vmEntryFrame):
+        (JSC::StackVisitor::Frame::callFrame):
+        (JSC::StackVisitor::Frame::Frame):
+        (JSC::StackVisitor::Frame::~Frame):
+        * tools/JSDollarVMPrototype.cpp:
+        (JSC::PrintFrameFunctor::operator()):
+
</ins><span class="cx"> 2016-06-02  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         global lexical environment variables are not accessible through functions created using the function constructor
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterStackVisitorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> 
</span><span class="cx"> void StackVisitor::gotoNextFrame()
</span><span class="cx"> {
</span><ins>+    m_frame.m_index++;
</ins><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="cx">     if (m_frame.isInlinedFrame()) {
</span><span class="cx">         InlineCallFrame* inlineCallFrame = m_frame.inlineCallFrame();
</span><span class="lines">@@ -208,7 +209,7 @@
</span><span class="cx">     return CodeType::Global;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StackVisitor::Frame::functionName()
</del><ins>+String StackVisitor::Frame::functionName() const
</ins><span class="cx"> {
</span><span class="cx">     String traceLine;
</span><span class="cx">     JSObject* callee = this-&gt;callee();
</span><span class="lines">@@ -234,7 +235,7 @@
</span><span class="cx">     return traceLine.isNull() ? emptyString() : traceLine;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StackVisitor::Frame::sourceURL()
</del><ins>+String StackVisitor::Frame::sourceURL() const
</ins><span class="cx"> {
</span><span class="cx">     String traceLine;
</span><span class="cx"> 
</span><span class="lines">@@ -255,7 +256,7 @@
</span><span class="cx">     return traceLine.isNull() ? emptyString() : traceLine;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StackVisitor::Frame::toString()
</del><ins>+String StackVisitor::Frame::toString() const
</ins><span class="cx"> {
</span><span class="cx">     StringBuilder traceBuild;
</span><span class="cx">     String functionName = this-&gt;functionName();
</span><span class="lines">@@ -305,7 +306,7 @@
</span><span class="cx">     return arguments;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StackVisitor::Frame::computeLineAndColumn(unsigned&amp; line, unsigned&amp; column)
</del><ins>+void StackVisitor::Frame::computeLineAndColumn(unsigned&amp; line, unsigned&amp; column) const
</ins><span class="cx"> {
</span><span class="cx">     CodeBlock* codeBlock = this-&gt;codeBlock();
</span><span class="cx">     if (!codeBlock) {
</span><span class="lines">@@ -328,7 +329,7 @@
</span><span class="cx">         line = codeBlock-&gt;ownerScriptExecutable()-&gt;overrideLineNumber();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StackVisitor::Frame::retrieveExpressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column)
</del><ins>+void StackVisitor::Frame::retrieveExpressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column) const
</ins><span class="cx"> {
</span><span class="cx">     CodeBlock* codeBlock = this-&gt;codeBlock();
</span><span class="cx">     codeBlock-&gt;unlinkedCodeBlock()-&gt;expressionRangeForBytecodeOffset(bytecodeOffset(), divot, startOffset, endOffset, line, column);
</span><span class="lines">@@ -343,46 +344,22 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void printIndents(int levels)
</del><ins>+void StackVisitor::Frame::dump(PrintStream&amp; out, Indenter indent) const
</ins><span class="cx"> {
</span><del>-    while (levels--)
-        dataLogFString(&quot;   &quot;);
</del><ins>+    dump(out, indent, [] (PrintStream&amp;) { });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;typename... Types&gt;
-void log(unsigned indent, const Types&amp;... values)
</del><ins>+void StackVisitor::Frame::dump(PrintStream&amp; out, Indenter indent, std::function&lt;void(PrintStream&amp;)&gt; prefix) const
</ins><span class="cx"> {
</span><del>-    printIndents(indent);
-    dataLog(values...);
-}
-
-template&lt;typename... Types&gt;
-void logF(unsigned indent, const char* format, const Types&amp;... values)
-{
-    printIndents(indent);
-
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored &quot;-Wformat-nonliteral&quot;
-#pragma GCC diagnostic ignored &quot;-Wmissing-format-attribute&quot;
-#endif
-
-    dataLogF(format, values...);
-
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic pop
-#endif
-}
-
-void StackVisitor::Frame::print(int indent)
-{
</del><span class="cx">     if (!this-&gt;callFrame()) {
</span><del>-        log(indent, &quot;frame 0x0\n&quot;);
</del><ins>+        out.print(indent, &quot;frame 0x0\n&quot;);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     CodeBlock* codeBlock = this-&gt;codeBlock();
</span><del>-    logF(indent, &quot;frame %p {\n&quot;, this-&gt;callFrame());
</del><ins>+    out.print(indent);
+    prefix(out);
+    out.print(&quot;frame &quot;, RawPointer(this-&gt;callFrame()), &quot; {\n&quot;);
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         indent++;
</span><span class="lines">@@ -391,43 +368,46 @@
</span><span class="cx">         CallFrame* callerFrame = this-&gt;callerFrame();
</span><span class="cx">         void* returnPC = callFrame-&gt;hasReturnPC() ? callFrame-&gt;returnPC().value() : nullptr;
</span><span class="cx"> 
</span><del>-        log(indent, &quot;name: &quot;, functionName(), &quot;\n&quot;);
-        log(indent, &quot;sourceURL: &quot;, sourceURL(), &quot;\n&quot;);
</del><ins>+        out.print(indent, &quot;name: &quot;, functionName(), &quot;\n&quot;);
+        out.print(indent, &quot;sourceURL: &quot;, sourceURL(), &quot;\n&quot;);
</ins><span class="cx"> 
</span><span class="cx">         bool isInlined = false;
</span><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="cx">         isInlined = isInlinedFrame();
</span><del>-        log(indent, &quot;isInlinedFrame: &quot;, isInlinedFrame(), &quot;\n&quot;);
</del><ins>+        out.print(indent, &quot;isInlinedFrame: &quot;, isInlinedFrame(), &quot;\n&quot;);
</ins><span class="cx">         if (isInlinedFrame())
</span><del>-            logF(indent, &quot;InlineCallFrame: %p\n&quot;, m_inlineCallFrame);
</del><ins>+            out.print(indent, &quot;InlineCallFrame: &quot;, RawPointer(m_inlineCallFrame), &quot;\n&quot;);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        logF(indent, &quot;callee: %p\n&quot;, callee());
-        logF(indent, &quot;returnPC: %p\n&quot;, returnPC);
-        logF(indent, &quot;callerFrame: %p\n&quot;, callerFrame);
</del><ins>+        out.print(indent, &quot;callee: &quot;, RawPointer(callee()), &quot;\n&quot;);
+        out.print(indent, &quot;returnPC: &quot;, RawPointer(returnPC), &quot;\n&quot;);
+        out.print(indent, &quot;callerFrame: &quot;, RawPointer(callerFrame), &quot;\n&quot;);
</ins><span class="cx">         unsigned locationRawBits = callFrame-&gt;callSiteAsRawBits();
</span><del>-        logF(indent, &quot;rawLocationBits: %u 0x%x\n&quot;, locationRawBits, locationRawBits);
-        logF(indent, &quot;codeBlock: %p &quot;, codeBlock);
</del><ins>+        out.print(indent, &quot;rawLocationBits: &quot;, static_cast&lt;uintptr_t&gt;(locationRawBits),
+            &quot; &quot;, RawPointer(reinterpret_cast&lt;void*&gt;(locationRawBits)), &quot;\n&quot;);
+        out.print(indent, &quot;codeBlock: &quot;, RawPointer(codeBlock));
</ins><span class="cx">         if (codeBlock)
</span><del>-            dataLog(*codeBlock);
-        dataLog(&quot;\n&quot;);
</del><ins>+            out.print(*codeBlock);
+        out.print(&quot;\n&quot;);
</ins><span class="cx">         if (codeBlock &amp;&amp; !isInlined) {
</span><span class="cx">             indent++;
</span><span class="cx"> 
</span><span class="cx">             if (callFrame-&gt;callSiteBitsAreBytecodeOffset()) {
</span><span class="cx">                 unsigned bytecodeOffset = callFrame-&gt;bytecodeOffset();
</span><del>-                log(indent, &quot;bytecodeOffset: &quot;, bytecodeOffset, &quot; of &quot;, codeBlock-&gt;instructions().size(), &quot;\n&quot;);
</del><ins>+                out.print(indent, &quot;bytecodeOffset: &quot;, bytecodeOffset, &quot; of &quot;, codeBlock-&gt;instructions().size(), &quot;\n&quot;);
</ins><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="cx">             } else {
</span><del>-                log(indent, &quot;hasCodeOrigins: &quot;, codeBlock-&gt;hasCodeOrigins(), &quot;\n&quot;);
</del><ins>+                out.print(indent, &quot;hasCodeOrigins: &quot;, codeBlock-&gt;hasCodeOrigins(), &quot;\n&quot;);
</ins><span class="cx">                 if (codeBlock-&gt;hasCodeOrigins()) {
</span><span class="cx">                     CallSiteIndex callSiteIndex = callFrame-&gt;callSiteIndex();
</span><del>-                    log(indent, &quot;callSiteIndex: &quot;, callSiteIndex.bits(), &quot; of &quot;, codeBlock-&gt;codeOrigins().size(), &quot;\n&quot;);
</del><ins>+                    out.print(indent, &quot;callSiteIndex: &quot;, callSiteIndex.bits(), &quot; of &quot;, codeBlock-&gt;codeOrigins().size(), &quot;\n&quot;);
</ins><span class="cx"> 
</span><span class="cx">                     JITCode::JITType jitType = codeBlock-&gt;jitType();
</span><span class="cx">                     if (jitType != JITCode::FTLJIT) {
</span><span class="cx">                         JITCode* jitCode = codeBlock-&gt;jitCode().get();
</span><del>-                        logF(indent, &quot;jitCode: %p start %p end %p\n&quot;, jitCode, jitCode-&gt;start(), jitCode-&gt;end());
</del><ins>+                        out.print(indent, &quot;jitCode: &quot;, RawPointer(jitCode),
+                            &quot; start &quot;, RawPointer(jitCode-&gt;start()),
+                            &quot; end &quot;, RawPointer(jitCode-&gt;end()), &quot;\n&quot;);
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="lines">@@ -435,14 +415,14 @@
</span><span class="cx">             unsigned line = 0;
</span><span class="cx">             unsigned column = 0;
</span><span class="cx">             computeLineAndColumn(line, column);
</span><del>-            log(indent, &quot;line: &quot;, line, &quot;\n&quot;);
-            log(indent, &quot;column: &quot;, column, &quot;\n&quot;);
</del><ins>+            out.print(indent, &quot;line: &quot;, line, &quot;\n&quot;);
+            out.print(indent, &quot;column: &quot;, column, &quot;\n&quot;);
</ins><span class="cx"> 
</span><span class="cx">             indent--;
</span><span class="cx">         }
</span><span class="cx">         indent--;
</span><span class="cx">     }
</span><del>-    log(indent, &quot;}\n&quot;);
</del><ins>+    out.print(indent, &quot;}\n&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterStackVisitorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/StackVisitor.h (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/StackVisitor.h        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/JavaScriptCore/interpreter/StackVisitor.h        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define StackVisitor_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;VMEntryRecord.h&quot;
</span><ins>+#include &lt;wtf/Indenter.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -74,26 +75,27 @@
</span><span class="cx">         bool isJSFrame() const { return !!codeBlock(); }
</span><span class="cx">         bool isInlinedFrame() const { return !!inlineCallFrame(); }
</span><span class="cx"> 
</span><del>-        JS_EXPORT_PRIVATE String functionName();
-        JS_EXPORT_PRIVATE String sourceURL();
-        JS_EXPORT_PRIVATE String toString();
</del><ins>+        JS_EXPORT_PRIVATE String functionName() const;
+        JS_EXPORT_PRIVATE String sourceURL() const;
+        JS_EXPORT_PRIVATE String toString() const;
</ins><span class="cx"> 
</span><span class="cx">         intptr_t sourceID();
</span><span class="cx"> 
</span><span class="cx">         CodeType codeType() const;
</span><del>-        JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned&amp; line, unsigned&amp; column);
</del><ins>+        JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned&amp; line, unsigned&amp; column) const;
</ins><span class="cx"> 
</span><span class="cx">         ClonedArguments* createArguments();
</span><span class="cx">         VMEntryFrame* vmEntryFrame() const { return m_VMEntryFrame; }
</span><span class="cx">         CallFrame* callFrame() const { return m_callFrame; }
</span><span class="cx">         
</span><del>-        JS_EXPORT_PRIVATE void print(int indentLevel);
</del><ins>+        void dump(PrintStream&amp;, Indenter = Indenter()) const;
+        void dump(PrintStream&amp;, Indenter, std::function&lt;void(PrintStream&amp;)&gt; prefix) const;
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         Frame() { }
</span><span class="cx">         ~Frame() { }
</span><span class="cx"> 
</span><del>-        void retrieveExpressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column);
</del><ins>+        void retrieveExpressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column) const;
</ins><span class="cx">         void setToEnd();
</span><span class="cx"> 
</span><span class="cx">         size_t m_index;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretoolsJSDollarVMPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -326,9 +326,11 @@
</span><span class="cx">     StackVisitor::Status operator()(StackVisitor&amp; visitor) const
</span><span class="cx">     {
</span><span class="cx">         m_currentFrame++;
</span><del>-        if (m_currentFrame &gt; m_framesToSkip)
-            visitor-&gt;print(2);
-        
</del><ins>+        if (m_currentFrame &gt; m_framesToSkip) {
+            visitor-&gt;dump(WTF::dataFile(), Indenter(2), [&amp;] (PrintStream&amp; out) {
+                out.print(&quot;[&quot;, (m_currentFrame - m_framesToSkip - 1), &quot;] &quot;);
+            });
+        }
</ins><span class="cx">         if (m_action == PrintOne &amp;&amp; m_currentFrame &gt; m_framesToSkip)
</span><span class="cx">             return StackVisitor::Done;
</span><span class="cx">         return StackVisitor::Continue;
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/WTF/ChangeLog        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-06-03  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Clean up how StackVisitor dumps its frames.
+        https://bugs.webkit.org/show_bug.cgi?id=158316
+
+        Reviewed by Keith Miller.
+
+        Added an Indenter class what works with dataLog.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/Indenter.h: Added.
+        (WTF::Indenter::Indenter):
+        (WTF::Indenter::dump):
+        (WTF::Indenter::operator++):
+        (WTF::Indenter::operator--):
+
</ins><span class="cx"> 2016-06-02  Said Abou-Hallawa  &lt;sabouhallawa@apple,com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] PDFDocumentImage should not create a cached image larger than 4M pixels
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (201640 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -319,6 +319,7 @@
</span><span class="cx">                 E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
</span><span class="cx">                 EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; };
</span><span class="cx">                 FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8225301B2A1E5B00BA68FD /* NakedPtr.h */; };
</span><ins>+                FE8925B01D00DAEC0046907E /* Indenter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8925AF1D00DAEC0046907E /* Indenter.h */; };
</ins><span class="cx">                 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
</span><span class="cx">                 FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; };
</span><span class="cx"> /* End PBXBuildFile section */
</span><span class="lines">@@ -650,6 +651,7 @@
</span><span class="cx">                 E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx"> /* End PBXFileReference section */
</span><span class="lines">@@ -855,6 +857,7 @@
</span><span class="cx">                                 A8A472B9151A825A004123FF /* HashTable.h */,
</span><span class="cx">                                 A8A472BA151A825A004123FF /* HashTraits.h */,
</span><span class="cx">                                 A8A472BB151A825A004123FF /* HexNumber.h */,
</span><ins>+                                FE8925AF1D00DAEC0046907E /* Indenter.h */,
</ins><span class="cx">                                 2684D4351C000D400081D663 /* IndexSparseSet.h */,
</span><span class="cx">                                 A8A472BC151A825A004123FF /* InlineASM.h */,
</span><span class="cx">                                 A70DA0821799F04D00529A9B /* Insertion.h */,
</span><span class="lines">@@ -1360,6 +1363,7 @@
</span><span class="cx">                                 149EF16316BBFE0D000A4331 /* TriState.h in Headers */,
</span><span class="cx">                                 83FBA93219DF459700F30ADB /* TypeCasts.h in Headers */,
</span><span class="cx">                                 1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */,
</span><ins>+                                FE8925B01D00DAEC0046907E /* Indenter.h in Headers */,
</ins><span class="cx">                                 A8A4746D151A825B004123FF /* UnionFind.h in Headers */,
</span><span class="cx">                                 70ECA60F1B02426800449739 /* UniquedStringImpl.h in Headers */,
</span><span class="cx">                                 A8A4746A151A825B004123FF /* UTF8.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfIndenterh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/Indenter.h (0 => 201641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Indenter.h                                (rev 0)
+++ trunk/Source/WTF/wtf/Indenter.h        2016-06-03 14:53:16 UTC (rev 201641)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Indenter_h
+#define Indenter_h
+
+#include &lt;wtf/FilePrintStream.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WTF {
+
+class Indenter {
+public:
+    Indenter(unsigned count = 0, String string = ASCIILiteral(&quot;  &quot;))
+        : m_count(count)
+        , m_string(string)
+    { }
+
+    Indenter(const Indenter&amp; other)
+        : m_count(other.m_count)
+        , m_string(other.m_string)
+    { }
+
+    void dump(PrintStream&amp; out) const
+    {
+        unsigned levels = m_count;
+        while (levels--)
+            out.print(m_string);
+    }
+
+    unsigned operator++() { return ++m_count; }
+    unsigned operator++(int) { return m_count++; }
+    unsigned operator--() { return --m_count; }
+    unsigned operator--(int) { return m_count--; }
+
+private:
+    unsigned m_count;
+    String m_string;
+};
+
+} // namespace WTF
+
+using WTF::Indenter;
+
+#endif // Indenter_h
</ins></span></pre>
</div>
</div>

</body>
</html>