haikuwebkit/Source/WTF/wtf/StringHashDumpContext.h

119 lines
4.0 KiB
C
Raw Permalink Normal View History

fourthTier: DFG IR dumps should be easier to read https://bugs.webkit.org/show_bug.cgi?id=119050 Source/JavaScriptCore: Reviewed by Mark Hahnenberg. Added a DumpContext that includes support for printing an endnote that describes all structures in full, while the main flow of the dump just uses made-up names for the structures. This is helpful since Structure::dump() may print a lot. The stuff it prints is useful, but if it's all inline with the surrounding thing you're dumping (often, a node in the DFG), then you get a ridiculously long print-out. All classes that dump structures (including Structure itself) now have dumpInContext() methods that use inContext() for dumping anything that might transitively print a structure. If Structure::dumpInContext() is called with a NULL context, it just uses dump() like before. Hence you don't have to know anything about DumpContext unless you want to. inContext(*structure, context) dumps something like %B4:Array, and the endnote will have something like: %B4:Array = 0x10e91a180:[Array, {Edge:100, Normal:101, Line:102, NumPx:103, LastPx:104}, ArrayWithContiguous, Proto:0x10e99ffe0] where B4 is the inferred name that StringHashDumpContext came up with. Also shortened a bunch of other dumps, removing information that isn't so important. * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/ArrayProfile.cpp: (JSC::dumpArrayModes): * bytecode/CodeBlockHash.cpp: (JSC): (JSC::CodeBlockHash::CodeBlockHash): (JSC::CodeBlockHash::dump): * bytecode/CodeOrigin.cpp: (JSC::CodeOrigin::dumpInContext): (JSC): (JSC::InlineCallFrame::dumpInContext): (JSC::InlineCallFrame::dump): * bytecode/CodeOrigin.h: (CodeOrigin): (InlineCallFrame): * bytecode/Operands.h: (JSC::OperandValueTraits::isEmptyForDump): (Operands): (JSC::Operands::dump): (JSC): * bytecode/OperandsInlines.h: Added. (JSC): (JSC::::dumpInContext): * bytecode/StructureSet.h: (JSC::StructureSet::dumpInContext): (JSC::StructureSet::dump): (StructureSet): * dfg/DFGAbstractValue.cpp: (JSC::DFG::AbstractValue::dump): (DFG): (JSC::DFG::AbstractValue::dumpInContext): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::operator!): (AbstractValue): * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::performBlockCFA): * dfg/DFGCommon.cpp: * dfg/DFGCommon.h: (JSC::DFG::NodePointerTraits::isEmptyForDump): * dfg/DFGDisassembler.cpp: (JSC::DFG::Disassembler::createDumpList): * dfg/DFGDisassembler.h: (Disassembler): * dfg/DFGFlushFormat.h: (WTF::inContext): (WTF): * dfg/DFGFlushLivenessAnalysisPhase.cpp: * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dumpCodeOrigin): (JSC::DFG::Graph::dump): (JSC::DFG::Graph::dumpBlockHeader): * dfg/DFGGraph.h: (Graph): * dfg/DFGLazyJSValue.cpp: (JSC::DFG::LazyJSValue::dumpInContext): (JSC::DFG::LazyJSValue::dump): (DFG): * dfg/DFGLazyJSValue.h: (LazyJSValue): * dfg/DFGNode.h: (JSC::DFG::nodeMapDump): (WTF::inContext): (WTF): * dfg/DFGOSRExitCompiler32_64.cpp: (JSC::DFG::OSRExitCompiler::compileExit): * dfg/DFGOSRExitCompiler64.cpp: (JSC::DFG::OSRExitCompiler::compileExit): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dumpInContext): (JSC::DFG::StructureAbstractValue::dump): (StructureAbstractValue): * ftl/FTLExitValue.cpp: (JSC::FTL::ExitValue::dumpInContext): (JSC::FTL::ExitValue::dump): (FTL): * ftl/FTLExitValue.h: (ExitValue): * ftl/FTLLowerDFGToLLVM.cpp: * ftl/FTLValueSource.cpp: (JSC::FTL::ValueSource::dumpInContext): (FTL): * ftl/FTLValueSource.h: (ValueSource): * runtime/DumpContext.cpp: Added. (JSC): (JSC::DumpContext::DumpContext): (JSC::DumpContext::~DumpContext): (JSC::DumpContext::isEmpty): (JSC::DumpContext::dump): * runtime/DumpContext.h: Added. (JSC): (DumpContext): * runtime/JSCJSValue.cpp: (JSC::JSValue::dump): (JSC): (JSC::JSValue::dumpInContext): * runtime/JSCJSValue.h: (JSC): (JSValue): * runtime/Structure.cpp: (JSC::Structure::dumpInContext): (JSC): (JSC::Structure::dumpBrief): (JSC::Structure::dumpContextHeader): * runtime/Structure.h: (JSC): (Structure): Source/WTF: Reviewed by Mark Hahnenberg. Added support for dumping values within a context. By default, if you say print(inContext(value, context)) it calls value.dumpInContext(out, context) instead of value.dump(out). Hoisted the support for six-character hashes out of JSC::CodeBlockHash into WTF, in the form of SixCharacterHash.h. Added a helper for creating dump contexts where the inContext() dump will just use a short string hash to "name" the object being dumped, and then will print out the full dumps in an endnote to your dump. Added support for using CString as a hashtable key. * WTF.xcodeproj/project.pbxproj: * wtf/PrintStream.h: (WTF): (ValueInContext): (WTF::ValueInContext::ValueInContext): (WTF::ValueInContext::dump): (WTF::inContext): * wtf/SixCharacterHash.cpp: Added. (WTF): (WTF::sixCharacterHashStringToInteger): (WTF::integerToSixCharacterHashString): * wtf/SixCharacterHash.h: Added. (WTF): * wtf/StringHashDumpContext.h: Added. (WTF): (StringHashDumpContext): (WTF::StringHashDumpContext::StringHashDumpContext): (WTF::StringHashDumpContext::getID): (WTF::StringHashDumpContext::dumpBrief): (WTF::StringHashDumpContext::brief): (WTF::StringHashDumpContext::isEmpty): (WTF::StringHashDumpContext::dump): * wtf/text/CString.cpp: (WTF::CString::hash): (WTF): (WTF::operator<): (WTF::CStringHash::equal): * wtf/text/CString.h: (WTF::CString::CString): (CString): (WTF::CString::isHashTableDeletedValue): (WTF): (WTF::CStringHash::hash): (CStringHash): Canonical link: https://commits.webkit.org/137080@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-07-25 04:05:36 +00:00
/*
* Copyright (C) 2013 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
fourthTier: DFG IR dumps should be easier to read https://bugs.webkit.org/show_bug.cgi?id=119050 Source/JavaScriptCore: Reviewed by Mark Hahnenberg. Added a DumpContext that includes support for printing an endnote that describes all structures in full, while the main flow of the dump just uses made-up names for the structures. This is helpful since Structure::dump() may print a lot. The stuff it prints is useful, but if it's all inline with the surrounding thing you're dumping (often, a node in the DFG), then you get a ridiculously long print-out. All classes that dump structures (including Structure itself) now have dumpInContext() methods that use inContext() for dumping anything that might transitively print a structure. If Structure::dumpInContext() is called with a NULL context, it just uses dump() like before. Hence you don't have to know anything about DumpContext unless you want to. inContext(*structure, context) dumps something like %B4:Array, and the endnote will have something like: %B4:Array = 0x10e91a180:[Array, {Edge:100, Normal:101, Line:102, NumPx:103, LastPx:104}, ArrayWithContiguous, Proto:0x10e99ffe0] where B4 is the inferred name that StringHashDumpContext came up with. Also shortened a bunch of other dumps, removing information that isn't so important. * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/ArrayProfile.cpp: (JSC::dumpArrayModes): * bytecode/CodeBlockHash.cpp: (JSC): (JSC::CodeBlockHash::CodeBlockHash): (JSC::CodeBlockHash::dump): * bytecode/CodeOrigin.cpp: (JSC::CodeOrigin::dumpInContext): (JSC): (JSC::InlineCallFrame::dumpInContext): (JSC::InlineCallFrame::dump): * bytecode/CodeOrigin.h: (CodeOrigin): (InlineCallFrame): * bytecode/Operands.h: (JSC::OperandValueTraits::isEmptyForDump): (Operands): (JSC::Operands::dump): (JSC): * bytecode/OperandsInlines.h: Added. (JSC): (JSC::::dumpInContext): * bytecode/StructureSet.h: (JSC::StructureSet::dumpInContext): (JSC::StructureSet::dump): (StructureSet): * dfg/DFGAbstractValue.cpp: (JSC::DFG::AbstractValue::dump): (DFG): (JSC::DFG::AbstractValue::dumpInContext): * dfg/DFGAbstractValue.h: (JSC::DFG::AbstractValue::operator!): (AbstractValue): * dfg/DFGCFAPhase.cpp: (JSC::DFG::CFAPhase::performBlockCFA): * dfg/DFGCommon.cpp: * dfg/DFGCommon.h: (JSC::DFG::NodePointerTraits::isEmptyForDump): * dfg/DFGDisassembler.cpp: (JSC::DFG::Disassembler::createDumpList): * dfg/DFGDisassembler.h: (Disassembler): * dfg/DFGFlushFormat.h: (WTF::inContext): (WTF): * dfg/DFGFlushLivenessAnalysisPhase.cpp: * dfg/DFGGraph.cpp: (JSC::DFG::Graph::dumpCodeOrigin): (JSC::DFG::Graph::dump): (JSC::DFG::Graph::dumpBlockHeader): * dfg/DFGGraph.h: (Graph): * dfg/DFGLazyJSValue.cpp: (JSC::DFG::LazyJSValue::dumpInContext): (JSC::DFG::LazyJSValue::dump): (DFG): * dfg/DFGLazyJSValue.h: (LazyJSValue): * dfg/DFGNode.h: (JSC::DFG::nodeMapDump): (WTF::inContext): (WTF): * dfg/DFGOSRExitCompiler32_64.cpp: (JSC::DFG::OSRExitCompiler::compileExit): * dfg/DFGOSRExitCompiler64.cpp: (JSC::DFG::OSRExitCompiler::compileExit): * dfg/DFGStructureAbstractValue.h: (JSC::DFG::StructureAbstractValue::dumpInContext): (JSC::DFG::StructureAbstractValue::dump): (StructureAbstractValue): * ftl/FTLExitValue.cpp: (JSC::FTL::ExitValue::dumpInContext): (JSC::FTL::ExitValue::dump): (FTL): * ftl/FTLExitValue.h: (ExitValue): * ftl/FTLLowerDFGToLLVM.cpp: * ftl/FTLValueSource.cpp: (JSC::FTL::ValueSource::dumpInContext): (FTL): * ftl/FTLValueSource.h: (ValueSource): * runtime/DumpContext.cpp: Added. (JSC): (JSC::DumpContext::DumpContext): (JSC::DumpContext::~DumpContext): (JSC::DumpContext::isEmpty): (JSC::DumpContext::dump): * runtime/DumpContext.h: Added. (JSC): (DumpContext): * runtime/JSCJSValue.cpp: (JSC::JSValue::dump): (JSC): (JSC::JSValue::dumpInContext): * runtime/JSCJSValue.h: (JSC): (JSValue): * runtime/Structure.cpp: (JSC::Structure::dumpInContext): (JSC): (JSC::Structure::dumpBrief): (JSC::Structure::dumpContextHeader): * runtime/Structure.h: (JSC): (Structure): Source/WTF: Reviewed by Mark Hahnenberg. Added support for dumping values within a context. By default, if you say print(inContext(value, context)) it calls value.dumpInContext(out, context) instead of value.dump(out). Hoisted the support for six-character hashes out of JSC::CodeBlockHash into WTF, in the form of SixCharacterHash.h. Added a helper for creating dump contexts where the inContext() dump will just use a short string hash to "name" the object being dumped, and then will print out the full dumps in an endnote to your dump. Added support for using CString as a hashtable key. * WTF.xcodeproj/project.pbxproj: * wtf/PrintStream.h: (WTF): (ValueInContext): (WTF::ValueInContext::ValueInContext): (WTF::ValueInContext::dump): (WTF::inContext): * wtf/SixCharacterHash.cpp: Added. (WTF): (WTF::sixCharacterHashStringToInteger): (WTF::integerToSixCharacterHashString): * wtf/SixCharacterHash.h: Added. (WTF): * wtf/StringHashDumpContext.h: Added. (WTF): (StringHashDumpContext): (WTF::StringHashDumpContext::StringHashDumpContext): (WTF::StringHashDumpContext::getID): (WTF::StringHashDumpContext::dumpBrief): (WTF::StringHashDumpContext::brief): (WTF::StringHashDumpContext::isEmpty): (WTF::StringHashDumpContext::dump): * wtf/text/CString.cpp: (WTF::CString::hash): (WTF): (WTF::operator<): (WTF::CStringHash::equal): * wtf/text/CString.h: (WTF::CString::CString): (CString): (WTF::CString::isHashTableDeletedValue): (WTF): (WTF::CStringHash::hash): (CStringHash): Canonical link: https://commits.webkit.org/137080@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-07-25 04:05:36 +00:00
#include <wtf/HashMap.h>
#include <wtf/SixCharacterHash.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringPrintStream.h>
#include <wtf/text/CString.h>
namespace WTF {
template<typename T>
class StringHashDumpContext {
public:
StringHashDumpContext() { }
CString getID(const T* value)
{
typename HashMap<const T*, CString>::iterator iter = m_forwardMap.find(value);
if (iter != m_forwardMap.end())
return iter->value;
for (unsigned hashValue = toCString(*value).hash(); ; hashValue++) {
CString fullHash = integerToSixCharacterHashString(hashValue).data();
for (unsigned length = 2; length < 6; ++length) {
CString shortHash = CString(fullHash.data(), length);
if (!m_backwardMap.contains(shortHash)) {
m_forwardMap.add(value, shortHash);
m_backwardMap.add(shortHash, value);
return shortHash;
}
}
}
}
void dumpBrief(const T* value, PrintStream& out)
{
value->dumpBrief(out, getID(value));
}
CString brief(const T* value)
{
StringPrintStream out;
dumpBrief(value, out);
return out.toCString();
}
bool isEmpty() const { return m_forwardMap.isEmpty(); }
void dump(PrintStream& out, const char* prefix = "") const
{
out.print(prefix);
T::dumpContextHeader(out);
out.print("\n");
Vector<CString> keys;
unsigned maxKeySize = 0;
for (
typename HashMap<CString, const T*>::const_iterator iter = m_backwardMap.begin();
iter != m_backwardMap.end();
++iter) {
keys.append(iter->key);
maxKeySize = std::max(maxKeySize, static_cast<unsigned>(brief(iter->value, iter->key).length()));
}
std::sort(keys.begin(), keys.end());
for (unsigned i = 0; i < keys.size(); ++i) {
const T* value = m_backwardMap.get(keys[i]);
out.print(prefix, " ");
CString briefString = brief(value, keys[i]);
out.print(briefString);
for (unsigned n = briefString.length(); n < maxKeySize; ++n)
out.print(" ");
out.print(" = ", *value, "\n");
}
}
public:
static CString brief(const T* value, const CString& string)
{
StringPrintStream out;
value->dumpBrief(out, string);
return out.toCString();
}
HashMap<const T*, CString> m_forwardMap;
HashMap<CString, const T*> m_backwardMap;
};
} // namespace WTF
using WTF::StringHashDumpContext;