haikuwebkit/Source/WTF/wtf/Logger.cpp

60 lines
2.1 KiB
C++
Raw Permalink Normal View History

Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
/*
* Copyright (C) 2019 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 "Logger.h"
Use std::call_once + LazyNeverDestroyed to initialize complex data structures https://bugs.webkit.org/show_bug.cgi?id=215535 <rdar://problem/66774266> Reviewed by Mark Lam. NeverDestroyed<> is not thread-safe in Darwin build since it is not using C++11 thread-safe static variable semantics. This patch uses LazyNeverDestroyed and call_once to initialize complex data structures so that we can ensure they are initialized atomically. We also move some of `singleton` definitions from headers to cpp files. This is important since this ensures that singleton is only one instance which is generated in one translation unit. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/FastMalloc.cpp: (WTF::MallocCallTracker::singleton): * wtf/Language.cpp: (WTF::observerMap): (WTF::preferredLanguagesOverride): * wtf/Logger.cpp: (WTF::Logger::observers): * wtf/Logger.h: (WTF::Logger::observerLock): (WTF::Logger::observers): Deleted. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::singleton): * wtf/MemoryPressureHandler.h: * wtf/RunLoop.cpp: (WTF::RunLoop::current): * wtf/Threading.cpp: (WTF::Thread::initializeInThread): * wtf/URL.cpp: (WTF::aboutBlankURL): (WTF::aboutSrcDocURL): * wtf/cf/LanguageCF.cpp: (WTF::preferredLanguages): * wtf/cocoa/NSURLExtras.mm: (WTF::rangeOfURLScheme): * wtf/text/LineBreakIteratorPoolICU.cpp: Copied from Source/WTF/wtf/Logger.cpp. (WTF::LineBreakIteratorPool::sharedPool): * wtf/text/LineBreakIteratorPoolICU.h: (WTF::LineBreakIteratorPool::sharedPool): Deleted. * wtf/text/StringView.cpp: * wtf/text/TextBreakIterator.cpp: (WTF::TextBreakIteratorCache::singleton): * wtf/text/TextBreakIterator.h: (WTF::TextBreakIteratorCache::singleton): Deleted. * wtf/threads/Signals.cpp: (WTF::activeThreads): Canonical link: https://commits.webkit.org/228310@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 18:40:50 +00:00
#include <mutex>
Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
#include <wtf/HexNumber.h>
Add AggregateLogger, a Logger specialization for singleton classes. https://bugs.webkit.org/show_bug.cgi?id=195644 Reviewed by Eric Carlson. Source/WebCore: Convert debug logging over to release logging through the use of AggregateLogger. * platform/audio/PlatformMediaSession.h: (WebCore::PlatformMediaSession::client const): * platform/audio/PlatformMediaSessionManager.cpp: (WebCore::PlatformMediaSessionManager::PlatformMediaSessionManager): (WebCore::PlatformMediaSessionManager::beginInterruption): (WebCore::PlatformMediaSessionManager::endInterruption): (WebCore::PlatformMediaSessionManager::addSession): (WebCore::PlatformMediaSessionManager::removeSession): (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback): (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback): (WebCore::PlatformMediaSessionManager::setCurrentSession): (WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive const): (WebCore::PlatformMediaSessionManager::applicationDidBecomeActive const): (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground const): (WebCore::PlatformMediaSessionManager::applicationWillEnterForeground const): (WebCore::PlatformMediaSessionManager::logChannel const): * platform/audio/PlatformMediaSessionManager.h: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: (MediaSessionManagerCocoa::updateSessionState): (MediaSessionManagerCocoa::sessionWillBeginPlayback): (MediaSessionManagerCocoa::removeSession): (MediaSessionManagerCocoa::sessionWillEndPlayback): (MediaSessionManagerCocoa::clientCharacteristicsChanged): (MediaSessionManagerCocoa::updateNowPlayingInfo): * platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::resetRestrictions): (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Source/WTF: Add a new class, AggregateLogger, which will log messages to each of its aggregated loggers. Drive-by fixes: allow "const void*" to be directly logged by converting the pointer to a hex string. * WTF.xcodeproj/project.pbxproj: * wtf/AggregateLogger.h: Added. (WTF::AggregateLogger::create): (WTF::AggregateLogger::addLogger): (WTF::AggregateLogger::removeLogger): (WTF::AggregateLogger::logAlways const): (WTF::AggregateLogger::error const): (WTF::AggregateLogger::warning const): (WTF::AggregateLogger::info const): (WTF::AggregateLogger::debug const): (WTF::AggregateLogger::willLog const): (WTF::AggregateLogger::AggregateLogger): (WTF::AggregateLogger::log const): * wtf/CMakeLists.h: * wtf/Logger.cpp: (WTF::>::toString): * wtf/Logger.h: Canonical link: https://commits.webkit.org/209992@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242901 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-13 20:18:08 +00:00
#include <wtf/text/WTFString.h>
Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
namespace WTF {
Drop CheckedLock / CheckedCondition aliases https://bugs.webkit.org/show_bug.cgi?id=226176 Reviewed by Kate Cheney. Drop CheckedLock / CheckedCondition aliases now that they are the default. Source/JavaScriptCore: * API/JSVirtualMachine.mm: * API/glib/JSCVirtualMachine.cpp: * assembler/PerfLog.h: * assembler/testmasm.cpp: * bytecode/StructureStubInfo.h: * bytecode/SuperSampler.cpp: * dfg/DFGCommon.cpp: * dfg/DFGCommonData.cpp: * dfg/DFGPlan.h: * dfg/DFGThreadData.h: * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::Worklist): * dfg/DFGWorklist.h: * disassembler/Disassembler.cpp: * dynbench.cpp: * heap/BlockDirectory.cpp: (JSC::BlockDirectory::parallelNotEmptyBlockSource): * heap/BlockDirectory.h: (JSC::BlockDirectory::bitvectorLock): * heap/CodeBlockSet.h: (JSC::CodeBlockSet::getLock): * heap/Heap.cpp: (JSC::Heap::Heap): * heap/Heap.h: * heap/IsoSubspacePerVM.h: * heap/MarkedSpace.h: (JSC::MarkedSpace::directoryLock): * heap/MarkingConstraintSolver.h: * heap/SlotVisitor.cpp: (JSC::SlotVisitor::donateKnownParallel): * heap/SlotVisitor.h: * inspector/remote/socket/RemoteInspectorConnectionClient.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::getLock const): (JSC::dumpJITMemory): * jit/ExecutableAllocator.h: (JSC::ExecutableAllocatorBase::getLock const): * jit/JITWorklist.cpp: (JSC::JITWorklist::JITWorklist): * jit/JITWorklist.h: * jsc.cpp: * profiler/ProfilerDatabase.h: * runtime/ConcurrentJSLock.h: * runtime/DeferredWorkTimer.h: * runtime/JSLock.h: * runtime/SamplingProfiler.cpp: (JSC::FrameWalker::FrameWalker): (JSC::CFrameWalker::CFrameWalker): (JSC::SamplingProfiler::takeSample): * runtime/SamplingProfiler.h: (JSC::SamplingProfiler::getLock): * runtime/VM.h: * runtime/VMTraps.cpp: (JSC::VMTraps::invalidateCodeBlocksOnStack): (JSC::VMTraps::VMTraps): * runtime/VMTraps.h: * tools/FunctionOverrides.h: * tools/VMInspector.cpp: (JSC::ensureIsSafeToLock): * tools/VMInspector.h: (JSC::VMInspector::getLock): * wasm/WasmCalleeRegistry.h: (JSC::Wasm::CalleeRegistry::getLock): * wasm/WasmPlan.h: * wasm/WasmStreamingCompiler.h: * wasm/WasmThunks.h: * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::Worklist): * wasm/WasmWorklist.h: Source/WebCore: * Modules/indexeddb/IDBObjectStore.h: * Modules/indexeddb/IDBTransaction.h: * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBSerializationContext.cpp: * Modules/indexeddb/server/IDBServer.cpp: * Modules/mediastream/RTCDataChannel.cpp: * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransform.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.h: * Modules/speech/SpeechRecognitionCaptureSourceImpl.h: * Modules/webaudio/AudioParamTimeline.h: * Modules/webaudio/MediaElementAudioSourceNode.h: * Modules/webdatabase/Database.cpp: * Modules/webdatabase/Database.h: * Modules/webdatabase/DatabaseManager.h: * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.h: * Modules/webdatabase/DatabaseTracker.cpp: (WebCore::DatabaseTracker::openDatabaseMutex): * Modules/webdatabase/DatabaseTracker.h: * Modules/webdatabase/OriginLock.cpp: * Modules/webdatabase/SQLCallbackWrapper.h: * Modules/webdatabase/SQLTransaction.h: * Modules/webgpu/WebGPUDevice.cpp: (WebCore::WebGPUDevice::instancesLock): * Modules/webgpu/WebGPUDevice.h: * Modules/webgpu/WebGPUPipeline.cpp: (WebCore::WebGPUPipeline::instancesLock): * Modules/webgpu/WebGPUPipeline.h: * Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::allActiveWebSocketsLock): * Modules/websockets/WebSocket.h: * accessibility/isolatedtree/AXIsolatedTree.cpp: * accessibility/isolatedtree/AXIsolatedTree.h: * bindings/js/JSDOMGlobalObject.h: * bridge/objc/WebScriptObject.mm: * crypto/CryptoAlgorithmRegistry.h: * dom/MessagePort.cpp: * dom/Node.cpp: * dom/ScriptExecutionContext.cpp: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::createMediaPlayer): * html/canvas/CanvasRenderingContext.cpp: (WebCore::CanvasRenderingContext::instancesLock): * html/canvas/CanvasRenderingContext.h: * html/canvas/WebGLContextGroup.cpp: (WebCore::WebGLContextGroup::objectGraphLockForAContext): * html/canvas/WebGLContextGroup.h: * html/canvas/WebGLContextObject.cpp: (WebCore::WebGLContextObject::objectGraphLockForContext): * html/canvas/WebGLContextObject.h: * html/canvas/WebGLObject.h: * html/canvas/WebGLProgram.cpp: (WebCore::WebGLProgram::instancesLock): * html/canvas/WebGLProgram.h: * html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::objectGraphLock): * html/canvas/WebGLRenderingContextBase.h: * html/canvas/WebGLSharedObject.cpp: (WebCore::WebGLSharedObject::objectGraphLockForContext): * html/canvas/WebGLSharedObject.h: * inspector/agents/WebHeapAgent.cpp: * page/ResourceUsageThread.h: * page/SecurityPolicy.cpp: * page/WheelEventTestMonitor.h: * page/scrolling/ScrollingTree.h: (WebCore::ScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/ScrollingTreeLatchingController.h: * page/scrolling/ThreadedScrollingTree.h: (WebCore::ThreadedScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/mac/ScrollingTreeMac.h: * platform/AbortableTaskQueue.h: * platform/GenericTaskQueue.cpp: * platform/GenericTaskQueue.h: * platform/LegacySchemeRegistry.cpp: * platform/audio/AudioDestination.h: * platform/audio/HRTFDatabaseLoader.h: * platform/audio/ReverbConvolver.cpp: (WebCore::ReverbConvolver::backgroundThreadEntry): * platform/audio/cocoa/AudioDestinationCocoa.h: * platform/audio/gstreamer/AudioSourceProviderGStreamer.h: * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp: * platform/audio/mac/FFTFrameMac.cpp: * platform/encryptedmedia/CDMProxy.h: * platform/graphics/MediaPlayer.cpp: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::lock): (WebCore::ShadowBlur::drawRectShadowWithTiling): (WebCore::ShadowBlur::drawInsetShadowWithTiling): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: * platform/graphics/cg/IOSurfacePool.h: * platform/graphics/cg/SubimageCacheWithTimer.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/ImageDecoderGStreamer.h: * platform/graphics/gstreamer/MainThreadNotifier.h: * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: * platform/graphics/gstreamer/VideoSinkGStreamer.cpp: * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp: * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: (WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK): * platform/image-decoders/ScalableImageDecoder.h: * platform/ios/QuickLook.mm: * platform/ios/WebSQLiteDatabaseTrackerClient.mm: * platform/ios/wak/WebCoreThreadRun.cpp: * platform/mediarecorder/MediaRecorderPrivateMock.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediastream/RealtimeMediaSource.h: * platform/mediastream/RealtimeOutgoingAudioSource.h: * platform/mediastream/RealtimeOutgoingVideoSource.h: * platform/mediastream/cocoa/AudioMediaStreamTrackRendererUnit.h: * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h: * platform/network/cf/LoaderRunLoopCF.cpp: (WebCore::loaderRunLoop): * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/network/mac/UTIUtilities.mm: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteDatabaseTracker.cpp: * platform/text/TextEncodingRegistry.cpp: * storage/StorageQuotaManager.h: * workers/WorkerGlobalScope.cpp: * workers/WorkerOrWorkletScriptController.h: * workers/WorkerOrWorkletThread.cpp: (WebCore::WorkerOrWorkletThread::workerOrWorkletThreadsLock): * workers/WorkerOrWorkletThread.h: * worklets/PaintWorkletGlobalScope.h: Source/WebKit: * GPUProcess/graphics/RemoteGraphicsContextGL.cpp: (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer): * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h: * NetworkProcess/IndexedDB/WebIDBServer.cpp: * NetworkProcess/NetworkProcess.h: * NetworkProcess/WebStorage/StorageManagerSet.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: * NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h: * NetworkProcess/glib/DNSCache.h: * Platform/IPC/Connection.cpp: * Platform/IPC/Connection.h: * Platform/IPC/StreamConnectionWorkQueue.h: * Platform/IPC/StreamServerConnection.h: * Shared/BlockingResponseMap.h: * Shared/Cocoa/XPCEndpointClient.h: * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h: * Shared/mac/MediaFormatReader/MediaFormatReader.h: * Shared/mac/MediaFormatReader/MediaSampleCursor.h: * Shared/mac/MediaFormatReader/MediaTrackReader.h: * UIProcess/API/glib/IconDatabase.h: * UIProcess/WebURLSchemeTask.h: * UIProcess/mac/DisplayLink.h: * UIProcess/mac/WKPrintingView.mm: (-[WKPrintingView knowsPageRange:]): * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: * WebProcess/GPU/webrtc/LibWebRTCCodecs.h: * WebProcess/Network/WebSocketStream.cpp: * WebProcess/Plugins/PluginProcessConnectionManager.h: * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebPage/ViewUpdateDispatcher.h: Source/WebKitLegacy: * Storage/StorageAreaSync.h: Source/WebKitLegacy/mac: * DOM/DOMInternal.mm: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: (WTF::AutomaticThreadCondition::wait): (WTF::AutomaticThreadCondition::waitFor): (WTF::AutomaticThread::AutomaticThread): * wtf/AutomaticThread.h: * wtf/CMakeLists.txt: * wtf/CheckedCondition.h: Removed. * wtf/CheckedLock.h: Removed. * wtf/Condition.h: * wtf/CrossThreadQueue.h: * wtf/CrossThreadTaskHandler.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/FastMalloc.cpp: * wtf/Forward.h: * wtf/Language.cpp: * wtf/Lock.cpp: (WTF::UncheckedLock::lockSlow): (WTF::UncheckedLock::unlockSlow): (WTF::UncheckedLock::unlockFairlySlow): (WTF::UncheckedLock::safepointSlow): * wtf/Lock.h: (WTF::WTF_ASSERTS_ACQUIRED_LOCK): * wtf/Logger.cpp: * wtf/Logger.h: (WTF::Logger::WTF_RETURNS_LOCK): * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocator::MetaAllocator): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/MetaAllocator.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: (WTF::ParallelHelperPool::ParallelHelperPool): * wtf/ParallelHelperPool.h: * wtf/ParallelJobsGeneric.h: * wtf/ParallelVectorIterator.h: * wtf/ReadWriteLock.h: * wtf/RecursiveLockAdapter.h: * wtf/RunLoop.h: * wtf/SynchronizedFixedQueue.h: * wtf/Threading.cpp: (WTF::Thread::allThreadsLock): * wtf/Threading.h: * wtf/TimingScope.cpp: * wtf/URL.cpp: * wtf/WTFSemaphore.h: * wtf/WorkQueue.cpp: (WTF::WorkQueue::concurrentApply): * wtf/WorkerPool.cpp: (WTF::WorkerPool::WorkerPool): * wtf/WorkerPool.h: * wtf/cf/LanguageCF.cpp: * wtf/text/AtomStringImpl.cpp: (WTF::AtomStringTableLocker::AtomStringTableLocker): * wtf/text/StringView.cpp: * wtf/threads/BinarySemaphore.h: * wtf/unicode/icu/CollatorICU.cpp: Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/CheckedConditionTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/CheckedLockTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/Condition.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp: (WTR::AXThread::createThreadIfNeeded): Canonical link: https://commits.webkit.org/238085@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 18:29:01 +00:00
Lock loggerObserverLock;
Use std::call_once + LazyNeverDestroyed to initialize complex data structures https://bugs.webkit.org/show_bug.cgi?id=215535 <rdar://problem/66774266> Reviewed by Mark Lam. NeverDestroyed<> is not thread-safe in Darwin build since it is not using C++11 thread-safe static variable semantics. This patch uses LazyNeverDestroyed and call_once to initialize complex data structures so that we can ensure they are initialized atomically. We also move some of `singleton` definitions from headers to cpp files. This is important since this ensures that singleton is only one instance which is generated in one translation unit. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/FastMalloc.cpp: (WTF::MallocCallTracker::singleton): * wtf/Language.cpp: (WTF::observerMap): (WTF::preferredLanguagesOverride): * wtf/Logger.cpp: (WTF::Logger::observers): * wtf/Logger.h: (WTF::Logger::observerLock): (WTF::Logger::observers): Deleted. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::singleton): * wtf/MemoryPressureHandler.h: * wtf/RunLoop.cpp: (WTF::RunLoop::current): * wtf/Threading.cpp: (WTF::Thread::initializeInThread): * wtf/URL.cpp: (WTF::aboutBlankURL): (WTF::aboutSrcDocURL): * wtf/cf/LanguageCF.cpp: (WTF::preferredLanguages): * wtf/cocoa/NSURLExtras.mm: (WTF::rangeOfURLScheme): * wtf/text/LineBreakIteratorPoolICU.cpp: Copied from Source/WTF/wtf/Logger.cpp. (WTF::LineBreakIteratorPool::sharedPool): * wtf/text/LineBreakIteratorPoolICU.h: (WTF::LineBreakIteratorPool::sharedPool): Deleted. * wtf/text/StringView.cpp: * wtf/text/TextBreakIterator.cpp: (WTF::TextBreakIteratorCache::singleton): * wtf/text/TextBreakIterator.h: (WTF::TextBreakIteratorCache::singleton): Deleted. * wtf/threads/Signals.cpp: (WTF::activeThreads): Canonical link: https://commits.webkit.org/228310@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 18:40:50 +00:00
Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
String Logger::LogSiteIdentifier::toString() const
{
Further simplify StringBuilder usage by standardizing hex formating to a single hex() function https://bugs.webkit.org/show_bug.cgi?id=205759 Reviewed by Dean Jackson. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): * runtime/JSGlobalObjectFunctions.cpp: (JSC::encode): (JSC::globalFuncEscape): Replace appendUnsignedAsHex() and appendByteAsHex() with append(hex()). Source/WebCore: * Modules/websockets/WebSocket.cpp: (WebCore::encodeProtocolString): * css/CSSMarkup.cpp: (WebCore::serializeCharacterAsCodePoint): * css/parser/CSSParserToken.cpp: (WebCore::CSSParserToken::serialize const): * platform/graphics/Color.cpp: (WebCore::Color::serialized const): * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection): * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: (WebCore::generateHashedName): * platform/network/curl/CurlCacheEntry.cpp: (WebCore::CurlCacheEntry::generateBaseFilename): * rendering/RenderTreeAsText.cpp: (WebCore::quoteAndEscapeNonPrintables): Replace appendByteAsHex()/appendUnsignedAsHex()/appendUnsignedAsHexFixedSize() with append(hex()). * platform/network/FormDataBuilder.cpp: (WebCore::FormDataBuilder::appendFormURLEncoded): This was the last non-StringBuilder/makeString use of appendByteAsHex. Rather than keep appendByteAsHex around, it is replaced with direct appends of the character buffer hex() produces. Source/WebKit: * UIProcess/DeviceIdHashSaltStorage.cpp: (WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Replace appendUnsignedAsHex() with append(hex()). Source/WTF: Removes appendByteAsHex, appendUnsignedAsHex and appendUnsignedAsHexFixedSize with the following mappings: appendByteAsHex(value, builder, case) -> builder.append(hex(static_cast<unsigned char>(value), 2, case)) appendUnsignedAsHex(value, builder, case) -> builder.append(hex(value, case)) appendUnsignedAsHexFixedSize(value, builder, size, case) -> builder.append(hex(value, size, case)) Adds new API test for HexNumber.cpp * wtf/HexNumber.h: (WTF::appendByteAsHex): Deleted. (WTF::appendUnsignedAsHex): Deleted. (WTF::appendUnsignedAsHexFixedSize): Deleted. Remove now unused helper functions. * wtf/FileSystem.cpp: (WTF::FileSystemImpl::encodeForFileName): Replace appendByteAsHex with direct use of hex(x, 2). The static_cast is needed since there was an implicit down cast when appendByteAsHex was used. * wtf/Logger.cpp: (WTF::Logger::LogSiteIdentifier::toString const): (WTF::>::toString): * wtf/UUID.cpp: (WTF::createCanonicalUUIDString): Replace appendUnsignedAsHex/appendUnsignedAsHexFixedSize with hex(). Use makeString() rather StringBuilder to simplify things further. * wtf/text/WTFString.cpp: (asciiDebug): Replace appendUnsignedAsHexFixedSize with append(hex()). Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/HexNumber.cpp: Added. Add testing for hex formatting of integers. Canonical link: https://commits.webkit.org/218921@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 00:20:57 +00:00
if (className)
return makeString(className, "::", methodName, '(', hex(objectPtr), ") ");
return makeString(methodName, '(', hex(objectPtr), ") ");
Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
}
Add AggregateLogger, a Logger specialization for singleton classes. https://bugs.webkit.org/show_bug.cgi?id=195644 Reviewed by Eric Carlson. Source/WebCore: Convert debug logging over to release logging through the use of AggregateLogger. * platform/audio/PlatformMediaSession.h: (WebCore::PlatformMediaSession::client const): * platform/audio/PlatformMediaSessionManager.cpp: (WebCore::PlatformMediaSessionManager::PlatformMediaSessionManager): (WebCore::PlatformMediaSessionManager::beginInterruption): (WebCore::PlatformMediaSessionManager::endInterruption): (WebCore::PlatformMediaSessionManager::addSession): (WebCore::PlatformMediaSessionManager::removeSession): (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback): (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback): (WebCore::PlatformMediaSessionManager::setCurrentSession): (WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive const): (WebCore::PlatformMediaSessionManager::applicationDidBecomeActive const): (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground const): (WebCore::PlatformMediaSessionManager::applicationWillEnterForeground const): (WebCore::PlatformMediaSessionManager::logChannel const): * platform/audio/PlatformMediaSessionManager.h: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: (MediaSessionManagerCocoa::updateSessionState): (MediaSessionManagerCocoa::sessionWillBeginPlayback): (MediaSessionManagerCocoa::removeSession): (MediaSessionManagerCocoa::sessionWillEndPlayback): (MediaSessionManagerCocoa::clientCharacteristicsChanged): (MediaSessionManagerCocoa::updateNowPlayingInfo): * platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::resetRestrictions): (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Source/WTF: Add a new class, AggregateLogger, which will log messages to each of its aggregated loggers. Drive-by fixes: allow "const void*" to be directly logged by converting the pointer to a hex string. * WTF.xcodeproj/project.pbxproj: * wtf/AggregateLogger.h: Added. (WTF::AggregateLogger::create): (WTF::AggregateLogger::addLogger): (WTF::AggregateLogger::removeLogger): (WTF::AggregateLogger::logAlways const): (WTF::AggregateLogger::error const): (WTF::AggregateLogger::warning const): (WTF::AggregateLogger::info const): (WTF::AggregateLogger::debug const): (WTF::AggregateLogger::willLog const): (WTF::AggregateLogger::AggregateLogger): (WTF::AggregateLogger::log const): * wtf/CMakeLists.h: * wtf/Logger.cpp: (WTF::>::toString): * wtf/Logger.h: Canonical link: https://commits.webkit.org/209992@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242901 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-13 20:18:08 +00:00
String LogArgument<const void*>::toString(const void* argument)
{
Further simplify StringBuilder usage by standardizing hex formating to a single hex() function https://bugs.webkit.org/show_bug.cgi?id=205759 Reviewed by Dean Jackson. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): * runtime/JSGlobalObjectFunctions.cpp: (JSC::encode): (JSC::globalFuncEscape): Replace appendUnsignedAsHex() and appendByteAsHex() with append(hex()). Source/WebCore: * Modules/websockets/WebSocket.cpp: (WebCore::encodeProtocolString): * css/CSSMarkup.cpp: (WebCore::serializeCharacterAsCodePoint): * css/parser/CSSParserToken.cpp: (WebCore::CSSParserToken::serialize const): * platform/graphics/Color.cpp: (WebCore::Color::serialized const): * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection): * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: (WebCore::generateHashedName): * platform/network/curl/CurlCacheEntry.cpp: (WebCore::CurlCacheEntry::generateBaseFilename): * rendering/RenderTreeAsText.cpp: (WebCore::quoteAndEscapeNonPrintables): Replace appendByteAsHex()/appendUnsignedAsHex()/appendUnsignedAsHexFixedSize() with append(hex()). * platform/network/FormDataBuilder.cpp: (WebCore::FormDataBuilder::appendFormURLEncoded): This was the last non-StringBuilder/makeString use of appendByteAsHex. Rather than keep appendByteAsHex around, it is replaced with direct appends of the character buffer hex() produces. Source/WebKit: * UIProcess/DeviceIdHashSaltStorage.cpp: (WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Replace appendUnsignedAsHex() with append(hex()). Source/WTF: Removes appendByteAsHex, appendUnsignedAsHex and appendUnsignedAsHexFixedSize with the following mappings: appendByteAsHex(value, builder, case) -> builder.append(hex(static_cast<unsigned char>(value), 2, case)) appendUnsignedAsHex(value, builder, case) -> builder.append(hex(value, case)) appendUnsignedAsHexFixedSize(value, builder, size, case) -> builder.append(hex(value, size, case)) Adds new API test for HexNumber.cpp * wtf/HexNumber.h: (WTF::appendByteAsHex): Deleted. (WTF::appendUnsignedAsHex): Deleted. (WTF::appendUnsignedAsHexFixedSize): Deleted. Remove now unused helper functions. * wtf/FileSystem.cpp: (WTF::FileSystemImpl::encodeForFileName): Replace appendByteAsHex with direct use of hex(x, 2). The static_cast is needed since there was an implicit down cast when appendByteAsHex was used. * wtf/Logger.cpp: (WTF::Logger::LogSiteIdentifier::toString const): (WTF::>::toString): * wtf/UUID.cpp: (WTF::createCanonicalUUIDString): Replace appendUnsignedAsHex/appendUnsignedAsHexFixedSize with hex(). Use makeString() rather StringBuilder to simplify things further. * wtf/text/WTFString.cpp: (asciiDebug): Replace appendUnsignedAsHexFixedSize with append(hex()). Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/HexNumber.cpp: Added. Add testing for hex formatting of integers. Canonical link: https://commits.webkit.org/218921@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 00:20:57 +00:00
return makeString('(', hex(reinterpret_cast<uintptr_t>(argument)), ')');
Add AggregateLogger, a Logger specialization for singleton classes. https://bugs.webkit.org/show_bug.cgi?id=195644 Reviewed by Eric Carlson. Source/WebCore: Convert debug logging over to release logging through the use of AggregateLogger. * platform/audio/PlatformMediaSession.h: (WebCore::PlatformMediaSession::client const): * platform/audio/PlatformMediaSessionManager.cpp: (WebCore::PlatformMediaSessionManager::PlatformMediaSessionManager): (WebCore::PlatformMediaSessionManager::beginInterruption): (WebCore::PlatformMediaSessionManager::endInterruption): (WebCore::PlatformMediaSessionManager::addSession): (WebCore::PlatformMediaSessionManager::removeSession): (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback): (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback): (WebCore::PlatformMediaSessionManager::setCurrentSession): (WebCore::PlatformMediaSessionManager::applicationWillBecomeInactive const): (WebCore::PlatformMediaSessionManager::applicationDidBecomeActive const): (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground const): (WebCore::PlatformMediaSessionManager::applicationWillEnterForeground const): (WebCore::PlatformMediaSessionManager::logChannel const): * platform/audio/PlatformMediaSessionManager.h: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: (MediaSessionManagerCocoa::updateSessionState): (MediaSessionManagerCocoa::sessionWillBeginPlayback): (MediaSessionManagerCocoa::removeSession): (MediaSessionManagerCocoa::sessionWillEndPlayback): (MediaSessionManagerCocoa::clientCharacteristicsChanged): (MediaSessionManagerCocoa::updateNowPlayingInfo): * platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::resetRestrictions): (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Source/WTF: Add a new class, AggregateLogger, which will log messages to each of its aggregated loggers. Drive-by fixes: allow "const void*" to be directly logged by converting the pointer to a hex string. * WTF.xcodeproj/project.pbxproj: * wtf/AggregateLogger.h: Added. (WTF::AggregateLogger::create): (WTF::AggregateLogger::addLogger): (WTF::AggregateLogger::removeLogger): (WTF::AggregateLogger::logAlways const): (WTF::AggregateLogger::error const): (WTF::AggregateLogger::warning const): (WTF::AggregateLogger::info const): (WTF::AggregateLogger::debug const): (WTF::AggregateLogger::willLog const): (WTF::AggregateLogger::AggregateLogger): (WTF::AggregateLogger::log const): * wtf/CMakeLists.h: * wtf/Logger.cpp: (WTF::>::toString): * wtf/Logger.h: Canonical link: https://commits.webkit.org/209992@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242901 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-13 20:18:08 +00:00
}
Use std::call_once + LazyNeverDestroyed to initialize complex data structures https://bugs.webkit.org/show_bug.cgi?id=215535 <rdar://problem/66774266> Reviewed by Mark Lam. NeverDestroyed<> is not thread-safe in Darwin build since it is not using C++11 thread-safe static variable semantics. This patch uses LazyNeverDestroyed and call_once to initialize complex data structures so that we can ensure they are initialized atomically. We also move some of `singleton` definitions from headers to cpp files. This is important since this ensures that singleton is only one instance which is generated in one translation unit. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/FastMalloc.cpp: (WTF::MallocCallTracker::singleton): * wtf/Language.cpp: (WTF::observerMap): (WTF::preferredLanguagesOverride): * wtf/Logger.cpp: (WTF::Logger::observers): * wtf/Logger.h: (WTF::Logger::observerLock): (WTF::Logger::observers): Deleted. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::singleton): * wtf/MemoryPressureHandler.h: * wtf/RunLoop.cpp: (WTF::RunLoop::current): * wtf/Threading.cpp: (WTF::Thread::initializeInThread): * wtf/URL.cpp: (WTF::aboutBlankURL): (WTF::aboutSrcDocURL): * wtf/cf/LanguageCF.cpp: (WTF::preferredLanguages): * wtf/cocoa/NSURLExtras.mm: (WTF::rangeOfURLScheme): * wtf/text/LineBreakIteratorPoolICU.cpp: Copied from Source/WTF/wtf/Logger.cpp. (WTF::LineBreakIteratorPool::sharedPool): * wtf/text/LineBreakIteratorPoolICU.h: (WTF::LineBreakIteratorPool::sharedPool): Deleted. * wtf/text/StringView.cpp: * wtf/text/TextBreakIterator.cpp: (WTF::TextBreakIteratorCache::singleton): * wtf/text/TextBreakIterator.h: (WTF::TextBreakIteratorCache::singleton): Deleted. * wtf/threads/Signals.cpp: (WTF::activeThreads): Canonical link: https://commits.webkit.org/228310@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 18:40:50 +00:00
Vector<std::reference_wrapper<Logger::Observer>>& Logger::observers()
{
static LazyNeverDestroyed<Vector<std::reference_wrapper<Observer>>> observers;
static std::once_flag onceKey;
std::call_once(onceKey, [&] {
observers.construct();
});
return observers;
}
Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. https://bugs.webkit.org/show_bug.cgi?id=194752 Reviewed by Daniel Bates. Source/JavaScriptCore: * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::json): Added back the "0x" that was removed when changing this file to use appendUnsignedAsHex instead of "%p". The intent at that time was to keep behavior the same, so let's do that. * parser/Lexer.cpp: (JSC::Lexer<T>::invalidCharacterMessage const): Use makeString and hex instead of String::format and "%04x". Source/WebCore: * Modules/websockets/WebSocket.cpp: Added an include of HexNumber.h. This previously got included because of Logger.h, but that no longer pulls in HexNumber.h. * css/CSSMarkup.cpp: Removed unneeded include of StringBuffer.h. * css/CSSPrimitiveValue.cpp: Ditto. * css/CSSUnicodeRangeValue.cpp: (WebCore::CSSUnicodeRangeValue::customCSSText const): Use makeString and hex instead of String::format and "%x". * html/HTMLMediaElement.h: (WTF::ValueToString<WebCore::TextTrackCue::string): Use a non-template function, TextTrackCure::debugString, so we don't need to use HextNumber.h in a header. * html/canvas/WebGLRenderingContextBase.cpp: (GetErrorString): Use makeString and hex instead of String::format and "%04x". * html/track/TextTrackCue.cpp: (WebCore::TextTrackCue::debugString const): Added. Moved string conversion here from HTMLMediaElement.h and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * html/track/TextTrackCue.h: Added TextTrackCue::debugString. * page/linux/ResourceUsageOverlayLinux.cpp: (WebCore::formatByteNumber): Use makeString and FormattedNumber::fixedWidth instead of String::format and "%.1f" etc. * platform/cocoa/KeyEventCocoa.mm: (WebCore::keyIdentifierForCharCode): Use the new hex function here instead of the old code that did each of the four characters explicitly. * platform/gamepad/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::HIDGamepad): Use makeString instead of String::format. * platform/graphics/Color.cpp: (WebCore::Color::nameForRenderTreeAsText const): Use hex instead of doing each digit separately. * platform/graphics/FloatPolygon.cpp: (WebCore::FloatPolygonEdge::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * platform/graphics/FloatPolygon.h: Updated for the above. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setName): Use makeString instead of String::format. (WebCore::GraphicsLayerCA::recursiveCommitChanges): DItto. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::load): Ditto. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Ditto. * platform/gtk/PlatformKeyboardEventGtk.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForGdkKeyCode): Ditto. * platform/libwpe/PlatformKeyboardEventLibWPE.cpp: (WebCore::PlatformKeyboardEvent::keyIdentifierForWPEKeyCode): Ditto. * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: (WebCore::GStreamerVideoEncoder::makeElement): Ditto. (WebCore::GStreamerVideoEncoder::InitEncode): Ditto. * platform/text/TextCodecLatin1.cpp: Removed unneeded include of StringBuffer.h and "using namespace WTF". * platform/win/GDIObjectCounter.cpp: (WebCore::GDIObjectCounter::GDIObjectCounter): Use makeString instead of String::format. * platform/win/KeyEventWin.cpp: (WebCore::keyIdentifierForWindowsKeyCode): Ditto. * rendering/FloatingObjects.cpp: (WebCore::FloatingObject::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/FloatingObjects.h: Updated for the above. * rendering/RenderFragmentContainer.cpp: (WebCore::RenderFragmentContainer::debugString const): Added. Moved string conversion here from the header and use makeString instead of String::format. Also use the word "debug" to make it clear that it's not OK to use this string, with a pointer value serialized into it, outside of debugging. * rendering/RenderFragmentContainer.h: Updated for the above. * rendering/RenderFragmentedFlow.h: Ditto. * testing/Internals.cpp: (WebCore::Internals::address): Use makeString instead of String::format. Source/WebCore/PAL: * pal/FileSizeFormatter.cpp: (fileSizeDescription): Use makeString instead of String::format. Source/WebKit: * Platform/IPC/win/ConnectionWin.cpp: (IPC::Connection::createServerAndClientIdentifiers): Use makeString instead of String::format. * Shared/win/WebEventFactory.cpp: (WebKit::keyIdentifierFromEvent): Ditto. * UIProcess/API/APINavigation.cpp: (API::Navigation::loggingString const): Use hex instead of String::format. * UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::loggingString const): Ditto. * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::loggingString): Added a "0x". * UIProcess/gtk/InputMethodFilter.cpp: (WebKit::InputMethodFilter::logHandleKeyboardEventForTesting): Use makeString and hex instead of String::format and "%x". (WebKit::InputMethodFilter::logHandleKeyboardEventWithCompositionResultsForTesting): Ditto. Source/WTF: * WTF.xcodeproj/project.pbxproj: Added HexNumber.cpp and Logger.cpp. * wtf/CMakeLists.txt: Ditto. * wtf/HexNumber.cpp: Added. (WTF::Internal::appendHex): Non-inline, non-template hex formatting logic. * wtf/HexNumber.h: (WTF::Internal::appendHex): Refactored main logic of appendUnsignedAsHex and appendUnsignedAsHexFixedSize so they can be reused in a function named hex for use with StringTypeAdapter. (WTF::appendUnsignedAsHex): Ditto. (WTF::appendUnsignedAsHexFixedSize): Ditto. (WTF::hex): Added. (WTF::StringTypeAdapter<HexNumberBuffer>): Added. * wtf/Logger.cpp: Added. (WTF::Logger::LogSiteIdentifier::toString const): Made this a non-template function and moved it here so that we don't need to include HexNumber.h in Logger.h. Since HexNumber.h has substantial code in it, it's good if we don't include it in any other headers. * wtf/Logger.h: (WTF::LogArgument<Logger::LogSiteIdentifier>::toString): Changed to call a non-template function, LogSiteIdentifier::toString. * wtf/text/StringConcatenateNumbers.h: Replaced overloaded writeTo functions with function templates and used StringImpl::copyCharacters instead of hand-written loops. Canonical link: https://commits.webkit.org/209182@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-19 02:04:33 +00:00
} // namespace WTF