[webkit-dev] When to use FastAllocBase?
Tony Gentilcore
tonyg at chromium.org
Mon Oct 4 12:21:29 PDT 2010
Thanks for the responses. That clears everything up for me.
I would recommend we add something to
http://webkit.org/coding/coding-style.html, but it sounds like we
shouldn't do anything at this point since everything is change.
On Mon, Oct 4, 2010 at 11:46 AM, Darin Adler <darin at apple.com> wrote:
> On Oct 4, 2010, at 11:31 AM, Tony Gentilcore wrote:
>
>> If you subclass RefCounted<T> or Noncopyable, which is very common, you pick up FastAllocBase.
>
> Yes, so in those cases you don’t want to use it.
>
>> So, my naive guess is that any class/struct which doesn't pick up FastAllocBase through its inheritance chain should subclass it directly. Is that a reasonable guideline?
>
> That’s OK, but:
>
> 1) FastAllocBase has been causing object size bloat, so we are planning to switch from base classes to macros. See bug 42998 <https://bugs.webkit.org/show_bug.cgi?id=42998>.
>
> 2) If the object will not ever be allocated with new, there is no benefit to deriving from FastAllocBase.
>
> 3) Our original plan was to that on platforms where ENABLE_GLOBAL_FASTMALLOC_NEW, such as Mac OS X, we would change the operator new to check at runtime and immediately assert in debug builds if someone forgot to use FastAllocBase. But as you can see if you look at FastMalloc.h, this has not been done yet.
>
> So for the moment it’s fine to follow the guideline you mention, but (1) will change how we do it soon, (2) is worth considering, and (3) will eventually make the guideline clearer than it is now because we’ll notice when we do it wrong!
>
> -- Darin
>
>
More information about the webkit-dev
mailing list