Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (95452 => 95453)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2011-09-19 19:14:53 UTC (rev 95453)
@@ -50,7 +50,7 @@
heap/HandleStack.cpp
heap/MachineStackMarker.cpp
heap/MarkedBlock.cpp
- heap/NewSpace.cpp
+ heap/MarkedSpace.cpp
heap/ConservativeRoots.cpp
heap/MarkStack.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (95452 => 95453)
--- trunk/Source/_javascript_Core/ChangeLog 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-09-19 19:14:53 UTC (rev 95453)
@@ -1,5 +1,40 @@
2011-09-19 Oliver Hunt <[email protected]>
+ Rename NewSpace.{h,cpp} to MarkedSpace.{h,cpp}
+ https://bugs.webkit.org/show_bug.cgi?id=68376
+
+ Reviewed by Gavin Barraclough.
+
+ Renamed the the MarkedSpace files to match new name, and
+ updated the relevant references.
+
+ * 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/MarkedSpace.cpp: Renamed from Source/_javascript_Core/heap/NewSpace.cpp.
+ (JSC::MarkedSpace::MarkedSpace):
+ (JSC::MarkedSpace::addBlock):
+ (JSC::MarkedSpace::removeBlock):
+ (JSC::MarkedSpace::resetAllocator):
+ (JSC::MarkedSpace::canonicalizeBlocks):
+ * heap/MarkedSpace.h: Renamed from Source/_javascript_Core/heap/NewSpace.h.
+ (JSC::MarkedSpace::waterMark):
+ (JSC::MarkedSpace::highWaterMark):
+ (JSC::MarkedSpace::setHighWaterMark):
+ (JSC::MarkedSpace::sizeClassFor):
+ (JSC::MarkedSpace::allocate):
+ (JSC::MarkedSpace::forEachBlock):
+ (JSC::MarkedSpace::SizeClass::SizeClass):
+ (JSC::MarkedSpace::SizeClass::resetAllocator):
+ (JSC::MarkedSpace::SizeClass::canonicalizeBlock):
+ * runtime/JSCell.h:
+
+2011-09-19 Oliver Hunt <[email protected]>
+
Rename NewSpace to MarkedSpace
https://bugs.webkit.org/show_bug.cgi?id=68375
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (95452 => 95453)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2011-09-19 19:14:53 UTC (rev 95453)
@@ -155,8 +155,8 @@
Source/_javascript_Core/heap/MarkedBlock.h \
Source/_javascript_Core/heap/MarkedBlockSet.h \
Source/_javascript_Core/heap/TinyBloomFilter.h \
- Source/_javascript_Core/heap/NewSpace.cpp \
- Source/_javascript_Core/heap/NewSpace.h \
+ Source/_javascript_Core/heap/MarkedSpace.cpp \
+ Source/_javascript_Core/heap/MarkedSpace.h \
Source/_javascript_Core/heap/Strong.h \
Source/_javascript_Core/heap/VTableSpectrum.cpp \
Source/_javascript_Core/heap/VTableSpectrum.h \
Modified: trunk/Source/_javascript_Core/_javascript_Core.gypi (95452 => 95453)
--- trunk/Source/_javascript_Core/_javascript_Core.gypi 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/_javascript_Core.gypi 2011-09-19 19:14:53 UTC (rev 95453)
@@ -337,8 +337,8 @@
'heap/MarkedBlock.h',
'heap/MarkedBlockSet.h',
'heap/TinyBloomFilter.h',
- 'heap/NewSpace.cpp',
- 'heap/NewSpace.h',
+ 'heap/MarkedSpace.cpp',
+ 'heap/MarkedSpace.h',
'debugger/Debugger.cpp',
'debugger/DebuggerActivation.cpp',
'debugger/DebuggerCallFrame.cpp',
Modified: trunk/Source/_javascript_Core/_javascript_Core.pro (95452 => 95453)
--- trunk/Source/_javascript_Core/_javascript_Core.pro 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/_javascript_Core.pro 2011-09-19 19:14:53 UTC (rev 95453)
@@ -79,7 +79,7 @@
heap/MachineStackMarker.cpp \
heap/MarkStack.cpp \
heap/MarkedBlock.cpp \
- heap/NewSpace.cpp \
+ heap/MarkedSpace.cpp \
heap/VTableSpectrum.cpp \
heap/WriteBarrierSupport.cpp \
debugger/DebuggerActivation.cpp \
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj (95452 => 95453)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj 2011-09-19 19:14:53 UTC (rev 95453)
@@ -1914,11 +1914,11 @@
>
</File>
<File
- RelativePath="..\..\heap\NewSpace.cpp"
+ RelativePath="..\..\heap\MarkedSpace.cpp"
>
</File>
<File
- RelativePath="..\..\heap\NewSpace.h"
+ RelativePath="..\..\heap\MarkedSpace.h"
>
</File>
<File
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (95452 => 95453)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2011-09-19 19:14:53 UTC (rev 95453)
@@ -214,8 +214,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, ); }; };
+ 14D2F3DA139F4BE200491031 /* MarkedSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D2F3D8139F4BE200491031 /* MarkedSpace.cpp */; };
+ 14D2F3DB139F4BE200491031 /* MarkedSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D2F3D9139F4BE200491031 /* MarkedSpace.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 */; };
@@ -907,8 +907,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>"; };
+ 14D2F3D8139F4BE200491031 /* MarkedSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedSpace.cpp; sourceTree = "<group>"; };
+ 14D2F3D9139F4BE200491031 /* MarkedSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedSpace.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>"; };
@@ -1642,8 +1642,8 @@
141448CA13A176EC00F5BA1A /* MarkedBlockSet.h */,
142D6F0E13539A4100B02E86 /* MarkStack.cpp */,
142D6F0F13539A4100B02E86 /* MarkStack.h */,
- 14D2F3D8139F4BE200491031 /* NewSpace.cpp */,
- 14D2F3D9139F4BE200491031 /* NewSpace.h */,
+ 14D2F3D8139F4BE200491031 /* MarkedSpace.cpp */,
+ 14D2F3D9139F4BE200491031 /* MarkedSpace.h */,
14BA78F013AAB88F005B7C2C /* SlotVisitor.h */,
142E3132134FF0A600AFADB5 /* Strong.h */,
141448CC13A1783700F5BA1A /* TinyBloomFilter.h */,
@@ -2781,7 +2781,7 @@
14F97447138C853E00DA1C67 /* HeapRootVisitor.h in Headers */,
86BB09C1138E381B0056702F /* DFGRepatch.h in Headers */,
A72FFD64139985A800E5365A /* KeywordLookup.h in Headers */,
- 14D2F3DB139F4BE200491031 /* NewSpace.h in Headers */,
+ 14D2F3DB139F4BE200491031 /* MarkedSpace.h in Headers */,
141448CB13A176EC00F5BA1A /* MarkedBlockSet.h in Headers */,
141448CD13A1783700F5BA1A /* TinyBloomFilter.h in Headers */,
14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
@@ -3287,7 +3287,7 @@
86AE64A8135E5E1C00963012 /* MacroAssemblerSH4.cpp in Sources */,
7934BB7C1361979400CB99A1 /* ParallelJobsGeneric.cpp in Sources */,
86BB09C0138E381B0056702F /* DFGRepatch.cpp in Sources */,
- 14D2F3DA139F4BE200491031 /* NewSpace.cpp in Sources */,
+ 14D2F3DA139F4BE200491031 /* MarkedSpace.cpp in Sources */,
14BA7A9713AADFF8005B7C2C /* Heap.cpp in Sources */,
C22C52F113FAF6EF00B7DC0D /* bignum-dtoa.cc in Sources */,
C22C52F313FAF6EF00B7DC0D /* bignum.cc in Sources */,
Modified: trunk/Source/_javascript_Core/heap/Heap.h (95452 => 95453)
--- trunk/Source/_javascript_Core/heap/Heap.h 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2011-09-19 19:14:53 UTC (rev 95453)
@@ -26,7 +26,7 @@
#include "HandleStack.h"
#include "MarkedBlock.h"
#include "MarkedBlockSet.h"
-#include "NewSpace.h"
+#include "MarkedSpace.h"
#include "SlotVisitor.h"
#include "WriteBarrierSupport.h"
#include <wtf/Forward.h>
Copied: trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (from rev 95452, trunk/Source/_javascript_Core/heap/NewSpace.cpp) (0 => 95453)
--- trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (rev 0)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.cpp 2011-09-19 19:14:53 UTC (rev 95453)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Eric Seidel <[email protected]>
+ *
+ * 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 "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::addBlock(SizeClass& sizeClass, MarkedBlock* block)
+{
+ block->setInNewSpace(true);
+ sizeClass.nextBlock = block;
+ sizeClass.blockList.append(block);
+ ASSERT(!sizeClass.currentBlock);
+ ASSERT(!sizeClass.firstFreeCell);
+ sizeClass.currentBlock = block;
+ sizeClass.firstFreeCell = block->blessNewBlockForFastPath();
+}
+
+void MarkedSpace::removeBlock(MarkedBlock* block)
+{
+ block->setInNewSpace(false);
+ SizeClass& sizeClass = sizeClassFor(block->cellSize());
+ if (sizeClass.nextBlock == block)
+ sizeClass.nextBlock = block->next();
+ sizeClass.blockList.remove(block);
+}
+
+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();
+}
+
+void MarkedSpace::canonicalizeBlocks()
+{
+ for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
+ sizeClassFor(cellSize).canonicalizeBlock();
+
+ for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
+ sizeClassFor(cellSize).canonicalizeBlock();
+}
+
+} // namespace JSC
Added: trunk/Source/_javascript_Core/heap/MarkedSpace.h (0 => 95453)
--- trunk/Source/_javascript_Core/heap/MarkedSpace.h (rev 0)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.h 2011-09-19 19:14:53 UTC (rev 95453)
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 1999-2000 Harri Porten ([email protected])
+ * Copyright (C) 2001 Peter Kelly ([email protected])
+ * 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 WeakGCHandle;
+class SlotVisitor;
+
+class MarkedSpace {
+ WTF_MAKE_NONCOPYABLE(MarkedSpace);
+public:
+ static const size_t maxCellSize = 1024;
+
+ struct SizeClass {
+ SizeClass();
+ void resetAllocator();
+ void canonicalizeBlock();
+
+ MarkedBlock::FreeCell* firstFreeCell;
+ MarkedBlock* currentBlock;
+ MarkedBlock* nextBlock;
+ DoublyLinkedList<MarkedBlock> blockList;
+ size_t cellSize;
+ };
+
+ MarkedSpace(Heap*);
+
+ SizeClass& sizeClassFor(size_t);
+ void* allocate(SizeClass&);
+
+ void resetAllocator();
+
+ void addBlock(SizeClass&, MarkedBlock*);
+ void removeBlock(MarkedBlock*);
+
+ void canonicalizeBlocks();
+
+ size_t waterMark();
+ size_t highWaterMark();
+ void setHighWaterMark(size_t);
+
+ template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&); // Safe to remove the current item while iterating.
+ template<typename Functor> typename Functor::ReturnType forEachBlock();
+
+private:
+ // [ 8, 16... 128 )
+ static const size_t preciseStep = MarkedBlock::atomSize;
+ static const size_t preciseCutoff = 128;
+ static const size_t maximumPreciseAllocationSize = preciseCutoff - preciseStep;
+ 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;
+
+ SizeClass m_preciseSizeClasses[preciseCount];
+ SizeClass m_impreciseSizeClasses[impreciseCount];
+ size_t m_waterMark;
+ size_t m_highWaterMark;
+ Heap* m_heap;
+};
+
+inline size_t MarkedSpace::waterMark()
+{
+ return m_waterMark;
+}
+
+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 <= maximumPreciseAllocationSize)
+ return m_preciseSizeClasses[(bytes - 1) / preciseStep];
+ return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
+}
+
+inline void* MarkedSpace::allocate(SizeClass& sizeClass)
+{
+ MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;
+ if (!firstFreeCell) {
+ // There are two possibilities for why we got here:
+ // 1) We've exhausted the allocation cache for currentBlock, in which case
+ // currentBlock == nextBlock, and we know that there is no reason to
+ // repeat a lazy sweep of nextBlock because we won't find anything.
+ // 2) Allocation caches have been cleared, in which case nextBlock may
+ // have (and most likely does have) free cells, so we almost certainly
+ // should do a lazySweep for nextBlock. This also implies that
+ // currentBlock == 0.
+
+ if (sizeClass.currentBlock) {
+ ASSERT(sizeClass.currentBlock == sizeClass.nextBlock);
+ m_waterMark += sizeClass.nextBlock->capacity();
+ sizeClass.nextBlock = sizeClass.nextBlock->next();
+ sizeClass.currentBlock = 0;
+ }
+
+ for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) {
+ firstFreeCell = block->lazySweep();
+ if (firstFreeCell) {
+ sizeClass.firstFreeCell = firstFreeCell;
+ sizeClass.currentBlock = block;
+ break;
+ }
+
+ m_waterMark += block->capacity();
+ }
+
+ if (!firstFreeCell)
+ return 0;
+ }
+
+ ASSERT(firstFreeCell);
+
+ sizeClass.firstFreeCell = firstFreeCell->next;
+ return firstFreeCell;
+}
+
+template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock(Functor& functor)
+{
+ for (size_t i = 0; i < preciseCount; ++i) {
+ SizeClass& sizeClass = m_preciseSizeClasses[i];
+ MarkedBlock* next;
+ for (MarkedBlock* block = sizeClass.blockList.head(); block; block = next) {
+ next = block->next();
+ functor(block);
+ }
+ }
+
+ for (size_t i = 0; i < impreciseCount; ++i) {
+ SizeClass& sizeClass = m_impreciseSizeClasses[i];
+ MarkedBlock* next;
+ for (MarkedBlock* block = sizeClass.blockList.head(); block; block = next) {
+ next = block->next();
+ functor(block);
+ }
+ }
+
+ return functor.returnValue();
+}
+
+template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock()
+{
+ Functor functor;
+ return forEachBlock(functor);
+}
+
+inline MarkedSpace::SizeClass::SizeClass()
+ : firstFreeCell(0)
+ , currentBlock(0)
+ , nextBlock(0)
+ , cellSize(0)
+{
+}
+
+inline void MarkedSpace::SizeClass::resetAllocator()
+{
+ nextBlock = blockList.head();
+}
+
+inline void MarkedSpace::SizeClass::canonicalizeBlock()
+{
+ if (currentBlock) {
+ currentBlock->canonicalizeBlock(firstFreeCell);
+ firstFreeCell = 0;
+ }
+
+ ASSERT(!firstFreeCell);
+
+ currentBlock = 0;
+ firstFreeCell = 0;
+}
+
+} // namespace JSC
+
+#endif // MarkedSpace_h
Deleted: trunk/Source/_javascript_Core/heap/NewSpace.cpp (95452 => 95453)
--- trunk/Source/_javascript_Core/heap/NewSpace.cpp 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/heap/NewSpace.cpp 2011-09-19 19:14:53 UTC (rev 95453)
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Eric Seidel <[email protected]>
- *
- * 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::addBlock(SizeClass& sizeClass, MarkedBlock* block)
-{
- block->setInNewSpace(true);
- sizeClass.nextBlock = block;
- sizeClass.blockList.append(block);
- ASSERT(!sizeClass.currentBlock);
- ASSERT(!sizeClass.firstFreeCell);
- sizeClass.currentBlock = block;
- sizeClass.firstFreeCell = block->blessNewBlockForFastPath();
-}
-
-void MarkedSpace::removeBlock(MarkedBlock* block)
-{
- block->setInNewSpace(false);
- SizeClass& sizeClass = sizeClassFor(block->cellSize());
- if (sizeClass.nextBlock == block)
- sizeClass.nextBlock = block->next();
- sizeClass.blockList.remove(block);
-}
-
-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();
-}
-
-void MarkedSpace::canonicalizeBlocks()
-{
- for (size_t cellSize = preciseStep; cellSize < preciseCutoff; cellSize += preciseStep)
- sizeClassFor(cellSize).canonicalizeBlock();
-
- for (size_t cellSize = impreciseStep; cellSize < impreciseCutoff; cellSize += impreciseStep)
- sizeClassFor(cellSize).canonicalizeBlock();
-}
-
-} // namespace JSC
Deleted: trunk/Source/_javascript_Core/heap/NewSpace.h (95452 => 95453)
--- trunk/Source/_javascript_Core/heap/NewSpace.h 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/heap/NewSpace.h 2011-09-19 19:14:53 UTC (rev 95453)
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 1999-2000 Harri Porten ([email protected])
- * Copyright (C) 2001 Peter Kelly ([email protected])
- * 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 WeakGCHandle;
- class SlotVisitor;
-
- class MarkedSpace {
- WTF_MAKE_NONCOPYABLE(MarkedSpace);
- public:
- static const size_t maxCellSize = 1024;
-
- struct SizeClass {
- SizeClass();
- void resetAllocator();
- void canonicalizeBlock();
-
- MarkedBlock::FreeCell* firstFreeCell;
- MarkedBlock* currentBlock;
- MarkedBlock* nextBlock;
- DoublyLinkedList<MarkedBlock> blockList;
- size_t cellSize;
- };
-
- MarkedSpace(Heap*);
-
- SizeClass& sizeClassFor(size_t);
- void* allocate(SizeClass&);
-
- void resetAllocator();
-
- void addBlock(SizeClass&, MarkedBlock*);
- void removeBlock(MarkedBlock*);
-
- void canonicalizeBlocks();
-
- size_t waterMark();
- size_t highWaterMark();
- void setHighWaterMark(size_t);
-
- template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&); // Safe to remove the current item while iterating.
- template<typename Functor> typename Functor::ReturnType forEachBlock();
-
- private:
- // [ 8, 16... 128 )
- static const size_t preciseStep = MarkedBlock::atomSize;
- static const size_t preciseCutoff = 128;
- static const size_t maximumPreciseAllocationSize = preciseCutoff - preciseStep;
- 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;
-
- SizeClass m_preciseSizeClasses[preciseCount];
- SizeClass m_impreciseSizeClasses[impreciseCount];
- size_t m_waterMark;
- size_t m_highWaterMark;
- Heap* m_heap;
- };
-
- inline size_t MarkedSpace::waterMark()
- {
- return m_waterMark;
- }
-
- 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 <= maximumPreciseAllocationSize)
- return m_preciseSizeClasses[(bytes - 1) / preciseStep];
- return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
- }
-
- inline void* MarkedSpace::allocate(SizeClass& sizeClass)
- {
- MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;
- if (!firstFreeCell) {
- // There are two possibilities for why we got here:
- // 1) We've exhausted the allocation cache for currentBlock, in which case
- // currentBlock == nextBlock, and we know that there is no reason to
- // repeat a lazy sweep of nextBlock because we won't find anything.
- // 2) Allocation caches have been cleared, in which case nextBlock may
- // have (and most likely does have) free cells, so we almost certainly
- // should do a lazySweep for nextBlock. This also implies that
- // currentBlock == 0.
-
- if (sizeClass.currentBlock) {
- ASSERT(sizeClass.currentBlock == sizeClass.nextBlock);
- m_waterMark += sizeClass.nextBlock->capacity();
- sizeClass.nextBlock = sizeClass.nextBlock->next();
- sizeClass.currentBlock = 0;
- }
-
- for (MarkedBlock*& block = sizeClass.nextBlock ; block; block = block->next()) {
- firstFreeCell = block->lazySweep();
- if (firstFreeCell) {
- sizeClass.firstFreeCell = firstFreeCell;
- sizeClass.currentBlock = block;
- break;
- }
-
- m_waterMark += block->capacity();
- }
-
- if (!firstFreeCell)
- return 0;
- }
-
- ASSERT(firstFreeCell);
-
- sizeClass.firstFreeCell = firstFreeCell->next;
- return firstFreeCell;
- }
-
- template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock(Functor& functor)
- {
- for (size_t i = 0; i < preciseCount; ++i) {
- SizeClass& sizeClass = m_preciseSizeClasses[i];
- MarkedBlock* next;
- for (MarkedBlock* block = sizeClass.blockList.head(); block; block = next) {
- next = block->next();
- functor(block);
- }
- }
-
- for (size_t i = 0; i < impreciseCount; ++i) {
- SizeClass& sizeClass = m_impreciseSizeClasses[i];
- MarkedBlock* next;
- for (MarkedBlock* block = sizeClass.blockList.head(); block; block = next) {
- next = block->next();
- functor(block);
- }
- }
-
- return functor.returnValue();
- }
-
- template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock()
- {
- Functor functor;
- return forEachBlock(functor);
- }
-
- inline MarkedSpace::SizeClass::SizeClass()
- : firstFreeCell(0)
- , currentBlock(0)
- , nextBlock(0)
- , cellSize(0)
- {
- }
-
- inline void MarkedSpace::SizeClass::resetAllocator()
- {
- nextBlock = blockList.head();
- }
-
- inline void MarkedSpace::SizeClass::canonicalizeBlock()
- {
- if (currentBlock) {
- currentBlock->canonicalizeBlock(firstFreeCell);
- firstFreeCell = 0;
- }
-
- ASSERT(!firstFreeCell);
-
- currentBlock = 0;
- firstFreeCell = 0;
- }
-
-} // namespace JSC
-
-#endif // NewSpace_h
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (95452 => 95453)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2011-09-19 19:13:04 UTC (rev 95452)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2011-09-19 19:14:53 UTC (rev 95453)
@@ -65,7 +65,6 @@
friend class JSValue;
friend class JSAPIValueWrapper;
friend class JSGlobalData;
- friend class NewSpace;
friend class MarkedBlock;
friend class ScopeChainNode;
friend class Structure;