Replace calls to Vector::resize() with calls to more efficient shrink() / grow()...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 21:06:12 +0000 (21:06 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 21:06:12 +0000 (21:06 +0000)
commitdad599d92cf2e5a73599f45a08904962005c0c95
tree13bd3acd56354e44c38d15ebdc7e868435c0740e
parent104c413e349cc87976610a51d7aed01c42ff130b
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
78 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/B3BasicBlockUtils.h
Source/JavaScriptCore/b3/B3InferSwitches.cpp
Source/JavaScriptCore/b3/B3LowerToAir.cpp
Source/JavaScriptCore/b3/B3ReduceStrength.cpp
Source/JavaScriptCore/b3/B3SparseCollection.h
Source/JavaScriptCore/b3/B3UseCounts.cpp
Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp
Source/JavaScriptCore/b3/air/AirEmitShuffle.cpp
Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp
Source/JavaScriptCore/b3/air/AirOptimizeBlockOrder.cpp
Source/JavaScriptCore/bytecode/Operands.h
Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp
Source/JavaScriptCore/dfg/DFGBlockInsertionSet.cpp
Source/JavaScriptCore/dfg/DFGBlockMapInlines.h
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGDisassembler.cpp
Source/JavaScriptCore/dfg/DFGFlowIndexing.cpp
Source/JavaScriptCore/dfg/DFGGraph.cpp
Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp
Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
Source/JavaScriptCore/dfg/DFGLivenessAnalysisPhase.cpp
Source/JavaScriptCore/dfg/DFGNaturalLoops.cpp
Source/JavaScriptCore/dfg/DFGStoreBarrierClusteringPhase.cpp
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Source/JavaScriptCore/heap/CodeBlockSet.cpp
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp
Source/JavaScriptCore/interpreter/ShadowChicken.cpp
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Lexer.h
Source/JavaScriptCore/runtime/RegExpInlines.h
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/yarr/RegularExpression.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/IndexSparseSet.h
Source/WTF/wtf/Insertion.h
Source/WTF/wtf/RangeSet.h
Source/WTF/wtf/Vector.h
Source/WTF/wtf/persistence/Coders.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/gamepad/Gamepad.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/websockets/WebSocketChannel.cpp
Source/WebCore/Modules/websockets/WebSocketDeflater.cpp
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/DFABytecodeCompiler.cpp
Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp
Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp
Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm
Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp
Source/WebCore/platform/graphics/ImageBackingStore.h
Source/WebCore/platform/graphics/WOFFFileFormat.cpp
Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp
Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp
Source/WebCore/platform/image-encoders/JPEGImageEncoder.cpp
Source/WebCore/platform/text/DecodeEscapeSequences.h
Source/WebCore/platform/text/SuffixTree.h
Source/WebCore/rendering/Grid.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebKit/ChangeLog
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/Map.h