New issue
Advanced search Search tips

Issue 671414 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 781645
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Remove duplication between base::WrapUnique and WTF::wrapUnique (and similar pairs of functions)

Project Member Reported by lukasza@chromium.org, Dec 6 2016

Issue description

From https://codereview.chromium.org/2547053003/#msg14:

we shouldn't have two different implementations of WrapUnique(). 
Can we move assert() in WTF::wrapUnique() to base::WrapUnique(), or can we
implement the assertion in blink-gc clang plugin?
 
Owner: haraken@chromium.org
Status: Assigned (was: Available)
haraken@, would you agree that this sounds like something that could be implemented in blink-gc clang plugin?  I think this route sounds promising - if we can implement the equivalent of static_asserts from wtf/PtrUtil.h in blink-gc clang plugin, then wtf/PtrUtil.h can have no function bodies and can just say:

    namespace WTF {
    
    template <typename T>
    using makeUnique = base::MakeUnique<T>
    
    template <typename T>
    using wrapUnique = base::WrapUnique<T>
    
    ...
    
    }

IMO, the static asserts cannot be moved into //base (because //base doesn't know anything about things like WTF::IsGarbageCollectedType<T>.
Cc: dcheng@chromium.org
There's a cost to implementing checks in clang: it doesn't work in MSVC, it's harder to make changes, any changes take longer to propagate through the system, and it can make compiler rolls harder.

It is a bit unfortunate to have this bit of duplication, but it doesn't feel overly burdensome either.

Comment 4 by tkent@chromium.org, Dec 6 2016

Components: Blink>Internals>WTF
Labels: -Type-Bug -Pri-2 Pri-3 Type-Feature
https://codereview.chromium.org/2547053003/#msg16
haraken@ wrote: 
> What's the advantage of removing WTF::wrapUnique, in the first place? We are not
> allowed to use base:: types directly in core/ and modules/, so we anyway need to
> wrap the base:: types in wtf/.

Right.  There would be no much benefit because we limit base:: usage in Blink.  Just code duplication is harmful in general.
So if we need much effort to consolidate implementations into one, I don't think we need to do so.

Ok, blink-gc plugin isn't reasonable.
I think it's not difficult to move IsGarbageCollectedType to base.



Comment 5 by yutak@chromium.org, Dec 6 2016

wrapUnique is so small and obvious that I don't care about code duplication.
I'm in favor of WONTFIX-ing this.

Comment 6 by yutak@chromium.org, Dec 6 2016

Also, Clang plugins should be used for checks that cannot be expressed in C++.
If the equivalent check can be written in C++, the C++ version would be superior
in all respects.
Components: -Blink>MemoryAllocator>GarbageCollection

Comment 9 by tkent@chromium.org, Mar 26 2018

Mergedinto: 781645
Status: Duplicate (was: Assigned)

Sign in to add a comment