- Revision
- 119802
- Author
- [email protected]
- Date
- 2012-06-07 23:28:12 -0700 (Thu, 07 Jun 2012)
Log Message
Reduce Node object size from 72 byte to 64 byte
https://bugs.webkit.org/show_bug.cgi?id=88528
Reviewed by Ryosuke Niwa.
.:
Added a symbol for callRemovedLastRef().
* Source/autotools/symbols.filter:
Source/WebCore:
This patch removes all virtual methods from TreeShared.h,
by which we can remove a virtual method table pointer (8 byte
in a 64bit architechture) from each Node object. Consequently,
this patch reduces the Node object size from 72 byte to 64 byte.
e.g. The HTML spec (http://www.whatwg.org/specs/web-apps/current-work/)
contains 325640 Node objects. Thus this patch saves 325640 * 8 byte = 2.6 MB.
e.g. sizeof(Element) is reduced from 104 byte to 96 byte.
- In multiple inheritance, a virtual method table pointer is allocated
for each base class that has virtual methods. For example, for
'class A : public B, C {};' where B and C have virtual methods,
two virtual method table pointers are allocated for each A object.
In this patch, A = Node, B = EventTarget, and C = TreeShared.
By removing the virtual methods from TreeShared, we can save the virtual
method table pointer for TreeShared. 8 byte saving.
- Node and SVGElementInstance are the only classes that inherit TreeShared.
- This patch removes virtual TreeShared::removeLastRef() and implements
virtual Node::removeLastRef() and virtual SVGElementInstance::removeLastRef().
Node::removeLastRef() calls 'delete this' for 'this' of type Node*,
and SVGElementInstance::removeLastRef() calls 'delete this' for 'this' of type
SVGElementInstance*.
- This patch removes the virtual destructor of TreeShared. This removal is safe
because (1) no one calls 'delete this' for 'this' of type TreeShared*,
and (2) both Node and SVGElementInstance have virtual destructor.
No change in behavior. Confirm no regression in existing tests.
* dom/ContainerNode.cpp:
(WebCore::callRemovedLastRef):
(WebCore):
* dom/Node.h:
(WebCore::Node::removedLastRef):
* platform/TreeShared.h:
(WebCore):
(TreeShared):
(WebCore::TreeShared::deref):
* svg/SVGElementInstance.cpp:
(WebCore::callRemovedLastRef):
(WebCore):
* svg/SVGElementInstance.h:
(WebCore::SVGElementInstance::removedLastRef):
* WebCore.order: Added a symbol for callRemovedLastRef().
* WebCore.exp.in: Ditto.
Source/WebKit/mac:
Added a symbol for callRemovedLastRef().
* WebKit.order:
Source/WebKit2:
Added a symbol for callRemovedLastRef().
* mac/WebKit2.order:
* win/WebKit2.def:
* win/WebKit2CFLite.def:
Modified Paths
Diff
Modified: trunk/ChangeLog (119801 => 119802)
--- trunk/ChangeLog 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/ChangeLog 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1,3 +1,14 @@
+2012-06-07 Kentaro Hara <[email protected]>
+
+ Reduce Node object size from 72 byte to 64 byte
+ https://bugs.webkit.org/show_bug.cgi?id=88528
+
+ Reviewed by Ryosuke Niwa.
+
+ Added a symbol for callRemovedLastRef().
+
+ * Source/autotools/symbols.filter:
+
2012-06-07 Patrick Gansterer <[email protected]>
Build fix for WinCE after r113570.
Modified: trunk/Source/WebCore/ChangeLog (119801 => 119802)
--- trunk/Source/WebCore/ChangeLog 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/ChangeLog 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1,3 +1,60 @@
+2012-06-07 Kentaro Hara <[email protected]>
+
+ Reduce Node object size from 72 byte to 64 byte
+ https://bugs.webkit.org/show_bug.cgi?id=88528
+
+ Reviewed by Ryosuke Niwa.
+
+ This patch removes all virtual methods from TreeShared.h,
+ by which we can remove a virtual method table pointer (8 byte
+ in a 64bit architechture) from each Node object. Consequently,
+ this patch reduces the Node object size from 72 byte to 64 byte.
+
+ e.g. The HTML spec (http://www.whatwg.org/specs/web-apps/current-work/)
+ contains 325640 Node objects. Thus this patch saves 325640 * 8 byte = 2.6 MB.
+
+ e.g. sizeof(Element) is reduced from 104 byte to 96 byte.
+
+ - In multiple inheritance, a virtual method table pointer is allocated
+ for each base class that has virtual methods. For example, for
+ 'class A : public B, C {};' where B and C have virtual methods,
+ two virtual method table pointers are allocated for each A object.
+ In this patch, A = Node, B = EventTarget, and C = TreeShared.
+ By removing the virtual methods from TreeShared, we can save the virtual
+ method table pointer for TreeShared. 8 byte saving.
+
+ - Node and SVGElementInstance are the only classes that inherit TreeShared.
+
+ - This patch removes virtual TreeShared::removeLastRef() and implements
+ virtual Node::removeLastRef() and virtual SVGElementInstance::removeLastRef().
+ Node::removeLastRef() calls 'delete this' for 'this' of type Node*,
+ and SVGElementInstance::removeLastRef() calls 'delete this' for 'this' of type
+ SVGElementInstance*.
+
+ - This patch removes the virtual destructor of TreeShared. This removal is safe
+ because (1) no one calls 'delete this' for 'this' of type TreeShared*,
+ and (2) both Node and SVGElementInstance have virtual destructor.
+
+ No change in behavior. Confirm no regression in existing tests.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::callRemovedLastRef):
+ (WebCore):
+ * dom/Node.h:
+ (WebCore::Node::removedLastRef):
+ * platform/TreeShared.h:
+ (WebCore):
+ (TreeShared):
+ (WebCore::TreeShared::deref):
+ * svg/SVGElementInstance.cpp:
+ (WebCore::callRemovedLastRef):
+ (WebCore):
+ * svg/SVGElementInstance.h:
+ (WebCore::SVGElementInstance::removedLastRef):
+
+ * WebCore.order: Added a symbol for callRemovedLastRef().
+ * WebCore.exp.in: Ditto.
+
2012-06-07 Takashi Sakamoto <[email protected]>
ShadowRoot needs resetStyleInheritance
Modified: trunk/Source/WebCore/WebCore.exp.in (119801 => 119802)
--- trunk/Source/WebCore/WebCore.exp.in 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-06-08 06:28:12 UTC (rev 119802)
@@ -566,6 +566,7 @@
__ZNK7WebCore18PlatformPasteboard11changeCountEv
__ZN7WebCore18PlatformPasteboard5colorEv
__ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
+__ZN7WebCore18callRemovedLastRefEPNS_10TreeSharedINS_13ContainerNodeEEE
__ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
__ZN7WebCore18pluginScriptObjectEPN3JSC9ExecStateEPNS_13JSHTMLElementE
__ZN7WebCore18proxyServersForURLERKNS_4KURLEPKNS_17NetworkingContextE
Modified: trunk/Source/WebCore/WebCore.order (119801 => 119802)
--- trunk/Source/WebCore/WebCore.order 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/WebCore.order 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1923,6 +1923,7 @@
__ZN7WebCore11RenderBlock10paintCaretERNS_9PaintInfoEiiNS_9CaretTypeE
__ZNK7WebCore14FrameSelection13caretRendererEv
__ZNK7WebCore16VisibleSelection17isContentEditableEv
+__ZN7WebCore18callRemovedLastRefEPNS_10TreeSharedINS_13ContainerNodeEEE
__ZN7WebCore18isEditablePositionERKNS_8PositionE
__ZNK7WebCore19DragCaretController13caretRendererEv
__ZN7WebCore11RenderBlock25paintContinuationOutlinesERNS_9PaintInfoEii
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (119801 => 119802)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-06-08 06:28:12 UTC (rev 119802)
@@ -86,6 +86,11 @@
removeAllChildrenInContainer<Node, ContainerNode>(this);
}
+void callRemovedLastRef(TreeShared<ContainerNode>* self)
+{
+ static_cast<ContainerNode*>(self)->removedLastRef();
+}
+
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
NodeVector children;
Modified: trunk/Source/WebCore/dom/Node.h (119801 => 119802)
--- trunk/Source/WebCore/dom/Node.h 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/dom/Node.h 2012-06-08 06:28:12 UTC (rev 119802)
@@ -146,6 +146,7 @@
static StyleChange diff(const RenderStyle*, const RenderStyle*, Document*);
virtual ~Node();
+ virtual void removedLastRef() { delete this; }
// DOM methods & attributes for Node
Modified: trunk/Source/WebCore/platform/TreeShared.h (119801 => 119802)
--- trunk/Source/WebCore/platform/TreeShared.h 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/platform/TreeShared.h 2012-06-08 06:28:12 UTC (rev 119802)
@@ -32,6 +32,17 @@
template<typename T> void adopted(TreeShared<T>*);
#endif
+class ContainerNode;
+class SVGElementInstance;
+template<typename T> class TreeShared;
+
+// All classes that inherit TreeShared need to define
+// callRemovedLastRef(TreeShared<T>*). This is necessary
+// to kill all virtual methods from TreeShared, by which
+// we can save 8 byte for the virtual method table.
+void callRemovedLastRef(TreeShared<ContainerNode>*);
+void callRemovedLastRef(TreeShared<SVGElementInstance>*);
+
template<typename T> class TreeShared {
WTF_MAKE_NONCOPYABLE(TreeShared);
public:
@@ -48,6 +59,8 @@
m_inRemovedLastRefFunction = false;
#endif
}
+
+#ifndef NDEBUG
virtual ~TreeShared()
{
ASSERT(isMainThread());
@@ -55,6 +68,7 @@
ASSERT(m_deletionHasBegun);
ASSERT(!m_adoptionIsRequired);
}
+#endif
void ref()
{
@@ -75,8 +89,9 @@
if (--m_refCount <= 0 && !m_parent) {
#ifndef NDEBUG
m_inRemovedLastRefFunction = true;
+ m_deletionHasBegun = true;
#endif
- removedLastRef();
+ callRemovedLastRef(this);
}
}
@@ -109,16 +124,11 @@
bool m_inRemovedLastRefFunction;
#endif
-protected:
- virtual void removedLastRef()
- {
-#ifndef NDEBUG
- m_deletionHasBegun = true;
-#endif
- delete this;
- }
+private:
+ // Never called. removedLastRef() must be implemented in all the classes
+ // that inherit TreeShared.
+ void removedLastRef() { ASSERT(0); }
-private:
#ifndef NDEBUG
friend void adopted<>(TreeShared<T>*);
#endif
Modified: trunk/Source/WebCore/svg/SVGElementInstance.cpp (119801 => 119802)
--- trunk/Source/WebCore/svg/SVGElementInstance.cpp 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/svg/SVGElementInstance.cpp 2012-06-08 06:28:12 UTC (rev 119802)
@@ -72,6 +72,11 @@
m_element = 0;
}
+void callRemovedLastRef(TreeShared<SVGElementInstance>* self)
+{
+ static_cast<SVGElementInstance*>(self)->removedLastRef();
+}
+
void SVGElementInstance::detach()
{
// Clear all pointers. When the node is detached from the shadow DOM it should be removed but,
Modified: trunk/Source/WebCore/svg/SVGElementInstance.h (119801 => 119802)
--- trunk/Source/WebCore/svg/SVGElementInstance.h 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebCore/svg/SVGElementInstance.h 2012-06-08 06:28:12 UTC (rev 119802)
@@ -47,6 +47,7 @@
}
virtual ~SVGElementInstance();
+ virtual void removedLastRef() { delete this; };
void setParentOrHostNode(SVGElementInstance* instance) { setParent(instance); }
Modified: trunk/Source/WebKit/mac/ChangeLog (119801 => 119802)
--- trunk/Source/WebKit/mac/ChangeLog 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit/mac/ChangeLog 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1,3 +1,14 @@
+2012-06-07 Kentaro Hara <[email protected]>
+
+ Reduce Node object size from 72 byte to 64 byte
+ https://bugs.webkit.org/show_bug.cgi?id=88528
+
+ Reviewed by Ryosuke Niwa.
+
+ Added a symbol for callRemovedLastRef().
+
+ * WebKit.order:
+
2012-06-06 Andy Estes <[email protected]>
Wrap uppercaseWord, lowercaseWord, and capitalizeWord with USE(APPKIT)
Modified: trunk/Source/WebKit/mac/WebKit.order (119801 => 119802)
--- trunk/Source/WebKit/mac/WebKit.order 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit/mac/WebKit.order 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1349,6 +1349,7 @@
__ZN3WTF11VectorMoverILb0EN7WebCore18TextCheckingResultEE4moveEPKS2_S5_PS2_
__ZN3WTF6VectorIN7WebCore13GrammarDetailELm0EEC2ERKS3_
__ZN7WebCore18TextCheckingResultD1Ev
+__ZN7WebCore18callRemovedLastRefEPNS_10TreeSharedINS_13ContainerNodeEEE
__ZN3WTF6VectorIN7WebCore13GrammarDetailELm0EED1Ev
__ZN3WTF6VectorIN7WebCore18TextCheckingResultELm0EE14shrinkCapacityEm
__ZN15WebEditorClient25shouldShowDeleteInterfaceEPN7WebCore11HTMLElementE
Modified: trunk/Source/WebKit2/ChangeLog (119801 => 119802)
--- trunk/Source/WebKit2/ChangeLog 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit2/ChangeLog 2012-06-08 06:28:12 UTC (rev 119802)
@@ -1,3 +1,16 @@
+2012-06-07 Kentaro Hara <[email protected]>
+
+ Reduce Node object size from 72 byte to 64 byte
+ https://bugs.webkit.org/show_bug.cgi?id=88528
+
+ Reviewed by Ryosuke Niwa.
+
+ Added a symbol for callRemovedLastRef().
+
+ * mac/WebKit2.order:
+ * win/WebKit2.def:
+ * win/WebKit2CFLite.def:
+
2012-06-07 Andy Estes <[email protected]>
[WebKit2] Explicitly include CoreFoundation.h in config.h
Modified: trunk/Source/WebKit2/mac/WebKit2.order (119801 => 119802)
--- trunk/Source/WebKit2/mac/WebKit2.order 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit2/mac/WebKit2.order 2012-06-08 06:28:12 UTC (rev 119802)
@@ -2491,6 +2491,7 @@
__ZN7WebCore18TextCheckingResultC2ERKS0_
__ZN3WTF6VectorIN7WebCore13GrammarDetailELm0EEC2ERKS3_
__ZN7WebCore18TextCheckingResultD2Ev
+__ZN7WebCore18callRemovedLastRefEPNS_10TreeSharedINS_13ContainerNodeEEE
__ZN3WTF6VectorIN7WebCore13GrammarDetailELm0EED2Ev
__ZN3WTF6VectorIN7WebCore18TextCheckingResultELm0EE14shrinkCapacityEm
__ZN3WTF6VectorIN7WebCore18TextCheckingResultELm0EE6shrinkEm
Modified: trunk/Source/WebKit2/win/WebKit2.def (119801 => 119802)
--- trunk/Source/WebKit2/win/WebKit2.def 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit2/win/WebKit2.def 2012-06-08 06:28:12 UTC (rev 119802)
@@ -161,6 +161,7 @@
?add@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PBE@Z
?addSlowCase@AtomicString@WTF@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@2@PAVStringImpl@2@@Z
?cacheDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PAV23@PBUClassInfo@3@@Z
+ ?callRemovedLastRef@WebCore@@YAXPAV?$TreeShared@VContainerNode@WebCore@@@1@@Z
?create@HTMLContentElement@WebCore@@SA?AV?$PassRefPtr@VHTMLContentElement@WebCore@@@WTF@@PAVDocument@2@@Z
?create@Range@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@V?$PassRefPtr@VDocument@WebCore@@@4@V?$PassRefPtr@VNode@WebCore@@@4@H1H@Z
?create@ShadowRoot@WebCore@@SA?AV?$PassRefPtr@VShadowRoot@WebCore@@@WTF@@PAVElement@2@AAH@Z
Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (119801 => 119802)
--- trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def 2012-06-08 06:28:12 UTC (rev 119802)
@@ -108,6 +108,7 @@
??1ThreadCondition@WTF@@QAE@XZ
?broadcast@ThreadCondition@WTF@@QAEXXZ
?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
+ ?callRemovedLastRef@WebCore@@YAXPAV?$TreeShared@VContainerNode@WebCore@@@1@@Z
?consoleMessageArgumentCounts@InspectorConsoleAgent@WebCore@@QAE?AV?$Vector@I$0A@@WTF@@XZ
?counterValue@InspectorCounters@WebCore@@SAHW4CounterType@12@@Z
?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
Modified: trunk/Source/autotools/symbols.filter (119801 => 119802)
--- trunk/Source/autotools/symbols.filter 2012-06-08 06:22:26 UTC (rev 119801)
+++ trunk/Source/autotools/symbols.filter 2012-06-08 06:28:12 UTC (rev 119802)
@@ -63,6 +63,7 @@
_ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE;
_ZN7WebCore17InspectorCounters12counterValueENS0_11CounterTypeE;
_ZN7WebCore18HTMLContentElement6createEPNS_8DocumentE;
+_ZN7WebCore18callRemovedLastRefEPNS_10TreeSharedINS_13ContainerNodeEEE;
_ZN7WebCore19InspectorController39setResourcesDataSizeLimitsFromInternalsEii;
_ZN7WebCore21InspectorConsoleAgent28consoleMessageArgumentCountsEv;
_ZN7WebCore22instrumentationForPageEPNS_4PageE;