Title: [138263] trunk/Source/WebCore
Revision
138263
Author
a...@chromium.org
Date
2012-12-20 09:41:37 -0800 (Thu, 20 Dec 2012)

Log Message

CodeGen: Make [Reflect] use fastGetAttribute and fastHasAttribute
https://bugs.webkit.org/show_bug.cgi?id=105540

Reviewed by Andreas Kling.

Currently the codegen generates code that use getAttribute and hasAttribute. We can use
fastGetAttribute and fastHasAttribute when we use a non SVG animated attribute and not
HTML::styleAttr.

This improves Bindings/id-getter by 16% and Dromaeo/dom-attr by 21%.

No new tests. No change in behavior.

* bindings/scripts/CodeGenerator.pm:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/scripts/test/CPP/WebDOMTestObj.cpp:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
* bindings/scripts/test/V8/V8TestObj.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (138262 => 138263)


--- trunk/Source/WebCore/ChangeLog	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/ChangeLog	2012-12-20 17:41:37 UTC (rev 138263)
@@ -1,3 +1,26 @@
+2012-12-20  Erik Arvidsson  <a...@chromium.org>
+
+        CodeGen: Make [Reflect] use fastGetAttribute and fastHasAttribute
+        https://bugs.webkit.org/show_bug.cgi?id=105540
+
+        Reviewed by Andreas Kling.
+
+        Currently the codegen generates code that use getAttribute and hasAttribute. We can use
+        fastGetAttribute and fastHasAttribute when we use a non SVG animated attribute and not
+        HTML::styleAttr.
+
+        This improves Bindings/id-getter by 16% and Dromaeo/dom-attr by 21%.
+
+        No new tests. No change in behavior.
+
+        * bindings/scripts/CodeGenerator.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+
 2012-12-20  Tiancheng Jiang  <tiji...@rim.com>
 
         [BlackBerry]Change fullscreen back button size

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-12-20 17:41:37 UTC (rev 138263)
@@ -565,6 +565,15 @@
     return "WebCore::${namespace}::${contentAttributeName}Attr";
 }
 
+sub CanUseFastAttribute
+{
+    my ($generator, $attribute) = @_;
+    my $attributeType = $attribute->signature->type;
+    # HTMLNames::styleAttr cannot be used with fast{Get,Has}Attribute but we do not [Reflect] the
+    # style attribute.
+    return !$generator->IsSVGAnimatedType($attributeType);
+}
+
 sub GetterExpression
 {
     my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
@@ -579,13 +588,22 @@
     if ($attribute->signature->extendedAttributes->{"URL"}) {
         $functionName = "getURLAttribute";
     } elsif ($attribute->signature->type eq "boolean") {
-        $functionName = "hasAttribute";
+        my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+        if ($generator->CanUseFastAttribute($attribute)) {
+            $functionName = "fastHasAttribute";
+        } else {
+            $functionName = "hasAttribute";
+        }
     } elsif ($attribute->signature->type eq "long") {
         $functionName = "getIntegralAttribute";
     } elsif ($attribute->signature->type eq "unsigned long") {
         $functionName = "getUnsignedIntegralAttribute";
     } else {
-        $functionName = "getAttribute";
+        if ($generator->CanUseFastAttribute($attribute)) {
+            $functionName = "fastGetAttribute";
+        } else {
+            $functionName = "getAttribute";
+        }
     }
 
     return ($functionName, $contentAttributeName);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-12-20 17:41:37 UTC (rev 138263)
@@ -931,11 +931,9 @@
         my $url = ""
         if ($getterStringUsesImp && $reflect && !$url && $codeGenerator->IsSubType($interface, "Node") && $codeGenerator->IsStringType($attrType)) {
             # Generate super-compact call for regular attribute getter:
-            my $contentAttributeName = $reflect eq "VALUE_IS_MISSING" ? lc $attrName : $reflect;
-            my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
-            AddToImplIncludes("${namespace}.h");
+            my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
             push(@implContentDecls, "    Element* imp = V8Element::toNative(info.Holder());\n");
-            push(@implContentDecls, "    return v8String(imp->getAttribute(${namespace}::${contentAttributeName}Attr), info.GetIsolate());\n");
+            push(@implContentDecls, "    return v8String(imp->${functionName}(" . join(", ", @arguments) . "), info.GetIsolate());\n");
             push(@implContentDecls, "}\n\n");
             push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString;
             return;

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2012-12-20 17:41:37 UTC (rev 138263)
@@ -272,7 +272,7 @@
     if (!impl())
         return WebDOMString();
 
-    return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
+    return static_cast<const WTF::String&>(impl()->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
 }
 
 void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr)
@@ -320,7 +320,7 @@
     if (!impl())
         return false;
 
-    return impl()->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
+    return impl()->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
 }
 
 void WebDOMTestObj::setReflectedBooleanAttr(bool newReflectedBooleanAttr)
@@ -352,7 +352,7 @@
     if (!impl())
         return WebDOMString();
 
-    return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
+    return static_cast<const WTF::String&>(impl()->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
 }
 
 void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr)
@@ -384,7 +384,7 @@
     if (!impl())
         return false;
 
-    return impl()->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
+    return impl()->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
 }
 
 void WebDOMTestObj::setReflectedCustomBooleanAttr(bool newReflectedCustomBooleanAttr)

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2012-12-20 17:41:37 UTC (rev 138263)
@@ -331,7 +331,7 @@
         break;
     }
     case PROP_REFLECTED_STRING_ATTR: {
-        g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)));
+        g_value_take_string(value, convertToUTF8String(coreSelf->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr)));
         break;
     }
     case PROP_REFLECTED_INTEGRAL_ATTR: {
@@ -343,7 +343,7 @@
         break;
     }
     case PROP_REFLECTED_BOOLEAN_ATTR: {
-        g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr));
+        g_value_set_boolean(value, coreSelf->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr));
         break;
     }
     case PROP_REFLECTED_URL_ATTR: {
@@ -351,7 +351,7 @@
         break;
     }
     case PROP_REFLECTED_STRING_ATTR: {
-        g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)));
+        g_value_take_string(value, convertToUTF8String(coreSelf->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr)));
         break;
     }
     case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: {
@@ -359,7 +359,7 @@
         break;
     }
     case PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR: {
-        g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr));
+        g_value_set_boolean(value, coreSelf->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr));
         break;
     }
     case PROP_REFLECTED_CUSTOM_URL_ATTR: {
@@ -1623,7 +1623,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
     WebCore::TestObj* item = WebKit::core(self);
-    gchar* result = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
+    gchar* result = convertToUTF8String(item->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
     return result;
 }
 
@@ -1682,7 +1682,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), FALSE);
     WebCore::TestObj* item = WebKit::core(self);
-    gboolean result = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
+    gboolean result = item->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
     return result;
 }
 
@@ -1722,7 +1722,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
     WebCore::TestObj* item = WebKit::core(self);
-    gchar* result = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
+    gchar* result = convertToUTF8String(item->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
     return result;
 }
 
@@ -1762,7 +1762,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), FALSE);
     WebCore::TestObj* item = WebKit::core(self);
-    gboolean result = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
+    gboolean result = item->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
     return result;
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-12-20 17:41:37 UTC (rev 138263)
@@ -538,7 +538,7 @@
     JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
     UNUSED_PARAM(exec);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    JSValue result = jsStringWithCache(exec, impl->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
+    JSValue result = jsStringWithCache(exec, impl->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
     return result;
 }
 
@@ -568,7 +568,7 @@
     JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
     UNUSED_PARAM(exec);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    JSValue result = jsBoolean(impl->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr));
+    JSValue result = jsBoolean(impl->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr));
     return result;
 }
 
@@ -588,7 +588,7 @@
     JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
     UNUSED_PARAM(exec);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    JSValue result = jsStringWithCache(exec, impl->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
+    JSValue result = jsStringWithCache(exec, impl->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
     return result;
 }
 
@@ -608,7 +608,7 @@
     JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
     UNUSED_PARAM(exec);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    JSValue result = jsBoolean(impl->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr));
+    JSValue result = jsBoolean(impl->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr));
     return result;
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2012-12-20 17:41:37 UTC (rev 138263)
@@ -232,7 +232,7 @@
 - (NSString *)reflectedStringAttr
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr);
+    return IMPL->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr);
 }
 
 - (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr
@@ -268,7 +268,7 @@
 - (BOOL)reflectedBooleanAttr
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
+    return IMPL->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr);
 }
 
 - (void)setReflectedBooleanAttr:(BOOL)newReflectedBooleanAttr
@@ -292,7 +292,7 @@
 - (NSString *)reflectedStringAttr
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr);
+    return IMPL->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr);
 }
 
 - (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr
@@ -316,7 +316,7 @@
 - (BOOL)reflectedCustomBooleanAttr
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
+    return IMPL->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr);
 }
 
 - (void)setReflectedCustomBooleanAttr:(BOOL)newReflectedCustomBooleanAttr

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (138262 => 138263)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-12-20 17:34:24 UTC (rev 138262)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-12-20 17:41:37 UTC (rev 138263)
@@ -279,7 +279,7 @@
 {
     INC_STATS("DOM.TestObj.reflectedStringAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr), info.GetIsolate());
+    return v8String(imp->fastGetAttribute(WebCore::HTMLNames::reflectedstringattrAttr), info.GetIsolate());
 }
 
 static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -327,7 +327,7 @@
 {
     INC_STATS("DOM.TestObj.reflectedBooleanAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr), info.GetIsolate());
+    return v8Boolean(imp->fastHasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr), info.GetIsolate());
 }
 
 static void reflectedBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -359,7 +359,7 @@
 {
     INC_STATS("DOM.TestObj.reflectedStringAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr), info.GetIsolate());
+    return v8String(imp->fastGetAttribute(WebCore::HTMLNames::customContentStringAttrAttr), info.GetIsolate());
 }
 
 static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -391,7 +391,7 @@
 {
     INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr), info.GetIsolate());
+    return v8Boolean(imp->fastHasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr), info.GetIsolate());
 }
 
 static void reflectedCustomBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to