Title: [162801] trunk
Revision
162801
Author
[email protected]
Date
2014-01-26 02:30:47 -0800 (Sun, 26 Jan 2014)

Log Message

Improve the bindings of NodeList's name accessor
https://bugs.webkit.org/show_bug.cgi?id=127358

Patch by Benjamin Poulain <[email protected]> on 2014-01-26
Reviewed by Geoffrey Garen.

Source/WebCore: 

When accessing an item of NodeList by name, the default bindings was
going through the list of node twice:
-First, getOwnProperty calls canGetItemsForName() to find if a property exists for
 the given name. This in turn used NodeList::namedItem() which is a slow operation.
-Then, the value itself was queried through nameGetter(), calling NodeList::namedItem()
 a second time to find the same value.

This patch kills the default name getter in favor of a getOwnPropertySlotDelegate() returning
the value directly on the PropertySlot.

Ad Hoc testing show about 15% speed up for simple cases.

* bindings/js/JSNodeListCustom.cpp:
(WebCore::JSNodeList::getOwnPropertySlotDelegate):
* dom/NodeList.idl:

LayoutTests: 

* fast/dom/NodeList/nodelist-name-getter-properties-expected.txt: Added.
* fast/dom/NodeList/nodelist-name-getter-properties.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (162800 => 162801)


--- trunk/LayoutTests/ChangeLog	2014-01-26 10:26:44 UTC (rev 162800)
+++ trunk/LayoutTests/ChangeLog	2014-01-26 10:30:47 UTC (rev 162801)
@@ -1,5 +1,15 @@
 2014-01-26  Benjamin Poulain  <[email protected]>
 
+        Improve the bindings of NodeList's name accessor
+        https://bugs.webkit.org/show_bug.cgi?id=127358
+
+        Reviewed by Geoffrey Garen.
+
+        * fast/dom/NodeList/nodelist-name-getter-properties-expected.txt: Added.
+        * fast/dom/NodeList/nodelist-name-getter-properties.html: Added.
+
+2014-01-26  Benjamin Poulain  <[email protected]>
+
         ASSERTION FAILED: !m_hasPendingCharacter
         https://bugs.webkit.org/show_bug.cgi?id=110118
 

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties-expected.txt (0 => 162801)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties-expected.txt	2014-01-26 10:30:47 UTC (rev 162801)
@@ -0,0 +1,12 @@
+Test the _javascript_ property descriptor of the name getter.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Object.getOwnPropertyDescriptor(NodeList, 'aWildId').configurable is false
+PASS Object.getOwnPropertyDescriptor(NodeList, 'aWildId').enumerable is false
+PASS Object.getOwnPropertyDescriptor(NodeList, 'aWildId').writable is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Wild

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties.html (0 => 162801)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-name-getter-properties.html	2014-01-26 10:30:47 UTC (rev 162801)
@@ -0,0 +1,19 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id='aWildId'>Wild</div>
+
+<script>
+description('Test the _javascript_ property descriptor of the name getter.');
+
+var NodeList = document.getElementsByTagName('div');
+
+shouldBe("Object.getOwnPropertyDescriptor(NodeList, 'aWildId').configurable", 'false');
+shouldBe("Object.getOwnPropertyDescriptor(NodeList, 'aWildId').enumerable", 'false');
+shouldBe("Object.getOwnPropertyDescriptor(NodeList, 'aWildId').writable", 'false');
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (162800 => 162801)


--- trunk/Source/WebCore/ChangeLog	2014-01-26 10:26:44 UTC (rev 162800)
+++ trunk/Source/WebCore/ChangeLog	2014-01-26 10:30:47 UTC (rev 162801)
@@ -1,3 +1,26 @@
+2014-01-26  Benjamin Poulain  <[email protected]>
+
+        Improve the bindings of NodeList's name accessor
+        https://bugs.webkit.org/show_bug.cgi?id=127358
+
+        Reviewed by Geoffrey Garen.
+
+        When accessing an item of NodeList by name, the default bindings was
+        going through the list of node twice:
+        -First, getOwnProperty calls canGetItemsForName() to find if a property exists for
+         the given name. This in turn used NodeList::namedItem() which is a slow operation.
+        -Then, the value itself was queried through nameGetter(), calling NodeList::namedItem()
+         a second time to find the same value.
+
+        This patch kills the default name getter in favor of a getOwnPropertySlotDelegate() returning
+        the value directly on the PropertySlot.
+
+        Ad Hoc testing show about 15% speed up for simple cases.
+
+        * bindings/js/JSNodeListCustom.cpp:
+        (WebCore::JSNodeList::getOwnPropertySlotDelegate):
+        * dom/NodeList.idl:
+
 2014-01-26  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Move InspectorDebuggerAgent into _javascript_Core

Modified: trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp (162800 => 162801)


--- trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp	2014-01-26 10:26:44 UTC (rev 162800)
+++ trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp	2014-01-26 10:30:47 UTC (rev 162801)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 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
@@ -51,15 +51,13 @@
     return false;
 }
 
-bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, PropertyName propertyName)
+bool JSNodeList::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
-    return impl->namedItem(propertyNameToAtomicString(propertyName));
+    if (Node* item = impl().namedItem(propertyNameToAtomicString(propertyName))) {
+        slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS(exec, globalObject(), item));
+        return true;
+    }
+    return false;
 }
 
-EncodedJSValue JSNodeList::nameGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, PropertyName propertyName)
-{
-    JSNodeList* thisObj = jsCast<JSNodeList*>(JSValue::decode(slotBase));
-    return JSValue::encode(toJS(exec, thisObj->globalObject(), thisObj->impl().namedItem(propertyNameToAtomicString(propertyName))));
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/NodeList.idl (162800 => 162801)


--- trunk/Source/WebCore/dom/NodeList.idl	2014-01-26 10:26:44 UTC (rev 162800)
+++ trunk/Source/WebCore/dom/NodeList.idl	2014-01-26 10:30:47 UTC (rev 162801)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2006 Samuel Weinig <[email protected]>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,11 +20,11 @@
 
 [
     CustomIsReachable,
+    JSCustomGetOwnPropertySlotAndDescriptor,
     SkipVTableValidation,
 ] interface NodeList {
 
     getter Node item(unsigned long index);
-    getter (Node or unsigned long) (DOMString name);
 
     readonly attribute unsigned long length;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to