Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / core / v8 / V8GCController.cpp
index 3eead3e..4973a47 100644 (file)
@@ -111,7 +111,7 @@ public:
     virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classId) OVERRIDE
     {
         // A minor DOM GC can collect only Nodes.
-        if (classId != v8DOMNodeClassId)
+        if (classId != WrapperTypeInfo::NodeClassId)
             return;
 
         // To make minor GC cycle time bounded, we limit the number of wrappers handled
@@ -131,7 +131,7 @@ public:
         v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object>*>(value);
         ASSERT(V8DOMWrapper::isDOMWrapper(*wrapper));
         ASSERT(V8Node::hasInstance(*wrapper, m_isolate));
-        Node* node = V8Node::toNative(*wrapper);
+        Node* node = V8Node::toImpl(*wrapper);
         // A minor DOM GC can handle only node wrappers in the main world.
         // Note that node->wrapper().IsEmpty() returns true for nodes that
         // do not have wrappers in the main world.
@@ -146,8 +146,10 @@ public:
             // See https://code.google.com/p/chromium/issues/detail?id=164882
             if (isHTMLImageElement(*node) && toHTMLImageElement(*node).hasPendingActivity())
                 return;
-            // FIXME: Remove the special handling for SVG context elements.
-            if (node->isSVGElement() && toSVGElement(node)->isContextElement())
+            // FIXME: Remove the special handling for SVG elements.
+            // We currently can't collect SVG Elements from minor gc, as we have
+            // strong references from SVG property tear-offs keeping context SVG element alive.
+            if (node->isSVGElement())
                 return;
 
             m_nodesInNewSpace.append(node);
@@ -252,7 +254,7 @@ public:
 
     virtual void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t classId) OVERRIDE
     {
-        if (classId != v8DOMNodeClassId && classId != v8DOMObjectClassId)
+        if (classId != WrapperTypeInfo::NodeClassId && classId != WrapperTypeInfo::ObjectClassId)
             return;
 
         // Casting to a Handle is safe here, since the Persistent doesn't get GCd
@@ -270,17 +272,17 @@ public:
         if (activeDOMObject && activeDOMObject->hasPendingActivity())
             m_isolate->SetObjectGroupId(*value, liveRootId());
 
-        if (classId == v8DOMNodeClassId) {
+        if (classId == WrapperTypeInfo::NodeClassId) {
             ASSERT(V8Node::hasInstance(*wrapper, m_isolate));
-            Node* node = V8Node::toNative(*wrapper);
+            Node* node = V8Node::toImpl(*wrapper);
             if (node->hasEventListeners())
                 addReferencesForNodeWithEventListeners(m_isolate, node, v8::Persistent<v8::Object>::Cast(*value));
             Node* root = V8GCController::opaqueRootForGC(node, m_isolate);
             m_isolate->SetObjectGroupId(*value, v8::UniqueId(reinterpret_cast<intptr_t>(root)));
             if (m_constructRetainedObjectInfos)
                 m_groupsWhichNeedRetainerInfo.append(root);
-        } else if (classId == v8DOMObjectClassId) {
-            type->visitDOMWrapper(toInternalPointer(*wrapper), v8::Persistent<v8::Object>::Cast(*value), m_isolate);
+        } else if (classId == WrapperTypeInfo::ObjectClassId) {
+            type->visitDOMWrapper(toScriptWrappableBase(*wrapper), v8::Persistent<v8::Object>::Cast(*value), m_isolate);
         } else {
             ASSERT_NOT_REACHED();
         }
@@ -401,7 +403,7 @@ void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags)
         // to collect all garbage, you need to wait until the next event loop.
         // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because
         // GCController.collectAll() forces 7 V8's GC.
-        Heap::collectGarbage(ThreadState::HeapPointersOnStack);
+        Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::ForcedGC);
 
         // Forces a precise GC at the end of the current event loop.
         Heap::setForcePreciseGCForTesting();