Title: [207055] releases/WebKitGTK/webkit-2.14/Source/_javascript_Core
Revision
207055
Author
carlo...@webkit.org
Date
2016-10-10 23:53:03 -0700 (Mon, 10 Oct 2016)

Log Message

Merge r205658 - Heap version should be 32-bit
https://bugs.webkit.org/show_bug.cgi?id=161751

Reviewed by Mark Lam.

32-bit devices are probably getting hurt by the 64-bit version number. The reason why I made
it 64-bit initially is so that I wouldn't have to worry about wrap-around. But wrap-around is
easy to handle.

* heap/CellContainer.h:
* heap/CellContainerInlines.h:
(JSC::CellContainer::flipIfNecessary):
* heap/ConservativeRoots.cpp:
(JSC::ConservativeRoots::genericAddPointer):
(JSC::ConservativeRoots::genericAddSpan):
* heap/ConservativeRoots.h:
* heap/Heap.h:
* heap/HeapInlines.h:
(JSC::Heap::testAndSetMarked):
* heap/HeapUtil.h:
(JSC::HeapUtil::findGCObjectPointersForMarking):
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::MarkedBlock):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::flipIfNecessary):
(JSC::MarkedBlock::flipIfNecessaryConcurrently):
(JSC::MarkedBlock::Handle::flipIfNecessary):
(JSC::MarkedBlock::Handle::flipIfNecessaryConcurrently):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::flip):
* heap/MarkedSpace.h:
(JSC::MarkedSpace::version):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
* heap/SlotVisitor.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/ChangeLog	2016-10-11 06:53:03 UTC (rev 207055)
@@ -1,3 +1,41 @@
+2016-09-08  Filip Pizlo  <fpi...@apple.com>
+
+        Heap version should be 32-bit
+        https://bugs.webkit.org/show_bug.cgi?id=161751
+
+        Reviewed by Mark Lam.
+        
+        32-bit devices are probably getting hurt by the 64-bit version number. The reason why I made
+        it 64-bit initially is so that I wouldn't have to worry about wrap-around. But wrap-around is
+        easy to handle.
+
+        * heap/CellContainer.h:
+        * heap/CellContainerInlines.h:
+        (JSC::CellContainer::flipIfNecessary):
+        * heap/ConservativeRoots.cpp:
+        (JSC::ConservativeRoots::genericAddPointer):
+        (JSC::ConservativeRoots::genericAddSpan):
+        * heap/ConservativeRoots.h:
+        * heap/Heap.h:
+        * heap/HeapInlines.h:
+        (JSC::Heap::testAndSetMarked):
+        * heap/HeapUtil.h:
+        (JSC::HeapUtil::findGCObjectPointersForMarking):
+        * heap/MarkedBlock.cpp:
+        (JSC::MarkedBlock::MarkedBlock):
+        * heap/MarkedBlock.h:
+        (JSC::MarkedBlock::flipIfNecessary):
+        (JSC::MarkedBlock::flipIfNecessaryConcurrently):
+        (JSC::MarkedBlock::Handle::flipIfNecessary):
+        (JSC::MarkedBlock::Handle::flipIfNecessaryConcurrently):
+        * heap/MarkedSpace.cpp:
+        (JSC::MarkedSpace::flip):
+        * heap/MarkedSpace.h:
+        (JSC::MarkedSpace::version):
+        * heap/SlotVisitor.cpp:
+        (JSC::SlotVisitor::SlotVisitor):
+        * heap/SlotVisitor.h:
+
 2016-09-08  Mark Lam  <mark....@apple.com>
 
         Add support for a ternary sub32 emitter for ARM64 and 32-bit ARM.

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainer.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainer.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainer.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -34,6 +34,8 @@
 class MarkedBlock;
 class WeakSet;
 
+typedef uint32_t HeapVersion;
+
 // This is how we abstract over either MarkedBlock& or LargeAllocation&. Put things in here as you
 // find need for them.
 
@@ -71,7 +73,7 @@
         return *bitwise_cast<LargeAllocation*>(m_encodedPointer - isLargeAllocationBit);
     }
     
-    void flipIfNecessary(uint64_t heapVersion);
+    void flipIfNecessary(HeapVersion);
     void flipIfNecessary();
     
     bool isMarked() const;

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainerInlines.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainerInlines.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/CellContainerInlines.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -73,7 +73,7 @@
     return markedBlock().weakSet();
 }
 
-inline void CellContainer::flipIfNecessary(uint64_t heapVersion)
+inline void CellContainer::flipIfNecessary(HeapVersion heapVersion)
 {
     if (!isLargeAllocation())
         markedBlock().flipIfNecessary(heapVersion);

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.cpp (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.cpp	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.cpp	2016-10-11 06:53:03 UTC (rev 207055)
@@ -67,7 +67,7 @@
 }
 
 template<typename MarkHook>
-inline void ConservativeRoots::genericAddPointer(void* p, int64_t version, TinyBloomFilter filter, MarkHook& markHook)
+inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion version, TinyBloomFilter filter, MarkHook& markHook)
 {
     markHook.mark(p);
 
@@ -97,7 +97,7 @@
     RELEASE_ASSERT(isPointerAligned(end));
 
     TinyBloomFilter filter = m_heap.objectSpace().blocks().filter(); // Make a local copy of filter to show the compiler it won't alias, and can be register-allocated.
-    int64_t version = m_heap.objectSpace().version();
+    HeapVersion version = m_heap.objectSpace().version();
     for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it)
         genericAddPointer(*it, version, filter, markHook);
 }

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/ConservativeRoots.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -51,7 +51,7 @@
     static const size_t nonInlineCapacity = 8192 / sizeof(HeapCell*);
     
     template<typename MarkHook>
-    void genericAddPointer(void*, int64_t heapVersion, TinyBloomFilter, MarkHook&);
+    void genericAddPointer(void*, HeapVersion, TinyBloomFilter, MarkHook&);
 
     template<typename MarkHook>
     void genericAddSpan(void*, void* end, MarkHook&);

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/Heap.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/Heap.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/Heap.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -101,7 +101,7 @@
 
     static bool isLive(const void*);
     static bool isMarked(const void*);
-    static bool testAndSetMarked(int64_t, const void*);
+    static bool testAndSetMarked(HeapVersion, const void*);
     static void setMarked(const void*);
     
     static size_t cellSize(const void*);

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapInlines.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapInlines.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapInlines.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -94,7 +94,7 @@
     return block.isMarked(cell);
 }
 
-ALWAYS_INLINE bool Heap::testAndSetMarked(int64_t version, const void* rawCell)
+ALWAYS_INLINE bool Heap::testAndSetMarked(HeapVersion version, const void* rawCell)
 {
     HeapCell* cell = bitwise_cast<HeapCell*>(rawCell);
     if (cell->isLargeAllocation())

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapUtil.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapUtil.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/HeapUtil.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -46,7 +46,7 @@
     // before liveness data is cleared to be accurate.
     template<typename Func>
     static void findGCObjectPointersForMarking(
-        Heap& heap, int64_t heapVersion, TinyBloomFilter filter, void* passedPointer,
+        Heap& heap, HeapVersion heapVersion, TinyBloomFilter filter, void* passedPointer,
         const Func& func)
     {
         const HashSet<MarkedBlock*>& set = heap.objectSpace().blocks().set();

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.cpp (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.cpp	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.cpp	2016-10-11 06:53:03 UTC (rev 207055)
@@ -85,9 +85,9 @@
 
 MarkedBlock::MarkedBlock(VM& vm, Handle& handle)
     : m_needsDestruction(handle.needsDestruction())
+    , m_version(vm.heap.objectSpace().version())
     , m_handle(handle)
     , m_vm(&vm)
-    , m_version(vm.heap.objectSpace().version())
 {
     unsigned cellsPerBlock = MarkedSpace::blockPayload / handle.cellSize();
     double markCountBias = -(Options::minMarkedBlockUtilization() * cellsPerBlock);

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedBlock.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -42,6 +42,7 @@
 class MarkedAllocator;
 
 typedef uintptr_t Bits;
+typedef uint32_t HeapVersion;
 
 // Set to log state transitions of blocks.
 #define HEAP_LOG_BLOCK_STATE_TRANSITIONS 0
@@ -185,8 +186,8 @@
             
         bool needsFlip();
             
-        void flipIfNecessaryConcurrently(uint64_t heapVersion);
-        void flipIfNecessary(uint64_t heapVersion);
+        void flipIfNecessaryConcurrently(HeapVersion);
+        void flipIfNecessary(HeapVersion);
         void flipIfNecessary();
             
         void assertFlipped();
@@ -265,8 +266,8 @@
 
     bool needsFlip();
         
-    void flipIfNecessaryConcurrently(uint64_t heapVersion);
-    void flipIfNecessary(uint64_t heapVersion);
+    void flipIfNecessaryConcurrently(HeapVersion);
+    void flipIfNecessary(HeapVersion);
     void flipIfNecessary();
         
     void assertFlipped();
@@ -319,11 +320,11 @@
     //
     //     m_biasedMarkCount != m_markCountBias
     int16_t m_markCountBias;
+
+    HeapVersion m_version;
     
     Handle& m_handle;
     VM* m_vm;
-        
-    uint64_t m_version;
 };
 
 inline MarkedBlock::Handle& MarkedBlock::handle()
@@ -461,13 +462,13 @@
     return (reinterpret_cast<Bits>(p) - reinterpret_cast<Bits>(this)) / atomSize;
 }
 
-inline void MarkedBlock::flipIfNecessary(uint64_t heapVersion)
+inline void MarkedBlock::flipIfNecessary(HeapVersion heapVersion)
 {
     if (UNLIKELY(heapVersion != m_version))
         flipIfNecessarySlow();
 }
 
-inline void MarkedBlock::flipIfNecessaryConcurrently(uint64_t heapVersion)
+inline void MarkedBlock::flipIfNecessaryConcurrently(HeapVersion heapVersion)
 {
     if (UNLIKELY(heapVersion != m_version))
         flipIfNecessaryConcurrentlySlow();
@@ -474,12 +475,12 @@
     WTF::loadLoadFence();
 }
 
-inline void MarkedBlock::Handle::flipIfNecessary(uint64_t heapVersion)
+inline void MarkedBlock::Handle::flipIfNecessary(HeapVersion heapVersion)
 {
     block().flipIfNecessary(heapVersion);
 }
 
-inline void MarkedBlock::Handle::flipIfNecessaryConcurrently(uint64_t heapVersion)
+inline void MarkedBlock::Handle::flipIfNecessaryConcurrently(HeapVersion heapVersion)
 {
     block().flipIfNecessaryConcurrently(heapVersion);
 }

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.cpp (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.cpp	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.cpp	2016-10-11 06:53:03 UTC (rev 207055)
@@ -462,7 +462,16 @@
         for (unsigned i = 0; i < m_blocksWithNewObjects.size(); ++i)
             m_blocksWithNewObjects[i]->flipForEdenCollection();
     } else {
-        m_version++; // Henceforth, flipIfNecessary() will trigger on all blocks.
+        HeapVersion nextVersion = m_version + 1;
+        if (UNLIKELY(nextVersion == initialVersion)) {
+            // Oh no! Version wrap-around! We handle this by flipping all blocks. This happens
+            // super rarely, probably never for most users.
+            forEachBlock(
+                [&] (MarkedBlock::Handle* handle) {
+                    handle->flipIfNecessary();
+                });
+        }
+        m_version = nextVersion; // Henceforth, flipIfNecessary() will trigger on all blocks.
         for (LargeAllocation* allocation : m_largeAllocations)
             allocation->flip();
     }

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/MarkedSpace.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -42,6 +42,8 @@
 class LLIntOffsetsExtractor;
 class WeakSet;
 
+typedef uint32_t HeapVersion;
+
 class MarkedSpace {
     WTF_MAKE_NONCOPYABLE(MarkedSpace);
 public:
@@ -63,6 +65,8 @@
 
     static const size_t numSizeClasses = largeCutoff / sizeStep;
     
+    static const HeapVersion initialVersion = 42;  // This can be any value, including random garbage, so long as it's consistent for the lifetime of the process.
+    
     static size_t sizeClassToIndex(size_t size)
     {
         ASSERT(size);
@@ -151,7 +155,7 @@
 
     bool isPagedOut(double deadline);
     
-    uint64_t version() const { return m_version; }
+    HeapVersion version() const { return m_version; }
 
     const Vector<MarkedBlock::Handle*>& blocksWithNewObjects() const { return m_blocksWithNewObjects; }
     
@@ -189,7 +193,7 @@
     Subspace m_auxiliarySpace;
 
     Heap* m_heap;
-    uint64_t m_version { 42 }; // This can start at any value, including random garbage values.
+    HeapVersion m_version { initialVersion };
     size_t m_capacity;
     bool m_isIterating;
     MarkedBlockSet m_blocks;

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.cpp (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.cpp	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.cpp	2016-10-11 06:53:03 UTC (rev 207055)
@@ -81,7 +81,7 @@
     , m_bytesCopied(0)
     , m_visitCount(0)
     , m_isInParallelMode(false)
-    , m_version(42)
+    , m_version(MarkedSpace::initialVersion)
     , m_heap(heap)
 #if !ASSERT_DISABLED
     , m_isCheckingForDefaultMarkViolation(false)

Modified: releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.h (207054 => 207055)


--- releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.h	2016-10-11 06:43:35 UTC (rev 207054)
+++ releases/WebKitGTK/webkit-2.14/Source/_javascript_Core/heap/SlotVisitor.h	2016-10-11 06:53:03 UTC (rev 207055)
@@ -46,6 +46,8 @@
 class WeakReferenceHarvester;
 template<typename T> class WriteBarrierBase;
 
+typedef uint32_t HeapVersion;
+
 class SlotVisitor {
     WTF_MAKE_NONCOPYABLE(SlotVisitor);
     WTF_MAKE_FAST_ALLOCATED;
@@ -160,7 +162,7 @@
     size_t m_visitCount;
     bool m_isInParallelMode;
     
-    uint64_t m_version;
+    HeapVersion m_version;
     
     Heap& m_heap;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to