2011-01-13 Geoffrey Garen <ggaren@apple.com>
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Jan 2011 01:43:29 +0000 (01:43 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Jan 2011 01:43:29 +0000 (01:43 +0000)
        Reviewed by Oliver Hunt.

        Split out a MarkedSpace strategy object from Heap.
        https://bugs.webkit.org/show_bug.cgi?id=52421

        * Misc/WebCoreStatistics.mm:
        (+[WebCoreStatistics memoryStatistics]): Updated for class move.
2011-01-13  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Oliver Hunt.

        Split out a MarkedSpace strategy object from Heap.
        https://bugs.webkit.org/show_bug.cgi?id=52421

        SunSpider reports no change.

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * JavaScriptCore.gypi:
        * JavaScriptCore.pro:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj: Updated our 7 build systems. Which is cool.

        * runtime/Heap.cpp:
        (JSC::Heap::Heap):
        (JSC::Heap::destroy):
        (JSC::Heap::recordExtraCost):
        (JSC::Heap::allocate):
        (JSC::Heap::markConservatively):
        (JSC::Heap::markRoots):
        (JSC::Heap::objectCount):
        (JSC::Heap::statistics):
        (JSC::Heap::size):
        (JSC::Heap::isBusy):
        (JSC::Heap::collectAllGarbage):
        (JSC::Heap::primaryHeapBegin):
        (JSC::Heap::primaryHeapEnd):
        * runtime/Heap.h:
        (JSC::Heap::globalData):
        (JSC::Heap::markedSpace):
        (JSC::Heap::isCellMarked):
        (JSC::Heap::checkMarkCell):
        (JSC::Heap::markCell): Moved all code pertaining to managing chunks of
        collector memory out of this class. Heap now just delegates to MarkedSpace.

        * runtime/JSCell.h:
        (JSC::JSCell::Heap::heap): Updated for MarkedSpace delegation.

        * runtime/JSValue.h: Moved the ValueStringPair typedef to help with #includes.

        * runtime/MarkedSpace.cpp: Copied from runtime/Heap.cpp.
        (JSC::MarkedSpace::MarkedSpace):
        (JSC::MarkedSpace::destroy):
        (JSC::MarkedSpace::allocateBlock):
        (JSC::MarkedSpace::freeBlock):
        (JSC::MarkedSpace::allocate):
        (JSC::MarkedSpace::resizeBlocks):
        (JSC::MarkedSpace::growBlocks):
        (JSC::MarkedSpace::shrinkBlocks):
        (JSC::MarkedSpace::markConservatively):
        (JSC::MarkedSpace::clearMarkBits):
        (JSC::MarkedSpace::markedCells):
        (JSC::MarkedSpace::sweep):
        (JSC::MarkedSpace::objectCount):
        (JSC::MarkedSpace::addToStatistics):
        (JSC::MarkedSpace::statistics):
        (JSC::MarkedSpace::size):
        (JSC::MarkedSpace::reset):
        (JSC::MarkedSpace::primaryHeapBegin):
        (JSC::MarkedSpace::primaryHeapEnd):
        * runtime/MarkedSpace.h: Copied from runtime/Heap.h.
        (JSC::MarkedSpace::globalData):
        (JSC::MarkedSpace::didShrink):
        (JSC::MarkedSpace::cellBlock):
        (JSC::MarkedSpace::cellOffset):
        (JSC::MarkedSpace::isCellMarked):
        (JSC::MarkedSpace::checkMarkCell):
        (JSC::MarkedSpace::markCell): Moved all code pertaining to managing chunks of
        collector memory into this class.

        * runtime/MemoryStatistics.cpp:
        (JSC::heapStatistics):
        * runtime/MemoryStatistics.h: Updated for MarkedSpace delegation.
2011-01-13  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Oliver Hunt.

        Split out a MarkedSpace strategy object from Heap.
        https://bugs.webkit.org/show_bug.cgi?id=52421

        * Shared/mac/WebMemorySampler.mac.mm:
        (WebKit::WebMemorySampler::sampleWebKit): Updated for class move.

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

20 files changed:
Source/JavaScriptCore/Android.mk
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.am
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/JavaScriptCore.pro
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/runtime/Heap.cpp
Source/JavaScriptCore/runtime/Heap.h
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSValue.h
Source/JavaScriptCore/runtime/MarkedSpace.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/MarkedSpace.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/MemoryStatistics.cpp
Source/JavaScriptCore/runtime/MemoryStatistics.h
WebKit/mac/ChangeLog
WebKit/mac/Misc/WebCoreStatistics.mm
WebKit2/ChangeLog
WebKit2/Shared/mac/WebMemorySampler.mac.mm

index 5836c59..3c01aa0 100644 (file)
@@ -80,6 +80,7 @@ LOCAL_SRC_FILES := \
        runtime/BooleanObject.cpp \
        runtime/BooleanPrototype.cpp \
        runtime/CallData.cpp \
+       runtime/MarkedSpace.cpp \
        runtime/Heap.cpp \
        runtime/CommonIdentifiers.cpp \
        runtime/Completion.cpp \
index 3203b8d..29de8a7 100644 (file)
@@ -87,6 +87,7 @@ SET(JavaScriptCore_SOURCES
     runtime/BooleanObject.cpp
     runtime/BooleanPrototype.cpp
     runtime/CallData.cpp
+    runtime/MarkedSpace.cpp
     runtime/Heap.cpp
     runtime/CommonIdentifiers.cpp
     runtime/Completion.cpp
index a3043fb..1e7b7f9 100644 (file)
@@ -1,3 +1,81 @@
+2011-01-13  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Split out a MarkedSpace strategy object from Heap.
+        https://bugs.webkit.org/show_bug.cgi?id=52421
+        
+        SunSpider reports no change.
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * JavaScriptCore.gypi:
+        * JavaScriptCore.pro:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj: Updated our 7 build systems. Which is cool.
+
+        * runtime/Heap.cpp:
+        (JSC::Heap::Heap):
+        (JSC::Heap::destroy):
+        (JSC::Heap::recordExtraCost):
+        (JSC::Heap::allocate):
+        (JSC::Heap::markConservatively):
+        (JSC::Heap::markRoots):
+        (JSC::Heap::objectCount):
+        (JSC::Heap::statistics):
+        (JSC::Heap::size):
+        (JSC::Heap::isBusy):
+        (JSC::Heap::collectAllGarbage):
+        (JSC::Heap::primaryHeapBegin):
+        (JSC::Heap::primaryHeapEnd):
+        * runtime/Heap.h:
+        (JSC::Heap::globalData):
+        (JSC::Heap::markedSpace):
+        (JSC::Heap::isCellMarked):
+        (JSC::Heap::checkMarkCell):
+        (JSC::Heap::markCell): Moved all code pertaining to managing chunks of
+        collector memory out of this class. Heap now just delegates to MarkedSpace.
+
+        * runtime/JSCell.h:
+        (JSC::JSCell::Heap::heap): Updated for MarkedSpace delegation.
+
+        * runtime/JSValue.h: Moved the ValueStringPair typedef to help with #includes.
+
+        * runtime/MarkedSpace.cpp: Copied from runtime/Heap.cpp.
+        (JSC::MarkedSpace::MarkedSpace):
+        (JSC::MarkedSpace::destroy):
+        (JSC::MarkedSpace::allocateBlock):
+        (JSC::MarkedSpace::freeBlock):
+        (JSC::MarkedSpace::allocate):
+        (JSC::MarkedSpace::resizeBlocks):
+        (JSC::MarkedSpace::growBlocks):
+        (JSC::MarkedSpace::shrinkBlocks):
+        (JSC::MarkedSpace::markConservatively):
+        (JSC::MarkedSpace::clearMarkBits):
+        (JSC::MarkedSpace::markedCells):
+        (JSC::MarkedSpace::sweep):
+        (JSC::MarkedSpace::objectCount):
+        (JSC::MarkedSpace::addToStatistics):
+        (JSC::MarkedSpace::statistics):
+        (JSC::MarkedSpace::size):
+        (JSC::MarkedSpace::reset):
+        (JSC::MarkedSpace::primaryHeapBegin):
+        (JSC::MarkedSpace::primaryHeapEnd):
+        * runtime/MarkedSpace.h: Copied from runtime/Heap.h.
+        (JSC::MarkedSpace::globalData):
+        (JSC::MarkedSpace::didShrink):
+        (JSC::MarkedSpace::cellBlock):
+        (JSC::MarkedSpace::cellOffset):
+        (JSC::MarkedSpace::isCellMarked):
+        (JSC::MarkedSpace::checkMarkCell):
+        (JSC::MarkedSpace::markCell): Moved all code pertaining to managing chunks of
+        collector memory into this class.
+
+        * runtime/MemoryStatistics.cpp:
+        (JSC::heapStatistics):
+        * runtime/MemoryStatistics.h: Updated for MarkedSpace delegation.
+
 2011-01-14  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Gavin Barraclough.
index 401ac6f..4c8d204 100644 (file)
@@ -239,6 +239,8 @@ javascriptcore_sources += \
        Source/JavaScriptCore/runtime/CallData.cpp \
        Source/JavaScriptCore/runtime/CallData.h \
        Source/JavaScriptCore/runtime/ClassInfo.h \
+       Source/JavaScriptCore/runtime/MarkedSpace.cpp \
+       Source/JavaScriptCore/runtime/MarkedSpace.h \
        Source/JavaScriptCore/runtime/Heap.cpp \
        Source/JavaScriptCore/runtime/Heap.h \
        Source/JavaScriptCore/runtime/CollectorHeapIterator.h \
index fa30116..a08b439 100644 (file)
             'runtime/CallData.cpp',
             'runtime/CallData.h',
             'runtime/ClassInfo.h',
+            'runtime/MarkedSpace.cpp',
+            'runtime/MarkedSpace.h',
             'runtime/Heap.cpp',
             'runtime/Heap.h',
             'runtime/CollectorHeapIterator.h',
index 76cc8a8..ca420d2 100644 (file)
@@ -127,6 +127,7 @@ SOURCES += \
     runtime/BooleanObject.cpp \
     runtime/BooleanPrototype.cpp \
     runtime/CallData.cpp \
+    runtime/MarkedSpace.cpp \
     runtime/Heap.cpp \
     runtime/CommonIdentifiers.cpp \
     runtime/Completion.cpp \
index c75e85a..1ddc251 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\..\runtime\MarkedSpace.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\runtime\MarkedSpace.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\runtime\CollectorHeapIntrospector.h"
                                >
                        </File>
index c867ffa..0f9b4ab 100644 (file)
                140566D1107EC267005DBC8D /* JSStaticScopeObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E42C190E3938830065A544 /* JSStaticScopeObject.cpp */; };
                140566D6107EC271005DBC8D /* JSFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A85E0255597D01FF60F7 /* JSFunction.cpp */; };
                140B7D1D0DC69AF7009C42B8 /* JSActivation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DA818F0D99FD2000B0A4FB /* JSActivation.cpp */; };
+               140CDC7C12DC09BF0013CFC5 /* MarkedSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 140CDC7612DBEA330013CFC5 /* MarkedSpace.cpp */; };
+               140CDE7012DE97A00013CFC5 /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 140CDE6C12DE977E0013CFC5 /* Heap.cpp */; };
+               140CDE7112DE97B10013CFC5 /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 140CDE6D12DE977E0013CFC5 /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               140CDF0C12DECE5C0013CFC5 /* MarkedSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 140CDC7712DBEA330013CFC5 /* MarkedSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
                140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 140D17D60E8AD4A9000CD17D /* JSBasePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                141211310A48794D00480255 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
                141211340A48795800480255 /* minidom.c in Sources */ = {isa = PBXBuildFile; fileRef = 141211020A48780900480255 /* minidom.c */; };
                14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F3488E0E95EF8A003648BC /* CollectorHeapIterator.h */; settings = {ATTRIBUTES = (); }; };
                14F8BA3E107EC886009892DC /* FastMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */; };
                14F8BA43107EC88C009892DC /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
-               14F8BA4F107EC899009892DC /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8520255597D01FF60F7 /* Heap.cpp */; };
                14FFF98C12BFFF7500795BB8 /* PageAllocationAligned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FFF98A12BFFF7500795BB8 /* PageAllocationAligned.cpp */; };
                14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FFF98B12BFFF7500795BB8 /* PageAllocationAligned.h */; settings = {ATTRIBUTES = (Private, ); }; };
                180B9B080F16D94F009BDBC5 /* CurrentTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 180B9AF00F16C569009BDBC5 /* CurrentTime.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3EC0E16F5CD00B34460 /* BooleanObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 704FD35305697E6D003DBED9 /* BooleanObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3ED0E16F5CD00B34460 /* CallData.h in Headers */ = {isa = PBXBuildFile; fileRef = 145C507F0D9DF63B0088F6B9 /* CallData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3F00E16F5CD00B34460 /* Collator.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A862AA0D7EBB7D001EC6AA /* Collator.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               BC18C3F10E16F5CD00B34460 /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = F692A8530255597D01FF60F7 /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* Completion.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC18C3F50E16F5CD00B34460 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = F68EBB8C0255D4C601FF60F7 /* config.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1400067612A6F7830064D123 /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; };
                1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPosix.cpp; sourceTree = "<group>"; };
                14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCPtr.h; sourceTree = "<group>"; };
+               140CDC7612DBEA330013CFC5 /* MarkedSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedSpace.cpp; sourceTree = "<group>"; };
+               140CDC7712DBEA330013CFC5 /* MarkedSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedSpace.h; sourceTree = "<group>"; };
+               140CDE6C12DE977E0013CFC5 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Heap.cpp; sourceTree = "<group>"; };
+               140CDE6D12DE977E0013CFC5 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heap.h; sourceTree = "<group>"; };
                140D17D60E8AD4A9000CD17D /* JSBasePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBasePrivate.h; sourceTree = "<group>"; };
                141211020A48780900480255 /* minidom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = minidom.c; path = tests/minidom.c; sourceTree = "<group>"; };
                1412110D0A48788700480255 /* minidom.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = minidom.js; path = tests/minidom.js; sourceTree = "<group>"; };
                F692A84D0255597D01FF60F7 /* ArrayPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayPrototype.cpp; sourceTree = "<group>"; tabWidth = 8; };
                F692A84E0255597D01FF60F7 /* ArrayPrototype.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ArrayPrototype.h; sourceTree = "<group>"; tabWidth = 8; };
                F692A8500255597D01FF60F7 /* BooleanObject.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanObject.cpp; sourceTree = "<group>"; tabWidth = 8; };
-               F692A8520255597D01FF60F7 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Heap.cpp; sourceTree = "<group>"; tabWidth = 8; };
-               F692A8530255597D01FF60F7 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Heap.h; sourceTree = "<group>"; tabWidth = 8; };
                F692A8540255597D01FF60F7 /* create_hash_table */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = text.script.perl; path = create_hash_table; sourceTree = "<group>"; tabWidth = 8; };
                F692A8580255597D01FF60F7 /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Debugger.cpp; sourceTree = "<group>"; tabWidth = 8; };
                F692A8590255597D01FF60F7 /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Debugger.h; sourceTree = "<group>"; tabWidth = 8; };
                                BC337BDE0E1AF0B80076918A /* GetterSetter.h */,
                                BC257DED0E1F52ED0016B6C9 /* GlobalEvalFunction.cpp */,
                                BC257DEE0E1F52ED0016B6C9 /* GlobalEvalFunction.h */,
-                               F692A8520255597D01FF60F7 /* Heap.cpp */,
-                               F692A8530255597D01FF60F7 /* Heap.h */,
+                               140CDE6C12DE977E0013CFC5 /* Heap.cpp */,
+                               140CDE6D12DE977E0013CFC5 /* Heap.h */,
                                933A349D038AE80F008635CE /* Identifier.cpp */,
                                933A349A038AE7C6008635CE /* Identifier.h */,
                                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
                                F692A8690255597D01FF60F7 /* Lookup.h */,
                                14B7233F12D7D0DA003BD5ED /* MachineStackMarker.cpp */,
                                14B7234012D7D0DA003BD5ED /* MachineStackMarker.h */,
+                               140CDC7612DBEA330013CFC5 /* MarkedSpace.cpp */,
+                               140CDC7712DBEA330013CFC5 /* MarkedSpace.h */,
                                A74B3498102A5F8E0032AB98 /* MarkStack.cpp */,
                                A779558F101A74D500114E55 /* MarkStack.h */,
                                A7C530E3102A3813005BC741 /* MarkStackPosix.cpp */,
                                A784A26111D16622005776AC /* ASTBuilder.h in Headers */,
                                BC5F7BBE11823B590052C02C /* Atomics.h in Headers */,
                                868BFA09117CEFD100B908B1 /* AtomicString.h in Headers */,
+                               86F38859121130CA007A7CE3 /* AtomicStringHash.h in Headers */,
                                868BFA0A117CEFD100B908B1 /* AtomicStringImpl.h in Headers */,
                                BC18C3EB0E16F5CD00B34460 /* AVLTree.h in Headers */,
                                147B83AC0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h in Headers */,
                                86676D5211FED9BC004B6863 /* BumpPointerAllocator.h in Headers */,
                                A7A1F7AD0F252B3C00E184E2 /* ByteArray.h in Headers */,
                                969A07230ED1CE3300F1F681 /* BytecodeGenerator.h in Headers */,
-                               FDA15C1E12B0305C003A583A /* Complex.h in Headers */,
                                869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */,
                                BC18C3ED0E16F5CD00B34460 /* CallData.h in Headers */,
                                1429D8DE0ED2205B00B89619 /* CallFrame.h in Headers */,
                                969A07970ED1D3AE00F1F681 /* CodeBlock.h in Headers */,
                                86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */,
                                BC18C3F00E16F5CD00B34460 /* Collator.h in Headers */,
-                               BC18C3F10E16F5CD00B34460 /* Heap.h in Headers */,
                                14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */,
                                BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */,
                                BC18C3F40E16F5CD00B34460 /* Completion.h in Headers */,
+                               FDA15C1E12B0305C003A583A /* Complex.h in Headers */,
                                BC18C3F50E16F5CD00B34460 /* config.h in Headers */,
                                BC18C3F60E16F5CD00B34460 /* ConstructData.h in Headers */,
-                               5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */,
                                0BDFFAE00FC6192900D69EF4 /* CrossThreadRefCounted.h in Headers */,
                                86565743115BE3DA00291F40 /* CString.h in Headers */,
                                180B9B080F16D94F009BDBC5 /* CurrentTime.h in Headers */,
                                BC18C3FA0E16F5CD00B34460 /* Debugger.h in Headers */,
                                BC3135640F302FA3003DFD3A /* DebuggerActivation.h in Headers */,
                                BC18C3FB0E16F5CD00B34460 /* DebuggerCallFrame.h in Headers */,
+                               862AF4B612239C7B0024E5B8 /* DecimalNumber.h in Headers */,
+                               5135FAF212D26ACE003C083B /* Decoder.h in Headers */,
                                BC18C3FC0E16F5CD00B34460 /* Deque.h in Headers */,
                                BC18C3FD0E16F5CD00B34460 /* DisallowCType.h in Headers */,
                                BC18C3FE0E16F5CD00B34460 /* dtoa.h in Headers */,
+                               5135FAF312D26AD1003C083B /* Encoder.h in Headers */,
                                BC3046070E1F497F003232CF /* Error.h in Headers */,
                                BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */,
                                BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */,
                                BC18C4030E16F5CD00B34460 /* Forward.h in Headers */,
                                BC18C4040E16F5CD00B34460 /* FunctionConstructor.h in Headers */,
                                BC18C4050E16F5CD00B34460 /* FunctionPrototype.h in Headers */,
+                               DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */,
+                               DDE82AD81209D955005C1756 /* GCHandle.h in Headers */,
                                BC18C4060E16F5CD00B34460 /* GetPtr.h in Headers */,
                                BC257DF00E1F52ED0016B6C9 /* GlobalEvalFunction.h in Headers */,
                                BC18C4080E16F5CD00B34460 /* HashCountedSet.h in Headers */,
                                BC18C40C0E16F5CD00B34460 /* HashSet.h in Headers */,
                                BC18C40D0E16F5CD00B34460 /* HashTable.h in Headers */,
                                BC18C40E0E16F5CD00B34460 /* HashTraits.h in Headers */,
+                               140CDE7112DE97B10013CFC5 /* Heap.h in Headers */,
                                BC18C40F0E16F5CD00B34460 /* Identifier.h in Headers */,
                                BC18C4100E16F5CD00B34460 /* InitializeThreading.h in Headers */,
                                969A07990ED1D3AE00F1F681 /* Instruction.h in Headers */,
                                860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */,
                                BC18C4390E16F5CD00B34460 /* MainThread.h in Headers */,
                                BC18C43A0E16F5CD00B34460 /* MallocZoneSupport.h in Headers */,
+                               140CDF0C12DECE5C0013CFC5 /* MarkedSpace.h in Headers */,
                                A7795590101A74D500114E55 /* MarkStack.h in Headers */,
                                BC18C43B0E16F5CD00B34460 /* MathExtras.h in Headers */,
                                BC18C43C0E16F5CD00B34460 /* MathObject.h in Headers */,
                                BC18C52A0E16FCC200B34460 /* MathObject.lut.h in Headers */,
                                511FC4CB117EE2A800425272 /* MD5.h in Headers */,
+                               90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */,
                                BC18C43E0E16F5CD00B34460 /* MessageQueue.h in Headers */,
                                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
                                BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */,
                                A76EE6590FAE59D5003F069A /* NativeFunctionWrapper.h in Headers */,
                                7EFF00640EC05A9A00AA7C93 /* NodeInfo.h in Headers */,
                                BC18C43F0E16F5CD00B34460 /* Nodes.h in Headers */,
-                               65E1A3DF122B894500B26097 /* NonCopyingSort.h in Headers */,
                                BC18C4400E16F5CD00B34460 /* Noncopyable.h in Headers */,
+                               65E1A3DF122B894500B26097 /* NonCopyingSort.h in Headers */,
                                C0A272630E50A06300E96E15 /* NotFound.h in Headers */,
+                               933F5CDC1269229B0049191E /* NullPtr.h in Headers */,
                                BC18C4410E16F5CD00B34460 /* NumberConstructor.h in Headers */,
                                BC18C4420E16F5CD00B34460 /* NumberConstructor.lut.h in Headers */,
                                BC18C4430E16F5CD00B34460 /* NumberObject.h in Headers */,
                                E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */,
                                969A079B0ED1D3AE00F1F681 /* Opcode.h in Headers */,
                                BC18C4480E16F5CD00B34460 /* Operations.h in Headers */,
+                               1400067712A6F7830064D123 /* OSAllocator.h in Headers */,
                                BC18C4490E16F5CD00B34460 /* OwnArrayPtr.h in Headers */,
+                               BCFBE698122561D200309E9D /* OwnArrayPtrCommon.h in Headers */,
                                0BDFFAE10FC6193100D69EF4 /* OwnFastMallocPtr.h in Headers */,
                                BC18C44A0E16F5CD00B34460 /* OwnPtr.h in Headers */,
                                4409D8470FAF80A200523B87 /* OwnPtrCommon.h in Headers */,
                                8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */,
+                               14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */,
+                               14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */,
                                8690231512092D5C00630AF9 /* PageReservation.h in Headers */,
+                               9714AF5F122F32070092D9F5 /* ParsedURL.h in Headers */,
                                BC18C44B0E16F5CD00B34460 /* Parser.h in Headers */,
                                93052C350FB792190048FDC3 /* ParserArena.h in Headers */,
+                               BCFBE696122560E800309E9D /* PassOwnArrayPtr.h in Headers */,
                                44DD48530FAEA85000D6B4EB /* PassOwnPtr.h in Headers */,
                                BC18C44C0E16F5CD00B34460 /* PassRefPtr.h in Headers */,
                                BC18C44D0E16F5CD00B34460 /* pcre.h in Headers */,
                                147B84630E6DE6B1004775A4 /* PutPropertySlot.h in Headers */,
                                088FA5BC0EF76D4300578E6F /* RandomNumber.h in Headers */,
                                08E279E90EF83B10007DB523 /* RandomNumberSeed.h in Headers */,
+                               9714AF4B122F289A0092D9F5 /* RawURLBuffer.h in Headers */,
                                BC18C4570E16F5CD00B34460 /* RefCounted.h in Headers */,
                                90D3469C0E285280009492EE /* RefCountedLeakCounter.h in Headers */,
                                BC18C4580E16F5CD00B34460 /* RefPtr.h in Headers */,
                                86D87DDB12BCAF94008E73A1 /* StackBounds.h in Headers */,
                                868BFA60117D048200B908B1 /* StaticConstructors.h in Headers */,
                                FE1B447A0ECCD73B004F4DD1 /* StdLibExtras.h in Headers */,
+                               A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
                                86B99AE3117E578100DF5A90 /* StringBuffer.h in Headers */,
                                081469491264378500DFF935 /* StringBuilder.h in Headers */,
                                08CABBA61265AB3900B206CE /* StringConcatenate.h in Headers */,
                                BC18C46E0E16F5CD00B34460 /* TCSpinLock.h in Headers */,
                                BC18C46F0E16F5CD00B34460 /* TCSystemAlloc.h in Headers */,
                                971EDEA61169E0D3005E4262 /* Terminator.h in Headers */,
+                               F3BD31ED126735770065467F /* TextPosition.h in Headers */,
                                18BAB55410DAE066000D945B /* ThreadIdentifierDataPthreads.h in Headers */,
                                BC18C4700E16F5CD00B34460 /* Threading.h in Headers */,
                                BC5F7BBF11823B590052C02C /* ThreadingPrimitives.h in Headers */,
                                BC18C4730E16F5CD00B34460 /* Unicode.h in Headers */,
                                BC18C4740E16F5CD00B34460 /* UnicodeIcu.h in Headers */,
                                BC18C4750E16F5CD00B34460 /* UnusedParam.h in Headers */,
+                               9714AF4C122F289A0092D9F5 /* URLBuffer.h in Headers */,
+                               9714AF4D122F289A0092D9F5 /* URLComponent.h in Headers */,
+                               9714AF4E122F289A0092D9F5 /* URLParser.h in Headers */,
+                               9714AF4F122F289A0092D9F5 /* URLSegments.h in Headers */,
+                               9714AF60122F32070092D9F5 /* URLString.h in Headers */,
                                BC18C4760E16F5CD00B34460 /* UString.h in Headers */,
                                08DDA5C11264631700751732 /* UStringBuilder.h in Headers */,
                                BC18C4770E16F5CD00B34460 /* UTF8.h in Headers */,
                                868BFA18117CF19900B908B1 /* WTFString.h in Headers */,
                                86D08D5411793613006E5ED0 /* WTFThreadData.h in Headers */,
                                9688CB160ED12B4E001D649F /* X86Assembler.h in Headers */,
-                               DDF7ABD411F60ED200108E36 /* GCActivityCallback.h in Headers */,
-                               DDE82AD81209D955005C1756 /* GCHandle.h in Headers */,
-                               86F38859121130CA007A7CE3 /* AtomicStringHash.h in Headers */,
-                               862AF4B612239C7B0024E5B8 /* DecimalNumber.h in Headers */,
-                               BCFBE696122560E800309E9D /* PassOwnArrayPtr.h in Headers */,
-                               BCFBE698122561D200309E9D /* OwnArrayPtrCommon.h in Headers */,
-                               9714AF4B122F289A0092D9F5 /* RawURLBuffer.h in Headers */,
-                               9714AF4C122F289A0092D9F5 /* URLBuffer.h in Headers */,
-                               9714AF4D122F289A0092D9F5 /* URLComponent.h in Headers */,
-                               9714AF4E122F289A0092D9F5 /* URLParser.h in Headers */,
-                               9714AF4F122F289A0092D9F5 /* URLSegments.h in Headers */,
-                               9714AF5F122F32070092D9F5 /* ParsedURL.h in Headers */,
-                               9714AF60122F32070092D9F5 /* URLString.h in Headers */,
-                               90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */,
-                               A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
-                               933F5CDC1269229B0049191E /* NullPtr.h in Headers */,
-                               F3BD31ED126735770065467F /* TextPosition.h in Headers */,
-                               1400067712A6F7830064D123 /* OSAllocator.h in Headers */,
-                               14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */,
-                               14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */,
-                               5135FAF212D26ACE003C083B /* Decoder.h in Headers */,
-                               5135FAF312D26AD1003C083B /* Encoder.h in Headers */,
-                               86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
                                86704B8512DBA33700A9FE7B /* YarrInterpreter.h in Headers */,
                                86704B8712DBA33700A9FE7B /* YarrJIT.h in Headers */,
                                86704B8812DBA33700A9FE7B /* YarrParser.h in Headers */,
                                86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */,
+                               86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
+                               5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */,
                                451539B912DC994500EF7AC4 /* Yarr.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                969A07960ED1D3AE00F1F681 /* CodeBlock.cpp in Sources */,
                                E1A862D60D7F2B5C001EC6AA /* CollatorDefault.cpp in Sources */,
                                E1A862A90D7EBB76001EC6AA /* CollatorICU.cpp in Sources */,
-                               14F8BA4F107EC899009892DC /* Heap.cpp in Sources */,
                                147F39C1107EC37600427A48 /* CommonIdentifiers.cpp in Sources */,
                                147F39C2107EC37600427A48 /* Completion.cpp in Sources */,
                                1428082E107EC0570013E7B2 /* ConstructData.cpp in Sources */,
                                14280855107EC0E70013E7B2 /* GetterSetter.cpp in Sources */,
                                147F39CD107EC37600427A48 /* GlobalEvalFunction.cpp in Sources */,
                                65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */,
+                               140CDE7012DE97A00013CFC5 /* Heap.cpp in Sources */,
                                147F39CE107EC37600427A48 /* Identifier.cpp in Sources */,
                                E178636D0D9BEEC300D74E75 /* InitializeThreading.cpp in Sources */,
                                147F39CF107EC37600427A48 /* InternalFunction.cpp in Sources */,
                                86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
                                06D358B30DAADAA4003B174E /* MainThread.cpp in Sources */,
                                06D358B40DAADAAA003B174E /* MainThreadMac.mm in Sources */,
+                               140CDC7C12DC09BF0013CFC5 /* MarkedSpace.cpp in Sources */,
                                A74B3499102A5F8E0032AB98 /* MarkStack.cpp in Sources */,
                                A7C530E4102A3813005BC741 /* MarkStackPosix.cpp in Sources */,
                                14469DDF107EC7E700650446 /* MathObject.cpp in Sources */,
                                E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
                                868BFA17117CF19900B908B1 /* WTFString.cpp in Sources */,
                                86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */,
-                               86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
                                86704B8412DBA33700A9FE7B /* YarrInterpreter.cpp in Sources */,
                                86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
                                86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
+                               86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 71399cc..0de2a3b 100644 (file)
 #include "config.h"
 #include "Heap.h"
 
-#include "ArgList.h"
-#include "CallFrame.h"
-#include "CodeBlock.h"
 #include "CollectorHeapIterator.h"
 #include "GCActivityCallback.h"
+#include "GCHandle.h"
 #include "Interpreter.h"
-#include "JSArray.h"
+#include "JSGlobalData.h"
 #include "JSGlobalObject.h"
 #include "JSLock.h"
 #include "JSONObject.h"
-#include "JSString.h"
-#include "JSValue.h"
-#include "JSZombie.h"
-#include "MarkStack.h"
-#include "Nodes.h"
-#include "Tracing.h"
-#include <algorithm>
-#include <limits.h>
-#include <setjmp.h>
-#include <stdlib.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/HashCountedSet.h>
-#include <wtf/WTFThreadData.h>
-#include <wtf/UnusedParam.h>
-#include <wtf/VMTags.h>
+#include "TracingDtrace.h"
 
 #define COLLECT_ON_EVERY_ALLOCATION 0
 
-using std::max;
-
 namespace JSC {
 
-// tunable parameters
-
-const size_t GROWTH_FACTOR = 2;
-const size_t LOW_WATER_FACTOR = 4;
-const size_t ALLOCATIONS_PER_COLLECTION = 3600;
-// This value has to be a macro to be used in max() without introducing
-// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
-#define MIN_ARRAY_SIZE (static_cast<size_t>(14))
-
 Heap::Heap(JSGlobalData* globalData)
-    : m_markListSet(0)
+    : m_markedSpace(globalData)
+    , m_markListSet(0)
+    , m_activityCallback(DefaultGCActivityCallback::create(this))
     , m_globalData(globalData)
-    , m_machineStackMarker(this)
+    , m_machineStackMarker(&globalData->heap)
+    , m_extraCost(0)
 {
-    ASSERT(globalData);
-    memset(&m_heap, 0, sizeof(CollectorHeap));
-    allocateBlock();
-    m_activityCallback = DefaultGCActivityCallback::create(this);
     (*m_activityCallback)();
 }
 
@@ -88,7 +60,7 @@ void Heap::destroy()
         return;
 
     ASSERT(!m_globalData->dynamicGlobalObject);
-    ASSERT(!isBusy());
+    ASSERT(m_operationInProgress == NoOperation);
     
     // The global object is not GC protected at this point, so sweeping may delete it
     // (and thus the global data) before other objects that may use the global data.
@@ -97,91 +69,11 @@ void Heap::destroy()
     delete m_markListSet;
     m_markListSet = 0;
 
-    freeBlocks();
-
-    m_globalData = 0;
-}
-
-NEVER_INLINE CollectorBlock* Heap::allocateBlock()
-{
-    PageAllocationAligned allocation = PageAllocationAligned::allocate(BLOCK_SIZE, BLOCK_SIZE, OSAllocator::JSGCHeapPages);
-    CollectorBlock* block = static_cast<CollectorBlock*>(allocation.base());
-    if (!block)
-        CRASH();
-
-    // Initialize block.
-
-    block->heap = this;
-    clearMarkBits(block);
-
-    Structure* dummyMarkableCellStructure = m_globalData->dummyMarkableCellStructure.get();
-    for (size_t i = 0; i < HeapConstants::cellsPerBlock; ++i)
-        new (&block->cells[i]) JSCell(dummyMarkableCellStructure);
-    
-    // Add block to blocks vector.
-
-    size_t numBlocks = m_heap.numBlocks;
-    if (m_heap.usedBlocks == numBlocks) {
-        static const size_t maxNumBlocks = ULONG_MAX / sizeof(PageAllocationAligned) / GROWTH_FACTOR;
-        if (numBlocks > maxNumBlocks)
-            CRASH();
-        numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR);
-        m_heap.numBlocks = numBlocks;
-        m_heap.blocks = static_cast<PageAllocationAligned*>(fastRealloc(m_heap.blocks, numBlocks * sizeof(PageAllocationAligned)));
-    }
-    m_heap.blocks[m_heap.usedBlocks++] = allocation;
-
-    return block;
-}
-
-NEVER_INLINE void Heap::freeBlock(size_t block)
-{
-    m_heap.didShrink = true;
-
-    ObjectIterator it(m_heap, block);
-    ObjectIterator end(m_heap, block + 1);
-    for ( ; it != end; ++it)
-        (*it)->~JSCell();
-    m_heap.blocks[block].deallocate();
-
-    // swap with the last block so we compact as we go
-    m_heap.blocks[block] = m_heap.blocks[m_heap.usedBlocks - 1];
-    m_heap.usedBlocks--;
-
-    if (m_heap.numBlocks > MIN_ARRAY_SIZE && m_heap.usedBlocks < m_heap.numBlocks / LOW_WATER_FACTOR) {
-        m_heap.numBlocks = m_heap.numBlocks / GROWTH_FACTOR; 
-        m_heap.blocks = static_cast<PageAllocationAligned*>(fastRealloc(m_heap.blocks, m_heap.numBlocks * sizeof(PageAllocationAligned)));
-    }
-}
-
-void Heap::freeBlocks()
-{
     ProtectCountSet protectedValuesCopy = m_protectedValues;
-
-    clearMarkBits();
-    ProtectCountSet::iterator protectedValuesEnd = protectedValuesCopy.end();
-    for (ProtectCountSet::iterator it = protectedValuesCopy.begin(); it != protectedValuesEnd; ++it)
-        markCell(it->first);
-
-    m_heap.nextCell = 0;
-    m_heap.nextBlock = 0;
-    DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
-    DeadObjectIterator end(m_heap, m_heap.usedBlocks);
-    for ( ; it != end; ++it)
-        (*it)->~JSCell();
-
+    m_markedSpace.destroy(protectedValuesCopy);
     ASSERT(!protectedObjectCount());
 
-    protectedValuesEnd = protectedValuesCopy.end();
-    for (ProtectCountSet::iterator it = protectedValuesCopy.begin(); it != protectedValuesEnd; ++it)
-        it->first->~JSCell();
-
-    for (size_t block = 0; block < m_heap.usedBlocks; ++block)
-        m_heap.blocks[block].deallocate();
-
-    fastFree(m_heap.blocks);
-
-    memset(&m_heap, 0, sizeof(CollectorHeap));
+    m_globalData = 0;
 }
 
 void Heap::recordExtraCost(size_t cost)
@@ -197,167 +89,71 @@ void Heap::recordExtraCost(size_t cost)
     // if a large value survives one garbage collection, there is not much point to
     // collecting more frequently as long as it stays alive.
 
-    if (m_heap.extraCost > maxExtraCost && m_heap.extraCost > m_heap.usedBlocks * BLOCK_SIZE / 2) {
+    if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.size() / 2) {
+        JAVASCRIPTCORE_GC_BEGIN();
+
         // If the last iteration through the heap deallocated blocks, we need
         // to clean up remaining garbage before marking. Otherwise, the conservative
         // marking mechanism might follow a pointer to unmapped memory.
-        if (m_heap.didShrink)
-            sweep();
-        reset();
+        if (m_markedSpace.didShrink())
+            m_markedSpace.sweep();
+
+        markRoots();
+
+        JAVASCRIPTCORE_GC_MARKED();
+
+        m_markedSpace.reset();
+        m_extraCost = 0;
+
+        JAVASCRIPTCORE_GC_END();
+
+        (*m_activityCallback)();
     }
-    m_heap.extraCost += cost;
+    m_extraCost += cost;
 }
 
 void* Heap::allocate(size_t s)
 {
     ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
-    typedef HeapConstants::Block Block;
-    typedef HeapConstants::Cell Cell;
-    
     ASSERT(JSLock::lockCount() > 0);
     ASSERT(JSLock::currentThreadIsHoldingLock());
     ASSERT_UNUSED(s, s <= HeapConstants::cellSize);
-
-    ASSERT(m_heap.operationInProgress == NoOperation);
+    ASSERT(m_operationInProgress == NoOperation);
 
 #if COLLECT_ON_EVERY_ALLOCATION
     collectAllGarbage();
-    ASSERT(m_heap.operationInProgress == NoOperation);
+    ASSERT(m_operationInProgress == NoOperation);
 #endif
 
-allocate:
+    m_operationInProgress = Allocation;
+    void* result = m_markedSpace.allocate(s);
+    m_operationInProgress = NoOperation;
 
-    // Fast case: find the next garbage cell and recycle it.
+    if (!result) {
+        JAVASCRIPTCORE_GC_BEGIN();
 
-    do {
-        ASSERT(m_heap.nextBlock < m_heap.usedBlocks);
-        Block* block = m_heap.collectorBlock(m_heap.nextBlock);
-        do {
-            ASSERT(m_heap.nextCell < HeapConstants::cellsPerBlock);
-            if (!block->marked.get(m_heap.nextCell)) { // Always false for the last cell in the block
-                Cell* cell = &block->cells[m_heap.nextCell];
-
-                m_heap.operationInProgress = Allocation;
-                JSCell* imp = reinterpret_cast<JSCell*>(cell);
-                imp->~JSCell();
-                m_heap.operationInProgress = NoOperation;
-
-                ++m_heap.nextCell;
-                return cell;
-            }
-            block->marked.advanceToNextPossibleFreeCell(m_heap.nextCell);
-        } while (m_heap.nextCell != HeapConstants::cellsPerBlock);
-        m_heap.nextCell = 0;
-    } while (++m_heap.nextBlock != m_heap.usedBlocks);
-
-    // Slow case: reached the end of the heap. Mark live objects and start over.
-
-    reset();
-    goto allocate;
-}
+        markRoots();
 
-void Heap::resizeBlocks()
-{
-    m_heap.didShrink = false;
+        JAVASCRIPTCORE_GC_MARKED();
 
-    size_t usedCellCount = markedCells();
-    size_t minCellCount = usedCellCount + max(ALLOCATIONS_PER_COLLECTION, usedCellCount);
-    size_t minBlockCount = (minCellCount + HeapConstants::cellsPerBlock - 1) / HeapConstants::cellsPerBlock;
+        m_markedSpace.reset();
+        m_extraCost = 0;
 
-    size_t maxCellCount = 1.25f * minCellCount;
-    size_t maxBlockCount = (maxCellCount + HeapConstants::cellsPerBlock - 1) / HeapConstants::cellsPerBlock;
+        JAVASCRIPTCORE_GC_END();
 
-    if (m_heap.usedBlocks < minBlockCount)
-        growBlocks(minBlockCount);
-    else if (m_heap.usedBlocks > maxBlockCount)
-        shrinkBlocks(maxBlockCount);
-}
+        (*m_activityCallback)();
 
-void Heap::growBlocks(size_t neededBlocks)
-{
-    ASSERT(m_heap.usedBlocks < neededBlocks);
-    while (m_heap.usedBlocks < neededBlocks)
-        allocateBlock();
-}
-
-void Heap::shrinkBlocks(size_t neededBlocks)
-{
-    ASSERT(m_heap.usedBlocks > neededBlocks);
-    
-    // Clear the always-on last bit, so isEmpty() isn't fooled by it.
-    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        m_heap.collectorBlock(i)->marked.clear(HeapConstants::cellsPerBlock - 1);
-
-    for (size_t i = 0; i != m_heap.usedBlocks && m_heap.usedBlocks != neededBlocks; ) {
-        if (m_heap.collectorBlock(i)->marked.isEmpty()) {
-            freeBlock(i);
-        } else
-            ++i;
+        m_operationInProgress = Allocation;
+        result = m_markedSpace.allocate(s);
+        m_operationInProgress = NoOperation;
     }
-
-    // Reset the always-on last bit.
-    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        m_heap.collectorBlock(i)->marked.set(HeapConstants::cellsPerBlock - 1);
-}
-
-inline bool isPointerAligned(void* p)
-{
-    return (((intptr_t)(p) & (sizeof(char*) - 1)) == 0);
-}
-
-// Cell size needs to be a power of two for isPossibleCell to be valid.
-COMPILE_ASSERT(sizeof(CollectorCell) % 2 == 0, Collector_cell_size_is_power_of_two);
-
-static inline bool isCellAligned(void *p)
-{
-    return (((intptr_t)(p) & CELL_MASK) == 0);
-}
-
-static inline bool isPossibleCell(void* p)
-{
-    return isCellAligned(p) && p;
+    ASSERT(result);
+    return result;
 }
 
 void Heap::markConservatively(MarkStack& markStack, void* start, void* end)
 {
-#if OS(WINCE)
-    if (start > end) {
-        void* tmp = start;
-        start = end;
-        end = tmp;
-    }
-#else
-    ASSERT(start <= end);
-#endif
-
-    ASSERT((static_cast<char*>(end) - static_cast<char*>(start)) < 0x1000000);
-    ASSERT(isPointerAligned(start));
-    ASSERT(isPointerAligned(end));
-
-    char** p = static_cast<char**>(start);
-    char** e = static_cast<char**>(end);
-
-    while (p != e) {
-        char* x = *p++;
-        if (isPossibleCell(x)) {
-            size_t usedBlocks;
-            uintptr_t xAsBits = reinterpret_cast<uintptr_t>(x);
-            xAsBits &= CELL_ALIGN_MASK;
-
-            uintptr_t offset = xAsBits & BLOCK_OFFSET_MASK;
-            const size_t lastCellOffset = sizeof(CollectorCell) * (CELLS_PER_BLOCK - 1);
-            if (offset > lastCellOffset)
-                continue;
-
-            CollectorBlock* blockAddr = reinterpret_cast<CollectorBlock*>(xAsBits - offset);
-            usedBlocks = m_heap.usedBlocks;
-            for (size_t block = 0; block < usedBlocks; block++) {
-                if (m_heap.collectorBlock(block) != blockAddr)
-                    continue;
-                markStack.append(reinterpret_cast<JSCell*>(xAsBits));
-            }
-        }
-    }
+    m_markedSpace.markConservatively(markStack, start, end);
 }
 
 void Heap::updateWeakGCHandles()
@@ -448,67 +244,6 @@ void Heap::markTempSortVectors(MarkStack& markStack)
     }
 }
     
-void Heap::clearMarkBits()
-{
-    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
-        clearMarkBits(m_heap.collectorBlock(i));
-}
-
-void Heap::clearMarkBits(CollectorBlock* block)
-{
-    // allocate assumes that the last cell in every block is marked.
-    block->marked.clearAll();
-    block->marked.set(HeapConstants::cellsPerBlock - 1);
-}
-
-size_t Heap::markedCells(size_t startBlock, size_t startCell) const
-{
-    ASSERT(startBlock <= m_heap.usedBlocks);
-    ASSERT(startCell < HeapConstants::cellsPerBlock);
-
-    if (startBlock >= m_heap.usedBlocks)
-        return 0;
-
-    size_t result = 0;
-    result += m_heap.collectorBlock(startBlock)->marked.count(startCell);
-    for (size_t i = startBlock + 1; i < m_heap.usedBlocks; ++i)
-        result += m_heap.collectorBlock(i)->marked.count();
-
-    return result;
-}
-
-void Heap::sweep()
-{
-    ASSERT(m_heap.operationInProgress == NoOperation);
-    if (m_heap.operationInProgress != NoOperation)
-        CRASH();
-    m_heap.operationInProgress = Collection;
-    
-#if !ENABLE(JSC_ZOMBIES)
-    Structure* dummyMarkableCellStructure = m_globalData->dummyMarkableCellStructure.get();
-#endif
-
-    DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
-    DeadObjectIterator end(m_heap, m_heap.usedBlocks);
-    for ( ; it != end; ++it) {
-        JSCell* cell = *it;
-#if ENABLE(JSC_ZOMBIES)
-        if (!cell->isZombie()) {
-            const ClassInfo* info = cell->classInfo();
-            cell->~JSCell();
-            new (cell) JSZombie(info, JSZombie::leakedZombieStructure());
-            Heap::markCell(cell);
-        }
-#else
-        cell->~JSCell();
-        // Callers of sweep assume it's safe to mark any cell in the heap.
-        new (cell) JSCell(dummyMarkableCellStructure);
-#endif
-    }
-
-    m_heap.operationInProgress = NoOperation;
-}
-
 void Heap::markRoots()
 {
 #ifndef NDEBUG
@@ -518,16 +253,16 @@ void Heap::markRoots()
     }
 #endif
 
-    ASSERT(m_heap.operationInProgress == NoOperation);
-    if (m_heap.operationInProgress != NoOperation)
+    ASSERT(m_operationInProgress == NoOperation);
+    if (m_operationInProgress != NoOperation)
         CRASH();
 
-    m_heap.operationInProgress = Collection;
+    m_operationInProgress = Collection;
 
     MarkStack& markStack = m_globalData->markStack;
 
     // Reset mark bits.
-    clearMarkBits();
+    m_markedSpace.clearMarkBits();
 
     // Mark stack roots.
     m_machineStackMarker.markMachineStackConservatively(markStack);
@@ -556,33 +291,22 @@ void Heap::markRoots()
 
     updateWeakGCHandles();
 
-    m_heap.operationInProgress = NoOperation;
+    m_operationInProgress = NoOperation;
 }
 
 size_t Heap::objectCount() const
 {
-    return m_heap.nextBlock * HeapConstants::cellsPerBlock // allocated full blocks
-           + m_heap.nextCell // allocated cells in current block
-           + markedCells(m_heap.nextBlock, m_heap.nextCell) // marked cells in remainder of m_heap
-           - m_heap.usedBlocks; // 1 cell per block is a dummy sentinel
+    return m_markedSpace.objectCount();
 }
 
-void Heap::addToStatistics(Heap::Statistics& statistics) const
+MarkedSpace::Statistics Heap::statistics() const
 {
-    statistics.size += m_heap.usedBlocks * BLOCK_SIZE;
-    statistics.free += m_heap.usedBlocks * BLOCK_SIZE - (objectCount() * HeapConstants::cellSize);
-}
-
-Heap::Statistics Heap::statistics() const
-{
-    Statistics statistics = { 0, 0 };
-    addToStatistics(statistics);
-    return statistics;
+    return m_markedSpace.statistics();
 }
 
 size_t Heap::size() const
 {
-    return m_heap.usedBlocks * BLOCK_SIZE;
+    return m_markedSpace.size();
 }
 
 size_t Heap::globalObjectCount()
@@ -659,29 +383,7 @@ HashCountedSet<const char*>* Heap::objectTypeCounts()
 
 bool Heap::isBusy()
 {
-    return m_heap.operationInProgress != NoOperation;
-}
-
-void Heap::reset()
-{
-    ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
-    JAVASCRIPTCORE_GC_BEGIN();
-
-    markRoots();
-
-    JAVASCRIPTCORE_GC_MARKED();
-
-    m_heap.nextCell = 0;
-    m_heap.nextBlock = 0;
-    m_heap.extraCost = 0;
-#if ENABLE(JSC_ZOMBIES)
-    sweep();
-#endif
-    resizeBlocks();
-
-    JAVASCRIPTCORE_GC_END();
-
-    (*m_activityCallback)();
+    return m_operationInProgress != NoOperation;
 }
 
 void Heap::collectAllGarbage()
@@ -692,30 +394,30 @@ void Heap::collectAllGarbage()
     // If the last iteration through the heap deallocated blocks, we need
     // to clean up remaining garbage before marking. Otherwise, the conservative
     // marking mechanism might follow a pointer to unmapped memory.
-    if (m_heap.didShrink)
-        sweep();
+    if (m_markedSpace.didShrink())
+        m_markedSpace.sweep();
 
     markRoots();
 
     JAVASCRIPTCORE_GC_MARKED();
 
-    m_heap.nextCell = 0;
-    m_heap.nextBlock = 0;
-    m_heap.extraCost = 0;
-    sweep();
-    resizeBlocks();
+    m_markedSpace.reset();
+    m_markedSpace.sweep();
+    m_extraCost = 0;
 
     JAVASCRIPTCORE_GC_END();
+
+    (*m_activityCallback)();
 }
 
 LiveObjectIterator Heap::primaryHeapBegin()
 {
-    return LiveObjectIterator(m_heap, 0);
+    return m_markedSpace.primaryHeapBegin();
 }
 
 LiveObjectIterator Heap::primaryHeapEnd()
 {
-    return LiveObjectIterator(m_heap, m_heap.usedBlocks);
+    return m_markedSpace.primaryHeapEnd();
 }
 
 void Heap::setActivityCallback(PassOwnPtr<GCActivityCallback> activityCallback)
index 75f50dd..243bba3 100644 (file)
 #ifndef Heap_h
 #define Heap_h
 
-#include "GCHandle.h"
-#include "JSValue.h"
-#include "MachineStackMarker.h"
-#include <stddef.h>
-#include <string.h>
-#include <wtf/Bitmap.h>
-#include <wtf/FixedArray.h>
-#include <wtf/HashCountedSet.h>
+#include "MarkedSpace.h"
+#include <wtf/Forward.h>
 #include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PageAllocation.h>
-#include <wtf/PageAllocationAligned.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/StdLibExtras.h>
 
 #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell)
 
 namespace JSC {
 
-    class CollectorBlock;
+    class JSValue;
+    class UString;
     class GCActivityCallback;
     class JSCell;
     class JSGlobalData;
     class JSValue;
+    class LiveObjectIterator;
     class MarkedArgumentBuffer;
     class MarkStack;
+    class WeakGCHandlePool;
 
-    enum OperationInProgress { NoOperation, Allocation, Collection };
-
-    class LiveObjectIterator;
-
-#if OS(WINCE) || OS(SYMBIAN) || PLATFORM(BREWMP)
-    const size_t BLOCK_SIZE = 64 * 1024; // 64k
-#else
-    const size_t BLOCK_SIZE = 256 * 1024; // 256k
-#endif
-
-    struct CollectorHeap {
-        size_t nextBlock;
-        size_t nextCell;
-        PageAllocationAligned* blocks;
-        
-        size_t numBlocks;
-        size_t usedBlocks;
-
-        size_t extraCost;
-        bool didShrink;
+    typedef std::pair<JSValue, UString> ValueStringPair;
 
-        OperationInProgress operationInProgress;
-
-        CollectorBlock* collectorBlock(size_t index) const
-        {
-            return static_cast<CollectorBlock*>(blocks[index].base());
-        }
-    };
+    enum OperationInProgress { NoOperation, Allocation, Collection };
 
     class Heap : public Noncopyable {
     public:
@@ -97,11 +63,7 @@ namespace JSC {
         void reportExtraMemoryCost(size_t cost);
 
         size_t objectCount() const;
-        struct Statistics {
-            size_t size;
-            size_t free;
-        };
-        Statistics statistics() const;
+        MarkedSpace::Statistics statistics() const;
         size_t size() const;
 
         void protect(JSValue);
@@ -132,37 +94,21 @@ namespace JSC {
         HashSet<MarkedArgumentBuffer*>& markListSet() { if (!m_markListSet) m_markListSet = new HashSet<MarkedArgumentBuffer*>; return *m_markListSet; }
 
         JSGlobalData* globalData() const { return m_globalData; }
-        static bool isNumber(JSCell*);
         
         LiveObjectIterator primaryHeapBegin();
         LiveObjectIterator primaryHeapEnd();
-
+        
         MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
 
-    private:
-        void reset();
-        void sweep();
-        static CollectorBlock* cellBlock(const JSCell*);
-        static size_t cellOffset(const JSCell*);
+        MarkedSpace& markedSpace() { return m_markedSpace; }
 
+    private:
         friend class JSGlobalData;
         Heap(JSGlobalData*);
         ~Heap();
 
-        NEVER_INLINE CollectorBlock* allocateBlock();
-        NEVER_INLINE void freeBlock(size_t);
-        void freeBlocks();
-        void resizeBlocks();
-        void growBlocks(size_t neededBlocks);
-        void shrinkBlocks(size_t neededBlocks);
-        void clearMarkBits();
-        void clearMarkBits(CollectorBlock*);
-        size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
-
         void recordExtraCost(size_t);
 
-        void addToStatistics(Statistics&) const;
-
         void markRoots();
         void markProtectedObjects(MarkStack&);
         void markTempSortVectors(MarkStack&);
@@ -170,9 +116,8 @@ namespace JSC {
         void updateWeakGCHandles();
         WeakGCHandlePool* weakGCHandlePool(size_t index);
 
-        typedef HashCountedSet<JSCell*> ProtectCountSet;
-
-        CollectorHeap m_heap;
+        MarkedSpace m_markedSpace;
+        OperationInProgress m_operationInProgress;
 
         ProtectCountSet m_protectedValues;
         WTF::Vector<PageAllocationAligned> m_weakGCHandlePools;
@@ -185,105 +130,23 @@ namespace JSC {
         JSGlobalData* m_globalData;
         
         MachineStackMarker m_machineStackMarker;
+        
+        size_t m_extraCost;
     };
 
-    // tunable parameters
-    // derived constants
-    const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1;
-    const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK;
-    const size_t MINIMUM_CELL_SIZE = 64;
-    const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0);
-    const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double);
-    const size_t SMALL_CELL_SIZE = CELL_SIZE / 2;
-    const size_t CELL_MASK = CELL_SIZE - 1;
-    const size_t CELL_ALIGN_MASK = ~CELL_MASK;
-    const size_t CELLS_PER_BLOCK = (BLOCK_SIZE - sizeof(Heap*)) * 8 * CELL_SIZE / (8 * CELL_SIZE + 1) / CELL_SIZE; // one bitmap byte can represent 8 cells.
-    
-    const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8;
-    const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t);
-
-    struct CollectorBitmap {
-        FixedArray<uint32_t, BITMAP_WORDS> bits;
-        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } 
-        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } 
-        bool getset(size_t n)
-        {
-            unsigned i = (1 << (n & 0x1F));
-            uint32_t& b = bits[n >> 5];
-            bool r = !!(b & i);
-            b |= i;
-            return r;
-        } 
-        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } 
-        void clearAll() { memset(bits.data(), 0, sizeof(bits)); }
-        ALWAYS_INLINE void advanceToNextPossibleFreeCell(size_t& startCell)
-        {
-            if (!~bits[startCell >> 5])
-                startCell = (startCell & (~0x1F)) + 32;
-            else
-                ++startCell;
-        }
-        size_t count(size_t startCell = 0)
-        {
-            size_t result = 0;
-            for ( ; (startCell & 0x1F) != 0; ++startCell) {
-                if (get(startCell))
-                    ++result;
-            }
-            for (size_t i = startCell >> 5; i < BITMAP_WORDS; ++i)
-                result += WTF::bitCount(bits[i]);
-            return result;
-        }
-        size_t isEmpty() // Much more efficient than testing count() == 0.
-        {
-            for (size_t i = 0; i < BITMAP_WORDS; ++i)
-                if (bits[i] != 0)
-                    return false;
-            return true;
-        }
-    };
-  
-    struct CollectorCell {
-        FixedArray<double, CELL_ARRAY_LENGTH> memory;
-    };
-
-    class CollectorBlock {
-    public:
-        FixedArray<CollectorCell, CELLS_PER_BLOCK> cells;
-        CollectorBitmap marked;
-        Heap* heap;
-    };
-
-    struct HeapConstants {
-        static const size_t cellSize = CELL_SIZE;
-        static const size_t cellsPerBlock = CELLS_PER_BLOCK;
-        typedef CollectorCell Cell;
-        typedef CollectorBlock Block;
-    };
-
-    inline CollectorBlock* Heap::cellBlock(const JSCell* cell)
-    {
-        return reinterpret_cast<CollectorBlock*>(reinterpret_cast<uintptr_t>(cell) & BLOCK_MASK);
-    }
-
-    inline size_t Heap::cellOffset(const JSCell* cell)
-    {
-        return (reinterpret_cast<uintptr_t>(cell) & BLOCK_OFFSET_MASK) / CELL_SIZE;
-    }
-
     inline bool Heap::isCellMarked(const JSCell* cell)
     {
-        return cellBlock(cell)->marked.get(cellOffset(cell));
+        return MarkedSpace::isCellMarked(cell);
     }
 
     inline bool Heap::checkMarkCell(const JSCell* cell)
     {
-        return cellBlock(cell)->marked.getset(cellOffset(cell));
+        return MarkedSpace::checkMarkCell(cell);
     }
 
     inline void Heap::markCell(JSCell* cell)
     {
-        cellBlock(cell)->marked.set(cellOffset(cell));
+        MarkedSpace::markCell(cell);
     }
 
     inline void Heap::reportExtraMemoryCost(size_t cost)
@@ -296,6 +159,7 @@ namespace JSC {
     {
         return static_cast<WeakGCHandlePool*>(m_weakGCHandlePools[index].base());
     }
+
 } // namespace JSC
 
-#endif /* Heap_h */
+#endif // Heap_h
index cee781d..95f4efa 100644 (file)
@@ -63,6 +63,7 @@ namespace JSC {
         friend class JSAPIValueWrapper;
         friend class JSZombie;
         friend class JSGlobalData;
+        friend class MarkedSpace;
 
     private:
         explicit JSCell(Structure*);
@@ -362,7 +363,7 @@ namespace JSC {
 
     inline Heap* Heap::heap(JSCell* c)
     {
-        return cellBlock(c)->heap;
+        return MarkedSpace::cellBlock(c)->heap;
     }
     
 #if ENABLE(JSC_ZOMBIES)
index dc54f40..cad9662 100644 (file)
@@ -763,8 +763,7 @@ namespace JSC {
         return asValue() == jsNull();
     }
 #endif // USE(JSVALUE32_64)
-    
-    typedef std::pair<JSValue, UString> ValueStringPair;
+
 } // namespace JSC
 
 #endif // JSValue_h
diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.cpp b/Source/JavaScriptCore/runtime/MarkedSpace.cpp
new file mode 100644 (file)
index 0000000..4bc3c18
--- /dev/null
@@ -0,0 +1,367 @@
+/*
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Eric Seidel <eric@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 "CollectorHeapIterator.h"
+#include "JSCell.h"
+#include "JSGlobalData.h"
+#include "JSLock.h"
+
+using std::max;
+
+namespace JSC {
+
+class Structure;
+
+// tunable parameters
+
+const size_t GROWTH_FACTOR = 2;
+const size_t LOW_WATER_FACTOR = 4;
+const size_t ALLOCATIONS_PER_COLLECTION = 3600;
+// This value has to be a macro to be used in max() without introducing
+// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
+#define MIN_ARRAY_SIZE (static_cast<size_t>(14))
+
+MarkedSpace::MarkedSpace(JSGlobalData* globalData)
+    : m_globalData(globalData)
+{
+    memset(&m_heap, 0, sizeof(CollectorHeap));
+    allocateBlock();
+}
+
+void MarkedSpace::destroy(ProtectCountSet& protectedValuesCopy)
+{
+    clearMarkBits();
+    ProtectCountSet::iterator protectedValuesEnd = protectedValuesCopy.end();
+    for (ProtectCountSet::iterator it = protectedValuesCopy.begin(); it != protectedValuesEnd; ++it)
+        markCell(it->first);
+
+    m_heap.nextCell = 0;
+    m_heap.nextBlock = 0;
+    DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
+    DeadObjectIterator end(m_heap, m_heap.usedBlocks);
+    for ( ; it != end; ++it)
+        (*it)->~JSCell();
+
+    protectedValuesEnd = protectedValuesCopy.end();
+    for (ProtectCountSet::iterator it = protectedValuesCopy.begin(); it != protectedValuesEnd; ++it)
+        it->first->~JSCell();
+
+    for (size_t block = 0; block < m_heap.usedBlocks; ++block)
+        m_heap.blocks[block].deallocate();
+
+    fastFree(m_heap.blocks);
+
+    memset(&m_heap, 0, sizeof(CollectorHeap));
+}
+
+NEVER_INLINE CollectorBlock* MarkedSpace::allocateBlock()
+{
+    PageAllocationAligned allocation = PageAllocationAligned::allocate(BLOCK_SIZE, BLOCK_SIZE, OSAllocator::JSGCHeapPages);
+    CollectorBlock* block = static_cast<CollectorBlock*>(allocation.base());
+    if (!block)
+        CRASH();
+
+    // Initialize block.
+
+    block->heap = &globalData()->heap;
+    clearMarkBits(block);
+
+    Structure* dummyMarkableCellStructure = globalData()->dummyMarkableCellStructure.get();
+    for (size_t i = 0; i < HeapConstants::cellsPerBlock; ++i)
+        new (&block->cells[i]) JSCell(dummyMarkableCellStructure);
+    
+    // Add block to blocks vector.
+
+    size_t numBlocks = m_heap.numBlocks;
+    if (m_heap.usedBlocks == numBlocks) {
+        static const size_t maxNumBlocks = ULONG_MAX / sizeof(PageAllocationAligned) / GROWTH_FACTOR;
+        if (numBlocks > maxNumBlocks)
+            CRASH();
+        numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR);
+        m_heap.numBlocks = numBlocks;
+        m_heap.blocks = static_cast<PageAllocationAligned*>(fastRealloc(m_heap.blocks, numBlocks * sizeof(PageAllocationAligned)));
+    }
+    m_heap.blocks[m_heap.usedBlocks++] = allocation;
+
+    return block;
+}
+
+NEVER_INLINE void MarkedSpace::freeBlock(size_t block)
+{
+    m_heap.didShrink = true;
+
+    ObjectIterator it(m_heap, block);
+    ObjectIterator end(m_heap, block + 1);
+    for ( ; it != end; ++it)
+        (*it)->~JSCell();
+    m_heap.blocks[block].deallocate();
+
+    // swap with the last block so we compact as we go
+    m_heap.blocks[block] = m_heap.blocks[m_heap.usedBlocks - 1];
+    m_heap.usedBlocks--;
+
+    if (m_heap.numBlocks > MIN_ARRAY_SIZE && m_heap.usedBlocks < m_heap.numBlocks / LOW_WATER_FACTOR) {
+        m_heap.numBlocks = m_heap.numBlocks / GROWTH_FACTOR; 
+        m_heap.blocks = static_cast<PageAllocationAligned*>(fastRealloc(m_heap.blocks, m_heap.numBlocks * sizeof(PageAllocationAligned)));
+    }
+}
+
+void* MarkedSpace::allocate(size_t s)
+{
+    ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
+    typedef HeapConstants::Block Block;
+    typedef HeapConstants::Cell Cell;
+    
+    ASSERT(JSLock::lockCount() > 0);
+    ASSERT(JSLock::currentThreadIsHoldingLock());
+    ASSERT_UNUSED(s, s <= HeapConstants::cellSize);
+
+    // Fast case: find the next garbage cell and recycle it.
+
+    do {
+        ASSERT(m_heap.nextBlock < m_heap.usedBlocks);
+        Block* block = m_heap.collectorBlock(m_heap.nextBlock);
+        do {
+            ASSERT(m_heap.nextCell < HeapConstants::cellsPerBlock);
+            if (!block->marked.get(m_heap.nextCell)) { // Always false for the last cell in the block
+                Cell* cell = &block->cells[m_heap.nextCell];
+
+                JSCell* imp = reinterpret_cast<JSCell*>(cell);
+                imp->~JSCell();
+
+                ++m_heap.nextCell;
+                return cell;
+            }
+            block->marked.advanceToNextPossibleFreeCell(m_heap.nextCell);
+        } while (m_heap.nextCell != HeapConstants::cellsPerBlock);
+        m_heap.nextCell = 0;
+    } while (++m_heap.nextBlock != m_heap.usedBlocks);
+    
+    return 0;
+}
+
+void MarkedSpace::resizeBlocks()
+{
+    m_heap.didShrink = false;
+
+    size_t usedCellCount = markedCells();
+    size_t minCellCount = usedCellCount + max(ALLOCATIONS_PER_COLLECTION, usedCellCount);
+    size_t minBlockCount = (minCellCount + HeapConstants::cellsPerBlock - 1) / HeapConstants::cellsPerBlock;
+
+    size_t maxCellCount = 1.25f * minCellCount;
+    size_t maxBlockCount = (maxCellCount + HeapConstants::cellsPerBlock - 1) / HeapConstants::cellsPerBlock;
+
+    if (m_heap.usedBlocks < minBlockCount)
+        growBlocks(minBlockCount);
+    else if (m_heap.usedBlocks > maxBlockCount)
+        shrinkBlocks(maxBlockCount);
+}
+
+void MarkedSpace::growBlocks(size_t neededBlocks)
+{
+    ASSERT(m_heap.usedBlocks < neededBlocks);
+    while (m_heap.usedBlocks < neededBlocks)
+        allocateBlock();
+}
+
+void MarkedSpace::shrinkBlocks(size_t neededBlocks)
+{
+    ASSERT(m_heap.usedBlocks > neededBlocks);
+    
+    // Clear the always-on last bit, so isEmpty() isn't fooled by it.
+    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
+        m_heap.collectorBlock(i)->marked.clear(HeapConstants::cellsPerBlock - 1);
+
+    for (size_t i = 0; i != m_heap.usedBlocks && m_heap.usedBlocks != neededBlocks; ) {
+        if (m_heap.collectorBlock(i)->marked.isEmpty()) {
+            freeBlock(i);
+        } else
+            ++i;
+    }
+
+    // Reset the always-on last bit.
+    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
+        m_heap.collectorBlock(i)->marked.set(HeapConstants::cellsPerBlock - 1);
+}
+
+inline bool isPointerAligned(void* p)
+{
+    return (((intptr_t)(p) & (sizeof(char*) - 1)) == 0);
+}
+
+// Cell size needs to be a power of two for isPossibleCell to be valid.
+COMPILE_ASSERT(sizeof(CollectorCell) % 2 == 0, Collector_cell_size_is_power_of_two);
+
+static inline bool isCellAligned(void *p)
+{
+    return (((intptr_t)(p) & CELL_MASK) == 0);
+}
+
+static inline bool isPossibleCell(void* p)
+{
+    return isCellAligned(p) && p;
+}
+
+void MarkedSpace::markConservatively(MarkStack& markStack, void* start, void* end)
+{
+#if OS(WINCE)
+    if (start > end) {
+        void* tmp = start;
+        start = end;
+        end = tmp;
+    }
+#else
+    ASSERT(start <= end);
+#endif
+
+    ASSERT((static_cast<char*>(end) - static_cast<char*>(start)) < 0x1000000);
+    ASSERT(isPointerAligned(start));
+    ASSERT(isPointerAligned(end));
+
+    char** p = static_cast<char**>(start);
+    char** e = static_cast<char**>(end);
+
+    while (p != e) {
+        char* x = *p++;
+        if (isPossibleCell(x)) {
+            size_t usedBlocks;
+            uintptr_t xAsBits = reinterpret_cast<uintptr_t>(x);
+            xAsBits &= CELL_ALIGN_MASK;
+
+            uintptr_t offset = xAsBits & BLOCK_OFFSET_MASK;
+            const size_t lastCellOffset = sizeof(CollectorCell) * (CELLS_PER_BLOCK - 1);
+            if (offset > lastCellOffset)
+                continue;
+
+            CollectorBlock* blockAddr = reinterpret_cast<CollectorBlock*>(xAsBits - offset);
+            usedBlocks = m_heap.usedBlocks;
+            for (size_t block = 0; block < usedBlocks; block++) {
+                if (m_heap.collectorBlock(block) != blockAddr)
+                    continue;
+                markStack.append(reinterpret_cast<JSCell*>(xAsBits));
+            }
+        }
+    }
+}
+
+void MarkedSpace::clearMarkBits()
+{
+    for (size_t i = 0; i < m_heap.usedBlocks; ++i)
+        clearMarkBits(m_heap.collectorBlock(i));
+}
+
+void MarkedSpace::clearMarkBits(CollectorBlock* block)
+{
+    // allocate assumes that the last cell in every block is marked.
+    block->marked.clearAll();
+    block->marked.set(HeapConstants::cellsPerBlock - 1);
+}
+
+size_t MarkedSpace::markedCells(size_t startBlock, size_t startCell) const
+{
+    ASSERT(startBlock <= m_heap.usedBlocks);
+    ASSERT(startCell < HeapConstants::cellsPerBlock);
+
+    if (startBlock >= m_heap.usedBlocks)
+        return 0;
+
+    size_t result = 0;
+    result += m_heap.collectorBlock(startBlock)->marked.count(startCell);
+    for (size_t i = startBlock + 1; i < m_heap.usedBlocks; ++i)
+        result += m_heap.collectorBlock(i)->marked.count();
+
+    return result;
+}
+
+void MarkedSpace::sweep()
+{
+#if !ENABLE(JSC_ZOMBIES)
+    Structure* dummyMarkableCellStructure = globalData()->dummyMarkableCellStructure.get();
+#endif
+
+    DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
+    DeadObjectIterator end(m_heap, m_heap.usedBlocks);
+    for ( ; it != end; ++it) {
+        JSCell* cell = *it;
+#if ENABLE(JSC_ZOMBIES)
+        if (!cell->isZombie()) {
+            const ClassInfo* info = cell->classInfo();
+            cell->~JSCell();
+            new (cell) JSZombie(info, JSZombie::leakedZombieStructure());
+            Heap::markCell(cell);
+        }
+#else
+        cell->~JSCell();
+        // Callers of sweep assume it's safe to mark any cell in the heap.
+        new (cell) JSCell(dummyMarkableCellStructure);
+#endif
+    }
+}
+
+size_t MarkedSpace::objectCount() const
+{
+    return m_heap.nextBlock * HeapConstants::cellsPerBlock // allocated full blocks
+           + m_heap.nextCell // allocated cells in current block
+           + markedCells(m_heap.nextBlock, m_heap.nextCell) // marked cells in remainder of m_heap
+           - m_heap.usedBlocks; // 1 cell per block is a dummy sentinel
+}
+
+void MarkedSpace::addToStatistics(Statistics& statistics) const
+{
+    statistics.size += m_heap.usedBlocks * BLOCK_SIZE;
+    statistics.free += m_heap.usedBlocks * BLOCK_SIZE - (objectCount() * HeapConstants::cellSize);
+}
+
+MarkedSpace::Statistics MarkedSpace::statistics() const
+{
+    Statistics statistics = { 0, 0 };
+    addToStatistics(statistics);
+    return statistics;
+}
+
+size_t MarkedSpace::size() const
+{
+    return m_heap.usedBlocks * BLOCK_SIZE;
+}
+
+void MarkedSpace::reset()
+{
+    m_heap.nextCell = 0;
+    m_heap.nextBlock = 0;
+#if ENABLE(JSC_ZOMBIES)
+    sweep();
+#endif
+    resizeBlocks();
+}
+
+LiveObjectIterator MarkedSpace::primaryHeapBegin()
+{
+    return LiveObjectIterator(m_heap, 0);
+}
+
+LiveObjectIterator MarkedSpace::primaryHeapEnd()
+{
+    return LiveObjectIterator(m_heap, m_heap.usedBlocks);
+}
+
+} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/MarkedSpace.h b/Source/JavaScriptCore/runtime/MarkedSpace.h
new file mode 100644 (file)
index 0000000..78f918c
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 "PageAllocationAligned.h"
+#include <wtf/FixedArray.h>
+#include <wtf/HashCountedSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+    class CollectorBlock;
+    class Heap;
+    class JSCell;
+    class JSGlobalData;
+    class LiveObjectIterator;
+    class MarkStack;
+    class WeakGCHandle;
+
+#if OS(WINCE) || OS(SYMBIAN) || PLATFORM(BREWMP)
+    const size_t BLOCK_SIZE = 64 * 1024; // 64k
+#else
+    const size_t BLOCK_SIZE = 256 * 1024; // 256k
+#endif
+
+    typedef HashCountedSet<JSCell*> ProtectCountSet;
+
+    struct CollectorHeap {
+        size_t nextBlock;
+        size_t nextCell;
+        PageAllocationAligned* blocks;
+        
+        size_t numBlocks;
+        size_t usedBlocks;
+
+        bool didShrink;
+
+        CollectorBlock* collectorBlock(size_t index) const
+        {
+            return static_cast<CollectorBlock*>(blocks[index].base());
+        }
+    };
+
+    class MarkedSpace : public Noncopyable {
+    public:
+        MarkedSpace(JSGlobalData*);
+        void destroy(ProtectCountSet&);
+
+        void* allocate(size_t);
+
+        size_t objectCount() const;
+        struct Statistics {
+            size_t size;
+            size_t free;
+        };
+        Statistics statistics() const;
+        size_t size() const;
+
+        static Heap* heap(JSCell*);
+
+        static bool isCellMarked(const JSCell*);
+        static bool checkMarkCell(const JSCell*);
+        static void markCell(JSCell*);
+
+        WeakGCHandle* addWeakGCHandle(JSCell*);
+
+        void markConservatively(MarkStack&, void* start, void* end);
+
+        static bool isNumber(JSCell*);
+        
+        LiveObjectIterator primaryHeapBegin();
+        LiveObjectIterator primaryHeapEnd();
+
+        JSGlobalData* globalData() { return m_globalData; }
+
+        static CollectorBlock* cellBlock(const JSCell*);
+        static size_t cellOffset(const JSCell*);
+
+        void reset();
+        void sweep();
+
+        NEVER_INLINE CollectorBlock* allocateBlock();
+        NEVER_INLINE void freeBlock(size_t);
+        void resizeBlocks();
+        void growBlocks(size_t neededBlocks);
+        void shrinkBlocks(size_t neededBlocks);
+        void clearMarkBits();
+        void clearMarkBits(CollectorBlock*);
+        size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
+
+        void addToStatistics(Statistics&) const;
+
+        void markRoots();
+
+        bool didShrink() { return m_heap.didShrink; }
+        
+    private:
+        CollectorHeap m_heap;
+        JSGlobalData* m_globalData;
+    };
+
+    // tunable parameters
+    // derived constants
+    const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1;
+    const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK;
+    const size_t MINIMUM_CELL_SIZE = 64;
+    const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0);
+    const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double);
+    const size_t SMALL_CELL_SIZE = CELL_SIZE / 2;
+    const size_t CELL_MASK = CELL_SIZE - 1;
+    const size_t CELL_ALIGN_MASK = ~CELL_MASK;
+    const size_t CELLS_PER_BLOCK = (BLOCK_SIZE - sizeof(MarkedSpace*)) * 8 * CELL_SIZE / (8 * CELL_SIZE + 1) / CELL_SIZE; // one bitmap byte can represent 8 cells.
+    
+    const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8;
+    const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t);
+
+    struct CollectorBitmap {
+        FixedArray<uint32_t, BITMAP_WORDS> bits;
+        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } 
+        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } 
+        bool getset(size_t n)
+        {
+            unsigned i = (1 << (n & 0x1F));
+            uint32_t& b = bits[n >> 5];
+            bool r = !!(b & i);
+            b |= i;
+            return r;
+        } 
+        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } 
+        void clearAll() { memset(bits.data(), 0, sizeof(bits)); }
+        ALWAYS_INLINE void advanceToNextPossibleFreeCell(size_t& startCell)
+        {
+            if (!~bits[startCell >> 5])
+                startCell = (startCell & (~0x1F)) + 32;
+            else
+                ++startCell;
+        }
+        size_t count(size_t startCell = 0)
+        {
+            size_t result = 0;
+            for ( ; (startCell & 0x1F) != 0; ++startCell) {
+                if (get(startCell))
+                    ++result;
+            }
+            for (size_t i = startCell >> 5; i < BITMAP_WORDS; ++i)
+                result += WTF::bitCount(bits[i]);
+            return result;
+        }
+        size_t isEmpty() // Much more efficient than testing count() == 0.
+        {
+            for (size_t i = 0; i < BITMAP_WORDS; ++i)
+                if (bits[i] != 0)
+                    return false;
+            return true;
+        }
+    };
+  
+    struct CollectorCell {
+        FixedArray<double, CELL_ARRAY_LENGTH> memory;
+    };
+
+    class CollectorBlock {
+    public:
+        FixedArray<CollectorCell, CELLS_PER_BLOCK> cells;
+        CollectorBitmap marked;
+        Heap* heap;
+    };
+
+    struct HeapConstants {
+        static const size_t cellSize = CELL_SIZE;
+        static const size_t cellsPerBlock = CELLS_PER_BLOCK;
+        typedef CollectorCell Cell;
+        typedef CollectorBlock Block;
+    };
+
+    inline CollectorBlock* MarkedSpace::cellBlock(const JSCell* cell)
+    {
+        return reinterpret_cast<CollectorBlock*>(reinterpret_cast<uintptr_t>(cell) & BLOCK_MASK);
+    }
+
+    inline size_t MarkedSpace::cellOffset(const JSCell* cell)
+    {
+        return (reinterpret_cast<uintptr_t>(cell) & BLOCK_OFFSET_MASK) / CELL_SIZE;
+    }
+
+    inline bool MarkedSpace::isCellMarked(const JSCell* cell)
+    {
+        return cellBlock(cell)->marked.get(cellOffset(cell));
+    }
+
+    inline bool MarkedSpace::checkMarkCell(const JSCell* cell)
+    {
+        return cellBlock(cell)->marked.getset(cellOffset(cell));
+    }
+
+    inline void MarkedSpace::markCell(JSCell* cell)
+    {
+        cellBlock(cell)->marked.set(cellOffset(cell));
+    }
+
+} // namespace JSC
+
+#endif // MarkedSpace_h
index 7fafa9c..06a319b 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace JSC {
 
-Heap::Statistics heapStatistics(JSGlobalData* commonGlobalData)
+MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData)
 {
     return commonGlobalData->heap.statistics();
 }        
index e801916..2659702 100644 (file)
@@ -37,7 +37,7 @@ struct GlobalMemoryStatistics {
     size_t JITBytes;
 };
 
-Heap::Statistics heapStatistics(JSGlobalData* commonGlobalData);
+MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData);
 GlobalMemoryStatistics globalMemoryStatistics();
 
 }
index 7fb3d52..59854e0 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-13  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Split out a MarkedSpace strategy object from Heap.
+        https://bugs.webkit.org/show_bug.cgi?id=52421
+
+        * Misc/WebCoreStatistics.mm:
+        (+[WebCoreStatistics memoryStatistics]): Updated for class move.
+
 2011-01-14  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Simon Fraser.
index 5b5a1bc..5d96c95 100644 (file)
@@ -197,7 +197,7 @@ using namespace WebCore;
     WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
     
     JSLock lock(SilenceAssertionsOnly);
-    Heap::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
+    MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
     GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
     
     return [NSDictionary dictionaryWithObjectsAndKeys:
index 4e44c7e..68b7db5 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-13  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Split out a MarkedSpace strategy object from Heap.
+        https://bugs.webkit.org/show_bug.cgi?id=52421
+
+        * Shared/mac/WebMemorySampler.mac.mm:
+        (WebKit::WebMemorySampler::sampleWebKit): Updated for class move.
+
 2011-01-14  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Dan Bernstein.
index 2b8e0b3..5be52d4 100644 (file)
@@ -115,7 +115,7 @@ WebMemoryStatistics WebMemorySampler::sampleWebKit() const
     totalBytesCommitted += fastMallocBytesCommitted;
     
     JSLock lock(SilenceAssertionsOnly);
-    Heap::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
+    MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
     size_t jscHeapBytesInUse = heapMemoryStats.size - heapMemoryStats.free;
     size_t jscHeapBytesCommitted = heapMemoryStats.size;
     totalBytesInUse += jscHeapBytesInUse;