Clean up Marked classes
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Oct 2015 20:19:02 +0000 (20:19 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Oct 2015 20:19:02 +0000 (20:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149853

Reviewed by Darin Adler.

Source/JavaScriptCore:

* heap/Heap.h:
Move include here where it is really needed.

* heap/HeapStatistics.cpp:
* heap/HeapStatistics.h:
Simplify includes.

* heap/MarkedAllocator.h:
Add missing copyright header.

* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::needsSweeping):
Remove unused constants. Add some static asserts. Add some `const` ness.

* heap/MarkedSpace.h:
(JSC::MarkedSpace::isIterating):
Update comments to better reflect actual values.
Remove unimplemented method (moved to Heap).

* heap/MarkedSpace.cpp:
(JSC::Free::Free):
(JSC::Free::operator()):
(JSC::Free::returnValue): Deleted.
(JSC::FreeOrShrink::FreeOrShrink):
(JSC::FreeOrShrink::operator()):
(JSC::MarkedSpace::~MarkedSpace):
(JSC::MarkedSpace::shrink):
Replace conditional Functor that was not using return value
with simplified targeted VoidFunctors.

(JSC::Shrink::operator()): Deleted.
Remove unused functor.

* heap/WeakBlock.cpp:
* heap/WeakBlock.h:
* runtime/Options.cpp:
Remove dead code.

Source/WTF:

* wtf/PageBlock.h:
Remove duplicate using statement.

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

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/HeapStatistics.cpp
Source/JavaScriptCore/heap/HeapStatistics.h
Source/JavaScriptCore/heap/MarkedAllocator.h
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/heap/WeakBlock.cpp
Source/JavaScriptCore/heap/WeakBlock.h
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/runtime/Options.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/PageBlock.h

index 98f6210..1b5b93b 100644 (file)
@@ -1,3 +1,49 @@
+2015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Clean up Marked classes
+        https://bugs.webkit.org/show_bug.cgi?id=149853
+
+        Reviewed by Darin Adler.
+
+        * heap/Heap.h:
+        Move include here where it is really needed.
+
+        * heap/HeapStatistics.cpp:
+        * heap/HeapStatistics.h:
+        Simplify includes.
+
+        * heap/MarkedAllocator.h:
+        Add missing copyright header.
+
+        * heap/MarkedBlock.cpp:
+        * heap/MarkedBlock.h:
+        (JSC::MarkedBlock::needsSweeping):
+        Remove unused constants. Add some static asserts. Add some `const` ness.
+
+        * heap/MarkedSpace.h:
+        (JSC::MarkedSpace::isIterating):
+        Update comments to better reflect actual values.
+        Remove unimplemented method (moved to Heap).
+
+        * heap/MarkedSpace.cpp:
+        (JSC::Free::Free):
+        (JSC::Free::operator()):
+        (JSC::Free::returnValue): Deleted.
+        (JSC::FreeOrShrink::FreeOrShrink):
+        (JSC::FreeOrShrink::operator()):
+        (JSC::MarkedSpace::~MarkedSpace):
+        (JSC::MarkedSpace::shrink):
+        Replace conditional Functor that was not using return value
+        with simplified targeted VoidFunctors.
+
+        (JSC::Shrink::operator()): Deleted.
+        Remove unused functor.
+
+        * heap/WeakBlock.cpp:
+        * heap/WeakBlock.h:
+        * runtime/Options.cpp:
+        Remove dead code.
+
 2015-10-08  Saam barati  <sbarati@apple.com>
 
         We should be able to inline getter/setter calls inside an inline cache even when the SpillRegistersMode is NeedsToSpill
index 4674773..5dbb3c9 100644 (file)
@@ -31,6 +31,7 @@
 #include "HeapOperation.h"
 #include "JITStubRoutineSet.h"
 #include "ListableHandler.h"
+#include "MachineStackMarker.h"
 #include "MarkedAllocator.h"
 #include "MarkedBlock.h"
 #include "MarkedBlockSet.h"
index 4b0d284..3081f88 100644 (file)
 #include "JSObject.h"
 #include "Options.h"
 #include <stdlib.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/DataLog.h>
+#include <wtf/StdLibExtras.h>
+
 #if OS(UNIX)
 #include <sys/resource.h>
 #endif
-#include <wtf/CurrentTime.h>
-#include <wtf/DataLog.h>
-#include <wtf/Deque.h>
 
 namespace JSC {
 
index df36ecb..ca0f43b 100644 (file)
@@ -27,7 +27,7 @@
 #define HeapStatistics_h
 
 #include "JSExportMacros.h"
-#include <wtf/Deque.h>
+#include <wtf/Vector.h>
 
 namespace JSC {
 
@@ -43,10 +43,6 @@ public:
 
     static void showObjectStatistics(Heap*);
 
-    static const size_t KB = 1024;
-    static const size_t MB = 1024 * KB;
-    static const size_t GB = 1024 * MB;
-
 private:
     static void logStatistics();
     static Vector<double>* s_pauseTimeStarts;
index 161af48..2615000 100644 (file)
@@ -1,3 +1,28 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
 #ifndef MarkedAllocator_h
 #define MarkedAllocator_h
 
@@ -10,10 +35,6 @@ class Heap;
 class MarkedSpace;
 class LLIntOffsetsExtractor;
 
-namespace DFG {
-class SpeculativeJIT;
-}
-
 class MarkedAllocator {
     friend class LLIntOffsetsExtractor;
 
@@ -145,4 +166,4 @@ template <typename Functor> inline void MarkedAllocator::forEachBlock(Functor& f
 
 } // namespace JSC
 
-#endif
+#endif // MarkedAllocator_h
index 0434792..92c4ae9 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "MarkedBlock.h"
 
-#include "IncrementalSweeper.h"
 #include "JSCell.h"
 #include "JSDestructibleObject.h"
 #include "JSCInlines.h"
index 72719cb..b5833c2 100644 (file)
@@ -30,7 +30,6 @@
 #include <wtf/DoublyLinkedList.h>
 #include <wtf/HashFunctions.h>
 #include <wtf/StdLibExtras.h>
-#include <wtf/Vector.h>
 
 // Set to log state transitions of blocks.
 #define HEAP_LOG_BLOCK_STATE_TRANSITIONS 0
@@ -54,8 +53,6 @@ namespace JSC {
 
     typedef uintptr_t Bits;
 
-    static const size_t MB = 1024 * 1024;
-    
     bool isZapped(const JSCell*);
     
     // A marked block is a page-aligned container for heap-allocated objects.
@@ -72,14 +69,13 @@ namespace JSC {
         friend struct VerifyMarkedOrRetired;
     public:
         static const size_t atomSize = 16; // bytes
-        static const size_t atomShiftAmount = 4; // log_2(atomSize) FIXME: Change atomSize to 16.
         static const size_t blockSize = 16 * KB;
         static const size_t blockMask = ~(blockSize - 1); // blockSize must be a power of two.
 
         static const size_t atomsPerBlock = blockSize / atomSize;
-        static const size_t atomMask = atomsPerBlock - 1;
 
-        static const size_t markByteShiftAmount = 3; // log_2(word size for m_marks) FIXME: Change word size for m_marks to uint8_t.
+        static_assert(!(MarkedBlock::atomSize & (MarkedBlock::atomSize - 1)), "MarkedBlock::atomSize must be a power of two.");
+        static_assert(!(MarkedBlock::blockSize & (MarkedBlock::blockSize - 1)), "MarkedBlock::blockSize must be a power of two.");
 
         struct FreeCell {
             FreeCell* next;
@@ -168,7 +164,7 @@ namespace JSC {
         void clearNewlyAllocated(const void*);
 
         bool isAllocated() const;
-        bool needsSweeping();
+        bool needsSweeping() const;
         void didRetireBlock(const FreeList&);
         void willRemoveBlock();
 
@@ -177,7 +173,7 @@ namespace JSC {
         template <typename Functor> IterationStatus forEachDeadCell(Functor&);
 
     private:
-        static const size_t atomAlignmentMask = atomSize - 1; // atomSize must be a power of two.
+        static const size_t atomAlignmentMask = atomSize - 1;
 
         enum BlockState { New, FreeListed, Allocated, Marked, Retired };
         template<bool callDestructors> FreeList sweepHelper(SweepMode = SweepOnly);
@@ -442,7 +438,7 @@ namespace JSC {
         return IterationStatus::Continue;
     }
 
-    inline bool MarkedBlock::needsSweeping()
+    inline bool MarkedBlock::needsSweeping() const
     {
         return m_state == Marked;
     }
index 52a371c..00adc5a 100644 (file)
 #include "MarkedSpace.h"
 
 #include "IncrementalSweeper.h"
-#include "JSGlobalObject.h"
-#include "JSLock.h"
 #include "JSObject.h"
 #include "JSCInlines.h"
 
 namespace JSC {
 
-class Structure;
-
-class Free {
-public:
-    typedef MarkedBlock* ReturnType;
-
-    enum FreeMode { FreeOrShrink, FreeAll };
-
-    Free(FreeMode, MarkedSpace*);
-    void operator()(MarkedBlock*);
-    ReturnType returnValue();
-    
+struct Free : MarkedBlock::VoidFunctor {
+    Free(MarkedSpace& space) : m_markedSpace(space) { }
+    void operator()(MarkedBlock* block) { m_markedSpace.freeBlock(block); }
 private:
-    FreeMode m_freeMode;
-    MarkedSpace* m_markedSpace;
-    DoublyLinkedList<MarkedBlock> m_blocks;
+    MarkedSpace& m_markedSpace;
 };
 
-inline Free::Free(FreeMode freeMode, MarkedSpace* newSpace)
-    : m_freeMode(freeMode)
-    , m_markedSpace(newSpace)
-{
-}
-
-inline void Free::operator()(MarkedBlock* block)
-{
-    if (m_freeMode == FreeOrShrink)
-        m_markedSpace->freeOrShrinkBlock(block);
-    else
-        m_markedSpace->freeBlock(block);
-}
-
-inline Free::ReturnType Free::returnValue()
-{
-    return m_blocks.head();
-}
+struct FreeOrShrink : MarkedBlock::VoidFunctor {
+    FreeOrShrink(MarkedSpace& space) : m_markedSpace(space) { }
+    void operator()(MarkedBlock* block) { m_markedSpace.freeOrShrinkBlock(block); }
+private:
+    MarkedSpace& m_markedSpace;
+};
 
 struct VisitWeakSet : MarkedBlock::VoidFunctor {
     VisitWeakSet(HeapRootVisitor& heapRootVisitor) : m_heapRootVisitor(heapRootVisitor) { }
@@ -98,7 +73,7 @@ MarkedSpace::MarkedSpace(Heap* heap)
 
 MarkedSpace::~MarkedSpace()
 {
-    Free free(Free::FreeAll, this);
+    Free free(*this);
     forEachBlock(free);
     ASSERT(!m_blocks.set().size());
 }
@@ -247,13 +222,9 @@ void MarkedSpace::freeOrShrinkBlock(MarkedBlock* block)
     freeBlock(block);
 }
 
-struct Shrink : MarkedBlock::VoidFunctor {
-    void operator()(MarkedBlock* block) { block->shrink(); }
-};
-
 void MarkedSpace::shrink()
 {
-    Free freeOrShrink(Free::FreeOrShrink, this);
+    FreeOrShrink freeOrShrink(*this);
     forEachBlock(freeOrShrink);
 }
 
index 79721df..8619576 100644 (file)
 #ifndef MarkedSpace_h
 #define MarkedSpace_h
 
-#include "MachineStackMarker.h"
 #include "MarkedAllocator.h"
 #include "MarkedBlock.h"
 #include "MarkedBlockSet.h"
 #include <array>
-#include <wtf/Bitmap.h>
-#include <wtf/DoublyLinkedList.h>
 #include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RetainPtr.h>
@@ -38,11 +35,8 @@ namespace JSC {
 
 class Heap;
 class HeapIterationScope;
-class JSCell;
 class LiveObjectIterator;
 class LLIntOffsetsExtractor;
-class WeakGCHandle;
-class SlotVisitor;
 
 struct ClearMarks : MarkedBlock::VoidFunctor {
     void operator()(MarkedBlock* block)
@@ -74,12 +68,12 @@ struct Size : MarkedBlock::CountFunctor {
 class MarkedSpace {
     WTF_MAKE_NONCOPYABLE(MarkedSpace);
 public:
-    // [ 32... 128 ]
+    // [ 16 ... 128 ]
     static const size_t preciseStep = MarkedBlock::atomSize;
     static const size_t preciseCutoff = 128;
     static const size_t preciseCount = preciseCutoff / preciseStep;
 
-    // [ 1024... blockSize ]
+    // [ 256 ... blockSize/2 ]
     static const size_t impreciseStep = 2 * preciseCutoff;
     static const size_t impreciseCutoff = MarkedBlock::blockSize / 2;
     static const size_t impreciseCount = impreciseCutoff / impreciseStep;
@@ -110,21 +104,21 @@ public:
     MarkedBlockSet& blocks() { return m_blocks; }
 
     void willStartIterating();
-    bool isIterating() { return m_isIterating; }
+    bool isIterating() const { return m_isIterating; }
     void didFinishIterating();
 
     void stopAllocating();
     void resumeAllocating(); // If we just stopped allocation but we didn't do a collection, we need to resume allocation.
 
     typedef HashSet<MarkedBlock*>::iterator BlockIterator;
-    
+
     template<typename Functor> typename Functor::ReturnType forEachLiveCell(HeapIterationScope&, Functor&);
     template<typename Functor> typename Functor::ReturnType forEachLiveCell(HeapIterationScope&);
     template<typename Functor> typename Functor::ReturnType forEachDeadCell(HeapIterationScope&, Functor&);
     template<typename Functor> typename Functor::ReturnType forEachDeadCell(HeapIterationScope&);
     template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);
     template<typename Functor> typename Functor::ReturnType forEachBlock();
-    
+
     void shrink();
     void freeBlock(MarkedBlock*);
     void freeOrShrinkBlock(MarkedBlock*);
@@ -143,10 +137,6 @@ public:
 
     bool isPagedOut(double deadline);
 
-#if USE(CF)
-    template<typename T> void releaseSoon(RetainPtr<T>&&);
-#endif
-
     const Vector<MarkedBlock*>& blocksWithNewObjects() const { return m_blocksWithNewObjects; }
 
 private:
index 7c7d86c..63f6585 100644 (file)
@@ -28,9 +28,9 @@
 
 #include "Heap.h"
 #include "HeapRootVisitor.h"
-#include "JSObject.h"
 #include "JSCInlines.h"
-#include "Structure.h"
+#include "JSObject.h"
+#include "WeakHandleOwner.h"
 
 namespace JSC {
 
index b829e9d..9e19783 100644 (file)
@@ -26,8 +26,6 @@
 #ifndef WeakBlock_h
 #define WeakBlock_h
 
-#include <wtf/DoublyLinkedList.h>
-#include "WeakHandleOwner.h"
 #include "WeakImpl.h"
 #include <wtf/DoublyLinkedList.h>
 #include <wtf/StdLibExtras.h>
@@ -35,9 +33,7 @@
 namespace JSC {
 
 class HeapRootVisitor;
-class JSValue;
 class MarkedBlock;
-class WeakHandleOwner;
 
 class WeakBlock : public DoublyLinkedListNode<WeakBlock> {
 public:
index 2b01e9b..5dae706 100644 (file)
@@ -369,9 +369,6 @@ const Initialization = 0
 
 const MarkedBlockSize = 16 * 1024
 const MarkedBlockMask = ~(MarkedBlockSize - 1)
-# Constants for checking mark bits.
-const AtomNumberShift = 3
-const BitMapWordShift = 4
 
 # Allocation constants
 if JSVALUE64
index efadf49..b33858f 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "Options.h"
 
-#include "HeapStatistics.h"
 #include <algorithm>
 #include <limits>
 #include <math.h>
 #include <wtf/ASCIICType.h>
 #include <wtf/DataLog.h>
 #include <wtf/NumberOfCores.h>
-#include <wtf/PageBlock.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/StringExtras.h>
 #include <wtf/text/StringBuilder.h>
 
-#if OS(DARWIN)
-#include <sys/sysctl.h>
-#endif
-
 #if OS(WINDOWS)
 #include "MacroAssemblerX86.h"
 #endif
index 388e61d..3bd352c 100644 (file)
@@ -1,5 +1,15 @@
 2015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Clean up Marked classes
+        https://bugs.webkit.org/show_bug.cgi?id=149853
+
+        Reviewed by Darin Adler.
+
+        * wtf/PageBlock.h:
+        Remove duplicate using statement.
+
+2015-10-08  Joseph Pecoraro  <pecoraro@apple.com>
+
         Remove PageReservation.h clang fixme that has been fixed for a while
         https://bugs.webkit.org/show_bug.cgi?id=149908
 
index 56e5570..372c8b6 100644 (file)
@@ -82,7 +82,6 @@ inline PageBlock::PageBlock(void* base, size_t size, bool hasGuardPages)
 
 using WTF::pageSize;
 using WTF::isPageAligned;
-using WTF::isPageAligned;
 using WTF::isPowerOfTwo;
 
 #endif // PageBlock_h