Changeset 12559 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 4, 2006, 3:29:43 PM (19 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r12547 r12559 1 2006-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 1 18 2006-02-03 Timothy Hatcher <[email protected]> 2 19 -
trunk/JavaScriptCore/kjs/collector.cpp
r12329 r12559 1 // -*- c-basic-offset: 2-*-1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 3 * This file is part of the KDE libraries … … 35 35 #if __APPLE__ 36 36 37 #include <CoreFoundation/CoreFoundation.h>38 37 #include <pthread.h> 39 38 #include <mach/mach_port.h> … … 597 596 } 598 597 599 size_t Collector::numGCNotAllowedObjects() 600 { 601 return 0; 602 } 603 604 size_t Collector::numReferencedObjects() 598 size_t Collector::numProtectedObjects() 605 599 { 606 600 return protectedValues().size(); 607 601 } 608 602 609 #if __APPLE__ 610 611 static const char *className(JSCell *val) 603 static const char *typeName(JSCell *val) 612 604 { 613 605 const char *name = "???"; … … 642 634 } 643 635 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 636 HashCountedSet<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 } 662 647 663 648 } // namespace KJS -
trunk/JavaScriptCore/kjs/collector.h
r12317 r12559 26 26 27 27 #include "value.h" 28 #include <kxmlcore/HashCountedSet.h> 28 29 29 30 #define KJS_MEM_LIMIT 500000 … … 38 39 Collector(); 39 40 public: 40 /**41 * Register an object with the collector. The following assumptions are42 * made:43 * @li the operator new() of the object class is overloaded.44 * @li operator delete() has been overloaded as well and does not free45 * 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 */50 41 static void* allocate(size_t s); 51 /**52 * Run the garbage collection. This involves calling the delete operator53 * on each object and freeing the used memory.54 */55 42 static bool collect(); 43 56 44 static size_t size(); 57 static bool outOfMemory() { return memoryFull; }45 static bool isOutOfMemory() { return memoryFull; } 58 46 59 47 #ifdef KJS_DEBUG_MEM … … 68 56 69 57 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(); 73 60 74 61 class Thread; -
trunk/JavaScriptCore/kjs/nodes.cpp
r12512 r12559 65 65 return Completion(Throw, ex); \ 66 66 } \ 67 if (Collector:: outOfMemory()) \67 if (Collector::isOutOfMemory()) \ 68 68 return Completion(Throw, Error::create(exec, GeneralError, "Out of memory")); 69 69 … … 73 73 return jsUndefined(); \ 74 74 } \ 75 if (Collector:: outOfMemory()) \75 if (Collector::isOutOfMemory()) \ 76 76 return jsUndefined(); // will be picked up by KJS_CHECKEXCEPTION 77 77 … … 81 81 return List(); \ 82 82 } \ 83 if (Collector:: outOfMemory()) \83 if (Collector::isOutOfMemory()) \ 84 84 return List(); // will be picked up by KJS_CHECKEXCEPTION 85 85
Note:
See TracChangeset
for help on using the changeset viewer.