Hello WebKit folks!
They are drop-in-replacement to std::make_unique<T>, and we should not use std::make_unique<T> after that patch is introduced.
I’m planning to add cpplint check for `std::make_unique` to avoid the use of that.
The motivation behind this change is the following.
1. Our typical way of allocating heap memory is three-fold. Using containers (Vector etc.), RefCounted, and std::unique_ptr.
2. Containers and RefCounted are covered well by FastMalloc.
3. But std::unique_ptr case, we missed using FastMalloc in many places so far.
Even in very recently written code, we missed FastMalloc annotation. For example, we sometimes create a data structure just like a struct, and allocate it with make_unique.
struct XXXData {
...
};
m_data = std::make_unique<XXXData>();
We missed WTF_MAKE_STRUCT_FAST_ALLOCATED annotation in XXXData so frequently so that the allocation of XXXData ends up being allocated from system-malloc.
This WTF::makeUnique adds one `static_assert` over std::make_unique: the static_assert ensures T is FastMalloced or IsoHeap-allocated.
Otherwise, we see compile-error. This mechanism surprisingly found so many classes that do not have WTF_MAKE_FAST_ALLOCATED / WTF_MAKE_STRUCT_FAST_ALLOCATED in our code base.
If the type T comes from ThirdParty and if we cannot annotate T with FAST_ALLOCATED, we can use WTF::makeUniqueWithoutFastMallocCheck explicitly as a fallback.
I already annotated missed structs / classes with WTF_MAKE_FAST_ALLOCATED in
https://trac.webkit.org/changeset/248762. So, now I think 99% of allocations in WebKit-itself are handled well by FastMalloc.
-Yusuke