Title: [88368] trunk/Source/_javascript_Core
Revision
88368
Author
gga...@apple.com
Date
2011-06-08 11:58:04 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Geoffrey Garen  <gga...@apple.com>

        Reviewed by Darin Adler.

        Moved MarkedSpace.* to NewSpace.* in preparation for more renaming
        https://bugs.webkit.org/show_bug.cgi?id=62268

        * CMakeLists.txt:
        * GNUmakefile.list.am:
        * _javascript_Core.gypi:
        * _javascript_Core.pro:
        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
        * _javascript_Core.xcodeproj/project.pbxproj:
        * heap/Heap.h:
        * heap/MarkedBlock.h:
        * heap/MarkedSpace.cpp: Removed.
        * heap/MarkedSpace.h: Removed.
        * heap/NewSpace.cpp: Copied from Source/_javascript_Core/heap/MarkedSpace.cpp.
        * heap/NewSpace.h: Copied from Source/_javascript_Core/heap/MarkedSpace.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (88367 => 88368)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2011-06-08 18:58:04 UTC (rev 88368)
@@ -47,7 +47,7 @@
     heap/HandleStack.cpp
     heap/MachineStackMarker.cpp
     heap/MarkedBlock.cpp
-    heap/MarkedSpace.cpp
+    heap/NewSpace.cpp
     heap/ConservativeRoots.cpp
     heap/MarkStack.cpp
 

Modified: trunk/Source/_javascript_Core/ChangeLog (88367 => 88368)


--- trunk/Source/_javascript_Core/ChangeLog	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-06-08 18:58:04 UTC (rev 88368)
@@ -1,3 +1,23 @@
+2011-06-08  Geoffrey Garen  <gga...@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Moved MarkedSpace.* to NewSpace.* in preparation for more renaming
+        https://bugs.webkit.org/show_bug.cgi?id=62268
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * _javascript_Core.gypi:
+        * _javascript_Core.pro:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * heap/Heap.h:
+        * heap/MarkedBlock.h:
+        * heap/MarkedSpace.cpp: Removed.
+        * heap/MarkedSpace.h: Removed.
+        * heap/NewSpace.cpp: Copied from Source/_javascript_Core/heap/MarkedSpace.cpp.
+        * heap/NewSpace.h: Copied from Source/_javascript_Core/heap/MarkedSpace.h.
+
 2011-06-08  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r88365.

Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (88367 => 88368)


--- trunk/Source/_javascript_Core/GNUmakefile.list.am	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am	2011-06-08 18:58:04 UTC (rev 88368)
@@ -117,8 +117,8 @@
 	Source/_javascript_Core/heap/HeapRootVisitor.h \
 	Source/_javascript_Core/heap/MarkedBlock.cpp \
 	Source/_javascript_Core/heap/MarkedBlock.h \
-	Source/_javascript_Core/heap/MarkedSpace.cpp \
-	Source/_javascript_Core/heap/MarkedSpace.h \
+	Source/_javascript_Core/heap/NewSpace.cpp \
+	Source/_javascript_Core/heap/NewSpace.h \
 	Source/_javascript_Core/heap/Strong.h \
 	Source/_javascript_Core/heap/Weak.h \
 	Source/_javascript_Core/config.h \

Modified: trunk/Source/_javascript_Core/_javascript_Core.gypi (88367 => 88368)


--- trunk/Source/_javascript_Core/_javascript_Core.gypi	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/_javascript_Core.gypi	2011-06-08 18:58:04 UTC (rev 88368)
@@ -322,8 +322,8 @@
             'heap/HeapRootVisitor.h',
             'heap/MarkedBlock.cpp',
             'heap/MarkedBlock.h',
-            'heap/MarkedSpace.cpp',
-            'heap/MarkedSpace.h',
+            'heap/NewSpace.cpp',
+            'heap/NewSpace.h',
             'debugger/Debugger.cpp',
             'debugger/DebuggerActivation.cpp',
             'debugger/DebuggerCallFrame.cpp',

Modified: trunk/Source/_javascript_Core/_javascript_Core.pro (88367 => 88368)


--- trunk/Source/_javascript_Core/_javascript_Core.pro	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/_javascript_Core.pro	2011-06-08 18:58:04 UTC (rev 88368)
@@ -77,7 +77,7 @@
     heap/MachineStackMarker.cpp \
     heap/MarkStack.cpp \
     heap/MarkedBlock.cpp \
-    heap/MarkedSpace.cpp \
+    heap/NewSpace.cpp \
     debugger/DebuggerActivation.cpp \
     debugger/DebuggerCallFrame.cpp \
     debugger/Debugger.cpp \

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj (88367 => 88368)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2011-06-08 18:58:04 UTC (rev 88368)
@@ -1898,11 +1898,11 @@
                                     >
                             </File>
                             <File
-                                    RelativePath="..\..\heap\MarkedSpace.cpp"
+                                    RelativePath="..\..\heap\NewSpace.cpp"
                                     >
                             </File>
                             <File
-                                    RelativePath="..\..\heap\MarkedSpace.h"
+                                    RelativePath="..\..\heap\NewSpace.h"
                                     >
                             </File>
                             <File

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (88367 => 88368)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-06-08 18:58:04 UTC (rev 88368)
@@ -86,8 +86,6 @@
 		142D3939103E4560007DCB52 /* NumericStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 142D3938103E4560007DCB52 /* NumericStrings.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		142D6F0813539A2800B02E86 /* MarkedBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 142D6F0613539A2800B02E86 /* MarkedBlock.cpp */; };
 		142D6F0913539A2800B02E86 /* MarkedBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 142D6F0713539A2800B02E86 /* MarkedBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		142D6F0C13539A2F00B02E86 /* MarkedSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 142D6F0A13539A2F00B02E86 /* MarkedSpace.cpp */; };
-		142D6F0D13539A2F00B02E86 /* MarkedSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 142D6F0B13539A2F00B02E86 /* MarkedSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		142D6F1113539A4100B02E86 /* MarkStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 142D6F0E13539A4100B02E86 /* MarkStack.cpp */; };
 		142D6F1213539A4100B02E86 /* MarkStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 142D6F0F13539A4100B02E86 /* MarkStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		142E3134134FF0A600AFADB5 /* Handle.h in Headers */ = {isa = PBXBuildFile; fileRef = 142E312B134FF0A600AFADB5 /* Handle.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -185,6 +183,8 @@
 		14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; };
 		14BFCE6910CDB1FC00364CCE /* WeakGCMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14C5242B0F5355E900BA3D04 /* JITStubs.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A6581A0F4E36F4000150FD /* JITStubs.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		14D2F3DA139F4BE200491031 /* NewSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D2F3D8139F4BE200491031 /* NewSpace.cpp */; };
+		14D2F3DB139F4BE200491031 /* NewSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D2F3D9139F4BE200491031 /* NewSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		14E9D17B107EC469004DDA21 /* JSGlobalObjectFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC756FC60E2031B200DE7D12 /* JSGlobalObjectFunctions.cpp */; };
 		14F8BA3E107EC886009892DC /* FastMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */; };
 		14F8BA43107EC88C009892DC /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
@@ -743,8 +743,6 @@
 		142D3938103E4560007DCB52 /* NumericStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumericStrings.h; sourceTree = "<group>"; };
 		142D6F0613539A2800B02E86 /* MarkedBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedBlock.cpp; sourceTree = "<group>"; };
 		142D6F0713539A2800B02E86 /* MarkedBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedBlock.h; sourceTree = "<group>"; };
-		142D6F0A13539A2F00B02E86 /* MarkedSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedSpace.cpp; sourceTree = "<group>"; };
-		142D6F0B13539A2F00B02E86 /* MarkedSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedSpace.h; sourceTree = "<group>"; };
 		142D6F0E13539A4100B02E86 /* MarkStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkStack.cpp; sourceTree = "<group>"; };
 		142D6F0F13539A4100B02E86 /* MarkStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStack.h; sourceTree = "<group>"; };
 		142E312B134FF0A600AFADB5 /* Handle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Handle.h; sourceTree = "<group>"; };
@@ -813,6 +811,8 @@
 		14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSValueRef.cpp; sourceTree = "<group>"; };
 		14BD5A2D0A3E91F600BAF59C /* testapi.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testapi.c; path = API/tests/testapi.c; sourceTree = "<group>"; };
 		14BFCE6810CDB1FC00364CCE /* WeakGCMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMap.h; sourceTree = "<group>"; };
+		14D2F3D8139F4BE200491031 /* NewSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewSpace.cpp; sourceTree = "<group>"; };
+		14D2F3D9139F4BE200491031 /* NewSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewSpace.h; sourceTree = "<group>"; };
 		14D792640DAA03FB001A9F05 /* RegisterFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterFile.h; sourceTree = "<group>"; };
 		14D857740A4696C80032146C /* testapi.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; name = testapi.js; path = API/tests/testapi.js; sourceTree = "<group>"; };
 		14DA818E0D99FD2000B0A4FB /* JSActivation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSActivation.h; sourceTree = "<group>"; };
@@ -1499,10 +1499,10 @@
 				14B7234012D7D0DA003BD5ED /* MachineStackMarker.h */,
 				142D6F0613539A2800B02E86 /* MarkedBlock.cpp */,
 				142D6F0713539A2800B02E86 /* MarkedBlock.h */,
-				142D6F0A13539A2F00B02E86 /* MarkedSpace.cpp */,
-				142D6F0B13539A2F00B02E86 /* MarkedSpace.h */,
 				142D6F0E13539A4100B02E86 /* MarkStack.cpp */,
 				142D6F0F13539A4100B02E86 /* MarkStack.h */,
+				14D2F3D8139F4BE200491031 /* NewSpace.cpp */,
+				14D2F3D9139F4BE200491031 /* NewSpace.h */,
 				142E3132134FF0A600AFADB5 /* Strong.h */,
 				142E3133134FF0A600AFADB5 /* Weak.h */,
 			);
@@ -2536,7 +2536,6 @@
 				14FB986E135225410085A5DB /* Heap.h in Headers */,
 				865A30F1135007E100CDB49E /* JSValueInlineMethods.h in Headers */,
 				142D6F0913539A2800B02E86 /* MarkedBlock.h in Headers */,
-				142D6F0D13539A2F00B02E86 /* MarkedSpace.h in Headers */,
 				142D6F1213539A4100B02E86 /* MarkStack.h in Headers */,
 				A1D764521354448B00C5C7C0 /* Alignment.h in Headers */,
 				86AE64A9135E5E1C00963012 /* MacroAssemblerSH4.h in Headers */,
@@ -2551,6 +2550,7 @@
 				14F97447138C853E00DA1C67 /* HeapRootVisitor.h in Headers */,
 				86BB09C1138E381B0056702F /* DFGRepatch.h in Headers */,
 				A72FFD64139985A800E5365A /* KeywordLookup.h in Headers */,
+				14D2F3DB139F4BE200491031 /* NewSpace.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2993,11 +2993,11 @@
 				86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
 				14FB986D135225410085A5DB /* Heap.cpp in Sources */,
 				142D6F0813539A2800B02E86 /* MarkedBlock.cpp in Sources */,
-				142D6F0C13539A2F00B02E86 /* MarkedSpace.cpp in Sources */,
 				142D6F1113539A4100B02E86 /* MarkStack.cpp in Sources */,
 				86AE64A8135E5E1C00963012 /* MacroAssemblerSH4.cpp in Sources */,
 				7934BB7C1361979400CB99A1 /* ParallelJobsGeneric.cpp in Sources */,
 				86BB09C0138E381B0056702F /* DFGRepatch.cpp in Sources */,
+				14D2F3DA139F4BE200491031 /* NewSpace.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/_javascript_Core/heap/Heap.h (88367 => 88368)


--- trunk/Source/_javascript_Core/heap/Heap.h	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2011-06-08 18:58:04 UTC (rev 88368)
@@ -25,7 +25,7 @@
 #include "HandleHeap.h"
 #include "HandleStack.h"
 #include "MarkStack.h"
-#include "MarkedSpace.h"
+#include "NewSpace.h"
 #include <wtf/Forward.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>

Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (88367 => 88368)


--- trunk/Source/_javascript_Core/heap/MarkedBlock.h	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h	2011-06-08 18:58:04 UTC (rev 88368)
@@ -210,4 +210,4 @@
     
 } // namespace JSC
 
-#endif // MarkedSpace_h
+#endif // MarkedBlock_h

Deleted: trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (88367 => 88368)


--- trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2011-06-08 18:58:04 UTC (rev 88368)
@@ -1,154 +0,0 @@
-/*
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- *  Copyright (C) 2007 Eric Seidel <e...@webkit.org>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#include "config.h"
-#include "MarkedSpace.h"
-
-#include "JSGlobalObject.h"
-#include "JSCell.h"
-#include "JSLock.h"
-#include "JSObject.h"
-#include "ScopeChain.h"
-
-namespace JSC {
-
-class Structure;
-
-MarkedSpace::MarkedSpace(Heap* heap)
-    : m_waterMark(0)
-    , m_highWaterMark(0)
-    , m_heap(heap)
-{
-    for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
-        sizeClassFor(cellSize).cellSize = cellSize;
-
-    for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
-        sizeClassFor(cellSize).cellSize = cellSize;
-}
-
-void MarkedSpace::destroy()
-{
-    /* Keep our precious zombies! */
-#if !ENABLE(JSC_ZOMBIES)
-    clearMarks();
-    shrink();
-    ASSERT(!size());
-#endif
-}
-
-MarkedBlock* MarkedSpace::allocateBlock(SizeClass& sizeClass)
-{
-    MarkedBlock* block = MarkedBlock::create(m_heap, sizeClass.cellSize);
-    sizeClass.blockList.append(block);
-    sizeClass.nextBlock = block;
-    m_blocks.add(block);
-
-    return block;
-}
-
-void MarkedSpace::freeBlocks(DoublyLinkedList<MarkedBlock>& blocks)
-{
-    MarkedBlock* next;
-    for (MarkedBlock* block = blocks.head(); block; block = next) {
-        next = block->next();
-
-        blocks.remove(block);
-        m_blocks.remove(block);
-        MarkedBlock::destroy(block);
-    }
-}
-
-void MarkedSpace::shrink()
-{
-    // We record a temporary list of empties to avoid modifying m_blocks while iterating it.
-    DoublyLinkedList<MarkedBlock> empties;
-
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it) {
-        MarkedBlock* block = *it;
-        if (block->isEmpty()) {
-            SizeClass& sizeClass = sizeClassFor(block->cellSize());
-            sizeClass.blockList.remove(block);
-            sizeClass.nextBlock = sizeClass.blockList.head();
-            empties.append(block);
-        }
-    }
-    
-    freeBlocks(empties);
-    ASSERT(empties.isEmpty());
-}
-
-void MarkedSpace::clearMarks()
-{
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        (*it)->clearMarks();
-}
-
-void MarkedSpace::sweep()
-{
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        (*it)->sweep();
-}
-
-size_t MarkedSpace::objectCount() const
-{
-    size_t result = 0;
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        result += (*it)->markCount();
-    return result;
-}
-
-size_t MarkedSpace::size() const
-{
-    size_t result = 0;
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        result += (*it)->size();
-    return result;
-}
-
-size_t MarkedSpace::capacity() const
-{
-    size_t result = 0;
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        result += (*it)->capacity();
-    return result;
-}
-
-void MarkedSpace::resetAllocator()
-{
-    m_waterMark = 0;
-
-    for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
-        sizeClassFor(cellSize).resetAllocator();
-
-    for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
-        sizeClassFor(cellSize).resetAllocator();
-
-    BlockIterator end = m_blocks.end();
-    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-        (*it)->resetAllocator();
-}
-
-} // namespace JSC

Deleted: trunk/Source/_javascript_Core/heap/MarkedSpace.h (88367 => 88368)


--- trunk/Source/_javascript_Core/heap/MarkedSpace.h	2011-06-08 18:40:26 UTC (rev 88367)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.h	2011-06-08 18:58:04 UTC (rev 88368)
@@ -1,174 +0,0 @@
-/*
- *  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 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
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifndef MarkedSpace_h
-#define MarkedSpace_h
-
-#include "MachineStackMarker.h"
-#include "MarkedBlock.h"
-#include "PageAllocationAligned.h"
-#include <wtf/Bitmap.h>
-#include <wtf/DoublyLinkedList.h>
-#include <wtf/FixedArray.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-#define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) < MarkedSpace::maxCellSize, class_fits_in_cell)
-
-namespace JSC {
-
-    class Heap;
-    class JSCell;
-    class LiveObjectIterator;
-    class MarkStack;
-    class WeakGCHandle;
-    typedef MarkStack SlotVisitor;
-
-    class MarkedSpace {
-        WTF_MAKE_NONCOPYABLE(MarkedSpace);
-    public:
-        static const size_t maxCellSize = 1024;
-
-        struct SizeClass {
-            SizeClass();
-            void resetAllocator();
-
-            MarkedBlock* nextBlock;
-            DoublyLinkedList<MarkedBlock> blockList;
-            size_t cellSize;
-        };
-
-        MarkedSpace(Heap*);
-        void destroy();
-
-        size_t highWaterMark();
-        void setHighWaterMark(size_t);
-
-        SizeClass& sizeClassFor(size_t);
-        void* allocate(SizeClass&);
-
-        void clearMarks();
-        void markRoots();
-        void resetAllocator();
-        void sweep();
-        void shrink();
-
-        size_t size() const;
-        size_t capacity() const;
-        size_t objectCount() const;
-
-        bool contains(const void*);
-
-        template<typename Functor> void forEach(Functor&);
-
-    private:
-        // [ 8, 16... 128 )
-        static const size_t preciseStep = MarkedBlock::atomSize;
-        static const size_t preciseCutoff = 128;
-        static const size_t preciseCount = preciseCutoff / preciseStep - 1;
-
-        // [ 128, 256... 1024 )
-        static const size_t impreciseStep = preciseCutoff;
-        static const size_t impreciseCutoff = maxCellSize;
-        static const size_t impreciseCount = impreciseCutoff / impreciseStep - 1;
-
-        typedef HashSet<MarkedBlock*>::iterator BlockIterator;
-
-        MarkedBlock* allocateBlock(SizeClass&);
-        void freeBlocks(DoublyLinkedList<MarkedBlock>&);
-
-        void clearMarks(MarkedBlock*);
-
-        SizeClass m_preciseSizeClasses[preciseCount];
-        SizeClass m_impreciseSizeClasses[impreciseCount];
-        HashSet<MarkedBlock*> m_blocks;
-        size_t m_waterMark;
-        size_t m_highWaterMark;
-        Heap* m_heap;
-    };
-
-    inline bool MarkedSpace::contains(const void* x)
-    {
-        if (!MarkedBlock::isAtomAligned(x))
-            return false;
-
-        MarkedBlock* block = MarkedBlock::blockFor(x);
-        if (!block || !m_blocks.contains(block))
-            return false;
-            
-        return true;
-    }
-
-    template <typename Functor> inline void MarkedSpace::forEach(Functor& functor)
-    {
-        BlockIterator end = m_blocks.end();
-        for (BlockIterator it = m_blocks.begin(); it != end; ++it)
-            (*it)->forEach(functor);
-    }
-
-    inline size_t MarkedSpace::highWaterMark()
-    {
-        return m_highWaterMark;
-    }
-
-    inline void MarkedSpace::setHighWaterMark(size_t highWaterMark)
-    {
-        m_highWaterMark = highWaterMark;
-    }
-
-    inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes)
-    {
-        ASSERT(bytes && bytes < maxCellSize);
-        if (bytes < preciseCutoff)
-            return m_preciseSizeClasses[(bytes - 1) / preciseStep];
-        return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
-    }
-
-    inline void* MarkedSpace::allocate(SizeClass& sizeClass)
-    {
-        for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) {
-            if (void* result = block->allocate())
-                return result;
-
-            m_waterMark += block->capacity();
-        }
-
-        if (m_waterMark < m_highWaterMark)
-            return allocateBlock(sizeClass)->allocate();
-
-        return 0;
-    }
-
-    inline MarkedSpace::SizeClass::SizeClass()
-        : nextBlock(0)
-        , cellSize(0)
-    {
-    }
-
-    inline void MarkedSpace::SizeClass::resetAllocator()
-    {
-        nextBlock = blockList.head();
-    }
-
-} // namespace JSC
-
-#endif // MarkedSpace_h

Copied: trunk/Source/_javascript_Core/heap/NewSpace.cpp (from rev 88329, trunk/Source/_javascript_Core/heap/MarkedSpace.cpp) (0 => 88368)


--- trunk/Source/_javascript_Core/heap/NewSpace.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/heap/NewSpace.cpp	2011-06-08 18:58:04 UTC (rev 88368)
@@ -0,0 +1,154 @@
+/*
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Eric Seidel <e...@webkit.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "config.h"
+#include "NewSpace.h"
+
+#include "JSGlobalObject.h"
+#include "JSCell.h"
+#include "JSLock.h"
+#include "JSObject.h"
+#include "ScopeChain.h"
+
+namespace JSC {
+
+class Structure;
+
+MarkedSpace::MarkedSpace(Heap* heap)
+    : m_waterMark(0)
+    , m_highWaterMark(0)
+    , m_heap(heap)
+{
+    for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
+        sizeClassFor(cellSize).cellSize = cellSize;
+
+    for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
+        sizeClassFor(cellSize).cellSize = cellSize;
+}
+
+void MarkedSpace::destroy()
+{
+    /* Keep our precious zombies! */
+#if !ENABLE(JSC_ZOMBIES)
+    clearMarks();
+    shrink();
+    ASSERT(!size());
+#endif
+}
+
+MarkedBlock* MarkedSpace::allocateBlock(SizeClass& sizeClass)
+{
+    MarkedBlock* block = MarkedBlock::create(m_heap, sizeClass.cellSize);
+    sizeClass.blockList.append(block);
+    sizeClass.nextBlock = block;
+    m_blocks.add(block);
+
+    return block;
+}
+
+void MarkedSpace::freeBlocks(DoublyLinkedList<MarkedBlock>& blocks)
+{
+    MarkedBlock* next;
+    for (MarkedBlock* block = blocks.head(); block; block = next) {
+        next = block->next();
+
+        blocks.remove(block);
+        m_blocks.remove(block);
+        MarkedBlock::destroy(block);
+    }
+}
+
+void MarkedSpace::shrink()
+{
+    // We record a temporary list of empties to avoid modifying m_blocks while iterating it.
+    DoublyLinkedList<MarkedBlock> empties;
+
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it) {
+        MarkedBlock* block = *it;
+        if (block->isEmpty()) {
+            SizeClass& sizeClass = sizeClassFor(block->cellSize());
+            sizeClass.blockList.remove(block);
+            sizeClass.nextBlock = sizeClass.blockList.head();
+            empties.append(block);
+        }
+    }
+    
+    freeBlocks(empties);
+    ASSERT(empties.isEmpty());
+}
+
+void MarkedSpace::clearMarks()
+{
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        (*it)->clearMarks();
+}
+
+void MarkedSpace::sweep()
+{
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        (*it)->sweep();
+}
+
+size_t MarkedSpace::objectCount() const
+{
+    size_t result = 0;
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        result += (*it)->markCount();
+    return result;
+}
+
+size_t MarkedSpace::size() const
+{
+    size_t result = 0;
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        result += (*it)->size();
+    return result;
+}
+
+size_t MarkedSpace::capacity() const
+{
+    size_t result = 0;
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        result += (*it)->capacity();
+    return result;
+}
+
+void MarkedSpace::resetAllocator()
+{
+    m_waterMark = 0;
+
+    for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
+        sizeClassFor(cellSize).resetAllocator();
+
+    for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
+        sizeClassFor(cellSize).resetAllocator();
+
+    BlockIterator end = m_blocks.end();
+    for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+        (*it)->resetAllocator();
+}
+
+} // namespace JSC

Copied: trunk/Source/_javascript_Core/heap/NewSpace.h (from rev 88329, trunk/Source/_javascript_Core/heap/MarkedSpace.h) (0 => 88368)


--- trunk/Source/_javascript_Core/heap/NewSpace.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/heap/NewSpace.h	2011-06-08 18:58:04 UTC (rev 88368)
@@ -0,0 +1,174 @@
+/*
+ *  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 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
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef NewSpace_h
+#define NewSpace_h
+
+#include "MachineStackMarker.h"
+#include "MarkedBlock.h"
+#include "PageAllocationAligned.h"
+#include <wtf/Bitmap.h>
+#include <wtf/DoublyLinkedList.h>
+#include <wtf/FixedArray.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+#define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) < MarkedSpace::maxCellSize, class_fits_in_cell)
+
+namespace JSC {
+
+    class Heap;
+    class JSCell;
+    class LiveObjectIterator;
+    class MarkStack;
+    class WeakGCHandle;
+    typedef MarkStack SlotVisitor;
+
+    class MarkedSpace {
+        WTF_MAKE_NONCOPYABLE(MarkedSpace);
+    public:
+        static const size_t maxCellSize = 1024;
+
+        struct SizeClass {
+            SizeClass();
+            void resetAllocator();
+
+            MarkedBlock* nextBlock;
+            DoublyLinkedList<MarkedBlock> blockList;
+            size_t cellSize;
+        };
+
+        MarkedSpace(Heap*);
+        void destroy();
+
+        size_t highWaterMark();
+        void setHighWaterMark(size_t);
+
+        SizeClass& sizeClassFor(size_t);
+        void* allocate(SizeClass&);
+
+        void clearMarks();
+        void markRoots();
+        void resetAllocator();
+        void sweep();
+        void shrink();
+
+        size_t size() const;
+        size_t capacity() const;
+        size_t objectCount() const;
+
+        bool contains(const void*);
+
+        template<typename Functor> void forEach(Functor&);
+
+    private:
+        // [ 8, 16... 128 )
+        static const size_t preciseStep = MarkedBlock::atomSize;
+        static const size_t preciseCutoff = 128;
+        static const size_t preciseCount = preciseCutoff / preciseStep - 1;
+
+        // [ 128, 256... 1024 )
+        static const size_t impreciseStep = preciseCutoff;
+        static const size_t impreciseCutoff = maxCellSize;
+        static const size_t impreciseCount = impreciseCutoff / impreciseStep - 1;
+
+        typedef HashSet<MarkedBlock*>::iterator BlockIterator;
+
+        MarkedBlock* allocateBlock(SizeClass&);
+        void freeBlocks(DoublyLinkedList<MarkedBlock>&);
+
+        void clearMarks(MarkedBlock*);
+
+        SizeClass m_preciseSizeClasses[preciseCount];
+        SizeClass m_impreciseSizeClasses[impreciseCount];
+        HashSet<MarkedBlock*> m_blocks;
+        size_t m_waterMark;
+        size_t m_highWaterMark;
+        Heap* m_heap;
+    };
+
+    inline bool MarkedSpace::contains(const void* x)
+    {
+        if (!MarkedBlock::isAtomAligned(x))
+            return false;
+
+        MarkedBlock* block = MarkedBlock::blockFor(x);
+        if (!block || !m_blocks.contains(block))
+            return false;
+            
+        return true;
+    }
+
+    template <typename Functor> inline void MarkedSpace::forEach(Functor& functor)
+    {
+        BlockIterator end = m_blocks.end();
+        for (BlockIterator it = m_blocks.begin(); it != end; ++it)
+            (*it)->forEach(functor);
+    }
+
+    inline size_t MarkedSpace::highWaterMark()
+    {
+        return m_highWaterMark;
+    }
+
+    inline void MarkedSpace::setHighWaterMark(size_t highWaterMark)
+    {
+        m_highWaterMark = highWaterMark;
+    }
+
+    inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes)
+    {
+        ASSERT(bytes && bytes < maxCellSize);
+        if (bytes < preciseCutoff)
+            return m_preciseSizeClasses[(bytes - 1) / preciseStep];
+        return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
+    }
+
+    inline void* MarkedSpace::allocate(SizeClass& sizeClass)
+    {
+        for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) {
+            if (void* result = block->allocate())
+                return result;
+
+            m_waterMark += block->capacity();
+        }
+
+        if (m_waterMark < m_highWaterMark)
+            return allocateBlock(sizeClass)->allocate();
+
+        return 0;
+    }
+
+    inline MarkedSpace::SizeClass::SizeClass()
+        : nextBlock(0)
+        , cellSize(0)
+    {
+    }
+
+    inline void MarkedSpace::SizeClass::resetAllocator()
+    {
+        nextBlock = blockList.head();
+    }
+
+} // namespace JSC
+
+#endif // NewSpace_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to