Log Message
Clean up how StackVisitor dumps its frames. https://bugs.webkit.org/show_bug.cgi?id=158316
Reviewed by Keith Miller. Source/_javascript_Core: 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--):
Modified Paths
- trunk/Source/_javascript_Core/ChangeLog
- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp
- trunk/Source/_javascript_Core/interpreter/StackVisitor.h
- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (201640 => 201641)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-03 14:53:16 UTC (rev 201641)
@@ -1,3 +1,45 @@
+2016-06-03 Mark Lam <[email protected]>
+
+ 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()):
+
2016-06-02 Saam Barati <[email protected]>
global lexical environment variables are not accessible through functions created using the function constructor
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp (201640 => 201641)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2016-06-03 14:53:16 UTC (rev 201641)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2015-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
@@ -57,6 +57,7 @@
void StackVisitor::gotoNextFrame()
{
+ m_frame.m_index++;
#if ENABLE(DFG_JIT)
if (m_frame.isInlinedFrame()) {
InlineCallFrame* inlineCallFrame = m_frame.inlineCallFrame();
@@ -208,7 +209,7 @@
return CodeType::Global;
}
-String StackVisitor::Frame::functionName()
+String StackVisitor::Frame::functionName() const
{
String traceLine;
JSObject* callee = this->callee();
@@ -234,7 +235,7 @@
return traceLine.isNull() ? emptyString() : traceLine;
}
-String StackVisitor::Frame::sourceURL()
+String StackVisitor::Frame::sourceURL() const
{
String traceLine;
@@ -255,7 +256,7 @@
return traceLine.isNull() ? emptyString() : traceLine;
}
-String StackVisitor::Frame::toString()
+String StackVisitor::Frame::toString() const
{
StringBuilder traceBuild;
String functionName = this->functionName();
@@ -305,7 +306,7 @@
return arguments;
}
-void StackVisitor::Frame::computeLineAndColumn(unsigned& line, unsigned& column)
+void StackVisitor::Frame::computeLineAndColumn(unsigned& line, unsigned& column) const
{
CodeBlock* codeBlock = this->codeBlock();
if (!codeBlock) {
@@ -328,7 +329,7 @@
line = codeBlock->ownerScriptExecutable()->overrideLineNumber();
}
-void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
+void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const
{
CodeBlock* codeBlock = this->codeBlock();
codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeOffset(bytecodeOffset(), divot, startOffset, endOffset, line, column);
@@ -343,46 +344,22 @@
#endif
}
-static void printIndents(int levels)
+void StackVisitor::Frame::dump(PrintStream& out, Indenter indent) const
{
- while (levels--)
- dataLogFString(" ");
+ dump(out, indent, [] (PrintStream&) { });
}
-template<typename... Types>
-void log(unsigned indent, const Types&... values)
+void StackVisitor::Frame::dump(PrintStream& out, Indenter indent, std::function<void(PrintStream&)> prefix) const
{
- printIndents(indent);
- dataLog(values...);
-}
-
-template<typename... Types>
-void logF(unsigned indent, const char* format, const Types&... values)
-{
- printIndents(indent);
-
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
-#endif
-
- dataLogF(format, values...);
-
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic pop
-#endif
-}
-
-void StackVisitor::Frame::print(int indent)
-{
if (!this->callFrame()) {
- log(indent, "frame 0x0\n");
+ out.print(indent, "frame 0x0\n");
return;
}
CodeBlock* codeBlock = this->codeBlock();
- logF(indent, "frame %p {\n", this->callFrame());
+ out.print(indent);
+ prefix(out);
+ out.print("frame ", RawPointer(this->callFrame()), " {\n");
{
indent++;
@@ -391,43 +368,46 @@
CallFrame* callerFrame = this->callerFrame();
void* returnPC = callFrame->hasReturnPC() ? callFrame->returnPC().value() : nullptr;
- log(indent, "name: ", functionName(), "\n");
- log(indent, "sourceURL: ", sourceURL(), "\n");
+ out.print(indent, "name: ", functionName(), "\n");
+ out.print(indent, "sourceURL: ", sourceURL(), "\n");
bool isInlined = false;
#if ENABLE(DFG_JIT)
isInlined = isInlinedFrame();
- log(indent, "isInlinedFrame: ", isInlinedFrame(), "\n");
+ out.print(indent, "isInlinedFrame: ", isInlinedFrame(), "\n");
if (isInlinedFrame())
- logF(indent, "InlineCallFrame: %p\n", m_inlineCallFrame);
+ out.print(indent, "InlineCallFrame: ", RawPointer(m_inlineCallFrame), "\n");
#endif
- logF(indent, "callee: %p\n", callee());
- logF(indent, "returnPC: %p\n", returnPC);
- logF(indent, "callerFrame: %p\n", callerFrame);
+ out.print(indent, "callee: ", RawPointer(callee()), "\n");
+ out.print(indent, "returnPC: ", RawPointer(returnPC), "\n");
+ out.print(indent, "callerFrame: ", RawPointer(callerFrame), "\n");
unsigned locationRawBits = callFrame->callSiteAsRawBits();
- logF(indent, "rawLocationBits: %u 0x%x\n", locationRawBits, locationRawBits);
- logF(indent, "codeBlock: %p ", codeBlock);
+ out.print(indent, "rawLocationBits: ", static_cast<uintptr_t>(locationRawBits),
+ " ", RawPointer(reinterpret_cast<void*>(locationRawBits)), "\n");
+ out.print(indent, "codeBlock: ", RawPointer(codeBlock));
if (codeBlock)
- dataLog(*codeBlock);
- dataLog("\n");
+ out.print(*codeBlock);
+ out.print("\n");
if (codeBlock && !isInlined) {
indent++;
if (callFrame->callSiteBitsAreBytecodeOffset()) {
unsigned bytecodeOffset = callFrame->bytecodeOffset();
- log(indent, "bytecodeOffset: ", bytecodeOffset, " of ", codeBlock->instructions().size(), "\n");
+ out.print(indent, "bytecodeOffset: ", bytecodeOffset, " of ", codeBlock->instructions().size(), "\n");
#if ENABLE(DFG_JIT)
} else {
- log(indent, "hasCodeOrigins: ", codeBlock->hasCodeOrigins(), "\n");
+ out.print(indent, "hasCodeOrigins: ", codeBlock->hasCodeOrigins(), "\n");
if (codeBlock->hasCodeOrigins()) {
CallSiteIndex callSiteIndex = callFrame->callSiteIndex();
- log(indent, "callSiteIndex: ", callSiteIndex.bits(), " of ", codeBlock->codeOrigins().size(), "\n");
+ out.print(indent, "callSiteIndex: ", callSiteIndex.bits(), " of ", codeBlock->codeOrigins().size(), "\n");
JITCode::JITType jitType = codeBlock->jitType();
if (jitType != JITCode::FTLJIT) {
JITCode* jitCode = codeBlock->jitCode().get();
- logF(indent, "jitCode: %p start %p end %p\n", jitCode, jitCode->start(), jitCode->end());
+ out.print(indent, "jitCode: ", RawPointer(jitCode),
+ " start ", RawPointer(jitCode->start()),
+ " end ", RawPointer(jitCode->end()), "\n");
}
}
#endif
@@ -435,14 +415,14 @@
unsigned line = 0;
unsigned column = 0;
computeLineAndColumn(line, column);
- log(indent, "line: ", line, "\n");
- log(indent, "column: ", column, "\n");
+ out.print(indent, "line: ", line, "\n");
+ out.print(indent, "column: ", column, "\n");
indent--;
}
indent--;
}
- log(indent, "}\n");
+ out.print(indent, "}\n");
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.h (201640 => 201641)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2016-06-03 14:53:16 UTC (rev 201641)
@@ -27,6 +27,7 @@
#define StackVisitor_h
#include "VMEntryRecord.h"
+#include <wtf/Indenter.h>
#include <wtf/text/WTFString.h>
namespace JSC {
@@ -74,26 +75,27 @@
bool isJSFrame() const { return !!codeBlock(); }
bool isInlinedFrame() const { return !!inlineCallFrame(); }
- JS_EXPORT_PRIVATE String functionName();
- JS_EXPORT_PRIVATE String sourceURL();
- JS_EXPORT_PRIVATE String toString();
+ JS_EXPORT_PRIVATE String functionName() const;
+ JS_EXPORT_PRIVATE String sourceURL() const;
+ JS_EXPORT_PRIVATE String toString() const;
intptr_t sourceID();
CodeType codeType() const;
- JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column);
+ JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column) const;
ClonedArguments* createArguments();
VMEntryFrame* vmEntryFrame() const { return m_VMEntryFrame; }
CallFrame* callFrame() const { return m_callFrame; }
- JS_EXPORT_PRIVATE void print(int indentLevel);
+ void dump(PrintStream&, Indenter = Indenter()) const;
+ void dump(PrintStream&, Indenter, std::function<void(PrintStream&)> prefix) const;
private:
Frame() { }
~Frame() { }
- void retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column);
+ void retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const;
void setToEnd();
size_t m_index;
Modified: trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp (201640 => 201641)
--- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp 2016-06-03 09:03:12 UTC (rev 201640)
+++ trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp 2016-06-03 14:53:16 UTC (rev 201641)
@@ -326,9 +326,11 @@
StackVisitor::Status operator()(StackVisitor& visitor) const
{
m_currentFrame++;
- if (m_currentFrame > m_framesToSkip)
- visitor->print(2);
-
+ if (m_currentFrame > m_framesToSkip) {
+ visitor->dump(WTF::dataFile(), Indenter(2), [&] (PrintStream& out) {
+ out.print("[", (m_currentFrame - m_framesToSkip - 1), "] ");
+ });
+ }
if (m_action == PrintOne && m_currentFrame > m_framesToSkip)
return StackVisitor::Done;
return StackVisitor::Continue;
Modified: trunk/Source/WTF/ChangeLog (201640 => 201641)
--- 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)
@@ -1,3 +1,19 @@
+2016-06-03 Mark Lam <[email protected]>
+
+ 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--):
+
2016-06-02 Said Abou-Hallawa <sabouhallawa@apple,com>
[iOS] PDFDocumentImage should not create a cached image larger than 4M pixels
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (201640 => 201641)
--- 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)
@@ -319,6 +319,7 @@
E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; };
FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8225301B2A1E5B00BA68FD /* NakedPtr.h */; };
+ FE8925B01D00DAEC0046907E /* Indenter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8925AF1D00DAEC0046907E /* Indenter.h */; };
FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; };
FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */ = {isa = PBXBuildFile; fileRef = FEDACD3C1630F83F00C69634 /* StackStats.h */; };
/* End PBXBuildFile section */
@@ -650,6 +651,7 @@
E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; };
EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; };
FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; };
+ FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = "<group>"; };
FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; };
FEDACD3C1630F83F00C69634 /* StackStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackStats.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -855,6 +857,7 @@
A8A472B9151A825A004123FF /* HashTable.h */,
A8A472BA151A825A004123FF /* HashTraits.h */,
A8A472BB151A825A004123FF /* HexNumber.h */,
+ FE8925AF1D00DAEC0046907E /* Indenter.h */,
2684D4351C000D400081D663 /* IndexSparseSet.h */,
A8A472BC151A825A004123FF /* InlineASM.h */,
A70DA0821799F04D00529A9B /* Insertion.h */,
@@ -1360,6 +1363,7 @@
149EF16316BBFE0D000A4331 /* TriState.h in Headers */,
83FBA93219DF459700F30ADB /* TypeCasts.h in Headers */,
1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */,
+ FE8925B01D00DAEC0046907E /* Indenter.h in Headers */,
A8A4746D151A825B004123FF /* UnionFind.h in Headers */,
70ECA60F1B02426800449739 /* UniquedStringImpl.h in Headers */,
A8A4746A151A825B004123FF /* UTF8.h in Headers */,
Added: trunk/Source/WTF/wtf/Indenter.h (0 => 201641)
--- trunk/Source/WTF/wtf/Indenter.h (rev 0)
+++ trunk/Source/WTF/wtf/Indenter.h 2016-06-03 14:53:16 UTC (rev 201641)
@@ -0,0 +1,67 @@
+/*
+ * 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 <wtf/FilePrintStream.h>
+#include <wtf/text/WTFString.h>
+
+namespace WTF {
+
+class Indenter {
+public:
+ Indenter(unsigned count = 0, String string = ASCIILiteral(" "))
+ : m_count(count)
+ , m_string(string)
+ { }
+
+ Indenter(const Indenter& other)
+ : m_count(other.m_count)
+ , m_string(other.m_string)
+ { }
+
+ void dump(PrintStream& 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
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
