Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 206fc19611d7c0b49d5d67a7e0bed5c3051cab3d https://github.com/WebKit/WebKit/commit/206fc19611d7c0b49d5d67a7e0bed5c3051cab3d Author: Chris Dumez <cdu...@apple.com> Date: 2023-12-04 (Mon, 04 Dec 2023)
Changed paths: M Source/WTF/wtf/CheckedRef.h M Source/WTF/wtf/WeakHashCountedSet.h M Source/WTF/wtf/WeakPtr.h M Source/WebCore/accessibility/AccessibilityRenderObject.h M Source/WebCore/css/ComputedStyleExtractor.cpp M Source/WebCore/dom/FullscreenManager.cpp M Source/WebCore/editing/TextIterator.h M Source/WebCore/html/CustomPaintImage.h M Source/WebCore/inspector/agents/InspectorDOMAgent.h M Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h M Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentPainter.h M Source/WebCore/loader/ImageLoader.h M Source/WebCore/loader/LinkPreloadResourceClients.h M Source/WebCore/loader/cache/CachedImage.h M Source/WebCore/loader/cache/CachedResource.cpp M Source/WebCore/loader/cache/CachedResource.h M Source/WebCore/loader/cache/CachedResourceClient.h M Source/WebCore/loader/cache/CachedResourceClientWalker.h M Source/WebCore/page/AutoscrollController.h M Source/WebCore/page/EventHandler.cpp M Source/WebCore/page/EventHandler.h M Source/WebCore/page/LocalFrameView.cpp M Source/WebCore/page/LocalFrameView.h M Source/WebCore/page/LocalFrameViewLayoutContext.cpp M Source/WebCore/page/LocalFrameViewLayoutContext.h M Source/WebCore/page/Page.h M Source/WebCore/platform/PODInterval.h M Source/WebCore/rendering/AccessibilityRegionContext.h M Source/WebCore/rendering/AncestorSubgridIterator.cpp M Source/WebCore/rendering/AncestorSubgridIterator.h M Source/WebCore/rendering/BaselineAlignment.h M Source/WebCore/rendering/FloatingObjects.cpp M Source/WebCore/rendering/FloatingObjects.h M Source/WebCore/rendering/Grid.h M Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp M Source/WebCore/rendering/GridTrackSizingAlgorithm.h M Source/WebCore/rendering/LayerAncestorClippingStack.h M Source/WebCore/rendering/LegacyInlineBox.cpp M Source/WebCore/rendering/LegacyInlineBox.h M Source/WebCore/rendering/LegacyRootInlineBox.cpp M Source/WebCore/rendering/LegacyRootInlineBox.h M Source/WebCore/rendering/PaintInfo.h M Source/WebCore/rendering/RenderBlock.cpp M Source/WebCore/rendering/RenderBlock.h M Source/WebCore/rendering/RenderBlockFlow.h M Source/WebCore/rendering/RenderBoxModelObject.cpp M Source/WebCore/rendering/RenderBoxModelObject.h M Source/WebCore/rendering/RenderButton.h M Source/WebCore/rendering/RenderCounter.cpp M Source/WebCore/rendering/RenderDeprecatedFlexibleBox.h M Source/WebCore/rendering/RenderElement.cpp M Source/WebCore/rendering/RenderElement.h M Source/WebCore/rendering/RenderFlexibleBox.h M Source/WebCore/rendering/RenderFragmentContainer.h M Source/WebCore/rendering/RenderFragmentedFlow.cpp M Source/WebCore/rendering/RenderFragmentedFlow.h M Source/WebCore/rendering/RenderGrid.cpp M Source/WebCore/rendering/RenderGrid.h M Source/WebCore/rendering/RenderHighlight.h M Source/WebCore/rendering/RenderImageResource.h M Source/WebCore/rendering/RenderLayer.cpp M Source/WebCore/rendering/RenderLayer.h M Source/WebCore/rendering/RenderLayerBacking.cpp M Source/WebCore/rendering/RenderLayerBacking.h M Source/WebCore/rendering/RenderLayerCompositor.cpp M Source/WebCore/rendering/RenderLayerCompositor.h M Source/WebCore/rendering/RenderLayoutState.h M Source/WebCore/rendering/RenderLineBoxList.cpp M Source/WebCore/rendering/RenderListItem.h M Source/WebCore/rendering/RenderListMarker.h M Source/WebCore/rendering/RenderMenuList.h M Source/WebCore/rendering/RenderMultiColumnFlow.h M Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h M Source/WebCore/rendering/RenderObject.h M Source/WebCore/rendering/RenderTable.cpp M Source/WebCore/rendering/RenderTable.h M Source/WebCore/rendering/RenderTableSection.cpp M Source/WebCore/rendering/RenderTableSection.h M Source/WebCore/rendering/RenderText.cpp M Source/WebCore/rendering/RenderTextFragment.h M Source/WebCore/rendering/RenderView.cpp M Source/WebCore/rendering/RenderView.h M Source/WebCore/rendering/line/LineLayoutState.h M Source/WebCore/rendering/mathml/RenderMathMLFenced.h M Source/WebCore/rendering/style/StyleGeneratedImage.h M Source/WebCore/rendering/svg/RenderSVGRoot.h M Source/WebCore/rendering/svg/RenderSVGViewportContainer.h M Source/WebCore/rendering/svg/SVGRenderSupport.cpp M Source/WebCore/rendering/svg/SVGRenderSupport.h M Source/WebCore/rendering/svg/SVGResources.cpp M Source/WebCore/rendering/svg/SVGResources.h M Source/WebCore/rendering/svg/SVGResourcesCache.cpp M Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp M Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourcePattern.cpp M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourcePattern.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceSolidColor.h M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.h M Source/WebCore/rendering/updating/RenderTreeBuilder.cpp M Source/WebCore/rendering/updating/RenderTreePosition.h M Source/WebCore/rendering/updating/RenderTreeUpdaterGeneratedContent.h M Source/WebCore/svg/graphics/SVGResourceImage.h Log Message: ----------- Optimize use of WeakPtr with RenderObject types https://bugs.webkit.org/show_bug.cgi?id=265763 Reviewed by Darin Adler. We've found that converting CheckedPtr to WeakPtr in hot code path has caused performance regressions. At the same time, CheckedPtr crashes are much harder to investigate. After some investigation, I found that DefaultWeakPtrImpl subclasses ThreadSafeRefCounted. For many types though, we don't really need this thread safety and the cost incurred to achieve it. I this patch, I introduce a SingleThreadWeakPtrImpl which relies on a SingleThreadIntegralWrapper<uint32_t> internally. In release builds, this achieves better performance. In debug, threading assertion are in place to make sure it is indeed safe to use SingleThreadWeakPtrImpl. In this patch, I also port CachedResourceClient to SingleThreadWeakPtrImpl since subclasses are main thread only. RenderObject is the particular subclasses I am interested in since it is performance sensitive and since we have not so actionable CheckedPtr crashes in the wild involving RenderObject. In follow-up patches, I am planning to replace usage for CheckedPtr with WeakPtr for RenderObject, to make those crashes actionable. * Source/WTF/wtf/CheckedRef.h: (WTF::=): * Source/WTF/wtf/WeakPtr.h: (WTF::WeakPtrImplBaseSingleThread::get): (WTF::WeakPtrImplBaseSingleThread::operator bool const): (WTF::WeakPtrImplBaseSingleThread::clear): (WTF::WeakPtrImplBaseSingleThread::wasConstructedOnMainThread const): (WTF::WeakPtrImplBaseSingleThread::WeakPtrImplBaseSingleThread): (WTF::WeakPtrImplBaseSingleThread::refCount const): (WTF::WeakPtrImplBaseSingleThread::ref const): (WTF::WeakPtrImplBaseSingleThread::deref const): * Source/WebCore/accessibility/AccessibilityRenderObject.h: * Source/WebCore/css/ComputedStyleExtractor.cpp: (WebCore::computeRenderStyleForProperty): * Source/WebCore/dom/FullscreenManager.cpp: (WebCore::FullscreenManager::willEnterFullscreen): * Source/WebCore/editing/TextIterator.h: * Source/WebCore/html/CustomPaintImage.h: * Source/WebCore/inspector/agents/InspectorDOMAgent.h: * Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h: * Source/WebCore/layout/integration/inline/LayoutIntegrationInlineContentPainter.h: * Source/WebCore/loader/ImageLoader.h: * Source/WebCore/loader/LinkPreloadResourceClients.h: * Source/WebCore/loader/cache/CachedImage.h: * Source/WebCore/loader/cache/CachedResource.cpp: (WebCore::CachedResource::switchClientsToRevalidatedResource): * Source/WebCore/loader/cache/CachedResource.h: * Source/WebCore/loader/cache/CachedResourceClient.h: * Source/WebCore/loader/cache/CachedResourceClientWalker.h: * Source/WebCore/page/AutoscrollController.h: * Source/WebCore/page/EventHandler.cpp: (WebCore::EventHandler::handleMousePressEvent): * Source/WebCore/page/EventHandler.h: * Source/WebCore/page/LocalFrameView.cpp: (WebCore::LocalFrameView::willDoLayout): (WebCore::LocalFrameView::didLayout): (WebCore::LocalFrameView::addSlowRepaintObject): (WebCore::LocalFrameView::addViewportConstrainedObject): (WebCore::LocalFrameView::updateEmbeddedObject): (WebCore::LocalFrameView::updateEmbeddedObjects): * Source/WebCore/page/LocalFrameView.h: * Source/WebCore/page/LocalFrameViewLayoutContext.cpp: (WebCore::LocalFrameViewLayoutContext::performLayout): (WebCore::LocalFrameViewLayoutContext::setBoxNeedsTransformUpdateAfterContainerLayout): (WebCore::LocalFrameViewLayoutContext::takeBoxesNeedingTransformUpdateAfterContainerLayout): * Source/WebCore/page/LocalFrameViewLayoutContext.h: * Source/WebCore/page/Page.h: * Source/WebCore/platform/PODInterval.h: * Source/WebCore/rendering/AccessibilityRegionContext.h: * Source/WebCore/rendering/AncestorSubgridIterator.cpp: (WebCore::AncestorSubgridIterator::AncestorSubgridIterator): * Source/WebCore/rendering/AncestorSubgridIterator.h: (): Deleted. * Source/WebCore/rendering/BaselineAlignment.h: * Source/WebCore/rendering/FloatingObjects.cpp: * Source/WebCore/rendering/FloatingObjects.h: * Source/WebCore/rendering/Grid.h: * Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp: (WebCore::IndefiniteSizeStrategy::accumulateFlexFraction const): (WebCore::IndefiniteSizeStrategy::findUsedFlexFraction const): (WebCore::GridTrackSizingAlgorithm::accumulateIntrinsicSizesForTrack): (WebCore::GridTrackSizingAlgorithm::resolveIntrinsicTrackSizes): * Source/WebCore/rendering/GridTrackSizingAlgorithm.h: * Source/WebCore/rendering/LayerAncestorClippingStack.h: * Source/WebCore/rendering/LegacyInlineBox.cpp: * Source/WebCore/rendering/LegacyInlineBox.h: * Source/WebCore/rendering/LegacyRootInlineBox.cpp: * Source/WebCore/rendering/LegacyRootInlineBox.h: * Source/WebCore/rendering/PaintInfo.h: (WebCore::PaintInfo::PaintInfo): * Source/WebCore/rendering/RenderBlock.cpp: (WebCore::insertIntoTrackedRendererMaps): * Source/WebCore/rendering/RenderBlock.h: * Source/WebCore/rendering/RenderBlockFlow.h: * Source/WebCore/rendering/RenderBoxModelObject.cpp: * Source/WebCore/rendering/RenderBoxModelObject.h: * Source/WebCore/rendering/RenderButton.h: * Source/WebCore/rendering/RenderCounter.cpp: * Source/WebCore/rendering/RenderDeprecatedFlexibleBox.h: * Source/WebCore/rendering/RenderElement.cpp: (WebCore::RenderElement::backdropRenderer const): * Source/WebCore/rendering/RenderElement.h: * Source/WebCore/rendering/RenderFlexibleBox.h: * Source/WebCore/rendering/RenderFragmentContainer.h: * Source/WebCore/rendering/RenderFragmentedFlow.cpp: (WebCore::RenderFragmentedFlow::FragmentSearchAdapter::collectIfNeeded): * Source/WebCore/rendering/RenderFragmentedFlow.h: * Source/WebCore/rendering/RenderGrid.cpp: (WebCore::RenderGrid::getBaselineChild const): * Source/WebCore/rendering/RenderGrid.h: * Source/WebCore/rendering/RenderHighlight.h: * Source/WebCore/rendering/RenderImageResource.h: * Source/WebCore/rendering/RenderLayer.cpp: (WebCore::findCommonAncestor): * Source/WebCore/rendering/RenderLayer.h: * Source/WebCore/rendering/RenderLayerBacking.cpp: (WebCore::clearBackingSharingLayerProviders): (WebCore::RenderLayerBacking::setBackingSharingLayers): * Source/WebCore/rendering/RenderLayerBacking.h: * Source/WebCore/rendering/RenderLayerCompositor.cpp: * Source/WebCore/rendering/RenderLayerCompositor.h: * Source/WebCore/rendering/RenderLayoutState.h: * Source/WebCore/rendering/RenderLineBoxList.cpp: (WebCore::RenderLineBoxList::paint const): * Source/WebCore/rendering/RenderListItem.h: * Source/WebCore/rendering/RenderListMarker.h: * Source/WebCore/rendering/RenderMenuList.h: * Source/WebCore/rendering/RenderMultiColumnFlow.h: * Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h: * Source/WebCore/rendering/RenderObject.h: * Source/WebCore/rendering/RenderTable.cpp: (WebCore::resetSectionPointerIfNotBefore): * Source/WebCore/rendering/RenderTable.h: * Source/WebCore/rendering/RenderTableSection.cpp: (WebCore::compareCellPositions): (WebCore::compareCellPositionsWithOverflowingCells): * Source/WebCore/rendering/RenderTableSection.h: * Source/WebCore/rendering/RenderText.cpp: (WebCore::inlineWrapperForDisplayContentsMap): * Source/WebCore/rendering/RenderTextFragment.h: * Source/WebCore/rendering/RenderView.cpp: (WebCore::RenderView::resumePausedImageAnimationsIfNeeded): (WebCore::RenderView::takeCountersNeedingUpdate): * Source/WebCore/rendering/RenderView.h: * Source/WebCore/rendering/line/LineLayoutState.h: * Source/WebCore/rendering/mathml/RenderMathMLFenced.h: * Source/WebCore/rendering/style/StyleGeneratedImage.h: (WebCore::StyleGeneratedImage::clients const): * Source/WebCore/rendering/svg/RenderSVGRoot.h: * Source/WebCore/rendering/svg/RenderSVGViewportContainer.h: * Source/WebCore/rendering/svg/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::layoutChildren): (WebCore::SVGHitTestCycleDetectionScope::visitedElements): * Source/WebCore/rendering/svg/SVGRenderSupport.h: * Source/WebCore/rendering/svg/SVGResources.cpp: (WebCore::SVGResources::buildSetOfResources): * Source/WebCore/rendering/svg/SVGResources.h: * Source/WebCore/rendering/svg/SVGResourcesCache.cpp: (WebCore::SVGResourcesCache::addResourcesFromRenderer): (WebCore::SVGResourcesCache::removeResourcesFromRenderer): * Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp: (WebCore::SVGResourcesCycleSolver::resourceContainsCycles): (WebCore::SVGResourcesCycleSolver::resolveCycles): * Source/WebCore/rendering/svg/SVGResourcesCycleSolver.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.cpp: (WebCore::LegacyRenderSVGResource::removeAllClientsFromCache): (WebCore::removeFromCacheAndInvalidateDependencies): (WebCore::LegacyRenderSVGResource::markForLayoutAndParentResourceInvalidation): (WebCore::LegacyRenderSVGResource::markForLayoutAndParentResourceInvalidationIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResource.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.cpp: (WebCore::LegacyRenderSVGResourceClipper::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceClipper.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.cpp: (WebCore::LegacyRenderSVGResourceContainer::markAllClientsForInvalidation): (WebCore::LegacyRenderSVGResourceContainer::markAllClientsForInvalidationIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.cpp: (WebCore::LegacyRenderSVGResourceFilter::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceFilter.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.cpp: (WebCore::LegacyRenderSVGResourceGradient::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.cpp: (WebCore::LegacyRenderSVGResourceMarker::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMarker.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.cpp: (WebCore::LegacyRenderSVGResourceMasker::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourcePattern.cpp: (WebCore::LegacyRenderSVGResourcePattern::removeAllClientsFromCacheIfNeeded): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourcePattern.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceSolidColor.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.h: * Source/WebCore/rendering/updating/RenderTreeBuilder.cpp: (WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange): * Source/WebCore/rendering/updating/RenderTreePosition.h: * Source/WebCore/rendering/updating/RenderTreeUpdaterGeneratedContent.h: * Source/WebCore/svg/graphics/SVGResourceImage.h: Canonical link: https://commits.webkit.org/271522@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes