Title: [129971] trunk/Source/WebCore
Revision
129971
Author
[email protected]
Date
2012-09-28 19:50:28 -0700 (Fri, 28 Sep 2012)

Log Message

[V8] The concept of forceNewObject is unneeded (dom-traverse gets 3% faster)
https://bugs.webkit.org/show_bug.cgi?id=97943

Reviewed by Kentaro Hara.

We don't need the concept of forceNewObject. It doesn't do anything
useful and it makes the bindings slower.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
(GenerateToV8Converters):
(NativeToJSValue):
* bindings/v8/custom/V8DocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8HTMLElementCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8NodeCustom.cpp:
(WebCore::toV8Slow):
* bindings/v8/custom/V8SVGDocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8SVGElementCustom.cpp:
(WebCore::toV8):
* dom/make_names.pl:
(printWrapperFactoryCppFile):
(printWrapperFactoryHeaderFile):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129970 => 129971)


--- trunk/Source/WebCore/ChangeLog	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/ChangeLog	2012-09-29 02:50:28 UTC (rev 129971)
@@ -1,3 +1,33 @@
+2012-09-28  Adam Barth  <[email protected]>
+
+        [V8] The concept of forceNewObject is unneeded (dom-traverse gets 3% faster)
+        https://bugs.webkit.org/show_bug.cgi?id=97943
+
+        Reviewed by Kentaro Hara.
+
+        We don't need the concept of forceNewObject. It doesn't do anything
+        useful and it makes the bindings slower.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (GenerateToV8Converters):
+        (NativeToJSValue):
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLElementCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8NodeCustom.cpp:
+        (WebCore::toV8Slow):
+        * bindings/v8/custom/V8SVGDocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8SVGElementCustom.cpp:
+        (WebCore::toV8):
+        * dom/make_names.pl:
+        (printWrapperFactoryCppFile):
+        (printWrapperFactoryHeaderFile):
+
 2012-09-28  Elliott Sprehn  <[email protected]>
 
         Allow any kind of v8::Handle in invokeCallback instead of requiring a v8::Persistent.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (129970 => 129971)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-29 02:50:28 UTC (rev 129971)
@@ -372,10 +372,6 @@
         push(@headerContent, "false;\n");
     }
 
-    my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : "";
-    my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : "";
-    my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
-
     push(@headerContent, <<END);
     static bool HasInstance(v8::Handle<v8::Value>);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
@@ -384,7 +380,7 @@
     {
         return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
     }
-    inline static v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* = 0${forceNewObjectParameter});
+    inline static v8::Handle<v8::Object> wrap(${nativeType}*, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* = 0);
     static void derefObject(void*);
     static void visitDOMWrapper(DOMDataStore*, void*, v8::Persistent<v8::Object>);
     static WrapperTypeInfo info;
@@ -483,10 +479,9 @@
 END
 
     push(@headerContent, <<END);
-v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate${forceNewObjectInput})
+v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
 END
-    push(@headerContent, "    if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName);
     my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName, "isolate");
     my $getCachedWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getCachedWrapper(impl)" : "${domMapFunction}.get(impl)";
     push(@headerContent, <<END);
@@ -494,7 +489,6 @@
         if (!wrapper.IsEmpty())
             return wrapper;
 END
-    push(@headerContent, "    }\n") if IsDOMNodeType($interfaceName);
     push(@headerContent, <<END);
     return ${className}::wrapSlow(impl, creationContext, isolate);
 }
@@ -505,41 +499,39 @@
     } elsif (!($dataNode->extendedAttributes->{"CustomToJSObject"} or $dataNode->extendedAttributes->{"V8CustomToJSObject"})) {
         push(@headerContent, <<END);
 
-inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0${forceNewObjectParameter})
+inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
-    return ${className}::wrap(impl, creationContext, isolate${forceNewObjectCall});
+    return ${className}::wrap(impl, creationContext, isolate);
 }
 END
     } elsif ($interfaceName ne 'Node') {
         push(@headerContent, <<END);
 
-v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* = 0${forceNewObjectParameter});
+v8::Handle<v8::Value> toV8(${nativeType}*, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* = 0);
 END
     } else {
         push(@headerContent, <<END);
 
-v8::Handle<v8::Value> toV8Slow(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*, bool);
+v8::Handle<v8::Value> toV8Slow(Node*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
 
-inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0, bool forceNewObject = false)
+inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0)
 {
     if (UNLIKELY(!impl))
         return v8NullWithCheck(isolate);
-    if (UNLIKELY(forceNewObject))
-        return toV8Slow(impl, creationContext, isolate, forceNewObject);
     v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl);
     if (!wrapper.IsEmpty())
         return wrapper;
-    return toV8Slow(impl, creationContext, isolate, false);
+    return toV8Slow(impl, creationContext, isolate);
 }
 END
     }
 
     push(@headerContent, <<END);
-inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0${forceNewObjectParameter})
+inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Handle<v8::Object> creationContext = v8::Handle<v8::Object>(), v8::Isolate* isolate = 0)
 {
-    return toV8(impl.get(), creationContext, isolate${forceNewObjectCall});
+    return toV8(impl.get(), creationContext, isolate);
 }
 END
 
@@ -3357,8 +3349,6 @@
     my $nativeType = shift;
 
     my $domMapName = GetDomMapName($dataNode, $interfaceName);
-    my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : "";
-    my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
     my $wrapSlowArgumentType = GetPassRefPtrType($nativeType);
     my $baseType = BaseInterfaceName($dataNode);
 
@@ -4084,9 +4074,8 @@
 
     AddIncludesForType($type);
 
-    # special case for non-DOM node interfaces
     if (IsDOMNodeType($type)) {
-        return "toV8(${value}$getCreationContextArg$getIsolateArg" . ($signature->extendedAttributes->{"ReturnNewObject"} ? ", true)" : ")");
+        return "toV8($value$getCreationContextArg$getIsolateArg)";
     }
 
     if ($type eq "EventTarget") {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -95,17 +95,17 @@
     return toV8(result.release(), args.Holder(), args.GetIsolate());
 }
 
-v8::Handle<v8::Value> toV8(Document* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8(Document* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
     if (impl->isHTMLDocument())
-        return toV8(static_cast<HTMLDocument*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<HTMLDocument*>(impl), creationContext, isolate);
 #if ENABLE(SVG)
     if (impl->isSVGDocument())
-        return toV8(static_cast<SVGDocument*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<SVGDocument*>(impl), creationContext, isolate);
 #endif
-    v8::Handle<v8::Object> wrapper = V8Document::wrap(impl, creationContext, isolate, forceNewObject);
+    v8::Handle<v8::Object> wrapper = V8Document::wrap(impl, creationContext, isolate);
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8DOMWindowShell::enteredIsolatedContextData()) {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -176,11 +176,11 @@
     info.This()->ForceSet(name, value);
 }
 
-v8::Handle<v8::Value> toV8(HTMLDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8(HTMLDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, creationContext, isolate, forceNewObject);
+    v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, creationContext, isolate);
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8DOMWindowShell::enteredIsolatedContextData()) {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -40,11 +40,11 @@
 
 namespace WebCore {
 
-v8::Handle<v8::Value> toV8(HTMLElement* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8(HTMLElement* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
-    return createV8HTMLWrapper(impl, creationContext, isolate, forceNewObject);
+    return createV8HTMLWrapper(impl, creationContext, isolate);
 }
 
 #if ENABLE(MICRODATA)

Modified: trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -125,50 +125,49 @@
     return v8::Null(args.GetIsolate());
 }
 
-v8::Handle<v8::Value> toV8Slow(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8Slow(Node* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
 
-    if (!forceNewObject) {
-        v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl);
-        if (!wrapper.IsEmpty())
-            return wrapper;
-    }
+    v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl);
+    if (!wrapper.IsEmpty())
+        return wrapper;
+
     switch (impl->nodeType()) {
     case Node::ELEMENT_NODE:
         if (impl->isHTMLElement())
-            return toV8(toHTMLElement(impl), creationContext, isolate, forceNewObject);
+            return toV8(toHTMLElement(impl), creationContext, isolate);
 #if ENABLE(SVG)
         if (impl->isSVGElement())
-            return toV8(static_cast<SVGElement*>(impl), creationContext, isolate, forceNewObject);
+            return toV8(static_cast<SVGElement*>(impl), creationContext, isolate);
 #endif
-        return V8Element::wrap(static_cast<Element*>(impl), creationContext, isolate, forceNewObject);
+        return V8Element::wrap(static_cast<Element*>(impl), creationContext, isolate);
     case Node::ATTRIBUTE_NODE:
-        return toV8(static_cast<Attr*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<Attr*>(impl), creationContext, isolate);
     case Node::TEXT_NODE:
-        return toV8(toText(impl), creationContext, isolate, forceNewObject);
+        return toV8(toText(impl), creationContext, isolate);
     case Node::CDATA_SECTION_NODE:
-        return toV8(static_cast<CDATASection*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<CDATASection*>(impl), creationContext, isolate);
     case Node::ENTITY_REFERENCE_NODE:
-        return toV8(static_cast<EntityReference*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<EntityReference*>(impl), creationContext, isolate);
     case Node::ENTITY_NODE:
-        return toV8(static_cast<Entity*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<Entity*>(impl), creationContext, isolate);
     case Node::PROCESSING_INSTRUCTION_NODE:
-        return toV8(static_cast<ProcessingInstruction*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<ProcessingInstruction*>(impl), creationContext, isolate);
     case Node::COMMENT_NODE:
-        return toV8(static_cast<Comment*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<Comment*>(impl), creationContext, isolate);
     case Node::DOCUMENT_NODE:
-        return toV8(static_cast<Document*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<Document*>(impl), creationContext, isolate);
     case Node::DOCUMENT_TYPE_NODE:
-        return toV8(static_cast<DocumentType*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<DocumentType*>(impl), creationContext, isolate);
     case Node::DOCUMENT_FRAGMENT_NODE:
-        return toV8(static_cast<DocumentFragment*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<DocumentFragment*>(impl), creationContext, isolate);
     case Node::NOTATION_NODE:
-        return toV8(static_cast<Notation*>(impl), creationContext, isolate, forceNewObject);
+        return toV8(static_cast<Notation*>(impl), creationContext, isolate);
     default:
         break; // XPATH_NAMESPACE_NODE
     }
-    return V8Node::wrap(impl, creationContext, isolate, forceNewObject);
+    return V8Node::wrap(impl, creationContext, isolate);
 }
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -38,11 +38,11 @@
 
 namespace WebCore {
 
-v8::Handle<v8::Value> toV8(SVGDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8(SVGDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, creationContext, isolate, forceNewObject);
+    v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, creationContext, isolate);
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8DOMWindowShell::enteredIsolatedContextData()) {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp (129970 => 129971)


--- trunk/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp	2012-09-29 02:50:28 UTC (rev 129971)
@@ -37,11 +37,11 @@
 
 namespace WebCore {
 
-v8::Handle<v8::Value> toV8(SVGElement* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> toV8(SVGElement* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     if (!impl)
         return v8NullWithCheck(isolate);
-    return createV8SVGWrapper(impl, creationContext, isolate, forceNewObject);
+    return createV8SVGWrapper(impl, creationContext, isolate);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/make_names.pl (129970 => 129971)


--- trunk/Source/WebCore/dom/make_names.pl	2012-09-29 02:30:16 UTC (rev 129970)
+++ trunk/Source/WebCore/dom/make_names.pl	2012-09-29 02:50:28 UTC (rev 129971)
@@ -1176,7 +1176,7 @@
 ;
     } elsif ($wrapperFactoryType eq "V8") {
         print F <<END
-v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, bool forceNewObject)
+v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap;
     DEFINE_STATIC_LOCAL(FunctionMap, map, ());
@@ -1218,7 +1218,7 @@
     } elsif ($wrapperFactoryType eq "V8") {
         print F <<END
         return createWrapperFunction(element, creationContext, isolate);
-    return V8$parameters{fallbackInterfaceName}::wrap(to$parameters{fallbackInterfaceName}(element), creationContext, isolate, forceNewObject);
+    return V8$parameters{fallbackInterfaceName}::wrap(to$parameters{fallbackInterfaceName}(element), creationContext, isolate);
 END
 ;
     }
@@ -1278,7 +1278,7 @@
 
     class $parameters{namespace}Element;
 
-    v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*, bool);
+    v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
 }
 END
 ;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to