Changeset 12559 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Feb 4, 2006, 3:29:43 PM (19 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Hyatt.



  • kjs/collector.cpp: (KJS::Collector::numProtectedObjects): renamed from numReferencedObjects (KJS::typeName): (KJS::Collector::rootObjectTypeCounts): renamed from rootObjectClasses, use HashSet
  • kjs/collector.h: (KJS::Collector::isOutOfMemory): Renamed from outOfMemory.
  • kjs/nodes.cpp:

WebCore:

Reviewed by Hyatt.

  • kwq/WebCoreJavaScript.h:
  • kwq/WebCoreJavaScript.mm: (+[WebCoreJavaScript protectedObjectCount]): Renamed from referencedObjectCounts (+[WebCoreJavaScript rootObjectTypeCounts]): Renamed from rootObjectClasses, changed from NSSet to NSCountedSet.

WebKit:

Reviewed by Hyatt.

  • Misc.subproj/WebCoreStatistics.h:
  • Misc.subproj/WebCoreStatistics.m: (+[WebCoreStatistics javaScriptProtectedObjectsCount]): new (+[WebCoreStatistics javaScriptRootObjecTypeCounts]): new (+[WebCoreStatistics javaScriptRootObjectClasses]): deprecated (+[WebCoreStatistics javaScriptReferencedObjectsCount]): deprecated (+[WebCoreStatistics javaScriptNoGCAllowedObjectsCount]): Just return 0. Deprecated.
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r12547 r12559  
     12006-02-04  Maciej Stachowiak  <[email protected]>
     2
     3        Reviewed by Hyatt.
     4       
     5        - change JavaScript collector statistics calls to use HashCountedSet instead
     6        of CFSet; other misc cleanup
     7        http://bugzilla.opendarwin.org/show_bug.cgi?id=7072
     8       
     9        * kjs/collector.cpp:
     10        (KJS::Collector::numProtectedObjects): renamed from numReferencedObjects
     11        (KJS::typeName):
     12        (KJS::Collector::rootObjectTypeCounts): renamed from rootObjectClasses,
     13        use HashSet
     14        * kjs/collector.h:
     15        (KJS::Collector::isOutOfMemory): Renamed from outOfMemory.
     16        * kjs/nodes.cpp:
     17
    1182006-02-03  Timothy Hatcher  <[email protected]>
    219
  • trunk/JavaScriptCore/kjs/collector.cpp

    r12329 r12559  
    1 // -*- c-basic-offset: 2 -*-
     1// -*- mode: c++; c-basic-offset: 4 -*-
    22/*
    33 *  This file is part of the KDE libraries
     
    3535#if __APPLE__
    3636
    37 #include <CoreFoundation/CoreFoundation.h>
    3837#include <pthread.h>
    3938#include <mach/mach_port.h>
     
    597596}
    598597
    599 size_t Collector::numGCNotAllowedObjects()
    600 {
    601   return 0;
    602 }
    603 
    604 size_t Collector::numReferencedObjects()
     598size_t Collector::numProtectedObjects()
    605599{
    606600  return protectedValues().size();
    607601}
    608602
    609 #if __APPLE__
    610 
    611 static const char *className(JSCell *val)
     603static const char *typeName(JSCell *val)
    612604{
    613605  const char *name = "???";
     
    642634}
    643635
    644 const void *Collector::rootObjectClasses()
    645 {
    646   // FIXME: this should be a HashSet (or maybe even CountedHashSet)
    647   CFMutableSetRef classes = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
    648 
    649   ProtectCounts& pv = protectedValues();
    650   ProtectCounts::iterator end = pv.end();
    651   for (ProtectCounts::iterator it = pv.begin(); it != end; ++it) {
    652     JSCell *val = it->first;
    653     CFStringRef name = CFStringCreateWithCString(NULL, className(val), kCFStringEncodingASCII);
    654     CFSetAddValue(classes, name);
    655     CFRelease(name);
    656   }
    657 
    658   return classes;
    659 }
    660 
    661 #endif
     636HashCountedSet<const char*>* Collector::rootObjectTypeCounts()
     637{
     638    HashCountedSet<const char*>* counts = new HashCountedSet<const char*>;
     639
     640    ProtectCounts& pv = protectedValues();
     641    ProtectCounts::iterator end = pv.end();
     642    for (ProtectCounts::iterator it = pv.begin(); it != end; ++it)
     643        counts->add(typeName(it->first));
     644
     645    return counts;
     646}
    662647
    663648} // namespace KJS
  • trunk/JavaScriptCore/kjs/collector.h

    r12317 r12559  
    2626
    2727#include "value.h"
     28#include <kxmlcore/HashCountedSet.h>
    2829
    2930#define KJS_MEM_LIMIT 500000
     
    3839    Collector();
    3940  public:
    40     /**
    41      * Register an object with the collector. The following assumptions are
    42      * made:
    43      * @li the operator new() of the object class is overloaded.
    44      * @li operator delete() has been overloaded as well and does not free
    45      * the memory on its own.
    46      *
    47      * @param s Size of the memory to be registered.
    48      * @return A pointer to the allocated memory.
    49      */
    5041    static void* allocate(size_t s);
    51     /**
    52      * Run the garbage collection. This involves calling the delete operator
    53      * on each object and freeing the used memory.
    54      */
    5542    static bool collect();
     43
    5644    static size_t size();
    57     static bool outOfMemory() { return memoryFull; }
     45    static bool isOutOfMemory() { return memoryFull; }
    5846
    5947#ifdef KJS_DEBUG_MEM
     
    6856
    6957    static size_t numInterpreters();
    70     static size_t numGCNotAllowedObjects();
    71     static size_t numReferencedObjects();
    72     static const void *rootObjectClasses(); // actually returns CFSetRef
     58    static size_t numProtectedObjects();
     59    static HashCountedSet<const char*>* rootObjectTypeCounts();
    7360
    7461    class Thread;
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r12512 r12559  
    6565    return Completion(Throw, ex); \
    6666  } \
    67   if (Collector::outOfMemory()) \
     67  if (Collector::isOutOfMemory()) \
    6868    return Completion(Throw, Error::create(exec, GeneralError, "Out of memory"));
    6969
     
    7373    return jsUndefined(); \
    7474  } \
    75   if (Collector::outOfMemory()) \
     75  if (Collector::isOutOfMemory()) \
    7676    return jsUndefined(); // will be picked up by KJS_CHECKEXCEPTION
    7777
     
    8181    return List(); \
    8282  } \
    83   if (Collector::outOfMemory()) \
     83  if (Collector::isOutOfMemory()) \
    8484    return List(); // will be picked up by KJS_CHECKEXCEPTION
    8585
Note: See TracChangeset for help on using the changeset viewer.