Skip to content

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Jul 8, 2025

d5c8c97

Reduce use of Vector::resize()
https://bugs.webkit.org/show_bug.cgi?id=295565

Reviewed by Darin Adler.

Reduce use of Vector::resize(), in favor of more efficient alternatives.

* Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp:
(JSC::B3::Air::Greedy::GreedyAllocator::forEachTmpInGroup):
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGValidate.cpp:
* Source/JavaScriptCore/jit/ExecutableAllocator.cpp:
* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseFunctionType):
(JSC::Wasm::SectionParser::parseStructType):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/WTF/wtf/Assertions.cpp:
* Source/WTF/wtf/Dominators.h:
(WTF::Dominators::NaiveDominators::NaiveDominators):
* Source/WebCore/Modules/mediastream/STUNMessageParsing.cpp:
(WebCore::WebRTC::extractSTUNOrTURNMessages):
* Source/WebCore/contentextensions/DFAMinimizer.cpp:
* Source/WebCore/crypto/cocoa/CryptoAlgorithmRSA_OAEPMac.cpp:
(WebCore::decryptRSA_OAEP):
* Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::initializeContextState):
* Source/WebCore/platform/audio/AudioResampler.cpp:
(WebCore::AudioResampler::configureChannels):
* Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.mm:
(WebCore::MultiGamepadProvider::indexForNewlyConnectedDevice):
* Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::optionsForKeyRequestWithHashSalt):
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockAudioSharedInternalUnit::reconfigure):
* Source/WebCore/rendering/GridMasonryLayout.cpp:
(WebCore::GridMasonryLayout::resizeAndResetRunningPositions):
* Source/WebCore/rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::GridAxis::resize):
* Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:
(WebCore::SVGTextLayoutAttributes::clear):
* Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::measureTextRenderer):
* Source/WebCore/testing/MockGamepadProvider.cpp:
(WebCore::MockGamepadProvider::setMockGamepadDetails):
* Source/WebGPU/WebGPU/ComputePassEncoder.mm:
(WebGPU::ComputePassEncoder::setPipeline):
* Source/WebGPU/WebGPU/HardwareCapabilities.mm:
(WebGPU::mergeFeatures):
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::RenderPassEncoder::setPipeline):

Canonical link: https://commits.webkit.org/297166@main

7f562d7

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@cdumez cdumez self-assigned this Jul 8, 2025
@cdumez cdumez added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Jul 8, 2025
@cdumez cdumez marked this pull request as ready for review July 8, 2025 14:30
@cdumez cdumez requested review from a team, mwyrzykowski, rniwa and tadeuzagallo as code owners July 8, 2025 14:31
@cdumez cdumez requested a review from darinadler July 8, 2025 14:31
Copy link
Contributor

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ WebGPU changes

Copy link
Member

@darinadler darinadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a more optimized function for growing a known-to-be-freshly-created vector? It would be analogous to reserveInitialCapacity. Seems a common idiom but maybe not worth creating yet another function.

@cdumez
Copy link
Contributor Author

cdumez commented Jul 9, 2025

Should we have a more optimized function for growing a known-to-be-freshly-created vector? It would be analogous to reserveInitialCapacity. Seems a common idiom but maybe not worth creating yet another function.

I will look into it in a follow up. I guess I'll do some A/B testing to see if we see any impact when adopting globally.

@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Jul 9, 2025
https://bugs.webkit.org/show_bug.cgi?id=295565

Reviewed by Darin Adler.

Reduce use of Vector::resize(), in favor of more efficient alternatives.

* Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp:
(JSC::B3::Air::Greedy::GreedyAllocator::forEachTmpInGroup):
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGValidate.cpp:
* Source/JavaScriptCore/jit/ExecutableAllocator.cpp:
* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseFunctionType):
(JSC::Wasm::SectionParser::parseStructType):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/WTF/wtf/Assertions.cpp:
* Source/WTF/wtf/Dominators.h:
(WTF::Dominators::NaiveDominators::NaiveDominators):
* Source/WebCore/Modules/mediastream/STUNMessageParsing.cpp:
(WebCore::WebRTC::extractSTUNOrTURNMessages):
* Source/WebCore/contentextensions/DFAMinimizer.cpp:
* Source/WebCore/crypto/cocoa/CryptoAlgorithmRSA_OAEPMac.cpp:
(WebCore::decryptRSA_OAEP):
* Source/WebCore/html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::initializeContextState):
* Source/WebCore/platform/audio/AudioResampler.cpp:
(WebCore::AudioResampler::configureChannels):
* Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.mm:
(WebCore::MultiGamepadProvider::indexForNewlyConnectedDevice):
* Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::optionsForKeyRequestWithHashSalt):
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockAudioSharedInternalUnit::reconfigure):
* Source/WebCore/rendering/GridMasonryLayout.cpp:
(WebCore::GridMasonryLayout::resizeAndResetRunningPositions):
* Source/WebCore/rendering/RenderFrameSet.cpp:
(WebCore::RenderFrameSet::GridAxis::resize):
* Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:
(WebCore::SVGTextLayoutAttributes::clear):
* Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::measureTextRenderer):
* Source/WebCore/testing/MockGamepadProvider.cpp:
(WebCore::MockGamepadProvider::setMockGamepadDetails):
* Source/WebGPU/WebGPU/ComputePassEncoder.mm:
(WebGPU::ComputePassEncoder::setPipeline):
* Source/WebGPU/WebGPU/HardwareCapabilities.mm:
(WebGPU::mergeFeatures):
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::RenderPassEncoder::setPipeline):

Canonical link: https://commits.webkit.org/297166@main
@webkit-commit-queue webkit-commit-queue force-pushed the 295565_reduce_Vector_resize branch from 7f562d7 to d5c8c97 Compare July 9, 2025 16:50
@webkit-commit-queue
Copy link
Collaborator

Committed 297166@main (d5c8c97): https://commits.webkit.org/297166@main

Reviewed commits have been landed. Closing PR #47698 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit d5c8c97 into WebKit:main Jul 9, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants