Reduce Node object size from 72 byte to 64 byte
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2012 06:28:12 +0000 (06:28 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2012 06:28:12 +0000 (06:28 +0000)
commit5289e4b99bdb61bc0279adad519121b9dbfc05f7
tree36b959d4eb065f3da9a6ad415f0f459f20100cf5
parent2fa06067bd32187271d7d17a60fec880ba5ef3ed
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.order
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/Node.h
Source/WebCore/platform/TreeShared.h
Source/WebCore/svg/SVGElementInstance.cpp
Source/WebCore/svg/SVGElementInstance.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebKit.order
Source/WebKit2/ChangeLog
Source/WebKit2/mac/WebKit2.order
Source/WebKit2/win/WebKit2.def
Source/WebKit2/win/WebKit2CFLite.def
Source/autotools/symbols.filter