Summary: | FastAllocBase is probably making many of our objects a bit bigger | ||
---|---|---|---|
Product: | WebKit | Reporter: | Zoltan Horvath <zoltan> |
Component: | Web Template Framework | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | ap, darin, skyul |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | All | ||
Bug Depends on: | |||
Bug Blocks: | 39414 | ||
Attachments: |
Description
Zoltan Horvath
2010-01-20 05:45:48 PST
Created attachment 48558 [details]
List of classes which first member is RefPtr and inherited from FastAllocBase
This list contains almost all classes (142) which are inherited from FastAllocBase and their first member is a RefPtr.
Created attachment 48560 [details]
List of classes which are instantiated by new and inherited from FastAllocBase
I did another analysis . This txt contains the list of classes - 956 pieces - which are instantiated by new and inherited from FastAllocBase somehow.
Created attachment 52139 [details]
List of classes whose size grows
I've put more effort on this topic, the results:
The problem:
If a FastAllocBase class' first member is a FasAllocBase class then padding is added to the object and this making the object bigger.
The object's size grows by 4 bytes.
e.g. (on my Debian-x86)
FontPlatformDataCacheKey 28 bytes -> 32 bytes
Parser 76 bytes -> 80 bytes
MediaQueryExp 12 bytes -> 16 bytes
This problem stands for only in non-template cases, so aren't valid for the following cases:
- if the class is inherited from FastAllocBase through (e.g.) RefCounted<X>, padding are not added;
- if the first member is a template instantiation, padding are not added;
Solutions:
1. We can reorder the members (we can do this only a subset of the listed classes)
e.g. struct ScopeNodeData (JavaScriptCore/parser/Nodes.h:1375)
If we place int m_numConstants; to the first member of ScopeNodeData padding wont' be added.
2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so padding won't be added.
(In reply to comment #4) > 2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so > padding won't be added. Lets do that. (In reply to comment #5) > (In reply to comment #4) > > 2. Make FastAllocBase a class template and inherit from FastAllocBase<X>, so > > padding won't be added. > > Lets do that. I tested this solution on a simple instance and unfortunately it didn't work. Padding was added in template case as well. The solution for the problem is to using macros instead of inheriting. See: bug #46589 and bug #42998. |