Title: [204387] trunk
Revision
204387
Author
mark....@apple.com
Date
2016-08-11 14:18:14 -0700 (Thu, 11 Aug 2016)

Log Message

Disallow synchronous sweeping for eden GCs.
https://bugs.webkit.org/show_bug.cgi?id=160716

Reviewed by Geoffrey Garen.

JSTests:

* stress/eden-gc-with-retired-blocks.js: Added.
- This test is just in case we add back support for eden GCs with synchronous
  sweeping in the future.

Source/_javascript_Core:

* heap/Heap.cpp:
(JSC::Heap::collectAllGarbage):
(JSC::Heap::collectAndSweep): Deleted.
* heap/Heap.h:
(JSC::Heap::collectAllGarbage): Deleted.
- No need for a separate collectAndSweep() anymore since we only call it for
  FullCollections.
- Since we've already swept all the blocks, I cleared m_blockSnapshot so that the
  IncrementalSweeper can bail earlier when it runs later.

* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::sweepHelper):
- Removed the unreachable return statement.

* heap/MarkedBlock.h:
- Document what "Retired" means.

* tools/JSDollarVMPrototype.cpp:
(JSC::JSDollarVMPrototype::edenGC):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (204386 => 204387)


--- trunk/JSTests/ChangeLog	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/JSTests/ChangeLog	2016-08-11 21:18:14 UTC (rev 204387)
@@ -1,3 +1,14 @@
+2016-08-10  Mark Lam  <mark....@apple.com>
+
+        Disallow synchronous sweeping for eden GCs.
+        https://bugs.webkit.org/show_bug.cgi?id=160716
+
+        Reviewed by Geoffrey Garen.
+
+        * stress/eden-gc-with-retired-blocks.js: Added.
+        - This test is just in case we add back support for eden GCs with synchronous
+          sweeping in the future.
+
 2016-08-10  Michael Saboff  <msab...@apple.com>
 
         Baseline GetByVal and PutByVal for cache ID stubs need to handle exceptions

Added: trunk/JSTests/stress/eden-gc-with-retired-blocks.js (0 => 204387)


--- trunk/JSTests/stress/eden-gc-with-retired-blocks.js	                        (rev 0)
+++ trunk/JSTests/stress/eden-gc-with-retired-blocks.js	2016-08-11 21:18:14 UTC (rev 204387)
@@ -0,0 +1,24 @@
+//@ runDefault
+// This test should not crash.
+
+var objs;
+
+for (let i = 0; i < 500; i += 100) {
+    objs = [];
+    gc();
+
+    // Make "Retired" blocks.
+    for (let j = 0; j < i; j++) {
+        let o;
+        switch (i % 6) {
+        case 0: o = { };
+        case 1: o = { a: i };
+        case 2: o = { a: i, b: i};
+        case 3: o = { a: i, b: i, c: i };
+        case 4: o = { a: i, b: i, c: i, d: i };
+        case 5: o = { a: i, b: i, c: i, d: i, e: i };
+        }
+        objs[j] = o;
+    }
+    edenGC();
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (204386 => 204387)


--- trunk/Source/_javascript_Core/ChangeLog	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-08-11 21:18:14 UTC (rev 204387)
@@ -1,3 +1,30 @@
+2016-08-10  Mark Lam  <mark....@apple.com>
+
+        Disallow synchronous sweeping for eden GCs.
+        https://bugs.webkit.org/show_bug.cgi?id=160716
+
+        Reviewed by Geoffrey Garen.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::collectAllGarbage):
+        (JSC::Heap::collectAndSweep): Deleted.
+        * heap/Heap.h:
+        (JSC::Heap::collectAllGarbage): Deleted.
+        - No need for a separate collectAndSweep() anymore since we only call it for
+          FullCollections.
+        - Since we've already swept all the blocks, I cleared m_blockSnapshot so that the
+          IncrementalSweeper can bail earlier when it runs later.
+
+        * heap/MarkedBlock.cpp:
+        (JSC::MarkedBlock::sweepHelper):
+        - Removed the unreachable return statement.
+
+        * heap/MarkedBlock.h:
+        - Document what "Retired" means.
+
+        * tools/JSDollarVMPrototype.cpp:
+        (JSC::JSDollarVMPrototype::edenGC):
+
 2016-08-11  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Warning fix.

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (204386 => 204387)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2016-08-11 21:18:14 UTC (rev 204387)
@@ -1071,16 +1071,17 @@
     m_slotVisitor.appendToMarkStack(const_cast<JSCell*>(cell));
 }
 
-void Heap::collectAndSweep(HeapOperation collectionType)
+void Heap::collectAllGarbage()
 {
     if (!m_isSafeToCollect)
         return;
 
-    collect(collectionType);
+    collect(FullCollection);
 
     DeferGCForAWhile deferGC(*this);
     m_objectSpace.sweep();
     m_objectSpace.shrink();
+    m_blockSnapshot.clear();
 
     sweepAllLogicallyEmptyWeakBlocks();
 }

Modified: trunk/Source/_javascript_Core/heap/Heap.h (204386 => 204387)


--- trunk/Source/_javascript_Core/heap/Heap.h	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2016-08-11 21:18:14 UTC (rev 204387)
@@ -165,8 +165,8 @@
     JS_EXPORT_PRIVATE bool isHeapSnapshotting() const;
 
     JS_EXPORT_PRIVATE void collectAllGarbageIfNotDoneRecently();
-    void collectAllGarbage() { collectAndSweep(FullCollection); }
-    JS_EXPORT_PRIVATE void collectAndSweep(HeapOperation collectionType = AnyCollection);
+    JS_EXPORT_PRIVATE void collectAllGarbage();
+
     bool shouldCollect();
     JS_EXPORT_PRIVATE void collect(HeapOperation collectionType = AnyCollection);
     bool collectIfNecessaryOrDefer(); // Returns true if it did collect.

Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.cpp (204386 => 204387)


--- trunk/Source/_javascript_Core/heap/MarkedBlock.cpp	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.cpp	2016-08-11 21:18:14 UTC (rev 204387)
@@ -163,9 +163,6 @@
             ? specializedSweep<Marked, SweepToFreeList, callDestructors>()
             : specializedSweep<Marked, SweepOnly, callDestructors>();
     }
-
-    RELEASE_ASSERT_NOT_REACHED();
-    return FreeList();
 }
 
 class SetNewlyAllocatedFunctor : public MarkedBlock::VoidFunctor {

Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (204386 => 204387)


--- trunk/Source/_javascript_Core/heap/MarkedBlock.h	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h	2016-08-11 21:18:14 UTC (rev 204387)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (por...@kde.org)
  *  Copyright (C) 2001 Peter Kelly (p...@post.com)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003-2009, 2011, 2016 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -183,6 +183,16 @@
     private:
         static const size_t atomAlignmentMask = atomSize - 1;
 
+        // During allocation, we look for available space in free lists in blocks.
+        // If a block's utilization is sufficiently high (i.e. it's almost full),
+        // we want to remove that block as a candidate for allocating to reduce
+        // the likelihood of allocation having to take a slow path. When the
+        // block is in this state, we say that it is "Retired".
+        //
+        // A full GC can take a Retired blocks out of retirement. An eden GC
+        // will simply ignore Retired blocks (i.e. they will not be swept even
+        // if they no longer have live objects).
+
         enum BlockState { New, FreeListed, Allocated, Marked, Retired };
         template<bool callDestructors> FreeList sweepHelper(SweepMode = SweepOnly);
 

Modified: trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp (204386 => 204387)


--- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2016-08-11 21:17:44 UTC (rev 204386)
+++ trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2016-08-11 21:18:14 UTC (rev 204387)
@@ -129,7 +129,7 @@
 {
     if (!ensureCurrentThreadOwnsJSLock(exec))
         return;
-    exec->heap()->collectAndSweep(EdenCollection);
+    exec->heap()->collect(EdenCollection);
 }
 
 static EncodedJSValue JSC_HOST_CALL functionEdenGC(ExecState* exec)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to