Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Issue 1850413002: Improve DEFINE_STATIC_LOCAL()'s handling of Blink GCed objects. (Closed)

Created:
4 years, 8 months ago by sof
Modified:
4 years, 8 months ago
Reviewers:
oilpan-reviews, haraken
CC:
chromium-reviews, blink-reviews-html_chromium.org, blink-reviews-style_chromium.org, blink-reviews-css, eae+blinkwatch, blink-reviews-dom_chromium.org, dglazkov+blink, apavlov+blink_chromium.org, darktears, blink-reviews, blink-reviews-wtf_chromium.org, Mikhail, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Improve DEFINE_STATIC_LOCAL()'s handling of Blink GCed objects. Extend DEFINE_STATIC_LOCAL() to automatically wrap up heap objects being exposed as static singletons -- the wrapping happening by way of a Persistent<>. With that in place, simplify various uses of DEFINE_STATIC_LOCAL() along with phasing out the use of DEFINE_STATIC_REF_WILL_BE_PERSISTENT() entirely. R=haraken BUG=585328 Committed: https://crrev.com/18dc8ecff5ba68d28fc536f723ae3c57eafa1b4e Cr-Commit-Position: refs/heads/master@{#384887} Committed: https://crrev.com/6b2e026b1c11833d558c8fd5c9d427f04ec3757b Cr-Commit-Position: refs/heads/master@{#384904}

Patch Set 1 #

Patch Set 2 : generalized #

Patch Set 3 : generalized even more.. #

Patch Set 4 : tidy up #

Patch Set 5 : msvc compile fix.. #

Total comments: 2

Patch Set 6 : add HeapTest unit test + rebase upto r384858. #

Total comments: 1

Patch Set 7 : rebased #

Patch Set 8 : address compilation failure #

Unified diffs Side-by-side diffs Delta from patch set Stats (+325 lines, -281 lines) Patch
M third_party/WebKit/Source/core/css/CSSDefaultStyleSheets.cpp View 1 2 1 chunk +6 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/css/CSSPathValue.h View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/css/CSSPathValue.cpp View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/css/CSSValuePool.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/css/StylePropertySerializer.cpp View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp View 1 2 3 4 5 6 1 chunk +8 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/dom/ChildListMutationScope.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/ContextFeatures.h View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/ContextFeatures.cpp View 1 2 2 chunks +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Document.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Element.cpp View 1 2 1 chunk +2 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/dom/MutationObserver.cpp View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Node.cpp View 1 2 2 chunks +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/dom/PresentationAttributeStyle.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/TreeScope.cpp View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/dom/WeakIdentifierMap.h View 1 2 3 4 3 chunks +4 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementObserver.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementProcessingStack.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/custom/CustomElementScheduler.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditingStyle.cpp View 1 2 5 chunks +13 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp View 1 2 2 chunks +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/events/EventDispatcher.cpp View 1 2 2 chunks +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/FetchContext.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/Resource.h View 1 2 chunks +2 lines, -14 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/Resource.cpp View 1 2 5 chunks +71 lines, -58 lines 0 comments Download
M third_party/WebKit/Source/core/frame/Frame.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLDetailsElement.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.cpp View 1 2 2 chunks +6 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLLinkElement.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLMediaElement.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLSourceElement.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLStyleElement.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLTableElement.cpp View 1 2 2 chunks +10 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/core/input/EventHandler.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/input/InputDeviceCapabilities.cpp View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutTestHelper.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/loader/EmptyClients.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/loader/ImageLoader.cpp View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/style/ComputedStyle.h View 1 1 chunk +0 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/style/ComputedStyle.cpp View 1 2 2 chunks +5 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/svg/SVGElement.cpp View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/svg/SVGStyleElement.cpp View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/svg/SVGUseElement.cpp View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/svg/animation/SVGSMILElement.cpp View 1 2 3 4 5 6 2 chunks +11 lines, -11 lines 0 comments Download
M third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp View 1 2 3 4 5 6 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/xml/XPathValue.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/battery/BatteryDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/device_light/DeviceLightDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/device_orientation/DeviceMotionDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/modules/gamepad/GamepadDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationDispatcher.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/fonts/FontCache.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/heap/HeapTest.cpp View 1 2 3 4 5 6 7 1 chunk +21 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/web/InspectorOverlay.cpp View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/web/WebPagePopupImpl.cpp View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/wtf/StdLibExtras.h View 1 2 3 4 5 6 7 2 chunks +52 lines, -22 lines 0 comments Download

Messages

Total messages: 40 (21 generated)
sof
please take a look. (Will rebase wrt https://codereview.chromium.org/1851383002/ once it is has landed.)
4 years, 8 months ago (2016-04-03 20:41:06 UTC) #4
haraken
LGTM. This looks like a nice refactoring! It would be worth adding a test for ...
4 years, 8 months ago (2016-04-03 23:46:42 UTC) #5
haraken
https://codereview.chromium.org/1850413002/diff/80001/third_party/WebKit/Source/wtf/StdLibExtras.h File third_party/WebKit/Source/wtf/StdLibExtras.h (right): https://codereview.chromium.org/1850413002/diff/80001/third_party/WebKit/Source/wtf/StdLibExtras.h#newcode99 third_party/WebKit/Source/wtf/StdLibExtras.h:99: // wrapped up by a strong off-heap Persistent<T> reference. ...
4 years, 8 months ago (2016-04-03 23:46:52 UTC) #7
sof
Added a HeapTest unit test over DEFINE_STATIC_LOCAL()s involving heap objects. https://codereview.chromium.org/1850413002/diff/80001/third_party/WebKit/Source/wtf/StdLibExtras.h File third_party/WebKit/Source/wtf/StdLibExtras.h (right): https://codereview.chromium.org/1850413002/diff/80001/third_party/WebKit/Source/wtf/StdLibExtras.h#newcode99 ...
4 years, 8 months ago (2016-04-04 07:09:00 UTC) #8
haraken
LGTM You can remove the definition of DEFINE_STATIC_REF_WILL_BE_PERSISTENT.
4 years, 8 months ago (2016-04-04 07:17:31 UTC) #9
sof
On 2016/04/04 07:17:31, haraken wrote: > LGTM > > You can remove the definition of ...
4 years, 8 months ago (2016-04-04 07:19:55 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1850413002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1850413002/100001
4 years, 8 months ago (2016-04-04 07:29:05 UTC) #12
commit-bot: I haz the power
Failed to apply patch for third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp: While running git apply --index -3 -p1; error: patch ...
4 years, 8 months ago (2016-04-04 09:27:49 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1850413002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1850413002/120001
4 years, 8 months ago (2016-04-04 10:47:41 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1850413002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1850413002/120001
4 years, 8 months ago (2016-04-04 12:15:56 UTC) #21
commit-bot: I haz the power
Committed patchset #7 (id:120001)
4 years, 8 months ago (2016-04-04 12:22:16 UTC) #23
commit-bot: I haz the power
Patchset 7 (id:??) landed as https://crrev.com/18dc8ecff5ba68d28fc536f723ae3c57eafa1b4e Cr-Commit-Position: refs/heads/master@{#384887}
4 years, 8 months ago (2016-04-04 12:23:26 UTC) #25
sof
A revert of this CL (patchset #7 id:120001) has been created in https://codereview.chromium.org/1855203002/ by sigbjornf@opera.com. ...
4 years, 8 months ago (2016-04-04 12:43:53 UTC) #26
sof
On 2016/04/04 12:43:53, sof wrote: > A revert of this CL (patchset #7 id:120001) has ...
4 years, 8 months ago (2016-04-04 13:13:18 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1850413002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1850413002/140001
4 years, 8 months ago (2016-04-04 13:15:38 UTC) #34
commit-bot: I haz the power
Committed patchset #8 (id:140001)
4 years, 8 months ago (2016-04-04 14:44:42 UTC) #36
commit-bot: I haz the power
Patchset 8 (id:??) landed as https://crrev.com/6b2e026b1c11833d558c8fd5c9d427f04ec3757b Cr-Commit-Position: refs/heads/master@{#384904}
4 years, 8 months ago (2016-04-04 14:46:11 UTC) #38
Jeffrey Yasskin
A revert of this CL (patchset #8 id:140001) has been created in https://codereview.chromium.org/1862513004/ by jyasskin@chromium.org. ...
4 years, 8 months ago (2016-04-05 20:33:14 UTC) #39
sof
4 years, 8 months ago (2016-04-05 20:43:59 UTC) #40
Message was sent while issue was closed.
On 2016/04/05 20:33:14, Jeffrey Yasskin wrote:
> A revert of this CL (patchset #8 id:140001) has been created in
> https://codereview.chromium.org/1862513004/ by mailto:jyasskin@chromium.org.
> 
> The reason for reverting is: Caused leaks in
>
https://build.chromium.org/p/chromium.memory.fyi/builders/Linux%20Tests%20%28...:
> 
> Leak_DefinitelyLost
> 16 bytes in 1 blocks are definitely lost in loss record 346 of 2,713
>   malloc (m_replacemalloc/vg_replace_malloc.c:1138)
>   WTF::Partitions::fastMalloc(unsigned long, char const*)
> (third_party/WebKit/Source/wtf/PartitionAlloc.h:736)
>  
>
blink::PersistentBase<blink::HeapHashSet<blink::WeakMember<blink::FontCacheClient>,
> WTF::WeakMemberHash<blink::FontCacheClient>,
> WTF::HashTraits<blink::WeakMember<blink::FontCacheClient> > >,
> (blink::WeaknessPersistentConfiguration)0,
> (blink::CrossThreadnessPersistentConfiguration)0>::operator new(unsigned long)
>
(/mnt/data/b/build/slave/chromium-rel-linux-valgrind-tests-2/build/src/out/Release/extensions_unittests)
>   blink::fontCacheClients()
> (third_party/WebKit/Source/platform/fonts/FontCache.cpp:300)
>   blink::FontCache::addClient(blink::FontCacheClient*)
> (third_party/WebKit/Source/platform/fonts/FontCache.cpp:308)
>   blink::CSSFontSelector::CSSFontSelector(blink::Document*)
> (third_party/WebKit/Source/core/css/CSSFontSelector.cpp:56)
>   blink::CSSFontSelector::create(blink::Document*)
>
(/mnt/data/b/build/slave/chromium-rel-linux-valgrind-tests-2/build/src/out/Release/extensions_unittests)
> 
> 
> Leak_DefinitelyLost
> 16 bytes in 1 blocks are definitely lost in loss record 352 of 2,713
>   malloc (m_replacemalloc/vg_replace_malloc.c:1138)
>   WTF::Partitions::fastMalloc(unsigned long, char const*)
> (third_party/WebKit/Source/wtf/PartitionAlloc.h:736)
>   blink::PersistentBase<blink::HeapHashSet<blink::Member<blink::Widget>,
> WTF::MemberHash<blink::Widget>, WTF::HashTraits<blink::Member<blink::Widget> >
> >, (blink::WeaknessPersistentConfiguration)0,
> (blink::CrossThreadnessPersistentConfiguration)0>::operator new(unsigned long)
>
(/mnt/data/b/build/slave/chromium-rel-linux-valgrind-tests-2/build/src/out/Release/extensions_unittests)
>   blink::widgetsPendingTemporaryRemovalFromParent()
> (third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.cpp:53)
>  
>
blink::HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOperations()
> (third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.cpp:91)
>   blink::HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope()
> (third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.cpp:103)
> 
> 
> Leak_DefinitelyLost
> 16 bytes in 1 blocks are definitely lost in loss record 347 of 2,713
>   malloc (m_replacemalloc/vg_replace_malloc.c:1138)
>   WTF::Partitions::fastMalloc(unsigned long, char const*)
> (third_party/WebKit/Source/wtf/PartitionAlloc.h:736)
>   blink::PersistentBase<blink::HeapHashSet<blink::WeakMember<blink::Document>,
> WTF::WeakMemberHash<blink::Document>,
> WTF::HashTraits<blink::WeakMember<blink::Document> > >,
> (blink::WeaknessPersistentConfiguration)0,
> (blink::CrossThreadnessPersistentConfiguration)0>::operator new(unsigned long)
>
(/mnt/data/b/build/slave/chromium-rel-linux-valgrind-tests-2/build/src/out/Release/extensions_unittests)
>   blink::Document::liveDocumentSet()
> (third_party/WebKit/Source/core/dom/Document.cpp:366)
>   blink::Document::Document(blink::DocumentInit const&, unsigned char)
> (third_party/WebKit/Source/core/dom/Document.cpp:509)
>   blink::HTMLDocument::HTMLDocument(blink::DocumentInit const&, unsigned char)
> (third_party/WebKit/Source/core/html/HTMLDocument.cpp:71)
> .

Hmm; the Persistent<> wrappers to these static singletons aren't leaks, really.
And that CL didn't fundamentally change the situation as Persistent<>s were used
before, so I don't get what memcheck is picking up on now.

Powered by Google App Engine
This is Rietveld 408576698