Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (256909 => 256910)
--- trunk/Source/_javascript_Core/ChangeLog 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-02-19 05:37:45 UTC (rev 256910)
@@ -1,3 +1,16 @@
+2020-02-18 Keith Miller <[email protected]>
+
+ Add an os_log PrintStream
+ https://bugs.webkit.org/show_bug.cgi?id=207898
+
+ Reviewed by Mark Lam.
+
+ Add jsc option to write dataLogs to os_log.
+
+ * runtime/Options.cpp:
+ (JSC::Options::initialize):
+ * runtime/OptionsList.h:
+
2020-02-18 Paulo Matos <[email protected]>
Fix order (in MIPS) under which CS-registers are saved/restored
Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (256909 => 256910)
--- trunk/Source/_javascript_Core/runtime/Options.cpp 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp 2020-02-19 05:37:45 UTC (rev 256910)
@@ -42,6 +42,7 @@
#include <wtf/DataLog.h>
#include <wtf/NumberOfCores.h>
#include <wtf/Optional.h>
+#include <wtf/OSLogPrintStream.h>
#include <wtf/PointerPreparations.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringBuilder.h>
@@ -613,6 +614,14 @@
handleSignalsWithMach();
#endif
+#if OS(DARWIN)
+ if (Options::useOSLog()) {
+ WTF::setDataFile(OSLogPrintStream::open("com.apple._javascript_Core", "DataLog", OS_LOG_TYPE_INFO));
+ // Make sure no one jumped here for nefarious reasons...
+ RELEASE_ASSERT(useOSLog());
+ }
+#endif
+
#if ASAN_ENABLED && OS(LINUX) && ENABLE(WEBASSEMBLY_FAST_MEMORY)
if (Options::useWebAssemblyFastMemory()) {
const char* asanOptions = getenv("ASAN_OPTIONS");
Modified: trunk/Source/_javascript_Core/runtime/OptionsList.h (256909 => 256910)
--- trunk/Source/_javascript_Core/runtime/OptionsList.h 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/_javascript_Core/runtime/OptionsList.h 2020-02-19 05:37:45 UTC (rev 256910)
@@ -119,6 +119,7 @@
v(Unsigned, shadowChickenLogSize, 1000, Normal, nullptr) \
v(Unsigned, shadowChickenMaxTailDeletedFramesSize, 128, Normal, nullptr) \
\
+ v(Bool, useOSLog, false, Normal, "Log dataLog()s to os_log instead of stderr") \
/* dumpDisassembly implies dumpDFGDisassembly. */ \
v(Bool, dumpDisassembly, false, Normal, "dumps disassembly of all JIT compiled code upon compilation") \
v(Bool, asyncDisassembly, false, Normal, nullptr) \
Modified: trunk/Source/WTF/ChangeLog (256909 => 256910)
--- trunk/Source/WTF/ChangeLog 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/ChangeLog 2020-02-19 05:37:45 UTC (rev 256910)
@@ -1,3 +1,37 @@
+2020-02-18 Keith Miller <[email protected]>
+
+ Add an os_log PrintStream
+ https://bugs.webkit.org/show_bug.cgi?id=207898
+
+ Reviewed by Mark Lam.
+
+ When debugging on iOS writing to a file can be hard (thanks
+ Sandboxing!) so logging our dataLogs to os_log would make things
+ easier. This patch adds a new subclass of PrintStream,
+ OSLogPrintStream, that converts our file writes to
+ os_log. Unfortunately, os_log doesn't buffer writes so
+ OSLogPrintStream needs to do its own buffering. e.g. if you call
+ `dataLogLn("some text with a ", number, " and a ", string);`
+ os_log will log that as 5 separate logs.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/DataLog.cpp:
+ (WTF::setDataFile):
+ * wtf/DataLog.h:
+ * wtf/OSLogPrintStream.cpp: Added.
+ (WTF::OSLogPrintStream::OSLogPrintStream):
+ (WTF::OSLogPrintStream::~OSLogPrintStream):
+ (WTF::OSLogPrintStream::open):
+ (WTF::OSLogPrintStream::vprintf):
+ * wtf/OSLogPrintStream.h: Copied from Source/WTF/wtf/DataLog.h.
+ * wtf/PrintStream.cpp:
+ (WTF::printExpectedCStringHelper):
+ (WTF::printInternal):
+ * wtf/text/CString.cpp:
+ (WTF::CString::grow):
+ * wtf/text/CString.h:
+
2020-02-18 Simon Fraser <[email protected]>
Move from "layer flush" terminology to "rendering update"
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (256909 => 256910)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2020-02-19 05:37:45 UTC (rev 256910)
@@ -78,6 +78,7 @@
5311BD531EA71CAD00525281 /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5311BD511EA71CAD00525281 /* Signals.cpp */; };
5311BD5C1EA822F900525281 /* ThreadMessage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5311BD5B1EA822F900525281 /* ThreadMessage.cpp */; };
53534F2A1EC0E10E00141B2F /* MachExceptions.defs in Sources */ = {isa = PBXBuildFile; fileRef = 53534F291EC0E10E00141B2F /* MachExceptions.defs */; settings = {ATTRIBUTES = (Client, Server, ); }; };
+ 53FC70D023FB950C005B1990 /* OSLogPrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FC70CF23FB950C005B1990 /* OSLogPrintStream.cpp */; };
5C1F05932164356B0039302C /* CFURLExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C1F05912164356B0039302C /* CFURLExtras.cpp */; };
5C1F0595216437B30039302C /* URLCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C1F0594216437B30039302C /* URLCF.cpp */; };
5CC0EE7521629F1900A1A842 /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC0EE7321629F1900A1A842 /* URLParser.cpp */; };
@@ -399,6 +400,8 @@
53EC253C1E95AD30000831B9 /* PriorityQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PriorityQueue.h; sourceTree = "<group>"; };
53F08A1BA39D49A8BAD369A1 /* StdSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdSet.h; sourceTree = "<group>"; };
53F1D98620477B9800EBC6BF /* FunctionTraits.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = FunctionTraits.h; sourceTree = "<group>"; };
+ 53FC70CE23FB950C005B1990 /* OSLogPrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSLogPrintStream.h; sourceTree = "<group>"; };
+ 53FC70CF23FB950C005B1990 /* OSLogPrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSLogPrintStream.cpp; sourceTree = "<group>"; };
553071C91C40427200384898 /* TinyLRUCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyLRUCache.h; sourceTree = "<group>"; };
5597F82C1D94B9970066BC21 /* SynchronizedFixedQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SynchronizedFixedQueue.h; sourceTree = "<group>"; };
5B43383A5D0B463C9433D933 /* IndexMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexMap.h; sourceTree = "<group>"; };
@@ -1112,6 +1115,8 @@
275DFB6B238BDF72001230E2 /* OptionSetHash.h */,
0F9495831C571CC900413A48 /* OrderMaker.h */,
A8A472D7151A825B004123FF /* OSAllocator.h */,
+ 53FC70CF23FB950C005B1990 /* OSLogPrintStream.cpp */,
+ 53FC70CE23FB950C005B1990 /* OSLogPrintStream.h */,
7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */,
A8A472DA151A825B004123FF /* OSRandomSource.cpp */,
A8A472DB151A825B004123FF /* OSRandomSource.h */,
@@ -1664,6 +1669,7 @@
A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */,
8348BA0E21FBC0D500FD3054 /* ObjectIdentifier.cpp in Sources */,
A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */,
+ 53FC70D023FB950C005B1990 /* OSLogPrintStream.cpp in Sources */,
A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */,
A8A47402151A825B004123FF /* PageBlock.cpp in Sources */,
0FFF19DC1BB334EB00886D91 /* ParallelHelperPool.cpp in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (256909 => 256910)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2020-02-19 05:37:45 UTC (rev 256910)
@@ -148,6 +148,7 @@
NotFound.h
NumberOfCores.h
OSAllocator.h
+ OSLogPrintStream.h
OSObjectPtr.h
OSRandomSource.h
ObjCRuntimeExtras.h
@@ -400,6 +401,7 @@
MetaAllocator.cpp
MonotonicTime.cpp
NumberOfCores.cpp
+ OSLogPrintStream.cpp
OSRandomSource.cpp
ObjectIdentifier.cpp
PageBlock.cpp
Modified: trunk/Source/WTF/wtf/DataLog.cpp (256909 => 256910)
--- trunk/Source/WTF/wtf/DataLog.cpp 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/DataLog.cpp 2020-02-19 05:37:45 UTC (rev 256910)
@@ -166,6 +166,11 @@
s_file = new (s_lockedFileData) LockedPrintStream(std::unique_ptr<FilePrintStream>(file));
}
+void setDataFile(std::unique_ptr<PrintStream>&& file)
+{
+ s_file = file.release();
+}
+
PrintStream& dataFile()
{
initializeLogFile();
Modified: trunk/Source/WTF/wtf/DataLog.h (256909 => 256910)
--- trunk/Source/WTF/wtf/DataLog.h 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/DataLog.h 2020-02-19 05:37:45 UTC (rev 256910)
@@ -34,6 +34,7 @@
WTF_EXPORT_PRIVATE PrintStream& dataFile();
WTF_EXPORT_PRIVATE void setDataFile(const char* path);
+WTF_EXPORT_PRIVATE void setDataFile(std::unique_ptr<PrintStream>&&);
WTF_EXPORT_PRIVATE void dataLogFV(const char* format, va_list) WTF_ATTRIBUTE_PRINTF(1, 0);
WTF_EXPORT_PRIVATE void dataLogF(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
Added: trunk/Source/WTF/wtf/OSLogPrintStream.cpp (0 => 256910)
--- trunk/Source/WTF/wtf/OSLogPrintStream.cpp (rev 0)
+++ trunk/Source/WTF/wtf/OSLogPrintStream.cpp 2020-02-19 05:37:45 UTC (rev 256910)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include "config.h"
+#include <wtf/OSLogPrintStream.h>
+
+#include <wtf/StringPrintStream.h>
+
+namespace WTF {
+
+#if OS(DARWIN)
+
+OSLogPrintStream::OSLogPrintStream(os_log_t log, os_log_type_t logType)
+ : m_log(log)
+ , m_logType(logType)
+ , m_string("initial string... lol")
+{
+}
+
+OSLogPrintStream::~OSLogPrintStream()
+{ }
+
+std::unique_ptr<OSLogPrintStream> OSLogPrintStream::open(const char* subsystem, const char* category, os_log_type_t logType)
+{
+ os_log_t log = os_log_create(subsystem, category);
+ return makeUnique<OSLogPrintStream>(log, logType);
+}
+
+void OSLogPrintStream::vprintf(const char* format, va_list argList)
+{
+ auto lock = holdLock(m_stringLock);
+ size_t offset = m_offset;
+ size_t freeBytes = m_string.length() - offset;
+ va_list backup;
+ va_copy(backup, argList);
+ size_t bytesWritten = vsnprintf(m_string.mutableData() + offset, freeBytes, format, argList);
+ if (UNLIKELY(bytesWritten >= freeBytes)) {
+ size_t newLength = std::max(bytesWritten + m_string.length(), m_string.length() * 2);
+ m_string.grow(newLength);
+ freeBytes = newLength - offset;
+ bytesWritten = vsnprintf(m_string.mutableData() + offset, freeBytes, format, backup);
+ ASSERT(bytesWritten < freeBytes);
+ }
+
+ size_t newOffset = offset + bytesWritten;
+ char* buffer = m_string.mutableData();
+ bool loggedText = false;
+ do {
+ if (buffer[offset] == '\n') {
+ // Set the new line to a null character so os_log stops copying there.
+ buffer[offset] = '\0';
+ os_log_with_type(m_log, m_logType, "%{public}s", buffer);
+ buffer += offset + 1;
+ newOffset -= offset + 1;
+ offset = 0;
+ loggedText = true;
+ } else
+ offset++;
+ } while (offset < newOffset);
+
+ if (loggedText)
+ memmove(m_string.mutableData(), buffer, newOffset);
+ m_offset = newOffset;
+}
+
+#endif
+
+} // namespace WTF
+
Copied: trunk/Source/WTF/wtf/OSLogPrintStream.h (from rev 256909, trunk/Source/WTF/wtf/DataLog.h) (0 => 256910)
--- trunk/Source/WTF/wtf/OSLogPrintStream.h (rev 0)
+++ trunk/Source/WTF/wtf/OSLogPrintStream.h 2020-02-19 05:37:45 UTC (rev 256910)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#if OS(DARWIN)
+
+#include <wtf/Lock.h>
+#include <wtf/PrintStream.h>
+#include <wtf/RecursiveLockAdapter.h>
+#include <wtf/text/CString.h>
+#include <wtf/Vector.h>
+
+#include <os/log.h>
+
+namespace WTF {
+
+class WTF_EXPORT_PRIVATE OSLogPrintStream final : public PrintStream {
+public:
+ OSLogPrintStream(os_log_t, os_log_type_t);
+ virtual ~OSLogPrintStream();
+
+ static std::unique_ptr<OSLogPrintStream> open(const char* subsystem, const char* category, os_log_type_t = OS_LOG_TYPE_DEFAULT);
+
+ void vprintf(const char* format, va_list) override WTF_ATTRIBUTE_PRINTF(2, 0);
+
+private:
+ os_log_t m_log;
+ os_log_type_t m_logType;
+ Lock m_stringLock;
+ // We need a buffer because os_log doesn't wait for a new line to print the characters.
+ CString m_string;
+ size_t m_offset { 0 };
+};
+
+} // namespace WTF
+
+using WTF::OSLogPrintStream;
+
+#endif
Modified: trunk/Source/WTF/wtf/PrintStream.cpp (256909 => 256910)
--- trunk/Source/WTF/wtf/PrintStream.cpp 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/PrintStream.cpp 2020-02-19 05:37:45 UTC (rev 256910)
@@ -77,13 +77,18 @@
static void printExpectedCStringHelper(PrintStream& out, const char* type, Expected<CString, UTF8ConversionError> expectedCString)
{
if (UNLIKELY(!expectedCString)) {
- if (expectedCString.error() == UTF8ConversionError::OutOfMemory)
- out.print("(Out of memory while converting ", type, " to utf8)");
- else
- out.print("(failed to convert ", type, " to utf8)");
+ if (expectedCString.error() == UTF8ConversionError::OutOfMemory) {
+ printInternal(out, "(Out of memory while converting ");
+ printInternal(out, type);
+ printInternal(out, " to utf8)");
+ } else {
+ printInternal(out, "(failed to convert ");
+ printInternal(out, type);
+ printInternal(out, " to utf8)");
+ }
return;
}
- out.print(expectedCString.value());
+ printInternal(out, expectedCString.value());
}
void printInternal(PrintStream& out, const StringView& string)
@@ -93,7 +98,7 @@
void printInternal(PrintStream& out, const CString& string)
{
- out.print(string.data());
+ printInternal(out, string.data());
}
void printInternal(PrintStream& out, const String& string)
@@ -104,7 +109,7 @@
void printInternal(PrintStream& out, const StringImpl* string)
{
if (!string) {
- out.print("(null StringImpl*)");
+ printInternal(out, "(null StringImpl*)");
return;
}
printExpectedCStringHelper(out, "StringImpl*", string->tryGetUtf8());
@@ -167,7 +172,7 @@
void printInternal(PrintStream& out, float value)
{
- out.print(static_cast<double>(value));
+ printInternal(out, static_cast<double>(value));
}
void printInternal(PrintStream& out, double value)
Modified: trunk/Source/WTF/wtf/text/CString.cpp (256909 => 256910)
--- trunk/Source/WTF/wtf/text/CString.cpp 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/text/CString.cpp 2020-02-19 05:37:45 UTC (rev 256910)
@@ -106,6 +106,15 @@
return !m_buffer || m_buffer->hasOneRef();
}
+void CString::grow(size_t newLength)
+{
+ ASSERT(newLength > length());
+
+ auto newBuffer = CStringBuffer::createUninitialized(newLength);
+ memcpy(newBuffer->mutableData(), m_buffer->data(), length() + 1);
+ m_buffer = WTFMove(newBuffer);
+}
+
bool operator==(const CString& a, const CString& b)
{
if (a.isNull() != b.isNull())
Modified: trunk/Source/WTF/wtf/text/CString.h (256909 => 256910)
--- trunk/Source/WTF/wtf/text/CString.h 2020-02-19 05:20:53 UTC (rev 256909)
+++ trunk/Source/WTF/wtf/text/CString.h 2020-02-19 05:37:45 UTC (rev 256910)
@@ -84,6 +84,9 @@
WTF_EXPORT_PRIVATE unsigned hash() const;
+ // Useful if you want your CString to hold dynamic data.
+ WTF_EXPORT_PRIVATE void grow(size_t newLength);
+
private:
void copyBufferIfNeeded();
void init(const char*, size_t length);