Title: [98123] trunk/Source/_javascript_Core
Revision
98123
Author
[email protected]
Date
2011-10-21 12:36:46 -0700 (Fri, 21 Oct 2011)

Log Message

Add finalizer to JSObject
https://bugs.webkit.org/show_bug.cgi?id=70336

Reviewed by Darin Adler.

* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::callDestructor): Skip the call to the destructor 
if we're a JSFinalObject, since the finalizer takes care of things.
* runtime/JSCell.h:
(JSC::JSCell::~JSCell): Remove the GC validation due to a conflict with 
future changes and the fact that we no longer always call the destructor, making 
the information provided less useful.
* runtime/JSObject.cpp:
(JSC::JSObject::finalize): Add finalizer for JSObject.
(JSC::JSObject::allocatePropertyStorage): The first time we need to allocate out-of-line
property storage, we add a finalizer to ourself.
* runtime/JSObject.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (98122 => 98123)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-21 19:33:56 UTC (rev 98122)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-21 19:36:46 UTC (rev 98123)
@@ -1,3 +1,23 @@
+2011-10-21  Mark Hahnenberg  <[email protected]>
+
+        Add finalizer to JSObject
+        https://bugs.webkit.org/show_bug.cgi?id=70336
+
+        Reviewed by Darin Adler.
+
+        * heap/MarkedBlock.cpp:
+        (JSC::MarkedBlock::callDestructor): Skip the call to the destructor 
+        if we're a JSFinalObject, since the finalizer takes care of things.
+        * runtime/JSCell.h:
+        (JSC::JSCell::~JSCell): Remove the GC validation due to a conflict with 
+        future changes and the fact that we no longer always call the destructor, making 
+        the information provided less useful.
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::finalize): Add finalizer for JSObject.
+        (JSC::JSObject::allocatePropertyStorage): The first time we need to allocate out-of-line
+        property storage, we add a finalizer to ourself.
+        * runtime/JSObject.h:
+
 2011-10-21  Simon Hausmann  <[email protected]>
 
         Remove QtScript source code from WebKit.

Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.cpp (98122 => 98123)


--- trunk/Source/_javascript_Core/heap/MarkedBlock.cpp	2011-10-21 19:33:56 UTC (rev 98122)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.cpp	2011-10-21 19:36:46 UTC (rev 98123)
@@ -70,9 +70,7 @@
 #if ENABLE(SIMPLE_HEAP_PROFILING)
     m_heap->m_destroyedTypeCounts.countVPtr(vptr);
 #endif
-    if (vptr == jsFinalObjectVPtr)
-        reinterpret_cast<JSFinalObject*>(cell)->JSFinalObject::~JSFinalObject();
-    else
+    if (vptr != jsFinalObjectVPtr)
         cell->~JSCell();
 
     cell->zap();

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (98122 => 98123)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-10-21 19:33:56 UTC (rev 98122)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-10-21 19:36:46 UTC (rev 98123)
@@ -177,9 +177,6 @@
 
     inline JSCell::~JSCell()
     {
-#if ENABLE(GC_VALIDATION)
-        m_structure.clear();
-#endif
     }
 
     inline Structure* JSCell::structure() const

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (98122 => 98123)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-10-21 19:33:56 UTC (rev 98122)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-10-21 19:36:46 UTC (rev 98123)
@@ -70,6 +70,11 @@
     }
 }
 
+void JSObject::finalize(JSCell* cell)
+{
+    delete [] static_cast<JSObject*>(cell)->m_propertyStorage.get();
+}
+
 void JSObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     JSObject* thisObject = static_cast<JSObject*>(cell);
@@ -688,7 +693,9 @@
     for (unsigned i = 0; i < oldSize; ++i)
        newPropertyStorage[i] = oldPropertyStorage[i];
 
-    if (!isUsingInlineStorage())
+    if (isUsingInlineStorage())
+        Heap::heap(this)->addFinalizer(this, &finalize);
+    else
         delete [] oldPropertyStorage;
 
     m_propertyStorage.set(globalData, this, newPropertyStorage);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (98122 => 98123)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-10-21 19:33:56 UTC (rev 98122)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-10-21 19:36:46 UTC (rev 98123)
@@ -84,9 +84,7 @@
 
         virtual UString className() const;
 
-        // The inline virtual destructor cannot be the first virtual function declared
-        // in the class as it results in the vtable being generated as a weak symbol
-        virtual ~JSObject();
+        static void finalize(JSCell*);
 
         JSValue prototype() const;
         void setPrototype(JSGlobalData&, JSValue prototype);
@@ -446,12 +444,6 @@
 {
 }
 
-inline JSObject::~JSObject()
-{
-    if (!isUsingInlineStorage())
-        delete [] m_propertyStorage.get();
-}
-
 inline JSValue JSObject::prototype() const
 {
     return structure()->storedPrototype();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to