Title: [87063] trunk/Source/WebCore
Revision
87063
Author
[email protected]
Date
2011-05-23 01:48:35 -0700 (Mon, 23 May 2011)

Log Message

2011-05-19  Vitaly Repeshko  <[email protected]>

        Reviewed by Adam Barth.

        [V8] Explicitly mark objects with complex GC rules.
        https://bugs.webkit.org/show_bug.cgi?id=61131

        From the GC point view there are two kinds of objects: the ones
        that may participate in object grouping (i.e. their lifetime
        depends on other objects) and the ones that never participate in
        grouping (independent). V8 added support for marking persistent
        handles as independent so that the GC can process the objects they
        hold faster. The motivating use case here is typed arrays.

        This patch adds V8-specific inherited IDL attribute
        V8DependentLifetime to types used in V8GCController, which is
        exactly the set of types with object lifetimes depending on other
        objects. The handles for the types that are not marked with the
        new attribute can be marked as independent and GC-ed faster.

        * bindings/scripts/CodeGeneratorV8.pm: Added proccessing of the new attribute.

        Updated test output:
        * bindings/scripts/test/V8/V8TestInterface.cpp:
        (WebCore::V8TestInterface::wrapSlow):
        * bindings/scripts/test/V8/V8TestInterface.h:
        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
        (WebCore::V8TestMediaQueryListListener::wrapSlow):
        * bindings/scripts/test/V8/V8TestMediaQueryListListener.h:
        * bindings/scripts/test/V8/V8TestObj.cpp:
        (WebCore::V8TestObj::wrapSlow):
        * bindings/scripts/test/V8/V8TestObj.h:
        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
        (WebCore::V8TestSerializedScriptValueInterface::wrapSlow):
        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h:

        Added the new attribute:
        * css/CSSRule.idl:
        * css/CSSRuleList.idl:
        * css/CSSStyleDeclaration.idl:
        * css/CSSValue.idl:
        * css/StyleSheet.idl:
        * css/StyleSheetList.idl:
        * dom/DOMImplementation.idl:
        * dom/Node.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87062 => 87063)


--- trunk/Source/WebCore/ChangeLog	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/ChangeLog	2011-05-23 08:48:35 UTC (rev 87063)
@@ -1,3 +1,49 @@
+2011-05-19  Vitaly Repeshko  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        [V8] Explicitly mark objects with complex GC rules.
+        https://bugs.webkit.org/show_bug.cgi?id=61131
+
+        From the GC point view there are two kinds of objects: the ones
+        that may participate in object grouping (i.e. their lifetime
+        depends on other objects) and the ones that never participate in
+        grouping (independent). V8 added support for marking persistent
+        handles as independent so that the GC can process the objects they
+        hold faster. The motivating use case here is typed arrays.
+
+        This patch adds V8-specific inherited IDL attribute
+        V8DependentLifetime to types used in V8GCController, which is
+        exactly the set of types with object lifetimes depending on other
+        objects. The handles for the types that are not marked with the
+        new attribute can be marked as independent and GC-ed faster.
+
+        * bindings/scripts/CodeGeneratorV8.pm: Added proccessing of the new attribute.
+
+        Updated test output:
+        * bindings/scripts/test/V8/V8TestInterface.cpp:
+        (WebCore::V8TestInterface::wrapSlow):
+        * bindings/scripts/test/V8/V8TestInterface.h:
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
+        (WebCore::V8TestMediaQueryListListener::wrapSlow):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.h:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::V8TestObj::wrapSlow):
+        * bindings/scripts/test/V8/V8TestObj.h:
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
+        (WebCore::V8TestSerializedScriptValueInterface::wrapSlow):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h:
+
+        Added the new attribute:
+        * css/CSSRule.idl:
+        * css/CSSRuleList.idl:
+        * css/CSSStyleDeclaration.idl:
+        * css/CSSValue.idl:
+        * css/StyleSheet.idl:
+        * css/StyleSheetList.idl:
+        * dom/DOMImplementation.idl:
+        * dom/Node.idl:
+
 2011-05-23  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r87014, r87016, and r87017.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-05-23 08:48:35 UTC (rev 87063)
@@ -232,6 +232,15 @@
     # EventTarget.
     $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1);
 
+    my $hasDependentLifetime = $dataNode->extendedAttributes->{"V8DependentLifetime"} || IsActiveDomType($interfaceName) || $className =~ /SVG/;
+    if (!$hasDependentLifetime) {
+        foreach (@{$dataNode->parents}) {
+            my $parent = $codeGenerator->StripModule($_);
+            next if $parent eq "EventTarget";
+            $headerIncludes{"V8${parent}.h"} = 1;
+        }
+    }
+
     my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
 
     # - Add default header template
@@ -268,7 +277,27 @@
     }
     push(@headerContent, "\nclass FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect";
     push(@headerContent, "\nclass $className {\n");
+    push(@headerContent, "public:\n");
 
+    push(@headerContent, "    static const bool hasDependentLifetime = ");
+    if ($hasDependentLifetime) {
+        push(@headerContent, "true;\n");
+    } elsif (@{$dataNode->parents}) {
+        # Even if this type doesn't have the V8DependentLifetime attribute its parents may.
+        # Let the compiler statically determine this for us.
+        my $separator = "";
+        foreach (@{$dataNode->parents}) {
+            my $parent = $codeGenerator->StripModule($_);
+            next if $parent eq "EventTarget";
+            $headerIncludes{"V8${parent}.h"} = 1;
+            push(@headerContent, "${separator}V8${parent}::hasDependentLifetime");
+            $separator = " || ";
+        }
+        push(@headerContent, ";\n");
+    } else {
+        push(@headerContent, "false;\n");
+    }
+
     my $nativeType = GetNativeTypeForConversions($dataNode, $interfaceName);
     my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName);
     my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : "";
@@ -276,8 +305,6 @@
     my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
 
     push(@headerContent, <<END);
-
-public:
     static bool HasInstance(v8::Handle<v8::Value> value);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
     static v8::Persistent<v8::FunctionTemplate> GetTemplate();
@@ -2526,6 +2553,8 @@
 
     push(@implContent, <<END);
     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
+    if (!hasDependentLifetime)
+        wrapperHandle.MarkIndependent();
 END
     if (IsNodeSubType($dataNode)) {
         push(@implContent, <<END);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2011-05-23 08:48:35 UTC (rev 87063)
@@ -88,6 +88,8 @@
 
     impl->ref();
     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
+    if (!hasDependentLifetime)
+        wrapperHandle.MarkIndependent();
     getDOMObjectMap().set(impl, wrapperHandle);
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h	2011-05-23 08:48:35 UTC (rev 87063)
@@ -33,8 +33,8 @@
 namespace WebCore {
 
 class V8TestInterface {
-
 public:
+    static const bool hasDependentLifetime = false;
     static bool HasInstance(v8::Handle<v8::Value> value);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
     static v8::Persistent<v8::FunctionTemplate> GetTemplate();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2011-05-23 08:48:35 UTC (rev 87063)
@@ -95,6 +95,8 @@
 
     impl->ref();
     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
+    if (!hasDependentLifetime)
+        wrapperHandle.MarkIndependent();
     getDOMObjectMap().set(impl, wrapperHandle);
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h	2011-05-23 08:48:35 UTC (rev 87063)
@@ -31,8 +31,8 @@
 namespace WebCore {
 
 class V8TestMediaQueryListListener {
-
 public:
+    static const bool hasDependentLifetime = false;
     static bool HasInstance(v8::Handle<v8::Value> value);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
     static v8::Persistent<v8::FunctionTemplate> GetTemplate();

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-05-23 08:48:35 UTC (rev 87063)
@@ -1381,6 +1381,8 @@
 
     impl->ref();
     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
+    if (!hasDependentLifetime)
+        wrapperHandle.MarkIndependent();
     getDOMObjectMap().set(impl, wrapperHandle);
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h	2011-05-23 08:48:35 UTC (rev 87063)
@@ -31,8 +31,8 @@
 namespace WebCore {
 
 class V8TestObj {
-
 public:
+    static const bool hasDependentLifetime = false;
     static bool HasInstance(v8::Handle<v8::Value> value);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
     static v8::Persistent<v8::FunctionTemplate> GetTemplate();

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2011-05-23 08:48:35 UTC (rev 87063)
@@ -84,6 +84,8 @@
     impl->ref();
     SerializedScriptValue::deserializeAndSetProperty(wrapper, "value", static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly), impl->value());
     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
+    if (!hasDependentLifetime)
+        wrapperHandle.MarkIndependent();
     getDOMObjectMap().set(impl, wrapperHandle);
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h (87062 => 87063)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h	2011-05-23 08:48:35 UTC (rev 87063)
@@ -33,8 +33,8 @@
 namespace WebCore {
 
 class V8TestSerializedScriptValueInterface {
-
 public:
+    static const bool hasDependentLifetime = false;
     static bool HasInstance(v8::Handle<v8::Value> value);
     static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
     static v8::Persistent<v8::FunctionTemplate> GetTemplate();

Modified: trunk/Source/WebCore/css/CSSRule.idl (87062 => 87063)


--- trunk/Source/WebCore/css/CSSRule.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/CSSRule.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -25,7 +25,8 @@
         CustomMarkFunction,
         GenerateIsReachable,
         CustomToJS,
-        Polymorphic
+        Polymorphic,
+        V8DependentLifetime
     ] CSSRule {
 
         // RuleType

Modified: trunk/Source/WebCore/css/CSSRuleList.idl (87062 => 87063)


--- trunk/Source/WebCore/css/CSSRuleList.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/CSSRuleList.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -28,7 +28,8 @@
     // Introduced in DOM Level 2:
     interface [
         CustomIsReachable,
-        HasIndexGetter
+        HasIndexGetter,
+        V8DependentLifetime
     ] CSSRuleList {
         readonly attribute unsigned long    length;
         CSSRule           item(in unsigned long index);

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.idl (87062 => 87063)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -26,7 +26,8 @@
         GenerateIsReachable=ImplRoot,
         DelegatingPutFunction,
         HasNameGetter,
-        HasIndexGetter
+        HasIndexGetter,
+        V8DependentLifetime
     ] CSSStyleDeclaration {
                  attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString        cssText
                      setter raises(DOMException);

Modified: trunk/Source/WebCore/css/CSSValue.idl (87062 => 87063)


--- trunk/Source/WebCore/css/CSSValue.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/CSSValue.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -24,7 +24,8 @@
         CustomToJS,
         CustomIsReachable,
         CustomFinalize,
-        Polymorphic
+        Polymorphic,
+        V8DependentLifetime
     ] CSSValue {
 
         // UnitTypes

Modified: trunk/Source/WebCore/css/StyleSheet.idl (87062 => 87063)


--- trunk/Source/WebCore/css/StyleSheet.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/StyleSheet.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -25,7 +25,8 @@
         CustomMarkFunction,
         GenerateIsReachable,
         CustomToJS,
-        Polymorphic
+        Polymorphic,
+        V8DependentLifetime
     ] StyleSheet {
         readonly attribute [ConvertNullStringTo=Null] DOMString        type;
                  attribute boolean          disabled;

Modified: trunk/Source/WebCore/css/StyleSheetList.idl (87062 => 87063)


--- trunk/Source/WebCore/css/StyleSheetList.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/css/StyleSheetList.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -24,7 +24,8 @@
     interface [
         GenerateIsReachable=ImplDocument,
         HasIndexGetter,
-        HasNameGetter
+        HasNameGetter,
+        V8DependentLifetime
     ] StyleSheetList {
         readonly attribute unsigned long    length;
         StyleSheet         item(in unsigned long index);

Modified: trunk/Source/WebCore/dom/DOMImplementation.idl (87062 => 87063)


--- trunk/Source/WebCore/dom/DOMImplementation.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/dom/DOMImplementation.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -21,7 +21,8 @@
 module core {
 
     interface [
-        GenerateIsReachable=ImplDocument
+        GenerateIsReachable=ImplDocument,
+        V8DependentLifetime
     ] DOMImplementation {
 
         // DOM Level 1

Modified: trunk/Source/WebCore/dom/Node.idl (87062 => 87063)


--- trunk/Source/WebCore/dom/Node.idl	2011-05-23 08:46:28 UTC (rev 87062)
+++ trunk/Source/WebCore/dom/Node.idl	2011-05-23 08:48:35 UTC (rev 87063)
@@ -30,7 +30,8 @@
         EventTarget,
         GenerateNativeConverter,
         InlineGetOwnPropertySlot,
-        Polymorphic
+        Polymorphic,
+        V8DependentLifetime
     ] Node
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
         : Object, EventTarget
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to