2010-02-24 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2010 04:07:37 +0000 (04:07 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2010 04:07:37 +0000 (04:07 +0000)
commit8da090cad1ec11c221e568131b8635c10c9ff879
treef70e5485634bac9d4f532c589b8ce8ed8051f759
parentf4bbad1fcd2955035114fa7fe0f8a26f6fc3ff70
2010-02-24  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Oliver Hunt.

        Cache JavaScript wrappers inline in DOM nodes
        https://bugs.webkit.org/show_bug.cgi?id=35226

        <rdar://problem/7664202>

        7.4% speedup on Dromaeo DOM Core tests.
        2.3% speedup on Hixie DOM Core tests.

        This fixes the following things from the last attempt:
        - Now builds in both debug and release and passes all tests
        - Properly use a WeakGCPtr, not just a raw pointer, in ScriptWrappable
        - Properly look in the appropriate per-document or per-world map
        - Added an assert that would have caught any of the problems I found
        - Handle clearing the inline cache properly in all cases

        * bindings/js/JSDOMBinding.cpp:
        (WebCore::cacheDOMObjectWrapper): Adjust for name changes.
        (WebCore::forgetDOMNode): Clear wrapper pointer.
        (WebCore::cacheDOMNodeWrapper): Cache inline too if caching for normal world.
        * bindings/js/JSDOMBinding.h:
        (WebCore::Document::getWrapperCache): Inlined.
        (WebCore::domObjectWrapperMapFor): Renamed to start with lowercase. Moved to header to inline.
        * bindings/js/JSDOMWrapper.h: Added.
        (WebCore::DOMObject::DOMObject): Factored this out of JSDOMBinding.h to avoid include
        cycle. I think the class should be renamed, I picked a forward-looking header name because
        we already have a DOMObject.h
        * bindings/js/JSNodeCustom.cpp:
        (WebCore::createWrapperInline): Renamed version of original createWrapper.
        (WebCore::createWrapper): Call createWrapperInline. Out-of-line version.
        (WebCore::toJSNewlyCreated): Call createWrapperInline instead of createWrapper.
        * bindings/js/JSNodeCustom.h: Added.
        (WebCore::getCachedDOMNodeWrapper): Moved from JSDOMBinding.cpp and moved here,
        so it could inline everywhere without creating an include cycle. Consider inline
        cache.
        (WebCore::toJS): Moved to header to inline.
        * bindings/js/ScriptWrappable.h:
        (WebCore::ScriptWrappable::ScriptWrappable): Implement this in the obvious
        way for JavaScriptCore. (Using a WeakGCPtr).
        (WebCore::ScriptWrappable::wrapper):
        (WebCore::ScriptWrappable::setWrapper):
        (WebCore::ScriptWrappable::clearWrapper):
        * bindings/scripts/CodeGeneratorJS.pm: Include CustomHeader heaaders
        in the header, not just the impl file, so they can add inlining.
        * dom/Node.idl: Add CustomHeader directive.

        Add new files to build.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55215 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSDOMBinding.cpp
WebCore/bindings/js/JSDOMBinding.h
WebCore/bindings/js/JSDOMWrapper.h [new file with mode: 0644]
WebCore/bindings/js/JSNodeCustom.cpp
WebCore/bindings/js/JSNodeCustom.h [new file with mode: 0644]
WebCore/bindings/js/ScriptWrappable.h
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/dom/Node.idl