I just landed a new script called 'dump-class-layout' in
http://trac.webkit.org/changeset/188350 that shows class and struct padding.
This script uses lldb Python bindings to collect information about the data
member layout, which can be used to look for padding holes to reduce class
size. It points lldb at your built frameworks, and by default uses the last
configuration built from the command line. Optional parameters can supply a
build directory and Debug/Release configuration.
Usage is:
dump-class-layout <framework> <classname>
for example:
./Tools/Scripts/dump-class-layout WebCore RenderElement
Found 1 types matching "RenderElement" in
"/Volumes/Data/Development/OSX/webkit/OpenSource/WebKitBuild/Release/WebCore.framework/WebCore"
+0 { 72} RenderElement
+0 { 48} WebCore::RenderObject
+0 { 8} WebCore::CachedImageClient
+0 { 8} WebCore::CachedResourceClient
+0 < 8> __vtbl_ptr_type * _vptr;
+8 < 8> WebCore::Node & m_node;
+16 < 8> WebCore::RenderElement * m_parent;
+24 < 8> WebCore::RenderObject * m_previous;
+32 < 8> WebCore::RenderObject * m_next;
+40 < 4> WebCore::RenderObject::RenderObjectBitfields m_bitfields;
+40 < 4> unsigned int:1 m_hasRareData;
+40 < 4> unsigned int:1 m_beingDestroyed;
+40 < 4> unsigned int:1 m_needsLayout;
+40 < 4> unsigned int:1 m_needsPositionedMovementLayout;
+40 < 4> unsigned int:1 m_normalChildNeedsLayout;
+40 < 4> unsigned int:1 m_posChildNeedsLayout;
+40 < 4> unsigned int:1 m_needsSimplifiedNormalFlowLayout;
+40 < 4> unsigned int:1 m_preferredLogicalWidthsDirty;
+41 < 4> unsigned int:1 m_floating;
+41 < 4> unsigned int:1 m_isAnonymous;
+41 < 4> unsigned int:1 m_isTextOrRenderView;
+41 < 4> unsigned int:1 m_isBox;
+41 < 4> unsigned int:1 m_isInline;
+41 < 4> unsigned int:1 m_isReplaced;
+41 < 4> unsigned int:1 m_isLineBreak;
+41 < 4> unsigned int:1 m_horizontalWritingMode;
+42 < 4> unsigned int:1 m_hasLayer;
+42 < 4> unsigned int:1 m_hasOverflowClip;
+42 < 4> unsigned int:1 m_hasTransformRelatedProperty;
+42 < 4> unsigned int:1 m_unused;
+42 < 4> unsigned int:1 m_everHadLayout;
+42 < 4> unsigned int:1 m_childrenInline;
+42 < 4> unsigned int:2 m_positionedState;
+43 < 4> unsigned int:3 m_selectionState;
+43 < 4> unsigned int:2 m_flowThreadState;
+43 < 4> unsigned int:2 m_boxDecorationState;
+47 < 1> <PADDING>
+44 < 4> unsigned int:6 m_baseTypeFlags;
+44 < 4> unsigned int:1 m_ancestorLineBoxDirty;
+44 < 4> unsigned int:1 m_hasInitializedStyle;
+45 < 4> unsigned int:1 m_renderInlineAlwaysCreatesLineBoxes;
+45 < 4> unsigned int:1 m_renderBoxNeedsLazyRepaint;
+45 < 4> unsigned int:1 m_hasPausedImageAnimations;
+45 < 4> unsigned int:1 m_hasCounterNodeMap;
+45 < 4> unsigned int:1 m_isCSSAnimating;
+45 < 4> unsigned int:1 m_hasContinuation;
+45 < 4> unsigned int:1 m_renderBlockHasMarginBeforeQuirk;
+45 < 4> unsigned int:1 m_renderBlockHasMarginAfterQuirk;
+46 < 4> unsigned int:1
m_renderBlockHasBorderOrPaddingLogicalWidthChanged;
+46 < 4> unsigned int:1 m_renderBlockFlowHasMarkupTruncation;
+46 < 4> unsigned int:2 m_renderBlockFlowLineLayoutPath;
+48 < 8> WebCore::RenderObject * m_firstChild;
+56 < 8> WebCore::RenderObject * m_lastChild;
+64 < 8> WTF::Ref<WebCore::RenderStyle> m_style;
+64 < 8> WebCore::RenderStyle * m_ptr;
Total byte size: 72
Total pad bytes: 1
Padding percentage: 1.39 %
Enhancements welcome. The most obvious one I can think of is to target a
specific architecture.
Simon
_______________________________________________
webkit-dev mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-dev