Title: [87434] trunk/Source/_javascript_Core
Revision
87434
Author
[email protected]
Date
2011-05-26 14:46:09 -0700 (Thu, 26 May 2011)

Log Message

2011-05-26  Geoffrey Garen  <[email protected]>

        Reviewed by Geoffrey Garen.

        Factored out some Heap ASSERTs
        https://bugs.webkit.org/show_bug.cgi?id=61565

        * _javascript_Core.exp:
        * heap/Heap.cpp:
        (JSC::isValidSharedInstanceThreadState):
        (JSC::isValidThreadState):
        (JSC::Heap::markRoots):
        (JSC::Heap::isValidAllocation):
        * heap/Heap.h:
        * runtime/JSCell.h:
        (JSC::JSCell::Heap::allocate):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (87433 => 87434)


--- trunk/Source/_javascript_Core/ChangeLog	2011-05-26 21:43:56 UTC (rev 87433)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-05-26 21:46:09 UTC (rev 87434)
@@ -1,3 +1,20 @@
+2011-05-26  Geoffrey Garen  <[email protected]>
+
+        Reviewed by Geoffrey Garen.
+
+        Factored out some Heap ASSERTs
+        https://bugs.webkit.org/show_bug.cgi?id=61565
+
+        * _javascript_Core.exp:
+        * heap/Heap.cpp:
+        (JSC::isValidSharedInstanceThreadState):
+        (JSC::isValidThreadState):
+        (JSC::Heap::markRoots):
+        (JSC::Heap::isValidAllocation):
+        * heap/Heap.h:
+        * runtime/JSCell.h:
+        (JSC::JSCell::Heap::allocate):
+
 2011-05-26  Gavin Barraclough  <[email protected]>
 
         Reviewed by Geoff Garen.

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (87433 => 87434)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2011-05-26 21:43:56 UTC (rev 87433)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2011-05-26 21:46:09 UTC (rev 87434)
@@ -227,6 +227,7 @@
 __ZN3JSC4Heap16objectTypeCountsEv
 __ZN3JSC4Heap17collectAllGarbageEv
 __ZN3JSC4Heap17globalObjectCountEv
+__ZN3JSC4Heap17isValidAllocationEm
 __ZN3JSC4Heap19setActivityCallbackEN3WTF10PassOwnPtrINS_18GCActivityCallbackEEE
 __ZN3JSC4Heap20protectedObjectCountEv
 __ZN3JSC4Heap25protectedObjectTypeCountsEv

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (87433 => 87434)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2011-05-26 21:43:56 UTC (rev 87433)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2011-05-26 21:46:09 UTC (rev 87434)
@@ -41,6 +41,28 @@
 
 const size_t minBytesPerCycle = 512 * 1024;
 
+static inline bool isValidSharedInstanceThreadState()
+{
+    if (!JSLock::lockCount())
+        return false;
+
+    if (!JSLock::currentThreadIsHoldingLock())
+        return false;
+
+    return true;
+}
+
+static inline bool isValidThreadState(JSGlobalData* globalData)
+{
+    if (globalData->identifierTable != wtfThreadData().currentIdentifierTable())
+        return false;
+
+    if (globalData->isSharedInstance() && !isValidSharedInstanceThreadState())
+        return false;
+
+    return true;
+}
+
 Heap::Heap(JSGlobalData* globalData)
     : m_operationInProgress(NoOperation)
     , m_markedSpace(globalData)
@@ -193,27 +215,18 @@
 
 void Heap::markRoots()
 {
-#ifndef NDEBUG
-    if (m_globalData->isSharedInstance()) {
-        ASSERT(JSLock::lockCount() > 0);
-        ASSERT(JSLock::currentThreadIsHoldingLock());
-    }
-#endif
-
-    void* dummy;
-
-    ASSERT(m_operationInProgress == NoOperation);
+    ASSERT(isValidThreadState(m_globalData));
     if (m_operationInProgress != NoOperation)
         CRASH();
-
     m_operationInProgress = Collection;
 
+    void* dummy;
+
     MarkStack& visitor = m_markStack;
     HeapRootVisitor heapRootMarker(visitor);
-    
-    // We gather conservative roots before clearing mark bits because
-    // conservative gathering uses the mark bits from our last mark pass to
-    // determine whether a reference is valid.
+
+    // We gather conservative roots before clearing mark bits because conservative
+    // gathering uses the mark bits to determine whether a reference is valid.
     ConservativeRoots machineThreadRoots(this);
     m_machineThreads.gatherConservativeRoots(machineThreadRoots, &dummy);
 
@@ -432,4 +445,18 @@
     return m_activityCallback.get();
 }
 
+bool Heap::isValidAllocation(size_t bytes)
+{
+    if (!isValidThreadState(m_globalData))
+        return false;
+
+    if (bytes > MarkedSpace::maxCellSize)
+        return false;
+
+    if (m_operationInProgress != NoOperation)
+        return false;
+    
+    return true;
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/Heap.h (87433 => 87434)


--- trunk/Source/_javascript_Core/heap/Heap.h	2011-05-26 21:43:56 UTC (rev 87433)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2011-05-26 21:46:09 UTC (rev 87434)
@@ -116,6 +116,7 @@
         static const size_t minExtraCost = 256;
         static const size_t maxExtraCost = 1024 * 1024;
 
+        bool isValidAllocation(size_t);
         void* allocateSlowCase(size_t);
         void reportExtraMemoryCostSlowCase(size_t);
 

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (87433 => 87434)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-05-26 21:43:56 UTC (rev 87433)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-05-26 21:46:09 UTC (rev 87434)
@@ -395,11 +395,7 @@
     
     inline void* Heap::allocate(size_t bytes)
     {
-        ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
-        ASSERT(JSLock::lockCount() > 0);
-        ASSERT(JSLock::currentThreadIsHoldingLock());
-        ASSERT(bytes <= MarkedSpace::maxCellSize);
-        ASSERT(m_operationInProgress == NoOperation);
+        ASSERT(isValidAllocation(bytes));
 
         m_operationInProgress = Allocation;
         void* result = m_markedSpace.allocate(bytes);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to