haikuwebkit/Source/WTF/wtf/BubbleSort.h

99 lines
3.8 KiB
C
Raw Permalink Normal View History

B3/Air should use bubble sort for their insertion sets, because it's faster than std::stable_sort https://bugs.webkit.org/show_bug.cgi?id=150828 Reviewed by Geoffrey Garen. Source/JavaScriptCore: Undo the 2% compile time regression caused by http://trac.webkit.org/changeset/191913. * b3/B3InsertionSet.cpp: (JSC::B3::InsertionSet::execute): Switch to bubble sort. * b3/air/AirInsertionSet.cpp: (JSC::B3::Air::InsertionSet::execute): Switch to bubble sort. * dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::execute): Switch back to quicksort. Source/WTF: Add a pretty good bubble sort implementation to WTF. This implementation has three common tricks: - Forward and backward scans. This reduces the severity of certain kinds of bubble sort pathologies. - Return if a scan finds the list to be sorted. This gives the algorithm one of its most attractive properties: it's super fast when the list is already sorted. - Each scan eliminates one element from future scans. This makes the algorithm no worse than insertion sort. Why do we want this? Because bubble sort is a really great stable sort for small lists, or large lists in which only a handful of elements are out of order. Compiler insertion sets tend to be one of those or somewhere in between: usually they are very small, and usually they are sorted. It's rare that an element will be out of order, and when it is, it's usually very close to where it's supposed to be. This is a significant speed-up for B3 compile times. * WTF.xcodeproj/project.pbxproj: * wtf/BubbleSort.h: Added. (WTF::bubbleSort): * wtf/CMakeLists.txt: Canonical link: https://commits.webkit.org/169048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-11-03 18:48:45 +00:00
/*
* Copyright (C) 2015 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/Air should use bubble sort for their insertion sets, because it's faster than std::stable_sort https://bugs.webkit.org/show_bug.cgi?id=150828 Reviewed by Geoffrey Garen. Source/JavaScriptCore: Undo the 2% compile time regression caused by http://trac.webkit.org/changeset/191913. * b3/B3InsertionSet.cpp: (JSC::B3::InsertionSet::execute): Switch to bubble sort. * b3/air/AirInsertionSet.cpp: (JSC::B3::Air::InsertionSet::execute): Switch to bubble sort. * dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::execute): Switch back to quicksort. Source/WTF: Add a pretty good bubble sort implementation to WTF. This implementation has three common tricks: - Forward and backward scans. This reduces the severity of certain kinds of bubble sort pathologies. - Return if a scan finds the list to be sorted. This gives the algorithm one of its most attractive properties: it's super fast when the list is already sorted. - Each scan eliminates one element from future scans. This makes the algorithm no worse than insertion sort. Why do we want this? Because bubble sort is a really great stable sort for small lists, or large lists in which only a handful of elements are out of order. Compiler insertion sets tend to be one of those or somewhere in between: usually they are very small, and usually they are sorted. It's rare that an element will be out of order, and when it is, it's usually very close to where it's supposed to be. This is a significant speed-up for B3 compile times. * WTF.xcodeproj/project.pbxproj: * wtf/BubbleSort.h: Added. (WTF::bubbleSort): * wtf/CMakeLists.txt: Canonical link: https://commits.webkit.org/169048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-11-03 18:48:45 +00:00
namespace WTF {
// Why would you want to use bubble sort? When you know that your input is already mostly
// sorted! This sort is guaranteed stable (it won't reorder elements that were equal), it
// doesn't require any scratch memory, and is the fastest available sorting algorithm if your
// input already happens to be sorted. This sort is also likely to have competetive performance
// for small inputs, even if they are very unsorted.
// We use this sorting algorithm for compiler insertion sets. An insertion set is usually very
// nearly sorted. It shouldn't take more than a few bubbles to make it fully sorted. We made
// this decision deliberately. Here's the performance of the testb3 Complex(64, 384) benchmark
// with the Air::InsertionSet doing no sorting, std::stable_sorting, and bubbleSorting:
//
// no sort: 8.8222 +- 0.1911 ms.
// std::stable_sort: 9.0135 +- 0.1418 ms.
// bubbleSort: 8.8457 +- 0.1511 ms.
//
// Clearly, bubble sort is superior.
//
// Note that the critical piece here is that insertion sets tend to be small, they must be
// sorted, the sort must be stable, they are usually already sorted to begin with, and when they
// are unsorted it's usually because of a few out-of-place elements.
template<typename IteratorType, typename LessThan>
void bubbleSort(IteratorType begin, IteratorType end, const LessThan& lessThan)
{
for (;;) {
bool changed = false;
ASSERT(end >= begin);
size_t limit = end - begin;
for (size_t i = limit; i-- > 1;) {
if (lessThan(begin[i], begin[i - 1])) {
std::swap(begin[i], begin[i - 1]);
changed = true;
}
}
if (!changed)
return;
// After one run, the first element in the list is guaranteed to be the smallest.
begin++;
// Now go in the other direction. This eliminates most sorting pathologies.
changed = false;
ASSERT(end >= begin);
limit = end - begin;
for (size_t i = 1; i < limit; ++i) {
if (lessThan(begin[i], begin[i - 1])) {
std::swap(begin[i], begin[i - 1]);
changed = true;
}
}
if (!changed)
return;
// Now the last element is guaranteed to be the largest.
end--;
}
}
template<typename IteratorType>
void bubbleSort(IteratorType begin, IteratorType end)
{
bubbleSort(
begin, end,
Use auto for some of our lambda function parameters https://bugs.webkit.org/show_bug.cgi?id=158001 Reviewed by Darin Adler. Use auto for some of our lambda function parameters now that we build with c++14. Source/WebCore: * Modules/mediasource/MediaSource.cpp: (WebCore::MediaSource::buffered): (WebCore::MediaSource::monitorSourceBuffers): (WebCore::MediaSource::endOfStream): * Modules/mediasource/SampleMap.cpp: (WebCore::PresentationOrderSampleMap::findSamplesWithinPresentationRangeFromEnd): * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::ariaSelectedRows): * bindings/js/SerializedScriptValue.cpp: (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB): * css/CSSValueList.cpp: (WebCore::CSSValueList::removeAll): * css/MediaList.cpp: (WebCore::MediaQuerySet::remove): * css/MediaQuery.cpp: (WebCore::MediaQuery::MediaQuery): * css/MediaQueryMatcher.cpp: (WebCore::MediaQueryMatcher::removeListener): * dom/Document.cpp: (WebCore::Document::validateAutoSizingNodes): * dom/Element.cpp: (WebCore::Element::detachAttrNodeFromElementWithValue): * dom/MutationObserver.cpp: (WebCore::MutationObserver::deliverAllMutations): * dom/Node.cpp: (WebCore::Node::unregisterMutationObserver): * html/LinkIconCollector.cpp: * inspector/InspectorIndexedDBAgent.cpp: (WebCore::InspectorIndexedDBAgent::requestDatabaseNames): * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::loadDataURL): * page/CaptionUserPreferences.cpp: (WebCore::CaptionUserPreferences::sortedTrackListForMenu): * page/CaptionUserPreferencesMediaAF.cpp: (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): * page/animation/AnimationController.cpp: (WebCore::AnimationControllerPrivate::clear): * platform/graphics/FontCascade.cpp: (WebCore::pruneUnreferencedEntriesFromFontCascadeCache): * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::pruneSystemFallbacks): * platform/graphics/PathUtilities.cpp: (WebCore::addIntersectionPoints): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateTracks): * platform/graphics/texmap/TextureMapperGL.cpp: (WebCore::TextureMapperGLData::SharedGLData::~SharedGLData): * platform/mac/HIDGamepad.cpp: (WebCore::HIDGamepad::initElements): * svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::appendLigatureSubtable): (WebCore::SVGToOTFFontConverter::finishAppendingKERNSubtable): Source/WebKit2: * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp: (WebKit::WebIDBConnectionToClient::didGetRecord): * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles): * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::retrieveCacheEntry): (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry): * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: (WebKit::NetworkCache::SpeculativeLoad::didFinishLoading): * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp: (WebKit::NetworkCache::SpeculativeLoadManager::registerLoad): (WebKit::NetworkCache::SpeculativeLoadManager::retrieveEntryFromStorage): (WebKit::NetworkCache::SpeculativeLoadManager::revalidateEntry): (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry): (WebKit::NetworkCache::SpeculativeLoadManager::retrieveSubresourcesEntry): * NetworkProcess/cache/NetworkCacheStorage.cpp: (WebKit::NetworkCache::Storage::removeFromPendingWriteOperations): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]): (-[WKNetworkSessionDelegate URLSession:task:_schemeUpgraded:completionHandler:]): * Shared/API/Cocoa/_WKRemoteObjectInterface.mm: (-[_WKRemoteObjectInterface debugDescription]): * UIProcess/API/C/WKApplicationCacheManager.cpp: (WKApplicationCacheManagerGetApplicationCacheOrigins): * UIProcess/API/C/WKKeyValueStorageManager.cpp: (WKKeyValueStorageManagerGetKeyValueStorageOrigins): (WKKeyValueStorageManagerGetStorageDetailsByOrigin): * UIProcess/API/C/WKResourceCacheManager.cpp: (WKResourceCacheManagerGetCacheOrigins): * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: (-[WKWebsiteDataStore _fetchDataRecordsOfTypes:withOptions:completionHandler:]): * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp: (WebKit::PlatformCALayerRemote::removeAnimationForKey): Source/WTF: * wtf/BubbleSort.h: (WTF::bubbleSort): Tools: * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: (WTR::InjectedBundle::willDestroyPage): Canonical link: https://commits.webkit.org/176143@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-24 16:50:26 +00:00
[](auto& left, auto& right) {
B3/Air should use bubble sort for their insertion sets, because it's faster than std::stable_sort https://bugs.webkit.org/show_bug.cgi?id=150828 Reviewed by Geoffrey Garen. Source/JavaScriptCore: Undo the 2% compile time regression caused by http://trac.webkit.org/changeset/191913. * b3/B3InsertionSet.cpp: (JSC::B3::InsertionSet::execute): Switch to bubble sort. * b3/air/AirInsertionSet.cpp: (JSC::B3::Air::InsertionSet::execute): Switch to bubble sort. * dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::execute): Switch back to quicksort. Source/WTF: Add a pretty good bubble sort implementation to WTF. This implementation has three common tricks: - Forward and backward scans. This reduces the severity of certain kinds of bubble sort pathologies. - Return if a scan finds the list to be sorted. This gives the algorithm one of its most attractive properties: it's super fast when the list is already sorted. - Each scan eliminates one element from future scans. This makes the algorithm no worse than insertion sort. Why do we want this? Because bubble sort is a really great stable sort for small lists, or large lists in which only a handful of elements are out of order. Compiler insertion sets tend to be one of those or somewhere in between: usually they are very small, and usually they are sorted. It's rare that an element will be out of order, and when it is, it's usually very close to where it's supposed to be. This is a significant speed-up for B3 compile times. * WTF.xcodeproj/project.pbxproj: * wtf/BubbleSort.h: Added. (WTF::bubbleSort): * wtf/CMakeLists.txt: Canonical link: https://commits.webkit.org/169048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-11-03 18:48:45 +00:00
return left < right;
});
}
} // namespace WTF
using WTF::bubbleSort;