haikuwebkit/Source/WTF/wtf/RangeSet.h

215 lines
6.7 KiB
C
Raw Permalink Normal View History

B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
/*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
#include <wtf/ListDump.h>
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
namespace WTF {
// A RangeSet is a set of numerical ranges. A value belongs to the set if it is within any of the
// ranges. A range belongs to the set if every value in the range belongs to the set. A range overlaps
// the set if any value in the range belongs to the set. You can add ranges and query range
// membership. The internal representation is a list of ranges that gets periodically compacted. This
// representation is optimal so long as the number of distinct ranges tends to be small, and the
// number of range sets tends to be small as well. This works reasonably well in a bunch of compiler
// algorithms, where the top range ends up being used a lot.
//
// The initial user of this is JSC::B3::HeapRange, which is used to perform alias analysis. You can
// model new users on that class. Basically, you need to define:
//
// T::Type - the type of the members of the range. HeapRange uses unsigned.
// T(T::Type begin, T::Type end) - construct a new range.
// T::Type T::begin() const - instance method giving the inclusive beginning of the range.
// T::Type T::end() const - instance method giving the exclusive end of the range.
// void T::dump(PrintStream&) const - some kind of dumping.
template<typename RangeType>
[WTF][JSC] Make JSC and WTF aggressively-fast-malloced https://bugs.webkit.org/show_bug.cgi?id=200611 Reviewed by Saam Barati. Source/JavaScriptCore: This patch aggressively puts many classes into FastMalloc. In JSC side, we grep `std::make_unique` etc. to find potentially system-malloc-allocated classes. After this patch, all the JSC related allocations in JetStream2 cli is done from bmalloc. In the future, it would be nice that we add `WTF::makeUnique<T>` helper function and throw a compile error if `T` is not FastMalloc annotated[1]. Putting WebKit classes in FastMalloc has many benefits. 1. Simply, it is fast. 2. vmmap can tell the amount of memory used for WebKit. 3. bmalloc can isolate WebKit memory allocation from the rest of the world. This is useful since we can know more about what component is corrupting the memory from the memory corruption crash. [1]: https://bugs.webkit.org/show_bug.cgi?id=200620 * API/ObjCCallbackFunction.mm: * assembler/AbstractMacroAssembler.h: * b3/B3PhiChildren.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirDisassembler.h: * bytecode/AccessCaseSnippetParams.h: * bytecode/CallVariant.h: * bytecode/DeferredSourceDump.h: * bytecode/ExecutionCounter.h: * bytecode/GetByIdStatus.h: * bytecode/GetByIdVariant.h: * bytecode/InByIdStatus.h: * bytecode/InByIdVariant.h: * bytecode/InstanceOfStatus.h: * bytecode/InstanceOfVariant.h: * bytecode/PutByIdStatus.h: * bytecode/PutByIdVariant.h: * bytecode/ValueProfile.h: * dfg/DFGAbstractInterpreter.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::newVariableAccessData): * dfg/DFGFlowIndexing.h: * dfg/DFGFlowMap.h: * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMaximalFlushInsertionPhase.cpp: (JSC::DFG::MaximalFlushInsertionPhase::newVariableAccessData): * dfg/DFGOSRExit.h: * dfg/DFGSpeculativeJIT.h: * dfg/DFGVariableAccessData.h: * disassembler/ARM64/A64DOpcode.h: * inspector/remote/socket/RemoteInspectorMessageParser.h: * inspector/remote/socket/RemoteInspectorSocket.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/PCToCodeOriginMap.h: * runtime/BasicBlockLocation.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/JSRunLoopTimer.h: * runtime/PromiseDeferredTimer.h: (JSC::PromiseDeferredTimer::create): PromiseDeferredTimer should be allocated as `Ref<>` instead of `std::unique_ptr` since it is inheriting ThreadSafeRefCounted<>. Holding such a class with std::unique_ptr could lead to potentially dangerous operations (like, someone holds it with Ref<> while it is deleted by std::unique_ptr<>). * runtime/RandomizingFuzzerAgent.h: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: * tools/SigillCrashAnalyzer.cpp: * wasm/WasmFormat.h: * wasm/WasmMemory.cpp: * wasm/WasmSignature.h: * yarr/YarrJIT.h: Source/WebCore: Changed the accessor since we changed std::unique_ptr to Ref for this field. No behavior change. * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::addTimerSetNotification): (WebCore::WorkerScriptController::removeTimerSetNotification): Source/WTF: WTF has many data structures, in particular, containers. And these containers can be allocated like `std::make_unique<Container>()`. Without WTF_MAKE_FAST_ALLOCATED, this container itself is allocated from the system malloc. This patch attaches WTF_MAKE_FAST_ALLOCATED more aggressively not to allocate them from the system malloc. And we add some `final` to containers and classes that would be never inherited. * wtf/Assertions.cpp: * wtf/Atomics.h: * wtf/AutodrainedPool.h: * wtf/Bag.h: (WTF::Bag::Bag): Deleted. (WTF::Bag::~Bag): Deleted. (WTF::Bag::clear): Deleted. (WTF::Bag::add): Deleted. (WTF::Bag::iterator::iterator): Deleted. (WTF::Bag::iterator::operator! const): Deleted. (WTF::Bag::iterator::operator* const): Deleted. (WTF::Bag::iterator::operator++): Deleted. (WTF::Bag::iterator::operator== const): Deleted. (WTF::Bag::iterator::operator!= const): Deleted. (WTF::Bag::begin): Deleted. (WTF::Bag::begin const): Deleted. (WTF::Bag::end const): Deleted. (WTF::Bag::isEmpty const): Deleted. (WTF::Bag::unwrappedHead const): Deleted. * wtf/BitVector.h: (WTF::BitVector::BitVector): Deleted. (WTF::BitVector::~BitVector): Deleted. (WTF::BitVector::operator=): Deleted. (WTF::BitVector::size const): Deleted. (WTF::BitVector::ensureSize): Deleted. (WTF::BitVector::quickGet const): Deleted. (WTF::BitVector::quickSet): Deleted. (WTF::BitVector::quickClear): Deleted. (WTF::BitVector::get const): Deleted. (WTF::BitVector::contains const): Deleted. (WTF::BitVector::set): Deleted. (WTF::BitVector::add): Deleted. (WTF::BitVector::ensureSizeAndSet): Deleted. (WTF::BitVector::clear): Deleted. (WTF::BitVector::remove): Deleted. (WTF::BitVector::merge): Deleted. (WTF::BitVector::filter): Deleted. (WTF::BitVector::exclude): Deleted. (WTF::BitVector::bitCount const): Deleted. (WTF::BitVector::isEmpty const): Deleted. (WTF::BitVector::findBit const): Deleted. (WTF::BitVector::isEmptyValue const): Deleted. (WTF::BitVector::isDeletedValue const): Deleted. (WTF::BitVector::isEmptyOrDeletedValue const): Deleted. (WTF::BitVector::operator== const): Deleted. (WTF::BitVector::hash const): Deleted. (WTF::BitVector::iterator::iterator): Deleted. (WTF::BitVector::iterator::operator* const): Deleted. (WTF::BitVector::iterator::operator++): Deleted. (WTF::BitVector::iterator::isAtEnd const): Deleted. (WTF::BitVector::iterator::operator== const): Deleted. (WTF::BitVector::iterator::operator!= const): Deleted. (WTF::BitVector::begin const): Deleted. (WTF::BitVector::end const): Deleted. (WTF::BitVector::bitsInPointer): Deleted. (WTF::BitVector::maxInlineBits): Deleted. (WTF::BitVector::byteCount): Deleted. (WTF::BitVector::makeInlineBits): Deleted. (WTF::BitVector::cleanseInlineBits): Deleted. (WTF::BitVector::bitCount): Deleted. (WTF::BitVector::findBitFast const): Deleted. (WTF::BitVector::findBitSimple const): Deleted. (WTF::BitVector::OutOfLineBits::numBits const): Deleted. (WTF::BitVector::OutOfLineBits::numWords const): Deleted. (WTF::BitVector::OutOfLineBits::bits): Deleted. (WTF::BitVector::OutOfLineBits::bits const): Deleted. (WTF::BitVector::OutOfLineBits::OutOfLineBits): Deleted. (WTF::BitVector::isInline const): Deleted. (WTF::BitVector::outOfLineBits const): Deleted. (WTF::BitVector::outOfLineBits): Deleted. (WTF::BitVector::bits): Deleted. (WTF::BitVector::bits const): Deleted. * wtf/Bitmap.h: (WTF::Bitmap::size): Deleted. (WTF::Bitmap::iterator::iterator): Deleted. (WTF::Bitmap::iterator::operator* const): Deleted. (WTF::Bitmap::iterator::operator++): Deleted. (WTF::Bitmap::iterator::operator== const): Deleted. (WTF::Bitmap::iterator::operator!= const): Deleted. (WTF::Bitmap::begin const): Deleted. (WTF::Bitmap::end const): Deleted. * wtf/Box.h: * wtf/BumpPointerAllocator.h: * wtf/CPUTime.h: * wtf/CheckedBoolean.h: * wtf/CommaPrinter.h: (WTF::CommaPrinter::CommaPrinter): Deleted. (WTF::CommaPrinter::dump const): Deleted. (WTF::CommaPrinter::didPrint const): Deleted. * wtf/CompactPointerTuple.h: (WTF::CompactPointerTuple::encodeType): Deleted. (WTF::CompactPointerTuple::decodeType): Deleted. (WTF::CompactPointerTuple::CompactPointerTuple): Deleted. (WTF::CompactPointerTuple::pointer const): Deleted. (WTF::CompactPointerTuple::setPointer): Deleted. (WTF::CompactPointerTuple::type const): Deleted. (WTF::CompactPointerTuple::setType): Deleted. * wtf/CompilationThread.h: (WTF::CompilationScope::CompilationScope): Deleted. (WTF::CompilationScope::~CompilationScope): Deleted. (WTF::CompilationScope::leaveEarly): Deleted. * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): (WTF::Detail::CallableWrapper<CompletionHandler<Out): (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::CompletionHandler<void): Deleted. * wtf/ConcurrentBuffer.h: (WTF::ConcurrentBuffer::ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::~ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::growExact): Deleted. (WTF::ConcurrentBuffer::grow): Deleted. (WTF::ConcurrentBuffer::array const): Deleted. (WTF::ConcurrentBuffer::operator[]): Deleted. (WTF::ConcurrentBuffer::operator[] const): Deleted. (WTF::ConcurrentBuffer::createArray): Deleted. * wtf/ConcurrentPtrHashSet.h: (WTF::ConcurrentPtrHashSet::contains): Deleted. (WTF::ConcurrentPtrHashSet::add): Deleted. (WTF::ConcurrentPtrHashSet::size const): Deleted. (WTF::ConcurrentPtrHashSet::Table::maxLoad const): Deleted. (WTF::ConcurrentPtrHashSet::hash): Deleted. (WTF::ConcurrentPtrHashSet::cast): Deleted. (WTF::ConcurrentPtrHashSet::containsImpl const): Deleted. (WTF::ConcurrentPtrHashSet::addImpl): Deleted. * wtf/ConcurrentVector.h: (WTF::ConcurrentVector::~ConcurrentVector): Deleted. (WTF::ConcurrentVector::size const): Deleted. (WTF::ConcurrentVector::isEmpty const): Deleted. (WTF::ConcurrentVector::at): Deleted. (WTF::ConcurrentVector::at const): Deleted. (WTF::ConcurrentVector::operator[]): Deleted. (WTF::ConcurrentVector::operator[] const): Deleted. (WTF::ConcurrentVector::first): Deleted. (WTF::ConcurrentVector::first const): Deleted. (WTF::ConcurrentVector::last): Deleted. (WTF::ConcurrentVector::last const): Deleted. (WTF::ConcurrentVector::takeLast): Deleted. (WTF::ConcurrentVector::append): Deleted. (WTF::ConcurrentVector::alloc): Deleted. (WTF::ConcurrentVector::removeLast): Deleted. (WTF::ConcurrentVector::grow): Deleted. (WTF::ConcurrentVector::begin): Deleted. (WTF::ConcurrentVector::end): Deleted. (WTF::ConcurrentVector::segmentExistsFor): Deleted. (WTF::ConcurrentVector::segmentFor): Deleted. (WTF::ConcurrentVector::subscriptFor): Deleted. (WTF::ConcurrentVector::ensureSegmentsFor): Deleted. (WTF::ConcurrentVector::ensureSegment): Deleted. (WTF::ConcurrentVector::allocateSegment): Deleted. * wtf/Condition.h: (WTF::Condition::waitUntil): Deleted. (WTF::Condition::waitFor): Deleted. (WTF::Condition::wait): Deleted. (WTF::Condition::notifyOne): Deleted. (WTF::Condition::notifyAll): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::LockHooks::lockHook): Deleted. (WTF::CountingLock::LockHooks::unlockHook): Deleted. (WTF::CountingLock::LockHooks::parkHook): Deleted. (WTF::CountingLock::LockHooks::handoffHook): Deleted. (WTF::CountingLock::tryLock): Deleted. (WTF::CountingLock::lock): Deleted. (WTF::CountingLock::unlock): Deleted. (WTF::CountingLock::isHeld const): Deleted. (WTF::CountingLock::isLocked const): Deleted. (WTF::CountingLock::Count::operator bool const): Deleted. (WTF::CountingLock::Count::operator== const): Deleted. (WTF::CountingLock::Count::operator!= const): Deleted. (WTF::CountingLock::tryOptimisticRead): Deleted. (WTF::CountingLock::validate): Deleted. (WTF::CountingLock::doOptimizedRead): Deleted. (WTF::CountingLock::tryOptimisticFencelessRead): Deleted. (WTF::CountingLock::fencelessValidate): Deleted. (WTF::CountingLock::doOptimizedFencelessRead): Deleted. (WTF::CountingLock::getCount): Deleted. * wtf/CrossThreadQueue.h: * wtf/CrossThreadTask.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/DataMutex.h: * wtf/DateMath.h: * wtf/Deque.h: (WTF::Deque::size const): Deleted. (WTF::Deque::isEmpty const): Deleted. (WTF::Deque::begin): Deleted. (WTF::Deque::end): Deleted. (WTF::Deque::begin const): Deleted. (WTF::Deque::end const): Deleted. (WTF::Deque::rbegin): Deleted. (WTF::Deque::rend): Deleted. (WTF::Deque::rbegin const): Deleted. (WTF::Deque::rend const): Deleted. (WTF::Deque::first): Deleted. (WTF::Deque::first const): Deleted. (WTF::Deque::last): Deleted. (WTF::Deque::last const): Deleted. (WTF::Deque::append): Deleted. * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/Expected.h: * wtf/FastBitVector.h: * wtf/FileMetadata.h: * wtf/FileSystem.h: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.h: (WTF::GregorianDateTime::GregorianDateTime): Deleted. (WTF::GregorianDateTime::year const): Deleted. (WTF::GregorianDateTime::month const): Deleted. (WTF::GregorianDateTime::yearDay const): Deleted. (WTF::GregorianDateTime::monthDay const): Deleted. (WTF::GregorianDateTime::weekDay const): Deleted. (WTF::GregorianDateTime::hour const): Deleted. (WTF::GregorianDateTime::minute const): Deleted. (WTF::GregorianDateTime::second const): Deleted. (WTF::GregorianDateTime::utcOffset const): Deleted. (WTF::GregorianDateTime::isDST const): Deleted. (WTF::GregorianDateTime::setYear): Deleted. (WTF::GregorianDateTime::setMonth): Deleted. (WTF::GregorianDateTime::setYearDay): Deleted. (WTF::GregorianDateTime::setMonthDay): Deleted. (WTF::GregorianDateTime::setWeekDay): Deleted. (WTF::GregorianDateTime::setHour): Deleted. (WTF::GregorianDateTime::setMinute): Deleted. (WTF::GregorianDateTime::setSecond): Deleted. (WTF::GregorianDateTime::setUtcOffset): Deleted. (WTF::GregorianDateTime::setIsDST): Deleted. (WTF::GregorianDateTime::operator tm const): Deleted. (WTF::GregorianDateTime::copyFrom): Deleted. * wtf/HashTable.h: * wtf/Hasher.h: * wtf/HexNumber.h: * wtf/Indenter.h: * wtf/IndexMap.h: * wtf/IndexSet.h: * wtf/IndexSparseSet.h: * wtf/IndexedContainerIterator.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/KeyValuePair.h: * wtf/ListHashSet.h: (WTF::ListHashSet::begin): Deleted. (WTF::ListHashSet::end): Deleted. (WTF::ListHashSet::begin const): Deleted. (WTF::ListHashSet::end const): Deleted. (WTF::ListHashSet::random): Deleted. (WTF::ListHashSet::random const): Deleted. (WTF::ListHashSet::rbegin): Deleted. (WTF::ListHashSet::rend): Deleted. (WTF::ListHashSet::rbegin const): Deleted. (WTF::ListHashSet::rend const): Deleted. * wtf/Liveness.h: * wtf/LocklessBag.h: (WTF::LocklessBag::LocklessBag): Deleted. (WTF::LocklessBag::add): Deleted. (WTF::LocklessBag::iterate): Deleted. (WTF::LocklessBag::consumeAll): Deleted. (WTF::LocklessBag::consumeAllWithNode): Deleted. (WTF::LocklessBag::~LocklessBag): Deleted. * wtf/LoggingHashID.h: * wtf/MD5.h: * wtf/MachSendRight.h: * wtf/MainThreadData.h: * wtf/Markable.h: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.h: * wtf/MessageQueue.h: (WTF::MessageQueue::MessageQueue): Deleted. * wtf/MetaAllocator.h: * wtf/MonotonicTime.h: (WTF::MonotonicTime::MonotonicTime): Deleted. (WTF::MonotonicTime::fromRawSeconds): Deleted. (WTF::MonotonicTime::infinity): Deleted. (WTF::MonotonicTime::nan): Deleted. (WTF::MonotonicTime::secondsSinceEpoch const): Deleted. (WTF::MonotonicTime::approximateMonotonicTime const): Deleted. (WTF::MonotonicTime::operator bool const): Deleted. (WTF::MonotonicTime::operator+ const): Deleted. (WTF::MonotonicTime::operator- const): Deleted. (WTF::MonotonicTime::operator% const): Deleted. (WTF::MonotonicTime::operator+=): Deleted. (WTF::MonotonicTime::operator-=): Deleted. (WTF::MonotonicTime::operator== const): Deleted. (WTF::MonotonicTime::operator!= const): Deleted. (WTF::MonotonicTime::operator< const): Deleted. (WTF::MonotonicTime::operator> const): Deleted. (WTF::MonotonicTime::operator<= const): Deleted. (WTF::MonotonicTime::operator>= const): Deleted. (WTF::MonotonicTime::isolatedCopy const): Deleted. (WTF::MonotonicTime::encode const): Deleted. (WTF::MonotonicTime::decode): Deleted. * wtf/NaturalLoops.h: * wtf/NoLock.h: * wtf/OSAllocator.h: * wtf/OptionSet.h: * wtf/Optional.h: * wtf/OrderMaker.h: * wtf/Packed.h: (WTF::alignof): * wtf/PackedIntVector.h: (WTF::PackedIntVector::PackedIntVector): Deleted. (WTF::PackedIntVector::operator=): Deleted. (WTF::PackedIntVector::size const): Deleted. (WTF::PackedIntVector::ensureSize): Deleted. (WTF::PackedIntVector::resize): Deleted. (WTF::PackedIntVector::clearAll): Deleted. (WTF::PackedIntVector::get const): Deleted. (WTF::PackedIntVector::set): Deleted. (WTF::PackedIntVector::mask): Deleted. * wtf/PageBlock.h: * wtf/ParallelJobsOpenMP.h: * wtf/ParkingLot.h: * wtf/PriorityQueue.h: (WTF::PriorityQueue::size const): Deleted. (WTF::PriorityQueue::isEmpty const): Deleted. (WTF::PriorityQueue::enqueue): Deleted. (WTF::PriorityQueue::peek const): Deleted. (WTF::PriorityQueue::dequeue): Deleted. (WTF::PriorityQueue::decreaseKey): Deleted. (WTF::PriorityQueue::increaseKey): Deleted. (WTF::PriorityQueue::begin const): Deleted. (WTF::PriorityQueue::end const): Deleted. (WTF::PriorityQueue::isValidHeap const): Deleted. (WTF::PriorityQueue::parentOf): Deleted. (WTF::PriorityQueue::leftChildOf): Deleted. (WTF::PriorityQueue::rightChildOf): Deleted. (WTF::PriorityQueue::siftUp): Deleted. (WTF::PriorityQueue::siftDown): Deleted. * wtf/RandomDevice.h: * wtf/Range.h: * wtf/RangeSet.h: (WTF::RangeSet::RangeSet): Deleted. (WTF::RangeSet::~RangeSet): Deleted. (WTF::RangeSet::add): Deleted. (WTF::RangeSet::contains const): Deleted. (WTF::RangeSet::overlaps const): Deleted. (WTF::RangeSet::clear): Deleted. (WTF::RangeSet::dump const): Deleted. (WTF::RangeSet::dumpRaw const): Deleted. (WTF::RangeSet::begin const): Deleted. (WTF::RangeSet::end const): Deleted. (WTF::RangeSet::addAll): Deleted. (WTF::RangeSet::compact): Deleted. (WTF::RangeSet::overlapsNonEmpty): Deleted. (WTF::RangeSet::subsumesNonEmpty): Deleted. (WTF::RangeSet::findRange const): Deleted. * wtf/RecursableLambda.h: * wtf/RedBlackTree.h: (WTF::RedBlackTree::Node::successor const): Deleted. (WTF::RedBlackTree::Node::predecessor const): Deleted. (WTF::RedBlackTree::Node::successor): Deleted. (WTF::RedBlackTree::Node::predecessor): Deleted. (WTF::RedBlackTree::Node::reset): Deleted. (WTF::RedBlackTree::Node::parent const): Deleted. (WTF::RedBlackTree::Node::setParent): Deleted. (WTF::RedBlackTree::Node::left const): Deleted. (WTF::RedBlackTree::Node::setLeft): Deleted. (WTF::RedBlackTree::Node::right const): Deleted. (WTF::RedBlackTree::Node::setRight): Deleted. (WTF::RedBlackTree::Node::color const): Deleted. (WTF::RedBlackTree::Node::setColor): Deleted. (WTF::RedBlackTree::RedBlackTree): Deleted. (WTF::RedBlackTree::insert): Deleted. (WTF::RedBlackTree::remove): Deleted. (WTF::RedBlackTree::findExact const): Deleted. (WTF::RedBlackTree::findLeastGreaterThanOrEqual const): Deleted. (WTF::RedBlackTree::findGreatestLessThanOrEqual const): Deleted. (WTF::RedBlackTree::first const): Deleted. (WTF::RedBlackTree::last const): Deleted. (WTF::RedBlackTree::size): Deleted. (WTF::RedBlackTree::isEmpty): Deleted. (WTF::RedBlackTree::treeMinimum): Deleted. (WTF::RedBlackTree::treeMaximum): Deleted. (WTF::RedBlackTree::treeInsert): Deleted. (WTF::RedBlackTree::leftRotate): Deleted. (WTF::RedBlackTree::rightRotate): Deleted. (WTF::RedBlackTree::removeFixup): Deleted. * wtf/ResourceUsage.h: * wtf/RunLoop.cpp: * wtf/RunLoopTimer.h: * wtf/SHA1.h: * wtf/Seconds.h: (WTF::Seconds::Seconds): Deleted. (WTF::Seconds::value const): Deleted. (WTF::Seconds::minutes const): Deleted. (WTF::Seconds::seconds const): Deleted. (WTF::Seconds::milliseconds const): Deleted. (WTF::Seconds::microseconds const): Deleted. (WTF::Seconds::nanoseconds const): Deleted. (WTF::Seconds::minutesAs const): Deleted. (WTF::Seconds::secondsAs const): Deleted. (WTF::Seconds::millisecondsAs const): Deleted. (WTF::Seconds::microsecondsAs const): Deleted. (WTF::Seconds::nanosecondsAs const): Deleted. (WTF::Seconds::fromMinutes): Deleted. (WTF::Seconds::fromHours): Deleted. (WTF::Seconds::fromMilliseconds): Deleted. (WTF::Seconds::fromMicroseconds): Deleted. (WTF::Seconds::fromNanoseconds): Deleted. (WTF::Seconds::infinity): Deleted. (WTF::Seconds::nan): Deleted. (WTF::Seconds::operator bool const): Deleted. (WTF::Seconds::operator+ const): Deleted. (WTF::Seconds::operator- const): Deleted. (WTF::Seconds::operator* const): Deleted. (WTF::Seconds::operator/ const): Deleted. (WTF::Seconds::operator% const): Deleted. (WTF::Seconds::operator+=): Deleted. (WTF::Seconds::operator-=): Deleted. (WTF::Seconds::operator*=): Deleted. (WTF::Seconds::operator/=): Deleted. (WTF::Seconds::operator%=): Deleted. (WTF::Seconds::operator== const): Deleted. (WTF::Seconds::operator!= const): Deleted. (WTF::Seconds::operator< const): Deleted. (WTF::Seconds::operator> const): Deleted. (WTF::Seconds::operator<= const): Deleted. (WTF::Seconds::operator>= const): Deleted. (WTF::Seconds::isolatedCopy const): Deleted. (WTF::Seconds::encode const): Deleted. (WTF::Seconds::decode): Deleted. * wtf/SegmentedVector.h: (WTF::SegmentedVector::~SegmentedVector): Deleted. (WTF::SegmentedVector::size const): Deleted. (WTF::SegmentedVector::isEmpty const): Deleted. (WTF::SegmentedVector::at): Deleted. (WTF::SegmentedVector::at const): Deleted. (WTF::SegmentedVector::operator[]): Deleted. (WTF::SegmentedVector::operator[] const): Deleted. (WTF::SegmentedVector::first): Deleted. (WTF::SegmentedVector::first const): Deleted. (WTF::SegmentedVector::last): Deleted. (WTF::SegmentedVector::last const): Deleted. (WTF::SegmentedVector::takeLast): Deleted. (WTF::SegmentedVector::append): Deleted. (WTF::SegmentedVector::alloc): Deleted. (WTF::SegmentedVector::removeLast): Deleted. (WTF::SegmentedVector::grow): Deleted. (WTF::SegmentedVector::clear): Deleted. (WTF::SegmentedVector::begin): Deleted. (WTF::SegmentedVector::end): Deleted. (WTF::SegmentedVector::shrinkToFit): Deleted. (WTF::SegmentedVector::deleteAllSegments): Deleted. (WTF::SegmentedVector::segmentExistsFor): Deleted. (WTF::SegmentedVector::segmentFor): Deleted. (WTF::SegmentedVector::subscriptFor): Deleted. (WTF::SegmentedVector::ensureSegmentsFor): Deleted. (WTF::SegmentedVector::ensureSegment): Deleted. (WTF::SegmentedVector::allocateSegment): Deleted. * wtf/SetForScope.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SmallPtrSet.h: * wtf/SpanningTree.h: * wtf/Spectrum.h: * wtf/StackBounds.h: * wtf/StackShot.h: * wtf/StackShotProfiler.h: * wtf/StackStats.h: * wtf/StackTrace.h: * wtf/StreamBuffer.h: * wtf/SynchronizedFixedQueue.h: (WTF::SynchronizedFixedQueue::create): Deleted. (WTF::SynchronizedFixedQueue::open): Deleted. (WTF::SynchronizedFixedQueue::close): Deleted. (WTF::SynchronizedFixedQueue::isOpen): Deleted. (WTF::SynchronizedFixedQueue::enqueue): Deleted. (WTF::SynchronizedFixedQueue::dequeue): Deleted. (WTF::SynchronizedFixedQueue::SynchronizedFixedQueue): Deleted. * wtf/SystemTracing.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::create): Deleted. (WTF::ThreadGroup::threads const): Deleted. (WTF::ThreadGroup::getLock): Deleted. (WTF::ThreadGroup::weakFromThis): Deleted. * wtf/ThreadSpecific.h: * wtf/ThreadingPrimitives.h: (WTF::Mutex::impl): Deleted. * wtf/TimeWithDynamicClockType.h: (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): Deleted. (WTF::TimeWithDynamicClockType::fromRawSeconds): Deleted. (WTF::TimeWithDynamicClockType::secondsSinceEpoch const): Deleted. (WTF::TimeWithDynamicClockType::clockType const): Deleted. (WTF::TimeWithDynamicClockType::withSameClockAndRawSeconds const): Deleted. (WTF::TimeWithDynamicClockType::operator bool const): Deleted. (WTF::TimeWithDynamicClockType::operator+ const): Deleted. (WTF::TimeWithDynamicClockType::operator- const): Deleted. (WTF::TimeWithDynamicClockType::operator+=): Deleted. (WTF::TimeWithDynamicClockType::operator-=): Deleted. (WTF::TimeWithDynamicClockType::operator== const): Deleted. (WTF::TimeWithDynamicClockType::operator!= const): Deleted. * wtf/TimingScope.h: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/URLParser.cpp: * wtf/URLParser.h: * wtf/Unexpected.h: * wtf/Variant.h: * wtf/WTFSemaphore.h: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::signal): Deleted. (WTF::Semaphore::waitUntil): Deleted. (WTF::Semaphore::waitFor): Deleted. (WTF::Semaphore::wait): Deleted. * wtf/WallTime.h: (WTF::WallTime::WallTime): Deleted. (WTF::WallTime::fromRawSeconds): Deleted. (WTF::WallTime::infinity): Deleted. (WTF::WallTime::nan): Deleted. (WTF::WallTime::secondsSinceEpoch const): Deleted. (WTF::WallTime::approximateWallTime const): Deleted. (WTF::WallTime::operator bool const): Deleted. (WTF::WallTime::operator+ const): Deleted. (WTF::WallTime::operator- const): Deleted. (WTF::WallTime::operator+=): Deleted. (WTF::WallTime::operator-=): Deleted. (WTF::WallTime::operator== const): Deleted. (WTF::WallTime::operator!= const): Deleted. (WTF::WallTime::operator< const): Deleted. (WTF::WallTime::operator> const): Deleted. (WTF::WallTime::operator<= const): Deleted. (WTF::WallTime::operator>= const): Deleted. (WTF::WallTime::isolatedCopy const): Deleted. * wtf/WeakHashSet.h: (WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::get const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator* const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator++): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator== const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const): Deleted. (WTF::WeakHashSet::WeakHashSet): Deleted. (WTF::WeakHashSet::begin const): Deleted. (WTF::WeakHashSet::end const): Deleted. (WTF::WeakHashSet::add): Deleted. (WTF::WeakHashSet::remove): Deleted. (WTF::WeakHashSet::contains const): Deleted. (WTF::WeakHashSet::capacity const): Deleted. (WTF::WeakHashSet::computesEmpty const): Deleted. (WTF::WeakHashSet::hasNullReferences const): Deleted. (WTF::WeakHashSet::computeSize const): Deleted. (WTF::WeakHashSet::checkConsistency const): Deleted. * wtf/WeakRandom.h: (WTF::WeakRandom::WeakRandom): Deleted. (WTF::WeakRandom::setSeed): Deleted. (WTF::WeakRandom::seed const): Deleted. (WTF::WeakRandom::get): Deleted. (WTF::WeakRandom::getUint32): Deleted. (WTF::WeakRandom::lowOffset): Deleted. (WTF::WeakRandom::highOffset): Deleted. (WTF::WeakRandom::nextState): Deleted. (WTF::WeakRandom::generate): Deleted. (WTF::WeakRandom::advance): Deleted. * wtf/WordLock.h: (WTF::WordLock::lock): Deleted. (WTF::WordLock::unlock): Deleted. (WTF::WordLock::isHeld const): Deleted. (WTF::WordLock::isLocked const): Deleted. (WTF::WordLock::isFullyReset const): Deleted. * wtf/generic/MainThreadGeneric.cpp: * wtf/glib/GMutexLocker.h: * wtf/linux/CurrentProcessMemoryStatus.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::~Semaphore): Deleted. (WTF::Semaphore::wait): Deleted. (WTF::Semaphore::post): Deleted. * wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::operator const char* const): Deleted. (WTF::ASCIILiteral::fromLiteralUnsafe): Deleted. (WTF::ASCIILiteral::null): Deleted. (WTF::ASCIILiteral::characters const): Deleted. (WTF::ASCIILiteral::ASCIILiteral): Deleted. * wtf/text/AtomString.h: (WTF::AtomString::operator=): Deleted. (WTF::AtomString::isHashTableDeletedValue const): Deleted. (WTF::AtomString::existingHash const): Deleted. (WTF::AtomString::operator const String& const): Deleted. (WTF::AtomString::string const): Deleted. (WTF::AtomString::impl const): Deleted. (WTF::AtomString::is8Bit const): Deleted. (WTF::AtomString::characters8 const): Deleted. (WTF::AtomString::characters16 const): Deleted. (WTF::AtomString::length const): Deleted. (WTF::AtomString::operator[] const): Deleted. (WTF::AtomString::contains const): Deleted. (WTF::AtomString::containsIgnoringASCIICase const): Deleted. (WTF::AtomString::find const): Deleted. (WTF::AtomString::findIgnoringASCIICase const): Deleted. (WTF::AtomString::startsWith const): Deleted. (WTF::AtomString::startsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::endsWith const): Deleted. (WTF::AtomString::endsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::toInt const): Deleted. (WTF::AtomString::toDouble const): Deleted. (WTF::AtomString::toFloat const): Deleted. (WTF::AtomString::percentage const): Deleted. (WTF::AtomString::isNull const): Deleted. (WTF::AtomString::isEmpty const): Deleted. (WTF::AtomString::operator NSString * const): Deleted. * wtf/text/AtomStringImpl.h: (WTF::AtomStringImpl::lookUp): Deleted. (WTF::AtomStringImpl::add): Deleted. (WTF::AtomStringImpl::addWithStringTableProvider): Deleted. * wtf/text/CString.h: (WTF::CStringBuffer::data): Deleted. (WTF::CStringBuffer::length const): Deleted. (WTF::CStringBuffer::CStringBuffer): Deleted. (WTF::CStringBuffer::mutableData): Deleted. (WTF::CString::CString): Deleted. (WTF::CString::data const): Deleted. (WTF::CString::length const): Deleted. (WTF::CString::isNull const): Deleted. (WTF::CString::buffer const): Deleted. (WTF::CString::isHashTableDeletedValue const): Deleted. * wtf/text/ExternalStringImpl.h: (WTF::ExternalStringImpl::freeExternalBuffer): Deleted. * wtf/text/LineBreakIteratorPoolICU.h: * wtf/text/NullTextBreakIterator.h: * wtf/text/OrdinalNumber.h: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.h: * wtf/text/StringConcatenateNumbers.h: * wtf/text/StringHasher.h: * wtf/text/StringImpl.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: (WTF::StringView::left const): Deleted. (WTF::StringView::right const): Deleted. (WTF::StringView::underlyingStringIsValid const): Deleted. (WTF::StringView::setUnderlyingString): Deleted. * wtf/text/SymbolImpl.h: (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl): Deleted. (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&): Deleted. (WTF::PrivateSymbolImpl::PrivateSymbolImpl): Deleted. (WTF::RegisteredSymbolImpl::symbolRegistry const): Deleted. (WTF::RegisteredSymbolImpl::clearSymbolRegistry): Deleted. (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl): Deleted. * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.h: * wtf/text/WTFString.h: (WTF::String::swap): Deleted. (WTF::String::adopt): Deleted. (WTF::String::isNull const): Deleted. (WTF::String::isEmpty const): Deleted. (WTF::String::impl const): Deleted. (WTF::String::releaseImpl): Deleted. (WTF::String::length const): Deleted. (WTF::String::characters8 const): Deleted. (WTF::String::characters16 const): Deleted. (WTF::String::is8Bit const): Deleted. (WTF::String::sizeInBytes const): Deleted. (WTF::String::operator[] const): Deleted. (WTF::String::find const): Deleted. (WTF::String::findIgnoringASCIICase const): Deleted. (WTF::String::reverseFind const): Deleted. (WTF::String::contains const): Deleted. (WTF::String::containsIgnoringASCIICase const): Deleted. (WTF::String::startsWith const): Deleted. (WTF::String::startsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixStartingAt const): Deleted. (WTF::String::endsWith const): Deleted. (WTF::String::endsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixEndingAt const): Deleted. (WTF::String::append): Deleted. (WTF::String::left const): Deleted. (WTF::String::right const): Deleted. (WTF::String::createUninitialized): Deleted. (WTF::String::fromUTF8WithLatin1Fallback): Deleted. (WTF::String::isAllASCII const): Deleted. (WTF::String::isAllLatin1 const): Deleted. (WTF::String::isSpecialCharacter const): Deleted. (WTF::String::isHashTableDeletedValue const): Deleted. (WTF::String::hash const): Deleted. (WTF::String::existingHash const): Deleted. * wtf/text/cf/TextBreakIteratorCF.h: * wtf/text/icu/TextBreakIteratorICU.h: * wtf/text/icu/UTextProviderLatin1.h: * wtf/threads/BinarySemaphore.h: (WTF::BinarySemaphore::waitFor): Deleted. (WTF::BinarySemaphore::wait): Deleted. * wtf/unicode/Collator.h: * wtf/win/GDIObject.h: * wtf/win/PathWalker.h: * wtf/win/Win32Handle.h: Canonical link: https://commits.webkit.org/214396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 20:57:15 +00:00
class RangeSet final {
WTF_MAKE_FAST_ALLOCATED;
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
public:
typedef RangeType Range;
typedef typename Range::Type Type;
B3 should do LICM https://bugs.webkit.org/show_bug.cgi?id=174750 Reviewed by Keith Miller and Saam Barati. Source/JavaScriptCore: Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming convention for phases (it has to be an imperative). The phase uses NaturalLoops and BackwardsDominators, so this adds those analyses to B3. BackwardsDominators was already available in templatized form. This change templatizes DFG::NaturalLoops so that we can just use it. The LICM phase itself is really simple. We are decently precise with our handling of everything except the relationship between control dependence and side exits. Also added a bunch of tests. This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase so it doesn't hurt to have it. I wrote it because I thought I needed it for bug 174727. It turns out that there's a better way to handle the problem I had, so I ended up not needed it - but by then I had already written it. I think it's good to have it because LICM is one of those core compiler phases; every compiler has it eventually. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3BackwardsCFG.h: Added. (JSC::B3::BackwardsCFG::BackwardsCFG): * b3/B3BackwardsDominators.h: Added. (JSC::B3::BackwardsDominators::BackwardsDominators): * b3/B3BasicBlock.cpp: (JSC::B3::BasicBlock::appendNonTerminal): * b3/B3Effects.h: * b3/B3EnsureLoopPreHeaders.cpp: Added. (JSC::B3::ensureLoopPreHeaders): * b3/B3EnsureLoopPreHeaders.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HoistLoopInvariantValues.cpp: Added. (JSC::B3::hoistLoopInvariantValues): * b3/B3HoistLoopInvariantValues.h: Added. * b3/B3NaturalLoops.h: Added. (JSC::B3::NaturalLoops::NaturalLoops): * b3/B3Procedure.cpp: (JSC::B3::Procedure::invalidateCFG): (JSC::B3::Procedure::naturalLoops): (JSC::B3::Procedure::backwardsCFG): (JSC::B3::Procedure::backwardsDominators): * b3/B3Procedure.h: * b3/testb3.cpp: (JSC::B3::generateLoop): (JSC::B3::makeArrayForLoops): (JSC::B3::generateLoopNotBackwardsDominant): (JSC::B3::oneFunction): (JSC::B3::noOpFunction): (JSC::B3::testLICMPure): (JSC::B3::testLICMPureSideExits): (JSC::B3::testLICMPureWritesPinned): (JSC::B3::testLICMPureWrites): (JSC::B3::testLICMReadsLocalState): (JSC::B3::testLICMReadsPinned): (JSC::B3::testLICMReads): (JSC::B3::testLICMPureNotBackwardsDominant): (JSC::B3::testLICMPureFoiledByChild): (JSC::B3::testLICMPureNotBackwardsDominantFoiledByChild): (JSC::B3::testLICMExitsSideways): (JSC::B3::testLICMWritesLocalState): (JSC::B3::testLICMWrites): (JSC::B3::testLICMFence): (JSC::B3::testLICMWritesPinned): (JSC::B3::testLICMControlDependent): (JSC::B3::testLICMControlDependentNotBackwardsDominant): (JSC::B3::testLICMControlDependentSideExits): (JSC::B3::testLICMReadsPinnedWritesPinned): (JSC::B3::testLICMReadsWritesDifferentHeaps): (JSC::B3::testLICMReadsWritesOverlappingHeaps): (JSC::B3::testLICMDefaultCall): (JSC::B3::run): * dfg/DFGBasicBlock.h: * dfg/DFGCFG.h: * dfg/DFGNaturalLoops.cpp: Removed. * dfg/DFGNaturalLoops.h: (JSC::DFG::NaturalLoops::NaturalLoops): (JSC::DFG::NaturalLoop::NaturalLoop): Deleted. (JSC::DFG::NaturalLoop::header): Deleted. (JSC::DFG::NaturalLoop::size): Deleted. (JSC::DFG::NaturalLoop::at): Deleted. (JSC::DFG::NaturalLoop::operator[]): Deleted. (JSC::DFG::NaturalLoop::contains): Deleted. (JSC::DFG::NaturalLoop::index): Deleted. (JSC::DFG::NaturalLoop::isOuterMostLoop): Deleted. (JSC::DFG::NaturalLoop::addBlock): Deleted. (JSC::DFG::NaturalLoops::numLoops): Deleted. (JSC::DFG::NaturalLoops::loop): Deleted. (JSC::DFG::NaturalLoops::headerOf): Deleted. (JSC::DFG::NaturalLoops::innerMostLoopOf): Deleted. (JSC::DFG::NaturalLoops::innerMostOuterLoop): Deleted. (JSC::DFG::NaturalLoops::belongsTo): Deleted. (JSC::DFG::NaturalLoops::loopDepth): Deleted. Source/WTF: Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as Dominators<>. This allows us to add a B3::NaturalLoops for free. Also made small tweaks to RangeSet, which the LICM uses. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Dominators.h: * wtf/NaturalLoops.h: Added. (WTF::NaturalLoop::NaturalLoop): (WTF::NaturalLoop::graph): (WTF::NaturalLoop::header): (WTF::NaturalLoop::size): (WTF::NaturalLoop::at): (WTF::NaturalLoop::operator[]): (WTF::NaturalLoop::contains): (WTF::NaturalLoop::index): (WTF::NaturalLoop::isOuterMostLoop): (WTF::NaturalLoop::dump): (WTF::NaturalLoop::addBlock): (WTF::NaturalLoops::NaturalLoops): (WTF::NaturalLoops::graph): (WTF::NaturalLoops::numLoops): (WTF::NaturalLoops::loop): (WTF::NaturalLoops::headerOf): (WTF::NaturalLoops::innerMostLoopOf): (WTF::NaturalLoops::innerMostOuterLoop): (WTF::NaturalLoops::belongsTo): (WTF::NaturalLoops::loopDepth): (WTF::NaturalLoops::loopsOf): (WTF::NaturalLoops::dump): * wtf/RangeSet.h: (WTF::RangeSet::begin): (WTF::RangeSet::end): (WTF::RangeSet::addAll): Canonical link: https://commits.webkit.org/191658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-26 01:58:36 +00:00
typedef Vector<Range, 8> VectorType;
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
RangeSet()
{
}
~RangeSet()
{
}
void add(const Range& range)
{
if (range.begin() == range.end())
return;
// We expect the range set to become top in a lot of cases. We also expect the same range to
// be added repeatedly. That's why this is here.
if (!m_ranges.isEmpty() && subsumesNonEmpty(m_ranges.last(), range))
return;
m_isCompact = false;
// We append without compacting only if doing so is guaranteed not to resize the vector.
Air should support linear scan for optLevel<2 https://bugs.webkit.org/show_bug.cgi?id=170161 Reviewed by Saam Barati. Source/JavaScriptCore: This changes the default opt level of B3 to 2. It makes the other opt levels useful by adding a new register allocator. This new linear scan allocator will produce significantly worse code. But it will produce that code a lot faster than IRC or Briggs. The opt levels are: 0: no optimizations, linear scan 1: some optimizations, linear scan 2: full optimizations, graph coloring (IRC or Briggs based on CPU) What we used to call optLevel=1 is not called optLevel=2, or better yet, optLevel=B3::defaultOptLevel(). We no longer have anything like the old optLevel=0 (which did no optimizations but ran graph coloring). allocateRegistersByLinearScan() faithfully implements Massimiliano Poletto and Vivek Sarkar's famous algorithm. It uses the variant that handles clobbered registers by avoiding assigning ranges to those registers if the range overlaps a clobber. It's engineered to allocate registers very quickly and generate inefficient code without falling off a cliff. The new optLevel=1 speeds up B3 by a factor of 2, and results in a 80% throughput regression. Linear scan runs 4.7x faster than graph coloring on average. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3BasicBlockUtils.h: (JSC::B3::blocksInPreOrder): (JSC::B3::blocksInPostOrder): * b3/B3BlockWorklist.h: * b3/B3CFG.h: (JSC::B3::CFG::newMap): * b3/B3Common.h: (JSC::B3::defaultOptLevel): * b3/B3Compile.h: * b3/B3DuplicateTails.cpp: * b3/B3EliminateCommonSubexpressions.cpp: * b3/B3FixSSA.cpp: (JSC::B3::demoteValues): (JSC::B3::fixSSA): * b3/B3FixSSA.h: * b3/B3Generate.cpp: (JSC::B3::prepareForGeneration): (JSC::B3::generateToAir): * b3/B3Generate.h: * b3/B3HeapRange.cpp: Removed. * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): Deleted. (JSC::B3::HeapRange::top): Deleted. (JSC::B3::HeapRange::operator==): Deleted. (JSC::B3::HeapRange::operator!=): Deleted. (JSC::B3::HeapRange::operator|): Deleted. (JSC::B3::HeapRange::operator bool): Deleted. (JSC::B3::HeapRange::begin): Deleted. (JSC::B3::HeapRange::end): Deleted. (JSC::B3::HeapRange::overlaps): Deleted. * b3/B3LowerToAir.cpp: * b3/B3MoveConstants.cpp: * b3/B3PhiChildren.h: * b3/B3Procedure.cpp: (JSC::B3::Procedure::dump): (JSC::B3::Procedure::deleteOrphans): (JSC::B3::Procedure::setBlockOrderImpl): * b3/B3ReduceDoubleToFloat.cpp: * b3/B3ReduceStrength.cpp: * b3/B3SSACalculator.h: * b3/B3UseCounts.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirAllocateRegistersByLinearScan.cpp: Added. (JSC::B3::Air::allocateRegistersByLinearScan): * b3/air/AirAllocateRegistersByLinearScan.h: Added. * b3/air/AirAllocateStack.cpp: (JSC::B3::Air::allocateStack): * b3/air/AirArg.cpp: (WTF::printInternal): * b3/air/AirArg.h: (JSC::B3::Air::Arg::activeAt): (JSC::B3::Air::Arg::timing): (JSC::B3::Air::Arg::forEachPhase): * b3/air/AirBasicBlock.h: * b3/air/AirBlockWorklist.h: * b3/air/AirCFG.h: (JSC::B3::Air::CFG::newMap): * b3/air/AirEliminateDeadCode.cpp: (JSC::B3::Air::eliminateDeadCode): * b3/air/AirFixObviousSpills.cpp: * b3/air/AirFixPartialRegisterStalls.cpp: (JSC::B3::Air::fixPartialRegisterStalls): * b3/air/AirFixSpillsAfterTerminals.cpp: Added. (JSC::B3::Air::fixSpillsAfterTerminals): * b3/air/AirFixSpillsAfterTerminals.h: Added. * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): (JSC::B3::Air::generate): * b3/air/AirGenerate.h: * b3/air/AirGenerationContext.h: * b3/air/AirInsertionSet.h: * b3/air/AirInst.cpp: (JSC::B3::Air::Inst::needsPadding): * b3/air/AirLowerAfterRegAlloc.cpp: (JSC::B3::Air::lowerAfterRegAlloc): * b3/air/AirLowerEntrySwitch.cpp: (JSC::B3::Air::lowerEntrySwitch): * b3/air/AirOpcode.opcodes: * b3/air/AirPhaseInsertionSet.cpp: Added. (JSC::B3::Air::PhaseInsertionSet::execute): * b3/air/AirPhaseInsertionSet.h: Added. (JSC::B3::Air::PhaseInsertion::PhaseInsertion): (JSC::B3::Air::PhaseInsertion::phase): (JSC::B3::Air::PhaseInsertion::operator<): (JSC::B3::Air::PhaseInsertionSet::PhaseInsertionSet): (JSC::B3::Air::PhaseInsertionSet::appendInsertion): (JSC::B3::Air::PhaseInsertionSet::insertInst): (JSC::B3::Air::PhaseInsertionSet::insert): * b3/air/AirRegLiveness.h: (JSC::B3::Air::RegLiveness::LocalCalc::LocalCalc): * b3/air/AirSpillEverything.cpp: (JSC::B3::Air::spillEverything): * b3/air/AirTmp.cpp: * b3/air/AirTmp.h: (JSC::B3::Air::Tmp::tmpForIndex): * b3/air/AirTmpInlines.h: (JSC::B3::Air::Tmp::Indexed::Indexed): (JSC::B3::Air::Tmp::Indexed::index): (JSC::B3::Air::Tmp::AbsolutelyIndexed::AbsolutelyIndexed): (JSC::B3::Air::Tmp::AbsolutelyIndexed::index): (JSC::B3::Air::Tmp::indexed): (JSC::B3::Air::Tmp::absolutelyIndexed): (JSC::B3::Air::Tmp::tmpForAbsoluteIndex): * b3/testb3.cpp: (JSC::B3::compile): (JSC::B3::testMulLoadTwice): * jit/RegisterSet.h: (JSC::RegisterSet::add): (JSC::RegisterSet::remove): * runtime/Options.h: * wasm/WasmB3IRGenerator.h: Source/WTF: This change introduces a new low-latency register allocator. It can allocate registers very quickly by doing a relatively poor job. Implementing this algorithm required beefing up some of our core algorithms. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Deque.h: Make it possible to do some basic priority queueing with this data structure. (WTF::inlineCapacity>::removeAllMatching): (WTF::inlineCapacity>::appendAndBubble): (WTF::inlineCapacity>::takeLast): * wtf/IndexKeyType.h: Added. This makes it possible to use IndexMap and IndexSet with value or pointer types. Previously they just worked with pointer types. (WTF::IndexKeyType::index): * wtf/IndexMap.h: Adopt IndexKeyType. (WTF::IndexMap::operator[]): (WTF::IndexMap::append): * wtf/IndexSet.h: Adopt IndexKeyType. (WTF::IndexSet::add): (WTF::IndexSet::addAll): (WTF::IndexSet::remove): (WTF::IndexSet::contains): (WTF::IndexSet::Iterable::iterator::operator*): * wtf/Range.h: Added. This used to be B3::HeapRange. This generalizes that data structure to any kind of range stuff. (WTF::Range::Range): (WTF::Range::top): (WTF::Range::operator==): (WTF::Range::operator!=): (WTF::Range::operator bool): (WTF::Range::operator|): (WTF::Range::operator|=): (WTF::Range::begin): (WTF::Range::end): (WTF::Range::overlaps): (WTF::Range::dump): * wtf/RangeSet.h: (WTF::RangeSet::add): Tools: This makes us run a bunch of JS tests at optLevel=1 to force testing of this new compiler pipeline. * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/187230@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-30 22:55:44 +00:00
// FIXME: This heuristic is almost certainly wrong, because we don't control the capacity. I
// think that this means that we will sometimes be rage-compacting when we are just shy of the
// capacity.
// https://bugs.webkit.org/show_bug.cgi?id=170308
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
if (m_ranges.size() + 1 < m_ranges.capacity()) {
m_ranges.append(range);
return;
}
m_ranges.append(range);
compact();
}
bool contains(const Range& range) const
{
if (range.begin() == range.end())
return false;
unsigned index = findRange(range);
if (index != UINT_MAX)
return subsumesNonEmpty(m_ranges[index], range);
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
return false;
}
bool overlaps(const Range& range) const
{
if (range.begin() == range.end())
return false;
return findRange(range) != UINT_MAX;
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
}
void clear()
{
m_ranges.clear();
m_isCompact = true;
}
void dump(PrintStream& out) const
{
const_cast<RangeSet*>(this)->compact();
out.print(listDump(m_ranges));
}
void dumpRaw(PrintStream& out) const
{
out.print("{", listDump(m_ranges), ", isCompact = ", m_isCompact, "}");
}
B3 should do LICM https://bugs.webkit.org/show_bug.cgi?id=174750 Reviewed by Keith Miller and Saam Barati. Source/JavaScriptCore: Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming convention for phases (it has to be an imperative). The phase uses NaturalLoops and BackwardsDominators, so this adds those analyses to B3. BackwardsDominators was already available in templatized form. This change templatizes DFG::NaturalLoops so that we can just use it. The LICM phase itself is really simple. We are decently precise with our handling of everything except the relationship between control dependence and side exits. Also added a bunch of tests. This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase so it doesn't hurt to have it. I wrote it because I thought I needed it for bug 174727. It turns out that there's a better way to handle the problem I had, so I ended up not needed it - but by then I had already written it. I think it's good to have it because LICM is one of those core compiler phases; every compiler has it eventually. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3BackwardsCFG.h: Added. (JSC::B3::BackwardsCFG::BackwardsCFG): * b3/B3BackwardsDominators.h: Added. (JSC::B3::BackwardsDominators::BackwardsDominators): * b3/B3BasicBlock.cpp: (JSC::B3::BasicBlock::appendNonTerminal): * b3/B3Effects.h: * b3/B3EnsureLoopPreHeaders.cpp: Added. (JSC::B3::ensureLoopPreHeaders): * b3/B3EnsureLoopPreHeaders.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HoistLoopInvariantValues.cpp: Added. (JSC::B3::hoistLoopInvariantValues): * b3/B3HoistLoopInvariantValues.h: Added. * b3/B3NaturalLoops.h: Added. (JSC::B3::NaturalLoops::NaturalLoops): * b3/B3Procedure.cpp: (JSC::B3::Procedure::invalidateCFG): (JSC::B3::Procedure::naturalLoops): (JSC::B3::Procedure::backwardsCFG): (JSC::B3::Procedure::backwardsDominators): * b3/B3Procedure.h: * b3/testb3.cpp: (JSC::B3::generateLoop): (JSC::B3::makeArrayForLoops): (JSC::B3::generateLoopNotBackwardsDominant): (JSC::B3::oneFunction): (JSC::B3::noOpFunction): (JSC::B3::testLICMPure): (JSC::B3::testLICMPureSideExits): (JSC::B3::testLICMPureWritesPinned): (JSC::B3::testLICMPureWrites): (JSC::B3::testLICMReadsLocalState): (JSC::B3::testLICMReadsPinned): (JSC::B3::testLICMReads): (JSC::B3::testLICMPureNotBackwardsDominant): (JSC::B3::testLICMPureFoiledByChild): (JSC::B3::testLICMPureNotBackwardsDominantFoiledByChild): (JSC::B3::testLICMExitsSideways): (JSC::B3::testLICMWritesLocalState): (JSC::B3::testLICMWrites): (JSC::B3::testLICMFence): (JSC::B3::testLICMWritesPinned): (JSC::B3::testLICMControlDependent): (JSC::B3::testLICMControlDependentNotBackwardsDominant): (JSC::B3::testLICMControlDependentSideExits): (JSC::B3::testLICMReadsPinnedWritesPinned): (JSC::B3::testLICMReadsWritesDifferentHeaps): (JSC::B3::testLICMReadsWritesOverlappingHeaps): (JSC::B3::testLICMDefaultCall): (JSC::B3::run): * dfg/DFGBasicBlock.h: * dfg/DFGCFG.h: * dfg/DFGNaturalLoops.cpp: Removed. * dfg/DFGNaturalLoops.h: (JSC::DFG::NaturalLoops::NaturalLoops): (JSC::DFG::NaturalLoop::NaturalLoop): Deleted. (JSC::DFG::NaturalLoop::header): Deleted. (JSC::DFG::NaturalLoop::size): Deleted. (JSC::DFG::NaturalLoop::at): Deleted. (JSC::DFG::NaturalLoop::operator[]): Deleted. (JSC::DFG::NaturalLoop::contains): Deleted. (JSC::DFG::NaturalLoop::index): Deleted. (JSC::DFG::NaturalLoop::isOuterMostLoop): Deleted. (JSC::DFG::NaturalLoop::addBlock): Deleted. (JSC::DFG::NaturalLoops::numLoops): Deleted. (JSC::DFG::NaturalLoops::loop): Deleted. (JSC::DFG::NaturalLoops::headerOf): Deleted. (JSC::DFG::NaturalLoops::innerMostLoopOf): Deleted. (JSC::DFG::NaturalLoops::innerMostOuterLoop): Deleted. (JSC::DFG::NaturalLoops::belongsTo): Deleted. (JSC::DFG::NaturalLoops::loopDepth): Deleted. Source/WTF: Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as Dominators<>. This allows us to add a B3::NaturalLoops for free. Also made small tweaks to RangeSet, which the LICM uses. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Dominators.h: * wtf/NaturalLoops.h: Added. (WTF::NaturalLoop::NaturalLoop): (WTF::NaturalLoop::graph): (WTF::NaturalLoop::header): (WTF::NaturalLoop::size): (WTF::NaturalLoop::at): (WTF::NaturalLoop::operator[]): (WTF::NaturalLoop::contains): (WTF::NaturalLoop::index): (WTF::NaturalLoop::isOuterMostLoop): (WTF::NaturalLoop::dump): (WTF::NaturalLoop::addBlock): (WTF::NaturalLoops::NaturalLoops): (WTF::NaturalLoops::graph): (WTF::NaturalLoops::numLoops): (WTF::NaturalLoops::loop): (WTF::NaturalLoops::headerOf): (WTF::NaturalLoops::innerMostLoopOf): (WTF::NaturalLoops::innerMostOuterLoop): (WTF::NaturalLoops::belongsTo): (WTF::NaturalLoops::loopDepth): (WTF::NaturalLoops::loopsOf): (WTF::NaturalLoops::dump): * wtf/RangeSet.h: (WTF::RangeSet::begin): (WTF::RangeSet::end): (WTF::RangeSet::addAll): Canonical link: https://commits.webkit.org/191658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-26 01:58:36 +00:00
typename VectorType::const_iterator begin() const
{
return m_ranges.begin();
}
typename VectorType::const_iterator end() const
{
return m_ranges.end();
}
void addAll(const RangeSet& other)
{
for (Range range : other)
add(range);
}
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
void compact()
{
if (m_isCompact)
return;
if (m_ranges.isEmpty()) {
m_isCompact = true;
return;
}
std::sort(
m_ranges.begin(), m_ranges.end(),
[&] (const Range& a, const Range& b) -> bool {
return a.begin() < b.begin();
});
unsigned srcIndex = 1;
unsigned dstIndex = 1;
Range* lastRange = &m_ranges[0];
while (srcIndex < m_ranges.size()) {
Range range = m_ranges[srcIndex++];
ASSERT(range.begin() >= lastRange->begin());
if (range.end() <= lastRange->end())
continue;
if (range.begin() <= lastRange->end()) {
*lastRange = Range(lastRange->begin(), range.end());
continue;
}
ASSERT(!overlapsNonEmpty(*lastRange, range));
lastRange = &m_ranges[dstIndex++];
*lastRange = range;
}
Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable https://bugs.webkit.org/show_bug.cgi?id=174660 Reviewed by Geoffrey Garen. Replace calls to Vector::resize() with calls to more efficient shrink() / grow() when applicable. This essentially replaces a branch to figure out if the new size is less or greater than the current size by an assertion. Source/bmalloc: * bmalloc/Map.h: (bmalloc::Hash>::rehash): Source/JavaScriptCore: * b3/B3BasicBlockUtils.h: (JSC::B3::clearPredecessors): * b3/B3InferSwitches.cpp: * b3/B3LowerToAir.cpp: (JSC::B3::Air::LowerToAir::finishAppendingInstructions): * b3/B3ReduceStrength.cpp: * b3/B3SparseCollection.h: (JSC::B3::SparseCollection::packIndices): * b3/B3UseCounts.cpp: (JSC::B3::UseCounts::UseCounts): * b3/air/AirAllocateRegistersAndStackByLinearScan.cpp: * b3/air/AirEmitShuffle.cpp: (JSC::B3::Air::emitShuffle): * b3/air/AirLowerAfterRegAlloc.cpp: (JSC::B3::Air::lowerAfterRegAlloc): * b3/air/AirOptimizeBlockOrder.cpp: (JSC::B3::Air::optimizeBlockOrder): * bytecode/Operands.h: (JSC::Operands::ensureLocals): * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargetsInternal): * dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::execute): * dfg/DFGBlockMapInlines.h: (JSC::DFG::BlockMap<T>::BlockMap): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::processSetLocalQueue): (JSC::DFG::ByteCodeParser::clearCaches): * dfg/DFGDisassembler.cpp: (JSC::DFG::Disassembler::Disassembler): * dfg/DFGFlowIndexing.cpp: (JSC::DFG::FlowIndexing::recompute): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::registerFrozenValues): * dfg/DFGInPlaceAbstractState.cpp: (JSC::DFG::setLiveValues): * dfg/DFGLICMPhase.cpp: (JSC::DFG::LICMPhase::run): * dfg/DFGLivenessAnalysisPhase.cpp: * dfg/DFGNaturalLoops.cpp: (JSC::DFG::NaturalLoops::NaturalLoops): * dfg/DFGStoreBarrierClusteringPhase.cpp: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): * heap/CodeBlockSet.cpp: (JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced): * heap/MarkedSpace.cpp: (JSC::MarkedSpace::sweepLargeAllocations): * inspector/ContentSearchUtilities.cpp: (Inspector::ContentSearchUtilities::findMagicComment): * interpreter/ShadowChicken.cpp: (JSC::ShadowChicken::update): * parser/ASTBuilder.h: (JSC::ASTBuilder::shrinkOperandStackBy): * parser/Lexer.h: (JSC::Lexer::setOffset): * runtime/RegExpInlines.h: (JSC::RegExp::matchInline): * runtime/RegExpPrototype.cpp: (JSC::genericSplit): * yarr/RegularExpression.cpp: (JSC::Yarr::RegularExpression::match): Source/WebCore: * Modules/gamepad/Gamepad.cpp: (WebCore::Gamepad::Gamepad): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::addReaction): * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::skipBuffer): * Modules/websockets/WebSocketDeflater.cpp: (WebCore::WebSocketDeflater::finish): * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::serializeSelector): * contentextensions/DFABytecodeCompiler.cpp: (WebCore::ContentExtensions::append): * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp: (WebCore::gcryptEncrypt): (WebCore::gcryptDecrypt): * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp: (WebCore::gcryptDerive): * platform/gamepad/cocoa/GameControllerGamepadProvider.mm: (WebCore::GameControllerGamepadProvider::controllerDidConnect): * platform/gamepad/mac/HIDGamepadProvider.cpp: (WebCore::HIDGamepadProvider::deviceAdded): * platform/graphics/ImageBackingStore.h: (WebCore::ImageBackingStore::setSize): * platform/graphics/WOFFFileFormat.cpp: * platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp: (WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes): (WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues): * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp: (WebCore::InbandTextTrackPrivateAVF::resetCueValues): (WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer): * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp: (WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer): * platform/graphics/cg/ImageBufferCG.cpp: (WebCore::cfData): * platform/image-decoders/bmp/BMPImageDecoder.cpp: (WebCore::BMPImageDecoder::frameBufferAtIndex): * platform/image-decoders/ico/ICOImageDecoder.cpp: (WebCore::ICOImageDecoder::decode): * platform/image-decoders/jpeg/JPEGImageDecoder.cpp: (WebCore::JPEGImageDecoder::frameBufferAtIndex): * platform/image-decoders/png/PNGImageDecoder.cpp: (WebCore::PNGImageDecoder::frameBufferAtIndex): (WebCore::PNGImageDecoder::readChunks): * platform/image-decoders/webp/WEBPImageDecoder.cpp: (WebCore::WEBPImageDecoder::frameBufferAtIndex): * platform/image-encoders/JPEGImageEncoder.cpp: (WebCore::compressRGBABigEndianToJPEG): * platform/text/DecodeEscapeSequences.h: (WebCore::URLEscapeSequence::decodeRun): * platform/text/SuffixTree.h: (WebCore::SuffixTree::Node::Node): * rendering/Grid.cpp: (WebCore::Grid::setNeedsItemsPlacement): * rendering/RenderTable.cpp: (WebCore::RenderTable::invalidateCachedColumns): Source/WebKit: * Platform/IPC/ArgumentCoders.h: * UIProcess/Gamepad/UIGamepadProvider.cpp: (WebKit::UIGamepadProvider::platformGamepadConnected): * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::setInitialConnectedGamepads): * WebProcess/Network/WebLoaderStrategy.cpp: (WebKit::WebLoaderStrategy::loadResourceSynchronously): * WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp: (WebKit::WebPasteboardOverrides::getDataForOverride): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestAutocorrectionData): Source/WebKitLegacy/mac: * Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]): Source/WTF: * wtf/IndexSparseSet.h: (WTF::OverflowHandler>::IndexSparseSet): (WTF::OverflowHandler>::clear): * wtf/Insertion.h: (WTF::executeInsertions): * wtf/RangeSet.h: (WTF::RangeSet::compact): * wtf/Vector.h: (WTF::removeRepeatedElements): * wtf/persistence/Coders.h: Canonical link: https://commits.webkit.org/191511@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-20 21:06:12 +00:00
m_ranges.shrink(dstIndex);
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
m_isCompact = true;
}
B3 should do LICM https://bugs.webkit.org/show_bug.cgi?id=174750 Reviewed by Keith Miller and Saam Barati. Source/JavaScriptCore: Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming convention for phases (it has to be an imperative). The phase uses NaturalLoops and BackwardsDominators, so this adds those analyses to B3. BackwardsDominators was already available in templatized form. This change templatizes DFG::NaturalLoops so that we can just use it. The LICM phase itself is really simple. We are decently precise with our handling of everything except the relationship between control dependence and side exits. Also added a bunch of tests. This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase so it doesn't hurt to have it. I wrote it because I thought I needed it for bug 174727. It turns out that there's a better way to handle the problem I had, so I ended up not needed it - but by then I had already written it. I think it's good to have it because LICM is one of those core compiler phases; every compiler has it eventually. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3BackwardsCFG.h: Added. (JSC::B3::BackwardsCFG::BackwardsCFG): * b3/B3BackwardsDominators.h: Added. (JSC::B3::BackwardsDominators::BackwardsDominators): * b3/B3BasicBlock.cpp: (JSC::B3::BasicBlock::appendNonTerminal): * b3/B3Effects.h: * b3/B3EnsureLoopPreHeaders.cpp: Added. (JSC::B3::ensureLoopPreHeaders): * b3/B3EnsureLoopPreHeaders.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HoistLoopInvariantValues.cpp: Added. (JSC::B3::hoistLoopInvariantValues): * b3/B3HoistLoopInvariantValues.h: Added. * b3/B3NaturalLoops.h: Added. (JSC::B3::NaturalLoops::NaturalLoops): * b3/B3Procedure.cpp: (JSC::B3::Procedure::invalidateCFG): (JSC::B3::Procedure::naturalLoops): (JSC::B3::Procedure::backwardsCFG): (JSC::B3::Procedure::backwardsDominators): * b3/B3Procedure.h: * b3/testb3.cpp: (JSC::B3::generateLoop): (JSC::B3::makeArrayForLoops): (JSC::B3::generateLoopNotBackwardsDominant): (JSC::B3::oneFunction): (JSC::B3::noOpFunction): (JSC::B3::testLICMPure): (JSC::B3::testLICMPureSideExits): (JSC::B3::testLICMPureWritesPinned): (JSC::B3::testLICMPureWrites): (JSC::B3::testLICMReadsLocalState): (JSC::B3::testLICMReadsPinned): (JSC::B3::testLICMReads): (JSC::B3::testLICMPureNotBackwardsDominant): (JSC::B3::testLICMPureFoiledByChild): (JSC::B3::testLICMPureNotBackwardsDominantFoiledByChild): (JSC::B3::testLICMExitsSideways): (JSC::B3::testLICMWritesLocalState): (JSC::B3::testLICMWrites): (JSC::B3::testLICMFence): (JSC::B3::testLICMWritesPinned): (JSC::B3::testLICMControlDependent): (JSC::B3::testLICMControlDependentNotBackwardsDominant): (JSC::B3::testLICMControlDependentSideExits): (JSC::B3::testLICMReadsPinnedWritesPinned): (JSC::B3::testLICMReadsWritesDifferentHeaps): (JSC::B3::testLICMReadsWritesOverlappingHeaps): (JSC::B3::testLICMDefaultCall): (JSC::B3::run): * dfg/DFGBasicBlock.h: * dfg/DFGCFG.h: * dfg/DFGNaturalLoops.cpp: Removed. * dfg/DFGNaturalLoops.h: (JSC::DFG::NaturalLoops::NaturalLoops): (JSC::DFG::NaturalLoop::NaturalLoop): Deleted. (JSC::DFG::NaturalLoop::header): Deleted. (JSC::DFG::NaturalLoop::size): Deleted. (JSC::DFG::NaturalLoop::at): Deleted. (JSC::DFG::NaturalLoop::operator[]): Deleted. (JSC::DFG::NaturalLoop::contains): Deleted. (JSC::DFG::NaturalLoop::index): Deleted. (JSC::DFG::NaturalLoop::isOuterMostLoop): Deleted. (JSC::DFG::NaturalLoop::addBlock): Deleted. (JSC::DFG::NaturalLoops::numLoops): Deleted. (JSC::DFG::NaturalLoops::loop): Deleted. (JSC::DFG::NaturalLoops::headerOf): Deleted. (JSC::DFG::NaturalLoops::innerMostLoopOf): Deleted. (JSC::DFG::NaturalLoops::innerMostOuterLoop): Deleted. (JSC::DFG::NaturalLoops::belongsTo): Deleted. (JSC::DFG::NaturalLoops::loopDepth): Deleted. Source/WTF: Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as Dominators<>. This allows us to add a B3::NaturalLoops for free. Also made small tweaks to RangeSet, which the LICM uses. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Dominators.h: * wtf/NaturalLoops.h: Added. (WTF::NaturalLoop::NaturalLoop): (WTF::NaturalLoop::graph): (WTF::NaturalLoop::header): (WTF::NaturalLoop::size): (WTF::NaturalLoop::at): (WTF::NaturalLoop::operator[]): (WTF::NaturalLoop::contains): (WTF::NaturalLoop::index): (WTF::NaturalLoop::isOuterMostLoop): (WTF::NaturalLoop::dump): (WTF::NaturalLoop::addBlock): (WTF::NaturalLoops::NaturalLoops): (WTF::NaturalLoops::graph): (WTF::NaturalLoops::numLoops): (WTF::NaturalLoops::loop): (WTF::NaturalLoops::headerOf): (WTF::NaturalLoops::innerMostLoopOf): (WTF::NaturalLoops::innerMostOuterLoop): (WTF::NaturalLoops::belongsTo): (WTF::NaturalLoops::loopDepth): (WTF::NaturalLoops::loopsOf): (WTF::NaturalLoops::dump): * wtf/RangeSet.h: (WTF::RangeSet::begin): (WTF::RangeSet::end): (WTF::RangeSet::addAll): Canonical link: https://commits.webkit.org/191658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-26 01:58:36 +00:00
private:
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
static bool overlapsNonEmpty(const Range& a, const Range& b)
{
return nonEmptyRangesOverlap(a.begin(), a.end(), b.begin(), b.end());
}
static bool subsumesNonEmpty(const Range& a, const Range& b)
{
return a.begin() <= b.begin() && a.end() >= b.end();
}
unsigned findRange(const Range& range) const
{
const_cast<RangeSet*>(this)->compact();
// FIXME: Once we start using this in anger, we will want this to be a binary search.
for (unsigned i = 0; i < m_ranges.size(); ++i) {
if (overlapsNonEmpty(m_ranges[i], range))
return i;
}
return UINT_MAX;
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
}
B3 should do LICM https://bugs.webkit.org/show_bug.cgi?id=174750 Reviewed by Keith Miller and Saam Barati. Source/JavaScriptCore: Added a LICM phase to B3. This phase is called hoistLoopInvariantValues, to conform to the B3 naming convention for phases (it has to be an imperative). The phase uses NaturalLoops and BackwardsDominators, so this adds those analyses to B3. BackwardsDominators was already available in templatized form. This change templatizes DFG::NaturalLoops so that we can just use it. The LICM phase itself is really simple. We are decently precise with our handling of everything except the relationship between control dependence and side exits. Also added a bunch of tests. This isn't super important. It's perf-neutral on JS benchmarks. FTL already does LICM on DFG SSA IR, and probably all current WebAssembly content has had LICM done to it. That being said, this is a cheap phase so it doesn't hurt to have it. I wrote it because I thought I needed it for bug 174727. It turns out that there's a better way to handle the problem I had, so I ended up not needed it - but by then I had already written it. I think it's good to have it because LICM is one of those core compiler phases; every compiler has it eventually. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3BackwardsCFG.h: Added. (JSC::B3::BackwardsCFG::BackwardsCFG): * b3/B3BackwardsDominators.h: Added. (JSC::B3::BackwardsDominators::BackwardsDominators): * b3/B3BasicBlock.cpp: (JSC::B3::BasicBlock::appendNonTerminal): * b3/B3Effects.h: * b3/B3EnsureLoopPreHeaders.cpp: Added. (JSC::B3::ensureLoopPreHeaders): * b3/B3EnsureLoopPreHeaders.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HoistLoopInvariantValues.cpp: Added. (JSC::B3::hoistLoopInvariantValues): * b3/B3HoistLoopInvariantValues.h: Added. * b3/B3NaturalLoops.h: Added. (JSC::B3::NaturalLoops::NaturalLoops): * b3/B3Procedure.cpp: (JSC::B3::Procedure::invalidateCFG): (JSC::B3::Procedure::naturalLoops): (JSC::B3::Procedure::backwardsCFG): (JSC::B3::Procedure::backwardsDominators): * b3/B3Procedure.h: * b3/testb3.cpp: (JSC::B3::generateLoop): (JSC::B3::makeArrayForLoops): (JSC::B3::generateLoopNotBackwardsDominant): (JSC::B3::oneFunction): (JSC::B3::noOpFunction): (JSC::B3::testLICMPure): (JSC::B3::testLICMPureSideExits): (JSC::B3::testLICMPureWritesPinned): (JSC::B3::testLICMPureWrites): (JSC::B3::testLICMReadsLocalState): (JSC::B3::testLICMReadsPinned): (JSC::B3::testLICMReads): (JSC::B3::testLICMPureNotBackwardsDominant): (JSC::B3::testLICMPureFoiledByChild): (JSC::B3::testLICMPureNotBackwardsDominantFoiledByChild): (JSC::B3::testLICMExitsSideways): (JSC::B3::testLICMWritesLocalState): (JSC::B3::testLICMWrites): (JSC::B3::testLICMFence): (JSC::B3::testLICMWritesPinned): (JSC::B3::testLICMControlDependent): (JSC::B3::testLICMControlDependentNotBackwardsDominant): (JSC::B3::testLICMControlDependentSideExits): (JSC::B3::testLICMReadsPinnedWritesPinned): (JSC::B3::testLICMReadsWritesDifferentHeaps): (JSC::B3::testLICMReadsWritesOverlappingHeaps): (JSC::B3::testLICMDefaultCall): (JSC::B3::run): * dfg/DFGBasicBlock.h: * dfg/DFGCFG.h: * dfg/DFGNaturalLoops.cpp: Removed. * dfg/DFGNaturalLoops.h: (JSC::DFG::NaturalLoops::NaturalLoops): (JSC::DFG::NaturalLoop::NaturalLoop): Deleted. (JSC::DFG::NaturalLoop::header): Deleted. (JSC::DFG::NaturalLoop::size): Deleted. (JSC::DFG::NaturalLoop::at): Deleted. (JSC::DFG::NaturalLoop::operator[]): Deleted. (JSC::DFG::NaturalLoop::contains): Deleted. (JSC::DFG::NaturalLoop::index): Deleted. (JSC::DFG::NaturalLoop::isOuterMostLoop): Deleted. (JSC::DFG::NaturalLoop::addBlock): Deleted. (JSC::DFG::NaturalLoops::numLoops): Deleted. (JSC::DFG::NaturalLoops::loop): Deleted. (JSC::DFG::NaturalLoops::headerOf): Deleted. (JSC::DFG::NaturalLoops::innerMostLoopOf): Deleted. (JSC::DFG::NaturalLoops::innerMostOuterLoop): Deleted. (JSC::DFG::NaturalLoops::belongsTo): Deleted. (JSC::DFG::NaturalLoops::loopDepth): Deleted. Source/WTF: Moved DFG::NaturalLoops to WTF. The new templatized NaturalLoops<> uses the same Graph abstraction as Dominators<>. This allows us to add a B3::NaturalLoops for free. Also made small tweaks to RangeSet, which the LICM uses. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Dominators.h: * wtf/NaturalLoops.h: Added. (WTF::NaturalLoop::NaturalLoop): (WTF::NaturalLoop::graph): (WTF::NaturalLoop::header): (WTF::NaturalLoop::size): (WTF::NaturalLoop::at): (WTF::NaturalLoop::operator[]): (WTF::NaturalLoop::contains): (WTF::NaturalLoop::index): (WTF::NaturalLoop::isOuterMostLoop): (WTF::NaturalLoop::dump): (WTF::NaturalLoop::addBlock): (WTF::NaturalLoops::NaturalLoops): (WTF::NaturalLoops::graph): (WTF::NaturalLoops::numLoops): (WTF::NaturalLoops::loop): (WTF::NaturalLoops::headerOf): (WTF::NaturalLoops::innerMostLoopOf): (WTF::NaturalLoops::innerMostOuterLoop): (WTF::NaturalLoops::belongsTo): (WTF::NaturalLoops::loopDepth): (WTF::NaturalLoops::loopsOf): (WTF::NaturalLoops::dump): * wtf/RangeSet.h: (WTF::RangeSet::begin): (WTF::RangeSet::end): (WTF::RangeSet::addAll): Canonical link: https://commits.webkit.org/191658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-26 01:58:36 +00:00
VectorType m_ranges;
B3 should have load elimination https://bugs.webkit.org/show_bug.cgi?id=153288 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This adds a complete GCSE pass that includes load elimination. It would have been super hard to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze control flow and reduceStrength() is messing with control flow. So, I did a compromise: I factored out the pure CSE that reduceStrength() was already doing, and now we have: - reduceStrength() still does pure CSE using the new PureCSE helper. - eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the PureCSE helper for pure values and does its own special thing for memory values. Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either, and it's likely to become a bigger pay-off once we implement other features, like mapping FTL's abstract heaps onto B3's heap ranges. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/B3EliminateCommonSubexpressions.cpp: Added. (JSC::B3::eliminateCommonSubexpressions): * b3/B3EliminateCommonSubexpressions.h: Added. * b3/B3Generate.cpp: (JSC::B3::generateToAir): * b3/B3HeapRange.h: (JSC::B3::HeapRange::HeapRange): * b3/B3InsertionSet.h: (JSC::B3::InsertionSet::InsertionSet): (JSC::B3::InsertionSet::isEmpty): (JSC::B3::InsertionSet::code): (JSC::B3::InsertionSet::appendInsertion): * b3/B3MemoryValue.h: * b3/B3PureCSE.cpp: Added. (JSC::B3::PureCSE::PureCSE): (JSC::B3::PureCSE::~PureCSE): (JSC::B3::PureCSE::clear): (JSC::B3::PureCSE::process): * b3/B3PureCSE.h: Added. * b3/B3ReduceStrength.cpp: * b3/B3ReduceStrength.h: * b3/B3Validate.cpp: Source/WTF: I needed a way to track sets of ranges, where there is a high likelihood that all of the ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges. Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set that just contains top and a set that contains nothing. In the future, most sets will either be top of empty but some of them will contain a handful of other things. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MathExtras.h: (WTF::leftShiftWithSaturation): (WTF::nonEmptyRangesOverlap): (WTF::rangesOverlap): * wtf/RangeSet.h: Added. (WTF::RangeSet::RangeSet): (WTF::RangeSet::~RangeSet): (WTF::RangeSet::add): (WTF::RangeSet::contains): (WTF::RangeSet::overlaps): (WTF::RangeSet::clear): (WTF::RangeSet::dump): (WTF::RangeSet::dumpRaw): (WTF::RangeSet::compact): (WTF::RangeSet::overlapsNonEmpty): (WTF::RangeSet::subsumesNonEmpty): (WTF::RangeSet::findRange): * wtf/StdLibExtras.h: (WTF::binarySearchImpl): (WTF::binarySearch): (WTF::tryBinarySearch): (WTF::approximateBinarySearch): Canonical link: https://commits.webkit.org/171387@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
bool m_isCompact { true };
};
} // namespace WTF
using WTF::RangeSet;