Reviewed by Oliver Hunt.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Feb 2008 01:35:07 +0000 (01:35 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Feb 2008 01:35:07 +0000 (01:35 +0000)
        Fix for http://bugs.webkit.org/show_bug.cgi?id=17504
        Speed up DOM lists array subscription syntax by using the fast
        getOwnPropertySlot and set paths

        - 6x speed improvement on Oliver's ImageData put test.

        * bindings/scripts/CodeGeneratorJS.pm: Add fast path for getOwnPropertySlot
        and put when an indexGetter or indexSetter is used.  We can not use the fast
        path if an overridingNameGetter is used as there would be no way to override.

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

WebCore/ChangeLog
WebCore/bindings/scripts/CodeGeneratorJS.pm

index 4f78a999f5015e126bf6376ffb6af03d1ae79cb2..2f335f94900d3262c375913bad94bebb12a5b4b7 100644 (file)
@@ -1,3 +1,17 @@
+2008-02-23  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver Hunt.
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=17504
+        Speed up DOM lists array subscription syntax by using the fast 
+        getOwnPropertySlot and set paths
+
+        - 6x speed improvement on Oliver's ImageData put test.
+
+        * bindings/scripts/CodeGeneratorJS.pm: Add fast path for getOwnPropertySlot
+        and put when an indexGetter or indexSetter is used.  We can not use the fast
+        path if an overridingNameGetter is used as there would be no way to override.
+
 2008-02-23  Kevin Ollivier  <kevino@theolliviers.com>
 
         wx build fix after JSImageData.cpp was added.
index 48ccf5649439d29e75bd9755dd6883b3eb8dff95..0a6ea507e111369055153c0b9ac3c9b87faf64be 100644 (file)
@@ -344,7 +344,8 @@ sub GenerateHeader
 
     # Getters
     if ($hasGetter) {
-        push(@headerContent, "    virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n");
+        push(@headerContent, "    virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::PropertySlot&);\n");
+        push(@headerContent, "    virtual bool getOwnPropertySlot(KJS::ExecState*, unsigned propertyName, KJS::PropertySlot&);\n") if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"};
         push(@headerContent, "    KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n") if $numAttributes > 0 || $dataNode->extendedAttributes->{"GenerateConstructor"};
         push(@headerContent, "    bool customGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n") if $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"};
     }
@@ -363,7 +364,8 @@ sub GenerateHeader
 
     # Getters
     if ($hasSetter) {
-        push(@headerContent, "    virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);\n");
+        push(@headerContent, "    virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::JSValue*, int attr = KJS::None);\n");
+        push(@headerContent, "    virtual void put(KJS::ExecState*, unsigned propertyName, KJS::JSValue*, int attr = KJS::None);\n") if $dataNode->extendedAttributes->{"HasCustomIndexSetter"};
         push(@headerContent, "    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);\n") if $hasReadWriteProperties;
         push(@headerContent, "    bool customPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr);\n") if $dataNode->extendedAttributes->{"CustomPutFunction"};
     }
@@ -376,7 +378,7 @@ sub GenerateHeader
     push(@headerContent, "    virtual void mark();\n\n") if $dataNode->extendedAttributes->{"CustomMarkFunction"};
 
     # Custom pushEventHandlerScope function
-    push(@headerContent, "    virtual void pushEventHandlerScope(KJS::ExecState*, KJS::ScopeChain&) const;\n\n")  if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
+    push(@headerContent, "    virtual void pushEventHandlerScope(KJS::ExecState*, KJS::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
 
     # Custom call functions
     if ($dataNode->extendedAttributes->{"CustomCall"}) {
@@ -908,6 +910,18 @@ sub GenerateImplementation
         }
         push(@implContent, "}\n\n");
 
+        if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) 
+                && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"}) {
+            push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)\n");
+            push(@implContent, "{\n");
+            push(@implContent, "    if (propertyName < static_cast<$implClassName*>(impl())->length()) {\n");
+            push(@implContent, "        slot.setCustomIndex(this, propertyName, indexGetter);\n");
+            push(@implContent, "        return true;\n");
+            push(@implContent, "    }\n");
+            push(@implContent, "    return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);\n");
+            push(@implContent, "}\n\n");
+        }
+
         if ($numAttributes > 0) {
             push(@implContent, "JSValue* ${className}::getValueProperty(ExecState* exec, int token) const\n");
             push(@implContent, "{\n");
@@ -1025,9 +1039,16 @@ sub GenerateImplementation
             } else {
                 push(@implContent, "    Base::put(exec, propertyName, value, attr);\n");
             }
-
             push(@implContent, "}\n\n");
 
+            if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
+                push(@implContent, "void ${className}::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)\n");
+                push(@implContent, "{\n");
+                push(@implContent, "    indexSetter(exec, propertyName, value, attr);\n");
+                push(@implContent, "    return;\n");
+                push(@implContent, "}\n\n");
+            }
+
             if ($hasReadWriteProperties) {
                 push(@implContent, "void ${className}::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)\n");
                 push(@implContent, "{\n");