Commit 07050262 authored by ggaren@apple.com's avatar ggaren@apple.com

2011-01-28 Geoffrey Garen <ggaren@apple.com>

        Reviewed by Maciej Stachowiak.

        Some more Heap cleanup.
        https://bugs.webkit.org/show_bug.cgi?id=53357
        
        * JavaScriptCore.exp:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Updated exported symbols.

        * runtime/Heap.cpp:
        (JSC::Heap::reportExtraMemoryCostSlowCase): Renamed recordExtraCost to 
        reportExtraMemoryCostSlowCase to match our naming conventions.

        (JSC::Heap::capacity): Renamed size to capacity because this function
        returns the capacity of the heap, including unused portions.

        * runtime/Heap.h:
        (JSC::Heap::globalData):
        (JSC::Heap::markedSpace):
        (JSC::Heap::machineStackMarker):
        (JSC::Heap::reportExtraMemoryCost): Moved statics to the top of the file.
        Moved ctor and dtor to the beginning of the class definition. Grouped
        functions by purpose.

        * runtime/MarkedSpace.cpp:
        (JSC::MarkedSpace::capacity): Renamed size to capacity because this
        function returns the capacity of the heap, including unused portions.

        * runtime/MarkedSpace.h: Removed statistics and the Statistics class because
        the same information can be gotten just by calling size() and capacity().

        * runtime/MemoryStatistics.cpp:
        * runtime/MemoryStatistics.h: Ditto.
2011-01-28  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Maciej Stachowiak.

        Some more Heap cleanup.
        https://bugs.webkit.org/show_bug.cgi?id=53357

        Updated for JavaScriptCore changes.

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

        Reviewed by Maciej Stachowiak.

        Some more Heap cleanup.
        https://bugs.webkit.org/show_bug.cgi?id=53357
        
        Updated for JavaScriptCore changes.

        * bindings/js/ScriptGCEvent.cpp:
        (WebCore::ScriptGCEvent::getHeapSize):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77077 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent efee1173
2011-01-28 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej Stachowiak.
Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Updated exported symbols.
* runtime/Heap.cpp:
(JSC::Heap::reportExtraMemoryCostSlowCase): Renamed recordExtraCost to
reportExtraMemoryCostSlowCase to match our naming conventions.
(JSC::Heap::capacity): Renamed size to capacity because this function
returns the capacity of the heap, including unused portions.
* runtime/Heap.h:
(JSC::Heap::globalData):
(JSC::Heap::markedSpace):
(JSC::Heap::machineStackMarker):
(JSC::Heap::reportExtraMemoryCost): Moved statics to the top of the file.
Moved ctor and dtor to the beginning of the class definition. Grouped
functions by purpose.
* runtime/MarkedSpace.cpp:
(JSC::MarkedSpace::capacity): Renamed size to capacity because this
function returns the capacity of the heap, including unused portions.
* runtime/MarkedSpace.h: Removed statistics and the Statistics class because
the same information can be gotten just by calling size() and capacity().
* runtime/MemoryStatistics.cpp:
* runtime/MemoryStatistics.h: Ditto.
2011-01-29 Daniel Bates <dbates@rim.com>
Reviewed by Eric Seidel.
......
......@@ -166,7 +166,6 @@ __ZN3JSC14SamplingThread4stopEv
__ZN3JSC14SamplingThread5startEj
__ZN3JSC14TimeoutChecker10didTimeOutEPNS_9ExecStateE
__ZN3JSC14TimeoutChecker5resetEv
__ZN3JSC14heapStatisticsEPNS_12JSGlobalDataE
__ZN3JSC14throwTypeErrorEPNS_9ExecStateE
__ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
__ZN3JSC15createTypeErrorEPNS_9ExecStateERKNS_7UStringE
......@@ -210,7 +209,6 @@ __ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
__ZN3JSC3NaNE
__ZN3JSC4Heap14primaryHeapEndEv
__ZN3JSC4Heap15addWeakGCHandleEPNS_6JSCellE
__ZN3JSC4Heap15recordExtraCostEm
__ZN3JSC4Heap16objectTypeCountsEv
__ZN3JSC4Heap16primaryHeapBeginEv
__ZN3JSC4Heap17collectAllGarbageEv
......@@ -219,6 +217,7 @@ __ZN3JSC4Heap19setActivityCallbackEN3WTF10PassOwnPtrINS_18GCActivityCallbackEEE
__ZN3JSC4Heap20protectedObjectCountEv
__ZN3JSC4Heap25protectedObjectTypeCountsEv
__ZN3JSC4Heap26protectedGlobalObjectCountEv
__ZN3JSC4Heap29reportExtraMemoryCostSlowCaseEm
__ZN3JSC4Heap6isBusyEv
__ZN3JSC4Heap7destroyEv
__ZN3JSC4Heap7protectENS_7JSValueE
......@@ -519,9 +518,9 @@ __ZNK3JSC18PropertyDescriptor6setterEv
__ZNK3JSC18PropertyDescriptor8writableEv
__ZNK3JSC19SourceProviderCache8byteSizeEv
__ZNK3JSC24JSObjectWithGlobalObject12globalObjectEv
__ZNK3JSC4Heap10statisticsEv
__ZNK3JSC4Heap11objectCountEv
__ZNK3JSC4Heap4sizeEv
__ZNK3JSC4Heap8capacityEv
__ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
__ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE
__ZNK3JSC6JSCell14isGetterSetterEv
......
......@@ -70,6 +70,7 @@ EXPORTS
?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
?callOnMainThreadAndWait@WTF@@YAXP6AXPAX@Z0@Z
?cancelCallOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
?capacity@Heap@JSC@@QBEIXZ
?changePrototypeTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@VJSValue@2@@Z
?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z
?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVJSGlobalData@2@@Z
......@@ -267,10 +268,10 @@ EXPORTS
?putWithAttributes@JSObject@JSC@@UAEXPAVJSGlobalData@2@IVJSValue@2@I@Z
?randomNumber@WTF@@YANXZ
?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z
?recordExtraCost@Heap@JSC@@AAEXI@Z
?reifyString@StringBuilder@WTF@@AAEXXZ
?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z
?releaseStack@MarkStack@JSC@@CAXPAXI@Z
?reportExtraMemoryCostSlowCase@Heap@JSC@@AAEXI@Z
?reserveAndCommit@OSAllocator@WTF@@SAPAXIW4Usage@12@_N1@Z
?reset@ParserArena@JSC@@QAEXXZ
?reset@TimeoutChecker@JSC@@QAEXXZ
......
......@@ -79,7 +79,7 @@ void Heap::destroy()
m_globalData = 0;
}
void Heap::recordExtraCost(size_t cost)
void Heap::reportExtraMemoryCostSlowCase(size_t cost)
{
// Our frequency of garbage collection tries to balance memory use against speed
// by collecting based on the number of newly created values. However, for values
......@@ -92,7 +92,7 @@ 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_extraCost > maxExtraCost && m_extraCost > m_markedSpace.size() / 2) {
if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.capacity() / 2) {
JAVASCRIPTCORE_GC_BEGIN();
markRoots();
......@@ -302,14 +302,14 @@ size_t Heap::objectCount() const
return m_markedSpace.objectCount();
}
MarkedSpace::Statistics Heap::statistics() const
size_t Heap::size() const
{
return m_markedSpace.statistics();
return m_markedSpace.size();
}
size_t Heap::size() const
size_t Heap::capacity() const
{
return m_markedSpace.size();
return m_markedSpace.capacity();
}
size_t Heap::globalObjectCount()
......
......@@ -50,45 +50,44 @@ namespace JSC {
class Heap {
WTF_MAKE_NONCOPYABLE(Heap);
public:
void destroy();
static Heap* heap(JSValue); // 0 for immediate values
static Heap* heap(JSCell*);
void* allocate(size_t);
static bool isCellMarked(const JSCell*);
static bool checkMarkCell(const JSCell*);
static void markCell(JSCell*);
Heap(JSGlobalData*);
~Heap();
void destroy(); // JSGlobalData must call destroy() before ~Heap().
bool isBusy(); // true if an allocation or collection is in progress
void collectAllGarbage();
JSGlobalData* globalData() const { return m_globalData; }
MarkedSpace& markedSpace() { return m_markedSpace; }
MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
GCActivityCallback* activityCallback();
void setActivityCallback(PassOwnPtr<GCActivityCallback>);
static const size_t minExtraCost = 256;
static const size_t maxExtraCost = 1024 * 1024;
bool isBusy(); // true if an allocation or collection is in progress
void* allocate(size_t);
void collectAllGarbage();
void reportExtraMemoryCost(size_t cost);
size_t objectCount() const;
MarkedSpace::Statistics statistics() const;
size_t size() const;
void protect(JSValue);
// Returns true if the value is no longer protected by any protect pointers
// (though it may still be alive due to heap/stack references).
bool unprotect(JSValue);
bool unprotect(JSValue); // True when the protect count drops to 0.
static Heap* heap(JSValue); // 0 for immediate values
static Heap* heap(JSCell*);
bool contains(void*);
size_t size() const;
size_t capacity() const;
size_t objectCount() const;
size_t globalObjectCount();
size_t protectedObjectCount();
size_t protectedGlobalObjectCount();
HashCountedSet<const char*>* protectedObjectTypeCounts();
HashCountedSet<const char*>* objectTypeCounts();
static bool isCellMarked(const JSCell*);
static bool checkMarkCell(const JSCell*);
static void markCell(JSCell*);
bool contains(void*);
WeakGCHandle* addWeakGCHandle(JSCell*);
void pushTempSortVector(WTF::Vector<ValueStringPair>*);
......@@ -96,21 +95,16 @@ namespace JSC {
HashSet<MarkedArgumentBuffer*>& markListSet() { if (!m_markListSet) m_markListSet = new HashSet<MarkedArgumentBuffer*>; return *m_markListSet; }
JSGlobalData* globalData() const { return m_globalData; }
LiveObjectIterator primaryHeapBegin();
LiveObjectIterator primaryHeapEnd();
MachineStackMarker& machineStackMarker() { return m_machineStackMarker; }
MarkedSpace& markedSpace() { return m_markedSpace; }
private:
friend class JSGlobalData;
Heap(JSGlobalData*);
~Heap();
void recordExtraCost(size_t);
static const size_t minExtraCost = 256;
static const size_t maxExtraCost = 1024 * 1024;
void reportExtraMemoryCostSlowCase(size_t);
void markRoots();
void markProtectedObjects(MarkStack&);
......@@ -163,7 +157,7 @@ namespace JSC {
inline void Heap::reportExtraMemoryCost(size_t cost)
{
if (cost > minExtraCost)
recordExtraCost(cost);
reportExtraMemoryCostSlowCase(cost);
}
inline WeakGCHandlePool* Heap::weakGCHandlePool(size_t index)
......
......@@ -295,20 +295,12 @@ size_t MarkedSpace::objectCount() const
- 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
size_t MarkedSpace::size() const
{
Statistics statistics = { 0, 0 };
addToStatistics(statistics);
return statistics;
return objectCount() * HeapConstants::cellSize;
}
size_t MarkedSpace::size() const
size_t MarkedSpace::capacity() const
{
return m_heap.usedBlocks * BLOCK_SIZE;
}
......
......@@ -64,11 +64,6 @@ namespace JSC {
class MarkedSpace {
WTF_MAKE_NONCOPYABLE(MarkedSpace);
public:
struct Statistics {
size_t size;
size_t free;
};
static Heap* heap(JSCell*);
static bool isCellMarked(const JSCell*);
......@@ -88,8 +83,8 @@ namespace JSC {
void sweep();
size_t size() const;
size_t capacity() const;
size_t objectCount() const;
Statistics statistics() const;
bool contains(void*);
......@@ -113,8 +108,6 @@ namespace JSC {
void clearMarkBits(CollectorBlock*);
size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
void addToStatistics(Statistics&) const;
CollectorHeap m_heap;
JSGlobalData* m_globalData;
};
......
......@@ -32,11 +32,6 @@
namespace JSC {
MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData)
{
return commonGlobalData->heap.statistics();
}
GlobalMemoryStatistics globalMemoryStatistics()
{
GlobalMemoryStatistics stats;
......
......@@ -37,7 +37,6 @@ struct GlobalMemoryStatistics {
size_t JITBytes;
};
MarkedSpace::Statistics heapStatistics(JSGlobalData* commonGlobalData);
GlobalMemoryStatistics globalMemoryStatistics();
}
......
2011-01-28 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej Stachowiak.
Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357
Updated for JavaScriptCore changes.
* bindings/js/ScriptGCEvent.cpp:
(WebCore::ScriptGCEvent::getHeapSize):
2011-01-29 Adam Barth <abarth@webkit.org>
Reviewed by Daniel Bates.
......@@ -45,9 +45,10 @@ using namespace JSC;
void ScriptGCEvent::getHeapSize(size_t& usedHeapSize, size_t& totalHeapSize)
{
JSGlobalData* globalData = JSDOMWindow::commonJSGlobalData();
totalHeapSize = globalData->heap.size();
totalHeapSize = globalData->heap.capacity();
usedHeapSize = totalHeapSize;
}
} // namespace WebCore
#endif // !ENABLE(INSPECTOR)
2011-01-28 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej Stachowiak.
Some more Heap cleanup.
https://bugs.webkit.org/show_bug.cgi?id=53357
Updated for JavaScriptCore changes.
* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics memoryStatistics]):
2011-01-28 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r77006 and r77020.
......
......@@ -197,15 +197,16 @@ using namespace WebCore;
WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
JSLock lock(SilenceAssertionsOnly);
MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
size_t heapSize = JSDOMWindow::commonJSGlobalData()->heap.size();
size_t heapFree = JSDOMWindow::commonJSGlobalData()->heap.capacity() - heapSize;
GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:fastMallocStatistics.reservedVMBytes], @"FastMallocReservedVMBytes",
[NSNumber numberWithInt:fastMallocStatistics.committedVMBytes], @"FastMallocCommittedVMBytes",
[NSNumber numberWithInt:fastMallocStatistics.freeListBytes], @"FastMallocFreeListBytes",
[NSNumber numberWithInt:heapMemoryStats.size], @"JavaScriptHeapSize",
[NSNumber numberWithInt:heapMemoryStats.free], @"JavaScriptFreeSize",
[NSNumber numberWithInt:heapSize], @"JavaScriptHeapSize",
[NSNumber numberWithInt:heapFree], @"JavaScriptFreeSize",
[NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.stackBytes], @"JavaScriptStackSize",
[NSNumber numberWithUnsignedInt:(unsigned int)globalMemoryStats.JITBytes], @"JavaScriptJITSize",
nil];
......
......@@ -116,9 +116,8 @@ WebMemoryStatistics WebMemorySampler::sampleWebKit() const
totalBytesCommitted += fastMallocBytesCommitted;
JSLock lock(SilenceAssertionsOnly);
MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
size_t jscHeapBytesInUse = heapMemoryStats.size - heapMemoryStats.free;
size_t jscHeapBytesCommitted = heapMemoryStats.size;
size_t jscHeapBytesInUse = JSDOMWindow::commonJSGlobalData()->heap.size();
size_t jscHeapBytesCommitted = JSDOMWindow::commonJSGlobalData()->heap.capacity();
totalBytesInUse += jscHeapBytesInUse;
totalBytesCommitted += jscHeapBytesCommitted;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment