Changeset 34824 in webkit


Ignore:
Timestamp:
Jun 26, 2008 9:32:47 PM (16 years ago)
Author:
mrowe@apple.com
Message:

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.
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r34821 r34824  
     12008-06-26  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler and Geoff Garen.
     4
     5        Fix the malloc zone introspection functions so that malloc_zone_statistics does not give
     6        bogus output in an application that uses JavaScriptCore.
     7
     8        * kjs/CollectorHeapIntrospector.cpp:
     9        (KJS::CollectorHeapIntrospector::statistics): Return statistics about memory allocated by the collector.
     10        * kjs/CollectorHeapIntrospector.h:
     11        * wtf/FastMalloc.cpp: Zero out the statistics.  FastMalloc doesn't track this information at present.
     12        Returning zero for all values is preferable to returning bogus data.
     13
    1142008-06-26  Darin Adler  <darin@apple.com>
    215
  • trunk/JavaScriptCore/kjs/CollectorHeapIntrospector.cpp

    r30576 r34824  
    9494}
    9595
     96void CollectorHeapIntrospector::statistics(malloc_zone_t* zone, malloc_statistics_t* stats)
     97{
     98    JSLock lock;
     99    CollectorHeapIntrospector* introspector = reinterpret_cast<CollectorHeapIntrospector*>(zone);
     100    CollectorHeap* primaryHeap = introspector->m_primaryHeap;
     101    CollectorHeap* numberHeap = introspector->m_numberHeap;
     102    stats->blocks_in_use = primaryHeap->usedBlocks + numberHeap->usedBlocks;
     103    stats->size_in_use = primaryHeap->usedBlocks * BLOCK_SIZE + numberHeap->usedBlocks * BLOCK_SIZE;
     104    stats->max_size_in_use = stats->size_in_use;
     105    stats->size_allocated = primaryHeap->numBlocks * BLOCK_SIZE + numberHeap->numBlocks * BLOCK_SIZE;
     106}
     107
    96108} // namespace KJS
  • trunk/JavaScriptCore/kjs/CollectorHeapIntrospector.h

    r29663 r34824  
    4747    static void forceLock(malloc_zone_t*) { }
    4848    static void forceUnlock(malloc_zone_t*) { }
    49     static void statistics(malloc_zone_t*, malloc_statistics_t*) { }
     49    static void statistics(malloc_zone_t*, malloc_statistics_t*);
    5050
    5151private:
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r34756 r34824  
    298298    static void forceLock(malloc_zone_t*) { }
    299299    static void forceUnlock(malloc_zone_t*) { }
    300     static void statistics(malloc_zone_t*, malloc_statistics_t*) { }
     300    static void statistics(malloc_zone_t*, malloc_statistics_t* stats) { memset(stats, 0, sizeof(malloc_statistics_t)); }
    301301
    302302private:
Note: See TracChangeset for help on using the changeset viewer.