From a8645cae5df8c2ce410225bec31039fbc1001893 Mon Sep 17 00:00:00 2001 From: "weinig@apple.com" Date: Sun, 24 Feb 2008 01:35:07 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30529 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 14 ++++++++++ WebCore/bindings/scripts/CodeGeneratorJS.pm | 29 ++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 4f78a999f501..2f335f94900d 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2008-02-23 Sam Weinig + + 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 wx build fix after JSImageData.cpp was added. diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 48ccf5649439..0a6ea507e111 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -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"); -- 2.36.0