Always inline toJS() for NodeList.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 20:23:21 +0000 (20:23 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Mar 2014 20:23:21 +0000 (20:23 +0000)
<https://webkit.org/b/130974>

This is a pretty cheesy optimization, but it's a 3% progression on
Dromaeo/dom-query.html on my MBP.

Reviewed by Benjamin Poulain.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSNodeListCustom.h: Added.
(WebCore::toJS):
* dom/NodeList.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166520 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSNodeListCustom.cpp
Source/WebCore/bindings/js/JSNodeListCustom.h [new file with mode: 0644]
Source/WebCore/dom/NodeList.idl

index 0ea3759..7edbcfe 100644 (file)
@@ -1,3 +1,19 @@
+2014-03-31  Andreas Kling  <akling@apple.com>
+
+        Always inline toJS() for NodeList.
+        <https://webkit.org/b/130974>
+
+        This is a pretty cheesy optimization, but it's a 3% progression on
+        Dromaeo/dom-query.html on my MBP.
+
+        Reviewed by Benjamin Poulain.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSNodeListCustom.h: Added.
+        (WebCore::toJS):
+        * dom/NodeList.idl:
+
 2014-03-31  Benjamin Poulain  <bpoulain@apple.com>
 
         Attempt to fix the 32bits debug builds
index be44e1d..f8f8336 100644 (file)
@@ -306,6 +306,7 @@ __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDERKN3WTF6S
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDEdNS_17CSSPrimitiveValue9UnitTypesEb
 __ZN7WebCore13cookiesForDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_
 __ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
+__ZN7WebCore13createWrapperERNS_17JSDOMGlobalObjectERNS_8NodeListE
 __ZN7WebCore13directoryNameERKN3WTF6StringE
 __ZN7WebCore13listDirectoryERKN3WTF6StringES3_
 __ZN7WebCore13pointerCursorEv
@@ -1081,7 +1082,6 @@ __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_13ScriptProfileE
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_14ClientRectListE
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_19CSSStyleDeclarationE
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_5RangeE
-__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_8NodeListE
 __ZN7WebCore50restrictScaleFactorToInitialScaleIfNotUserScalableERNS_18ViewportAttributesE
 __ZN7WebCore5Color11transparentE
 __ZN7WebCore5Color5whiteE
index a516339..a43c509 100644 (file)
                ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */; };
                ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */; };
                AD03AAFA1468455300A39B5B /* CSSValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD03AAF81468453900A39B5B /* CSSValue.cpp */; };
+               AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4495F1141FC08900541EDF /* EventListenerMap.cpp */; };
                AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4495F2141FC08900541EDF /* EventListenerMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */; };
                ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMenuList.cpp; sourceTree = "<group>"; };
                ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderMenuList.h; sourceTree = "<group>"; };
                AD03AAF81468453900A39B5B /* CSSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValue.cpp; sourceTree = "<group>"; };
+               AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeListCustom.h; sourceTree = "<group>"; };
                AD4495F1141FC08900541EDF /* EventListenerMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventListenerMap.cpp; sourceTree = "<group>"; };
                AD4495F2141FC08900541EDF /* EventListenerMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListenerMap.h; sourceTree = "<group>"; };
                AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentSharedObjectPool.cpp; sourceTree = "<group>"; };
                                BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */,
                                1A750DD30A90E729000FF215 /* JSNodeIteratorCustom.cpp */,
                                BCD9C2610C17AA67005C90A2 /* JSNodeListCustom.cpp */,
+                               AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */,
                                FDBD1DFB167FE27D0051A11E /* JSOscillatorNodeCustom.cpp */,
                                FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */,
                                A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
                                A81369D8097374F600D74463 /* HTMLSelectElement.h in Headers */,
                                E44613A80CD6331000FADA75 /* HTMLSourceElement.h in Headers */,
                                977E2DCE12F0E28300C13379 /* HTMLSourceTracker.h in Headers */,
+                               AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */,
                                978AD67514130A8D00C7CAE3 /* HTMLSpanElement.h in Headers */,
                                A871DC230A15205700B12A68 /* HTMLStyleElement.h in Headers */,
                                D3D4E973130C7CFE007BA540 /* HTMLSummaryElement.h in Headers */,
index 550dd40..7b62ecf 100644 (file)
@@ -60,4 +60,10 @@ bool JSNodeList::getOwnPropertySlotDelegate(ExecState* exec, PropertyName proper
     return false;
 }
 
+JSC::JSValue createWrapper(JSDOMGlobalObject& globalObject, NodeList& nodeList)
+{
+    globalObject.vm().heap.reportExtraMemoryCost(nodeList.memoryCost());
+    return createNewWrapper<JSNodeList>(&globalObject, &nodeList);
+}
+
 } // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSNodeListCustom.h b/Source/WebCore/bindings/js/JSNodeListCustom.h
new file mode 100644 (file)
index 0000000..8a00261
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSNodeListCustom_h
+#define JSNodeListCustom_h
+
+#include "JSDOMBinding.h"
+#include "JSNodeList.h"
+
+namespace WebCore {
+
+JSC::JSValue createWrapper(JSDOMGlobalObject&, NodeList&);
+
+ALWAYS_INLINE JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, NodeList* nodeList)
+{
+    if (!nodeList)
+        return JSC::jsNull();
+    if (JSC::JSValue existingWrapper = getExistingWrapper<JSNodeList>(globalObject, nodeList))
+        return existingWrapper;
+    return createWrapper(*globalObject, *nodeList);
+}
+
+} // namespace WebCore
+
+#endif // JSNodeListCustom_h
index 5ac4974..fc31b1b 100644 (file)
@@ -20,7 +20,9 @@
 
 [
     CustomIsReachable,
+    CustomToJSObject,
     JSCustomGetOwnPropertySlotAndDescriptor,
+    JSCustomHeader,
     SkipVTableValidation,
     ReportExtraMemoryCost,
 ] interface NodeList {