2011-04-04 Geoffrey Garen <ggaren@apple.com>
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 21:29:56 +0000 (21:29 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 21:29:56 +0000 (21:29 +0000)
        Reviewed by Oliver Hunt.

        Standardized handling of handles for immediate values
        https://bugs.webkit.org/show_bug.cgi?id=57788

        * collector/handles/HandleHeap.cpp:
        (JSC::HandleHeap::clearWeakPointers): Don't check for null or non-cell
        values here, because our write barrier guarantees that such values are
        not in the weak list.

        (JSC::HandleHeap::writeBarrier): Standardized on checking for null before
        checking for cell, and on using early return instead of if/else.

        * collector/handles/HandleHeap.h:
        (JSC::HandleHeap::deallocate):
        (JSC::HandleHeap::makeWeak): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82874 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/collector/handles/HandleHeap.cpp
Source/JavaScriptCore/collector/handles/HandleHeap.h

index 56b6456..8288bc3 100644 (file)
@@ -1,5 +1,24 @@
 2011-04-04  Geoffrey Garen  <ggaren@apple.com>
 
+        Reviewed by Oliver Hunt.
+
+        Standardized handling of handles for immediate values
+        https://bugs.webkit.org/show_bug.cgi?id=57788
+
+        * collector/handles/HandleHeap.cpp:
+        (JSC::HandleHeap::clearWeakPointers): Don't check for null or non-cell
+        values here, because our write barrier guarantees that such values are
+        not in the weak list.
+
+        (JSC::HandleHeap::writeBarrier): Standardized on checking for null before
+        checking for cell, and on using early return instead of if/else.
+
+        * collector/handles/HandleHeap.h:
+        (JSC::HandleHeap::deallocate):
+        (JSC::HandleHeap::makeWeak): Ditto.
+
+2011-04-04  Geoffrey Garen  <ggaren@apple.com>
+
         Not reviewed.
 
         Removed a redundant variable from HandleHeap
index 09d217c..e8356ce 100644 (file)
@@ -67,15 +67,14 @@ void HandleHeap::clearWeakPointers()
         m_nextToFinalize = node->next();
 
         JSValue value = *node->slot();
-        if (!value || !value.isCell())
-            continue;
-        
+        ASSERT(value);
+
         JSCell* cell = value.asCell();
-        ASSERT(!cell || cell->structure());
-        
+        ASSERT(cell && cell->structure());
 #if ENABLE(JSC_ZOMBIES)
         ASSERT(!cell->isZombie());
 #endif
+
         if (Heap::isMarked(cell))
             continue;
 
@@ -97,18 +96,22 @@ void HandleHeap::writeBarrier(HandleSlot slot, const JSValue& value)
 {
     ASSERT(!m_nextToFinalize); // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants.
 
-    if (slot->isCell() == value.isCell() && !value == !*slot)
+    if (!value == !*slot && slot->isCell() == value.isCell())
         return;
+
     Node* node = toNode(slot);
     SentinelLinkedList<Node>::remove(node);
-    if (!value.isCell() || !value) {
+    if (!value || !value.isCell()) {
         m_immediateList.push(node);
         return;
     }
-    if (node->isWeak())
+
+    if (node->isWeak()) {
         m_weakList.push(node);
-    else
-        m_strongList.push(node);
+        return;
+    }
+
+    m_strongList.push(node);
 }
 
 unsigned HandleHeap::protectedGlobalObjectCount()
index 1bf556c..6791216 100644 (file)
@@ -145,10 +145,11 @@ inline HandleSlot HandleHeap::allocate()
 inline void HandleHeap::deallocate(HandleSlot handle)
 {
     Node* node = toNode(handle);
-    if (m_nextToFinalize == node) {
+    if (node == m_nextToFinalize) {
         m_nextToFinalize = node->next();
         ASSERT(m_nextToFinalize->next());
     }
+
     SentinelLinkedList<Node>::remove(node);
     m_freeList.push(node);
 }
@@ -156,12 +157,15 @@ inline void HandleHeap::deallocate(HandleSlot handle)
 inline void HandleHeap::makeWeak(HandleSlot handle, WeakHandleOwner* weakOwner, void* context)
 {
     Node* node = toNode(handle);
-    SentinelLinkedList<Node>::remove(node);
     node->makeWeak(weakOwner, context);
-    if (handle->isCell() && *handle)
-        m_weakList.push(node);
-    else
+
+    SentinelLinkedList<Node>::remove(node);
+    if (!*handle || !handle->isCell()) {
         m_immediateList.push(node);
+        return;
+    }
+
+    m_weakList.push(node);
 }
 
 #if !ASSERT_DISABLED