Commit 90bfc79c authored by mrowe@apple.com's avatar mrowe@apple.com
Browse files

2008-06-26 Mark Rowe <mrowe@apple.com>

        Reviewed by Darin Adler and Geoff Garen.

        Fix the malloc zone introspection functions so that malloc_zone_statistics does not give
        bogus output in an application that uses JavaScriptCore.

        * kjs/CollectorHeapIntrospector.cpp:
        (KJS::CollectorHeapIntrospector::statistics): Return statistics about memory allocated by the collector.
        * kjs/CollectorHeapIntrospector.h:
        * wtf/FastMalloc.cpp: Zero out the statistics.  FastMalloc doesn't track this information at present.
        Returning zero for all values is preferable to returning bogus data.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34824 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6e5aa3f8
2008-06-26 Mark Rowe <mrowe@apple.com>
Reviewed by Darin Adler and Geoff Garen.
Fix the malloc zone introspection functions so that malloc_zone_statistics does not give
bogus output in an application that uses JavaScriptCore.
* kjs/CollectorHeapIntrospector.cpp:
(KJS::CollectorHeapIntrospector::statistics): Return statistics about memory allocated by the collector.
* kjs/CollectorHeapIntrospector.h:
* wtf/FastMalloc.cpp: Zero out the statistics. FastMalloc doesn't track this information at present.
Returning zero for all values is preferable to returning bogus data.
2008-06-26 Darin Adler <darin@apple.com>
 
Reviewed by Geoff.
......
......@@ -93,4 +93,16 @@ kern_return_t CollectorHeapIntrospector::enumerate(task_t task, void* context, u
return 0;
}
void CollectorHeapIntrospector::statistics(malloc_zone_t* zone, malloc_statistics_t* stats)
{
JSLock lock;
CollectorHeapIntrospector* introspector = reinterpret_cast<CollectorHeapIntrospector*>(zone);
CollectorHeap* primaryHeap = introspector->m_primaryHeap;
CollectorHeap* numberHeap = introspector->m_numberHeap;
stats->blocks_in_use = primaryHeap->usedBlocks + numberHeap->usedBlocks;
stats->size_in_use = primaryHeap->usedBlocks * BLOCK_SIZE + numberHeap->usedBlocks * BLOCK_SIZE;
stats->max_size_in_use = stats->size_in_use;
stats->size_allocated = primaryHeap->numBlocks * BLOCK_SIZE + numberHeap->numBlocks * BLOCK_SIZE;
}
} // namespace KJS
......@@ -46,7 +46,7 @@ public:
static void log(malloc_zone_t*, void*) { }
static void forceLock(malloc_zone_t*) { }
static void forceUnlock(malloc_zone_t*) { }
static void statistics(malloc_zone_t*, malloc_statistics_t*) { }
static void statistics(malloc_zone_t*, malloc_statistics_t*);
private:
CollectorHeapIntrospector(CollectorHeap*, CollectorHeap*);
......
......@@ -297,7 +297,7 @@ public:
static void log(malloc_zone_t*, void*) { }
static void forceLock(malloc_zone_t*) { }
static void forceUnlock(malloc_zone_t*) { }
static void statistics(malloc_zone_t*, malloc_statistics_t*) { }
static void statistics(malloc_zone_t*, malloc_statistics_t* stats) { memset(stats, 0, sizeof(malloc_statistics_t)); }
private:
FastMallocZone(TCMalloc_PageHeap*, TCMalloc_ThreadCache**, TCMalloc_Central_FreeListPadded*);
......
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