haikuwebkit/Source/WTF/wtf/FilePrintStream.h

58 lines
2.0 KiB
C
Raw Permalink Normal View History

Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
/*
* Copyright (C) 2012 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.
*/
Use pragma once in WTF https://bugs.webkit.org/show_bug.cgi?id=190527 Reviewed by Chris Dumez. Source/WTF: We also need to consistently include wtf headers from within wtf so we can build wtf without symbol redefinition errors from including the copy in Source and the copy in the build directory. * wtf/ASCIICType.h: * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/Atomics.h: * wtf/AutomaticThread.cpp: * wtf/AutomaticThread.h: * wtf/BackwardsGraph.h: * wtf/Bag.h: * wtf/BagToHashMap.h: * wtf/BitVector.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Box.h: * wtf/BubbleSort.h: * wtf/BumpPointerAllocator.h: * wtf/ByteOrder.h: * wtf/CPUTime.cpp: * wtf/CallbackAggregator.h: * wtf/CheckedArithmetic.h: * wtf/CheckedBoolean.h: * wtf/ClockType.cpp: * wtf/ClockType.h: * wtf/CommaPrinter.h: * wtf/CompilationThread.cpp: * wtf/CompilationThread.h: * wtf/Compiler.h: * wtf/ConcurrentPtrHashSet.cpp: * wtf/ConcurrentVector.h: * wtf/Condition.h: * wtf/CountingLock.cpp: * wtf/CrossThreadTaskHandler.cpp: * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/CryptographicallyRandomNumber.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DataLog.h: * wtf/DateMath.cpp: * wtf/DateMath.h: * wtf/DecimalNumber.cpp: * wtf/DecimalNumber.h: * wtf/Deque.h: * wtf/DisallowCType.h: * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/FastBitVector.cpp: * wtf/FastMalloc.cpp: * wtf/FastMalloc.h: * wtf/FeatureDefines.h: * wtf/FilePrintStream.cpp: * wtf/FilePrintStream.h: * wtf/FlipBytes.h: * wtf/FunctionDispatcher.cpp: * wtf/FunctionDispatcher.h: * wtf/GetPtr.h: * wtf/Gigacage.cpp: * wtf/GlobalVersion.cpp: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.cpp: * wtf/GregorianDateTime.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashMethod.h: * wtf/HashSet.h: * wtf/HashTable.cpp: * wtf/HashTraits.h: * wtf/Indenter.h: * wtf/IndexSparseSet.h: * wtf/InlineASM.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/JSONValues.cpp: * wtf/JSValueMalloc.cpp: * wtf/LEBDecoder.h: * wtf/Language.cpp: * wtf/ListDump.h: * wtf/Lock.cpp: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockedPrintStream.cpp: * wtf/Locker.h: * wtf/MD5.cpp: * wtf/MD5.h: * wtf/MainThread.cpp: * wtf/MainThread.h: * wtf/MallocPtr.h: * wtf/MathExtras.h: * wtf/MediaTime.cpp: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.cpp: * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: * wtf/MetaAllocator.h: * wtf/MetaAllocatorHandle.h: * wtf/MonotonicTime.cpp: * wtf/MonotonicTime.h: * wtf/NakedPtr.h: * wtf/NoLock.h: * wtf/NoTailCalls.h: * wtf/Noncopyable.h: * wtf/NumberOfCores.cpp: * wtf/NumberOfCores.h: * wtf/OSAllocator.h: * wtf/OSAllocatorPosix.cpp: * wtf/OSRandomSource.cpp: * wtf/OSRandomSource.h: * wtf/ObjcRuntimeExtras.h: * wtf/OrderMaker.h: * wtf/PackedIntVector.h: * wtf/PageAllocation.h: * wtf/PageBlock.cpp: * wtf/PageBlock.h: * wtf/PageReservation.h: * wtf/ParallelHelperPool.cpp: * wtf/ParallelHelperPool.h: * wtf/ParallelJobs.h: * wtf/ParallelJobsLibdispatch.h: * wtf/ParallelVectorIterator.h: * wtf/ParkingLot.cpp: * wtf/ParkingLot.h: * wtf/Platform.h: * wtf/PointerComparison.h: * wtf/Poisoned.cpp: * wtf/PrintStream.cpp: * wtf/PrintStream.h: * wtf/ProcessID.h: * wtf/ProcessPrivilege.cpp: * wtf/RAMSize.cpp: * wtf/RAMSize.h: * wtf/RandomDevice.cpp: * wtf/RandomNumber.cpp: * wtf/RandomNumber.h: * wtf/RandomNumberSeed.h: * wtf/RangeSet.h: * wtf/RawPointer.h: * wtf/ReadWriteLock.cpp: * wtf/RedBlackTree.h: * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefCountedLeakCounter.cpp: * wtf/RefCountedLeakCounter.h: * wtf/RefCounter.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/RunLoop.cpp: * wtf/RunLoop.h: * wtf/RunLoopTimer.h: * wtf/RunLoopTimerCF.cpp: * wtf/SHA1.cpp: * wtf/SHA1.h: * wtf/SaturatedArithmetic.h: (saturatedSubtraction): * wtf/SchedulePair.h: * wtf/SchedulePairCF.cpp: * wtf/SchedulePairMac.mm: * wtf/ScopedLambda.h: * wtf/Seconds.cpp: * wtf/Seconds.h: * wtf/SegmentedVector.h: * wtf/SentinelLinkedList.h: * wtf/SharedTask.h: * wtf/SimpleStats.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SixCharacterHash.cpp: * wtf/SixCharacterHash.h: * wtf/SmallPtrSet.h: * wtf/Spectrum.h: * wtf/StackBounds.cpp: * wtf/StackBounds.h: * wtf/StackStats.cpp: * wtf/StackStats.h: * wtf/StackTrace.cpp: * wtf/StdLibExtras.h: * wtf/StreamBuffer.h: * wtf/StringHashDumpContext.h: * wtf/StringPrintStream.cpp: * wtf/StringPrintStream.h: * wtf/ThreadGroup.cpp: * wtf/ThreadMessage.cpp: * wtf/ThreadSpecific.h: * wtf/Threading.cpp: * wtf/Threading.h: * wtf/ThreadingPrimitives.h: * wtf/ThreadingPthreads.cpp: * wtf/TimeWithDynamicClockType.cpp: * wtf/TimeWithDynamicClockType.h: * wtf/TimingScope.cpp: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/TriState.h: * wtf/TypeCasts.h: * wtf/UUID.cpp: * wtf/UnionFind.h: * wtf/VMTags.h: * wtf/ValueCheck.h: * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.cpp: * wtf/WallTime.h: * wtf/WeakPtr.h: * wtf/WeakRandom.h: * wtf/WordLock.cpp: * wtf/WordLock.h: * wtf/WorkQueue.cpp: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: * wtf/cf/LanguageCF.cpp: * wtf/cf/RunLoopCF.cpp: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryFootprintCocoa.cpp: * wtf/cocoa/WorkQueueCocoa.cpp: * wtf/dtoa.cpp: * wtf/dtoa.h: * wtf/ios/WebCoreThread.cpp: * wtf/ios/WebCoreThread.h: * wtf/mac/AppKitCompatibilityDeclarations.h: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mbmalloc.cpp: * wtf/persistence/PersistentCoders.cpp: * wtf/persistence/PersistentDecoder.cpp: * wtf/persistence/PersistentEncoder.cpp: * wtf/spi/cf/CFBundleSPI.h: * wtf/spi/darwin/CommonCryptoSPI.h: * wtf/text/ASCIIFastPath.h: * wtf/text/ASCIILiteral.cpp: * wtf/text/AtomicString.cpp: * wtf/text/AtomicString.h: * wtf/text/AtomicStringHash.h: * wtf/text/AtomicStringImpl.cpp: * wtf/text/AtomicStringImpl.h: * wtf/text/AtomicStringTable.cpp: * wtf/text/AtomicStringTable.h: * wtf/text/Base64.cpp: * wtf/text/CString.cpp: * wtf/text/CString.h: * wtf/text/ConversionMode.h: * wtf/text/ExternalStringImpl.cpp: * wtf/text/IntegerToStringConversion.h: * wtf/text/LChar.h: * wtf/text/LineEnding.cpp: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.cpp: * wtf/text/StringBuilder.h: * wtf/text/StringBuilderJSON.cpp: * wtf/text/StringCommon.h: * wtf/text/StringConcatenate.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.cpp: * wtf/text/StringImpl.h: * wtf/text/StringOperators.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: * wtf/text/SymbolImpl.cpp: * wtf/text/SymbolRegistry.cpp: * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.cpp: * wtf/text/TextBreakIterator.h: * wtf/text/TextBreakIteratorInternalICU.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.cpp: * wtf/text/UniquedStringImpl.h: * wtf/text/WTFString.cpp: * wtf/text/WTFString.h: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/StringViewCocoa.mm: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: * wtf/text/icu/UTextProvider.cpp: * wtf/text/icu/UTextProvider.h: * wtf/text/icu/UTextProviderLatin1.cpp: * wtf/text/icu/UTextProviderLatin1.h: * wtf/text/icu/UTextProviderUTF16.cpp: * wtf/text/icu/UTextProviderUTF16.h: * wtf/threads/BinarySemaphore.cpp: * wtf/threads/BinarySemaphore.h: * wtf/threads/Signals.cpp: * wtf/unicode/CharacterNames.h: * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: * wtf/unicode/UTF8.cpp: * wtf/unicode/UTF8.h: Tools: Put WorkQueue in namespace DRT so it does not conflict with WTF::WorkQueue. * DumpRenderTree/TestRunner.cpp: (TestRunner::queueLoadHTMLString): (TestRunner::queueLoadAlternateHTMLString): (TestRunner::queueBackNavigation): (TestRunner::queueForwardNavigation): (TestRunner::queueLoadingScript): (TestRunner::queueNonLoadingScript): (TestRunner::queueReload): * DumpRenderTree/WorkQueue.cpp: (WorkQueue::singleton): Deleted. (WorkQueue::WorkQueue): Deleted. (WorkQueue::queue): Deleted. (WorkQueue::dequeue): Deleted. (WorkQueue::count): Deleted. (WorkQueue::clear): Deleted. (WorkQueue::processWork): Deleted. * DumpRenderTree/WorkQueue.h: (WorkQueue::setFrozen): Deleted. * DumpRenderTree/WorkQueueItem.h: * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): * DumpRenderTree/mac/FrameLoadDelegate.mm: (-[FrameLoadDelegate processWork:]): (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]): * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): * DumpRenderTree/win/DumpRenderTree.cpp: (runTest): * DumpRenderTree/win/FrameLoadDelegate.cpp: (FrameLoadDelegate::processWork): (FrameLoadDelegate::locationChangeDone): * DumpRenderTree/win/TestRunnerWin.cpp: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): Canonical link: https://commits.webkit.org/205473@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237099 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-15 14:24:49 +00:00
#pragma once
Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
#include <stdio.h>
#include <wtf/PrintStream.h>
namespace WTF {
Fix existing usage of final/override/virtual in JSC and WTF https://bugs.webkit.org/show_bug.cgi?id=211772 Reviewed by Darin Adler. Source/JavaScriptCore: * API/JSAPIWrapperObject.mm: * API/JSManagedValue.mm: * API/JSScriptSourceProvider.h: * API/ObjCCallbackFunction.mm: * API/glib/JSAPIWrapperGlobalObject.cpp: * API/glib/JSAPIWrapperObjectGLib.cpp: * API/glib/JSCWeakValue.cpp: * bytecode/AccessCaseSnippetParams.cpp: * bytecode/AccessCaseSnippetParams.h: * bytecode/CodeBlock.cpp: * bytecode/StructureStubClearingWatchpoint.h: * bytecode/VariableWriteFireDetail.h: * bytecode/Watchpoint.h: * dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h: * dfg/DFGArrayifySlowPathGenerator.h: * dfg/DFGCallArrayAllocatorSlowPathGenerator.h: * dfg/DFGCallCreateDirectArgumentsSlowPathGenerator.h: * dfg/DFGSaneStringGetByValSlowPathGenerator.h: * dfg/DFGSlowPathGenerator.h: * dfg/DFGSnippetParams.h: * dfg/DFGWorklist.cpp: * ftl/FTLSnippetParams.h: * heap/BlockDirectory.cpp: * heap/EdenGCActivityCallback.h: * heap/FullGCActivityCallback.h: * heap/Heap.cpp: * heap/Heap.h: * heap/IncrementalSweeper.h: * heap/IsoCellSet.cpp: * heap/IsoCellSetInlines.h: * heap/IsoHeapCellType.h: * heap/IsoInlinedHeapCellType.h: * heap/ParallelSourceAdapter.h: * heap/StopIfNecessaryTimer.h: * heap/Subspace.cpp: * heap/SubspaceInlines.h: * inspector/InjectedScript.h: * inspector/JSGlobalObjectConsoleClient.h: * inspector/JSGlobalObjectInspectorController.h: * inspector/JSGlobalObjectScriptDebugServer.h: * inspector/JSInjectedScriptHost.cpp: * inspector/agents/InspectorAgent.h: * inspector/agents/InspectorScriptProfilerAgent.h: * inspector/agents/InspectorTargetAgent.h: * inspector/agents/JSGlobalObjectAuditAgent.h: * inspector/agents/JSGlobalObjectDebuggerAgent.h: * inspector/agents/JSGlobalObjectRuntimeAgent.h: * inspector/augmentable/AlternateDispatchableAgent.h: * inspector/remote/RemoteConnectionToTarget.h: * inspector/remote/RemoteInspector.h: * inspector/remote/socket/RemoteInspectorServer.h: * inspector/scripts/codegen/cpp_generator_templates.py: * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py: * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/expected/command-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/generic/expected/domain-debuggableTypes.json-result: * inspector/scripts/tests/generic/expected/domain-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/domain-targetTypes.json-result: * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result: * inspector/scripts/tests/generic/expected/enum-values.json-result: * inspector/scripts/tests/generic/expected/event-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result: * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result: * jit/JITWorklist.cpp: * parser/Nodes.h: * parser/SourceProvider.h: * runtime/DataView.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/FileBasedFuzzerAgent.h: * runtime/GenericTypedArrayView.h: * runtime/JSMicrotask.cpp: * runtime/NarrowingNumberPredictionFuzzerAgent.h: * runtime/ObjectPropertyChangeAdaptiveWatchpoint.h: * runtime/PredictionFileCreatingFuzzerAgent.h: * runtime/PromiseTimer.h: * runtime/RandomizingFuzzerAgent.h: * runtime/RegExpCache.h: * runtime/Structure.cpp: * runtime/StructureRareData.cpp: * runtime/VMTraps.cpp: * runtime/WideningNumberPredictionFuzzerAgent.h: * tools/JSDollarVM.cpp: * wasm/WasmBBQPlan.h: * wasm/WasmCallee.h: * wasm/WasmLLIntPlan.h: * wasm/WasmOMGForOSREntryPlan.h: * wasm/WasmOMGPlan.h: * wasm/WasmWorklist.cpp: * yarr/YarrJIT.cpp: Source/WTF: * wtf/Assertions.cpp: * wtf/Expected.h: * wtf/FilePrintStream.h: * wtf/JSONValues.h: * wtf/LockedPrintStream.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: * wtf/RunLoop.h: * wtf/SharedTask.h: * wtf/StringPrintStream.h: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: Canonical link: https://commits.webkit.org/224683@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 19:13:18 +00:00
class FilePrintStream final : public PrintStream {
Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
public:
enum AdoptionMode {
Adopt,
Borrow
};
FilePrintStream(FILE*, AdoptionMode = Adopt);
Fix existing usage of final/override/virtual in JSC and WTF https://bugs.webkit.org/show_bug.cgi?id=211772 Reviewed by Darin Adler. Source/JavaScriptCore: * API/JSAPIWrapperObject.mm: * API/JSManagedValue.mm: * API/JSScriptSourceProvider.h: * API/ObjCCallbackFunction.mm: * API/glib/JSAPIWrapperGlobalObject.cpp: * API/glib/JSAPIWrapperObjectGLib.cpp: * API/glib/JSCWeakValue.cpp: * bytecode/AccessCaseSnippetParams.cpp: * bytecode/AccessCaseSnippetParams.h: * bytecode/CodeBlock.cpp: * bytecode/StructureStubClearingWatchpoint.h: * bytecode/VariableWriteFireDetail.h: * bytecode/Watchpoint.h: * dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h: * dfg/DFGArrayifySlowPathGenerator.h: * dfg/DFGCallArrayAllocatorSlowPathGenerator.h: * dfg/DFGCallCreateDirectArgumentsSlowPathGenerator.h: * dfg/DFGSaneStringGetByValSlowPathGenerator.h: * dfg/DFGSlowPathGenerator.h: * dfg/DFGSnippetParams.h: * dfg/DFGWorklist.cpp: * ftl/FTLSnippetParams.h: * heap/BlockDirectory.cpp: * heap/EdenGCActivityCallback.h: * heap/FullGCActivityCallback.h: * heap/Heap.cpp: * heap/Heap.h: * heap/IncrementalSweeper.h: * heap/IsoCellSet.cpp: * heap/IsoCellSetInlines.h: * heap/IsoHeapCellType.h: * heap/IsoInlinedHeapCellType.h: * heap/ParallelSourceAdapter.h: * heap/StopIfNecessaryTimer.h: * heap/Subspace.cpp: * heap/SubspaceInlines.h: * inspector/InjectedScript.h: * inspector/JSGlobalObjectConsoleClient.h: * inspector/JSGlobalObjectInspectorController.h: * inspector/JSGlobalObjectScriptDebugServer.h: * inspector/JSInjectedScriptHost.cpp: * inspector/agents/InspectorAgent.h: * inspector/agents/InspectorScriptProfilerAgent.h: * inspector/agents/InspectorTargetAgent.h: * inspector/agents/JSGlobalObjectAuditAgent.h: * inspector/agents/JSGlobalObjectDebuggerAgent.h: * inspector/agents/JSGlobalObjectRuntimeAgent.h: * inspector/augmentable/AlternateDispatchableAgent.h: * inspector/remote/RemoteConnectionToTarget.h: * inspector/remote/RemoteInspector.h: * inspector/remote/socket/RemoteInspectorServer.h: * inspector/scripts/codegen/cpp_generator_templates.py: * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py: * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/expected/command-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/generic/expected/domain-debuggableTypes.json-result: * inspector/scripts/tests/generic/expected/domain-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/domain-targetTypes.json-result: * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result: * inspector/scripts/tests/generic/expected/enum-values.json-result: * inspector/scripts/tests/generic/expected/event-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result: * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result: * jit/JITWorklist.cpp: * parser/Nodes.h: * parser/SourceProvider.h: * runtime/DataView.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/FileBasedFuzzerAgent.h: * runtime/GenericTypedArrayView.h: * runtime/JSMicrotask.cpp: * runtime/NarrowingNumberPredictionFuzzerAgent.h: * runtime/ObjectPropertyChangeAdaptiveWatchpoint.h: * runtime/PredictionFileCreatingFuzzerAgent.h: * runtime/PromiseTimer.h: * runtime/RandomizingFuzzerAgent.h: * runtime/RegExpCache.h: * runtime/Structure.cpp: * runtime/StructureRareData.cpp: * runtime/VMTraps.cpp: * runtime/WideningNumberPredictionFuzzerAgent.h: * tools/JSDollarVM.cpp: * wasm/WasmBBQPlan.h: * wasm/WasmCallee.h: * wasm/WasmLLIntPlan.h: * wasm/WasmOMGForOSREntryPlan.h: * wasm/WasmOMGPlan.h: * wasm/WasmWorklist.cpp: * yarr/YarrJIT.cpp: Source/WTF: * wtf/Assertions.cpp: * wtf/Expected.h: * wtf/FilePrintStream.h: * wtf/JSONValues.h: * wtf/LockedPrintStream.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: * wtf/RunLoop.h: * wtf/SharedTask.h: * wtf/StringPrintStream.h: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: Canonical link: https://commits.webkit.org/224683@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 19:13:18 +00:00
WTF_EXPORT_PRIVATE ~FilePrintStream() final;
Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
Remove createOwned https://bugs.webkit.org/show_bug.cgi?id=122388 Reviewed by Darin Adler. Source/JavaScriptCore: * profiler/ProfilerDatabase.cpp: (JSC::Profiler::Database::save): Source/WebCore: * dom/Document.cpp: (WebCore::Document::Document): (WebCore::Document::~Document): (WebCore::Document::createRenderTree): (WebCore::Document::destroyRenderTree): * dom/Document.h: * page/Frame.cpp: (WebCore::Frame::Frame): * page/Frame.h: * page/animation/AnimationController.cpp: (WebCore::AnimationController::AnimationController): * page/animation/AnimationController.h: * platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.h: * platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm: (WebCore::AudioTrackPrivateAVFObjC::AudioTrackPrivateAVFObjC): (WebCore::AudioTrackPrivateAVFObjC::setPlayerItemTrack): * platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp: (WebCore::VideoTrackPrivateAVFObjC::VideoTrackPrivateAVFObjC): (WebCore::VideoTrackPrivateAVFObjC::setPlayerItemTrack): * platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.h: * rendering/svg/RenderSVGResourceClipper.cpp: (WebCore::RenderSVGResourceClipper::applyClippingToContext): * rendering/svg/RenderSVGResourceClipper.h: * rendering/svg/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::applyResource): * rendering/svg/RenderSVGResourceFilter.h: * rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyResource): * rendering/svg/RenderSVGResourceMasker.h: Source/WebKit2: * UIProcess/API/mac/WKView.mm: (-[WKView _setFindIndicator:fadeOut:animate:]): * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp: (WKBundlePageOverlayCreate): Source/WTF: Since we're going with std::unique_ptr instead of OwnPtr, there's no need for makeOwned to exist. Get rid of it and replace it with calls to std::make_unique. * wtf/FilePrintStream.cpp: (WTF::FilePrintStream::open): * wtf/FilePrintStream.h: * wtf/HashTable.h: (WTF::::HashTable): * wtf/ListHashSet.h: (WTF::::ListHashSet): * wtf/OwnPtr.h: * wtf/Threading.cpp: (WTF::compatEntryPoint): (WTF::createThread): * wtf/ThreadingPthreads.cpp: (WTF::wtfThreadEntryPoint): (WTF::createThreadInternal): * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: (WTF::Collator::userDefault): * wtf/unicode/icu/CollatorICU.cpp: (WTF::Collator::userDefault): Canonical link: https://commits.webkit.org/140445@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-10-05 18:59:00 +00:00
WTF_EXPORT_PRIVATE static std::unique_ptr<FilePrintStream> open(const char* filename, const char* mode);
JSC should be able to report profiling data associated with the IR dumps and disassembly https://bugs.webkit.org/show_bug.cgi?id=102999 Reviewed by Gavin Barraclough. Source/JavaScriptCore: Added a new profiler to JSC. It's simply called "Profiler" in anticipation of it ultimately replacing the previous profiling infrastructure. This profiler counts the number of times that a bytecode executes in various engines, and will record both the counts and all disassembly and bytecode dumps, into a database that can be at any time turned into either a JS object using any global object or global data of your choice, or can be turned into a JSON string, or saved to a file. Currently the only use of this is the new '-p <file>' flag to the jsc command-line. The profiler is always compiled in and normally incurs no execution time cost, but is only activated when you create a Profiler::Database and install it in JSGlobalData::m_perBytecodeProfiler. From that point on, all code blocks will be compiled along with disassembly and bytecode dumps stored into the Profiler::Database, and all code blocks will have execution counts, which are also stored in the database. The database will continue to keep information about code blocks alive even after they are otherwise GC'd. This currently still has some glitches, like the fact that it only counts executions in the JITs. Doing execution counting in the LLInt might require a bit of a rethink about how the counting is expressed - currently it is implicit in bytecode, so there is no easy way to "turn it on" in the LLInt. Also, right now there is no information recorded about OSR exits or out-of-line stubs. But, even so, it's quite cool, and gives you a peek into what JSC is doing that would otherwise not be possible. * CMakeLists.txt: * GNUmakefile.list.am: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * Target.pri: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::~CodeBlock): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::baselineVersion): * bytecode/CodeOrigin.cpp: (JSC::InlineCallFrame::baselineCodeBlock): (JSC): * bytecode/CodeOrigin.h: (InlineCallFrame): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::execute): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGDisassembler.cpp: (JSC::DFG::Disassembler::dump): (DFG): (JSC::DFG::Disassembler::reportToProfiler): (JSC::DFG::Disassembler::dumpHeader): (JSC::DFG::Disassembler::append): (JSC::DFG::Disassembler::createDumpList): * dfg/DFGDisassembler.h: (Disassembler): (JSC::DFG::Disassembler::DumpedOp::DumpedOp): (DumpedOp): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::Graph): (JSC::DFG::Graph::dumpCodeOrigin): (JSC::DFG::Graph::dump): * dfg/DFGGraph.h: (Graph): * dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::JITCompiler): (JSC::DFG::JITCompiler::compile): (JSC::DFG::JITCompiler::compileFunction): * dfg/DFGNode.h: (Node): (JSC::DFG::Node::hasExecutionCounter): (JSC::DFG::Node::executionCounter): * dfg/DFGNodeType.h: (DFG): * dfg/DFGPredictionPropagationPhase.cpp: (JSC::DFG::PredictionPropagationPhase::propagate): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * jit/JIT.cpp: (JSC::JIT::JIT): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompile): * jit/JIT.h: (JIT): * jit/JITDisassembler.cpp: (JSC::JITDisassembler::dump): (JSC::JITDisassembler::reportToProfiler): (JSC): (JSC::JITDisassembler::dumpHeader): (JSC::JITDisassembler::firstSlowLabel): (JSC::JITDisassembler::dumpVectorForInstructions): (JSC::JITDisassembler::dumpForInstructions): (JSC::JITDisassembler::reportInstructions): * jit/JITDisassembler.h: (JITDisassembler): (DumpedOp): * jsc.cpp: (CommandLine::CommandLine): (CommandLine): (printUsageStatement): (CommandLine::parseArguments): (jscmain): * profiler/ProfilerBytecode.cpp: Added. (Profiler): (JSC::Profiler::Bytecode::toJS): * profiler/ProfilerBytecode.h: Added. (Profiler): (Bytecode): (JSC::Profiler::Bytecode::Bytecode): (JSC::Profiler::Bytecode::bytecodeIndex): (JSC::Profiler::Bytecode::description): (JSC::Profiler::getBytecodeIndexForBytecode): * profiler/ProfilerBytecodes.cpp: Added. (Profiler): (JSC::Profiler::Bytecodes::Bytecodes): (JSC::Profiler::Bytecodes::~Bytecodes): (JSC::Profiler::Bytecodes::indexForBytecodeIndex): (JSC::Profiler::Bytecodes::forBytecodeIndex): (JSC::Profiler::Bytecodes::dump): (JSC::Profiler::Bytecodes::toJS): * profiler/ProfilerBytecodes.h: Added. (Profiler): (Bytecodes): (JSC::Profiler::Bytecodes::append): (JSC::Profiler::Bytecodes::id): (JSC::Profiler::Bytecodes::hash): (JSC::Profiler::Bytecodes::size): (JSC::Profiler::Bytecodes::at): * profiler/ProfilerCompilation.cpp: Added. (Profiler): (JSC::Profiler::Compilation::Compilation): (JSC::Profiler::Compilation::~Compilation): (JSC::Profiler::Compilation::addDescription): (JSC::Profiler::Compilation::executionCounterFor): (JSC::Profiler::Compilation::toJS): * profiler/ProfilerCompilation.h: Added. (Profiler): (Compilation): (JSC::Profiler::Compilation::bytecodes): (JSC::Profiler::Compilation::kind): * profiler/ProfilerCompilationKind.cpp: Added. (WTF): (WTF::printInternal): * profiler/ProfilerCompilationKind.h: Added. (Profiler): (WTF): * profiler/ProfilerCompiledBytecode.cpp: Added. (Profiler): (JSC::Profiler::CompiledBytecode::CompiledBytecode): (JSC::Profiler::CompiledBytecode::~CompiledBytecode): (JSC::Profiler::CompiledBytecode::toJS): * profiler/ProfilerCompiledBytecode.h: Added. (Profiler): (CompiledBytecode): (JSC::Profiler::CompiledBytecode::originStack): (JSC::Profiler::CompiledBytecode::description): * profiler/ProfilerDatabase.cpp: Added. (Profiler): (JSC::Profiler::Database::Database): (JSC::Profiler::Database::~Database): (JSC::Profiler::Database::addBytecodes): (JSC::Profiler::Database::ensureBytecodesFor): (JSC::Profiler::Database::notifyDestruction): (JSC::Profiler::Database::newCompilation): (JSC::Profiler::Database::toJS): (JSC::Profiler::Database::toJSON): (JSC::Profiler::Database::save): * profiler/ProfilerDatabase.h: Added. (Profiler): (Database): * profiler/ProfilerExecutionCounter.h: Added. (Profiler): (ExecutionCounter): (JSC::Profiler::ExecutionCounter::ExecutionCounter): (JSC::Profiler::ExecutionCounter::address): (JSC::Profiler::ExecutionCounter::count): * profiler/ProfilerOrigin.cpp: Added. (Profiler): (JSC::Profiler::Origin::Origin): (JSC::Profiler::Origin::dump): (JSC::Profiler::Origin::toJS): * profiler/ProfilerOrigin.h: Added. (JSC): (Profiler): (Origin): (JSC::Profiler::Origin::Origin): (JSC::Profiler::Origin::operator!): (JSC::Profiler::Origin::bytecodes): (JSC::Profiler::Origin::bytecodeIndex): (JSC::Profiler::Origin::operator!=): (JSC::Profiler::Origin::operator==): (JSC::Profiler::Origin::hash): (JSC::Profiler::Origin::isHashTableDeletedValue): (JSC::Profiler::OriginHash::hash): (JSC::Profiler::OriginHash::equal): (OriginHash): (WTF): * profiler/ProfilerOriginStack.cpp: Added. (Profiler): (JSC::Profiler::OriginStack::OriginStack): (JSC::Profiler::OriginStack::~OriginStack): (JSC::Profiler::OriginStack::append): (JSC::Profiler::OriginStack::operator==): (JSC::Profiler::OriginStack::hash): (JSC::Profiler::OriginStack::dump): (JSC::Profiler::OriginStack::toJS): * profiler/ProfilerOriginStack.h: Added. (JSC): (Profiler): (OriginStack): (JSC::Profiler::OriginStack::OriginStack): (JSC::Profiler::OriginStack::operator!): (JSC::Profiler::OriginStack::size): (JSC::Profiler::OriginStack::fromBottom): (JSC::Profiler::OriginStack::fromTop): (JSC::Profiler::OriginStack::isHashTableDeletedValue): (JSC::Profiler::OriginStackHash::hash): (JSC::Profiler::OriginStackHash::equal): (OriginStackHash): (WTF): * runtime/CommonIdentifiers.h: * runtime/ExecutionHarness.h: (JSC::prepareForExecution): (JSC::prepareFunctionForExecution): * runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): (JSC::JSGlobalData::~JSGlobalData): * runtime/JSGlobalData.h: (JSGlobalData): * runtime/Options.h: (JSC): Source/WTF: Made some minor changes to support the new profiler. FileOutputStream now has an open() method, and DataLog uses it. StringPrintStream has a reset() method, which allows you to reuse the same StringPrintStream for creating multiple strings. SegmentedVector now has a const operator[]. And, WTFString now can do fromUTF8() on a CString directly. * wtf/DataLog.cpp: (WTF::initializeLogFileOnce): * wtf/FilePrintStream.cpp: (WTF::FilePrintStream::open): (WTF): * wtf/FilePrintStream.h: * wtf/SegmentedVector.h: (WTF::SegmentedVector::at): (SegmentedVector): (WTF::SegmentedVector::operator[]): * wtf/StringPrintStream.cpp: (WTF::StringPrintStream::reset): (WTF): * wtf/StringPrintStream.h: (StringPrintStream): * wtf/text/WTFString.cpp: (WTF::String::fromUTF8): (WTF): * wtf/text/WTFString.h: (String): Tools: Added a tool that allows you to grok the output from JSC's new profiler. Currently, this still gets confused a bit about the execution counts of a method running standalone versus a method running inlined, but other than that, it's pretty cool. See the attached "sampling profiling session" attached to the bug to see it in action. Also had to feed EFL's build system. * DumpRenderTree/efl/CMakeLists.txt: * Scripts/display-profiler-output: Added. Canonical link: https://commits.webkit.org/122183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-12-05 01:26:13 +00:00
Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
FILE* file() { return m_file; }
Fix existing usage of final/override/virtual in JSC and WTF https://bugs.webkit.org/show_bug.cgi?id=211772 Reviewed by Darin Adler. Source/JavaScriptCore: * API/JSAPIWrapperObject.mm: * API/JSManagedValue.mm: * API/JSScriptSourceProvider.h: * API/ObjCCallbackFunction.mm: * API/glib/JSAPIWrapperGlobalObject.cpp: * API/glib/JSAPIWrapperObjectGLib.cpp: * API/glib/JSCWeakValue.cpp: * bytecode/AccessCaseSnippetParams.cpp: * bytecode/AccessCaseSnippetParams.h: * bytecode/CodeBlock.cpp: * bytecode/StructureStubClearingWatchpoint.h: * bytecode/VariableWriteFireDetail.h: * bytecode/Watchpoint.h: * dfg/DFGAdaptiveInferredPropertyValueWatchpoint.h: * dfg/DFGArrayifySlowPathGenerator.h: * dfg/DFGCallArrayAllocatorSlowPathGenerator.h: * dfg/DFGCallCreateDirectArgumentsSlowPathGenerator.h: * dfg/DFGSaneStringGetByValSlowPathGenerator.h: * dfg/DFGSlowPathGenerator.h: * dfg/DFGSnippetParams.h: * dfg/DFGWorklist.cpp: * ftl/FTLSnippetParams.h: * heap/BlockDirectory.cpp: * heap/EdenGCActivityCallback.h: * heap/FullGCActivityCallback.h: * heap/Heap.cpp: * heap/Heap.h: * heap/IncrementalSweeper.h: * heap/IsoCellSet.cpp: * heap/IsoCellSetInlines.h: * heap/IsoHeapCellType.h: * heap/IsoInlinedHeapCellType.h: * heap/ParallelSourceAdapter.h: * heap/StopIfNecessaryTimer.h: * heap/Subspace.cpp: * heap/SubspaceInlines.h: * inspector/InjectedScript.h: * inspector/JSGlobalObjectConsoleClient.h: * inspector/JSGlobalObjectInspectorController.h: * inspector/JSGlobalObjectScriptDebugServer.h: * inspector/JSInjectedScriptHost.cpp: * inspector/agents/InspectorAgent.h: * inspector/agents/InspectorScriptProfilerAgent.h: * inspector/agents/InspectorTargetAgent.h: * inspector/agents/JSGlobalObjectAuditAgent.h: * inspector/agents/JSGlobalObjectDebuggerAgent.h: * inspector/agents/JSGlobalObjectRuntimeAgent.h: * inspector/augmentable/AlternateDispatchableAgent.h: * inspector/remote/RemoteConnectionToTarget.h: * inspector/remote/RemoteInspector.h: * inspector/remote/socket/RemoteInspectorServer.h: * inspector/scripts/codegen/cpp_generator_templates.py: * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py: * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result: * inspector/scripts/tests/generic/expected/command-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/generic/expected/domain-debuggableTypes.json-result: * inspector/scripts/tests/generic/expected/domain-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/domain-targetTypes.json-result: * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result: * inspector/scripts/tests/generic/expected/enum-values.json-result: * inspector/scripts/tests/generic/expected/event-targetType-matching-domain-debuggableType.json-result: * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result: * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result: * jit/JITWorklist.cpp: * parser/Nodes.h: * parser/SourceProvider.h: * runtime/DataView.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/FileBasedFuzzerAgent.h: * runtime/GenericTypedArrayView.h: * runtime/JSMicrotask.cpp: * runtime/NarrowingNumberPredictionFuzzerAgent.h: * runtime/ObjectPropertyChangeAdaptiveWatchpoint.h: * runtime/PredictionFileCreatingFuzzerAgent.h: * runtime/PromiseTimer.h: * runtime/RandomizingFuzzerAgent.h: * runtime/RegExpCache.h: * runtime/Structure.cpp: * runtime/StructureRareData.cpp: * runtime/VMTraps.cpp: * runtime/WideningNumberPredictionFuzzerAgent.h: * tools/JSDollarVM.cpp: * wasm/WasmBBQPlan.h: * wasm/WasmCallee.h: * wasm/WasmLLIntPlan.h: * wasm/WasmOMGForOSREntryPlan.h: * wasm/WasmOMGPlan.h: * wasm/WasmWorklist.cpp: * yarr/YarrJIT.cpp: Source/WTF: * wtf/Assertions.cpp: * wtf/Expected.h: * wtf/FilePrintStream.h: * wtf/JSONValues.h: * wtf/LockedPrintStream.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: * wtf/RunLoop.h: * wtf/SharedTask.h: * wtf/StringPrintStream.h: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: Canonical link: https://commits.webkit.org/224683@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 19:13:18 +00:00
void vprintf(const char* format, va_list) final WTF_ATTRIBUTE_PRINTF(2, 0);
void flush() final;
Any function that can log things should be able to easily log them to a memory buffer as well https://bugs.webkit.org/show_bug.cgi?id=103000 Reviewed by Sam Weinig. Source/JavaScriptCore: Change all users of WTF::dataFile() to expect a PrintStream& rather than a FILE*. * bytecode/Operands.h: (JSC::OperandValueTraits::dump): (JSC::dumpOperands): (JSC): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::dump): * dfg/DFGAbstractState.h: (AbstractState): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::dump): * dfg/DFGCommon.h: (JSC::DFG::NodeIndexTraits::dump): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dump): * dfg/DFGVariableEvent.cpp: (JSC::DFG::VariableEvent::dump): (JSC::DFG::VariableEvent::dumpFillInfo): (JSC::DFG::VariableEvent::dumpSpillInfo): * dfg/DFGVariableEvent.h: (VariableEvent): * disassembler/Disassembler.h: (JSC): (JSC::tryToDisassemble): * disassembler/UDis86Disassembler.cpp: (JSC::tryToDisassemble): Source/WTF: We have a number of places where we pass around a FILE* as a target to which to print some logging information. But the purpose of passing FILE* instead of always assuming that we should dump to stderr is that it may be sometimes useful to send the logging information elsewhere. Unfortunately, FILE* isn't quite powerful enough: it's combersome to use it to send logging to a string, for example. We could get around this by using <iostream> and <sstream>, but so far this aspect of C++ has not been part of the WebKit coding conventions. Personally I find <iostream> awkward due to its abuse of operator overloading. So this patch introduces the PrintStream abstract class, which offers printf-like functionality while completely abstracting the destination and mechanism of the printing output. It would be trivial to implement a StringPrintStream, for example. This will feed into work on https://bugs.webkit.org/show_bug.cgi?id=102999. This also sets us up for creating templatized print() and println() methods that will allow us to say things like out.print("count = ", count, "\n"), but that is the topic of https://bugs.webkit.org/show_bug.cgi?id=103009. This patch also changes dataLog() to use FilePrintStream internally, and WTF::dataFile() now returns a FilePrintStream&. Any previous users of WTF::dataFile() have been changed to expect a PrintStream&. * GNUmakefile.list.am: * WTF.pro: * WTF.vcproj/WTF.vcproj: * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DataLog.cpp: (WTF): (WTF::initializeLogFileOnce): (WTF::initializeLogFile): (WTF::dataFile): (WTF::dataLogV): (WTF::dataLogString): * wtf/DataLog.h: (WTF): * wtf/FilePrintStream.cpp: Added. (WTF): (WTF::FilePrintStream::FilePrintStream): (WTF::FilePrintStream::~FilePrintStream): (WTF::FilePrintStream::vprintf): (WTF::FilePrintStream::flush): * wtf/FilePrintStream.h: Added. (WTF): (FilePrintStream): (WTF::FilePrintStream::file): * wtf/PrintStream.cpp: Added. (WTF): (WTF::PrintStream::PrintStream): (WTF::PrintStream::~PrintStream): (WTF::PrintStream::printf): (WTF::PrintStream::print): (WTF::PrintStream::println): (WTF::PrintStream::flush): (WTF::print): * wtf/PrintStream.h: Added. (WTF): (PrintStream): (WTF::print): (WTF::println): Canonical link: https://commits.webkit.org/121301@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-24 03:16:47 +00:00
private:
FILE* m_file;
AdoptionMode m_adoptionMode;
};
} // namespace WTF
using WTF::FilePrintStream;