Ignore:
Timestamp:
Aug 3, 2007, 9:21:44 AM (18 years ago)
Author:
bdash
Message:

2007-08-02 Mark Rowe <[email protected]>

Reviewed by Geoff Garen.

<rdar://problem/4212199> 'leaks' reports false leaks in WebKit (because the WTF allocator uses mmap?)

Implement malloc zone introspection routines to allow leaks, heap, and friends to request information
about specific memory regions that were allocated by FastMalloc or the JavaScriptCore collector.

This requires tool-side support before the regions will be displayed. The addition of that support is
tracked by <rdar://problems/5353057&5353060>.

  • JavaScriptCore.exp: Export the two variables that are used by leaks to introspect the allocators.
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/AllInOneFile.cpp:
  • kjs/CollectorZone.cpp: Added. (KJS::): (KJS::CollectorZone::registerZone): (KJS::CollectorZone::CollectorZone): Create and register our zone with the system. (KJS::CollectorZone::zoneEnumerator): Iterate over the CollectorBlocks that are in use and report them to the caller as being used.
  • kjs/CollectorZone.h: Added. (KJS::CollectorZone::zoneObjectSize): Return zero to indicate the specified pointer does not belong to this zone.
  • kjs/collector.cpp: (KJS::Collector::registerThread): Register the CollectorZone with the system when the first thread is registered with the collector.
  • wtf/FastMalloc.cpp: (WTF::TCMalloc_PageHeap::GetDescriptorEnsureSafe): (WTF::TCMalloc_ThreadCache_FreeList::enumerateFreeObjects): Enumerate the objects on the free list. (WTF::TCMalloc_ThreadCache::enumerateFreeObjects): Ditto. (WTF::TCMalloc_Central_FreeList::enumerateFreeObjects): Ditto. (WTF::TCMalloc_ThreadCache::InitModule): Register the FastMallocZone with the system when initializing TCMalloc. (WTF::FreeObjectFinder::FreeObjectFinder): (WTF::FreeObjectFinder::visit): Add an object to the free list. (WTF::FreeObjectFinder::isFreeObject): (WTF::FreeObjectFinder::freeObjectCount): (WTF::FreeObjectFinder::findFreeObjects): Find the free objects within a thread cache or free list. (WTF::PageMapFreeObjectFinder::PageMapFreeObjectFinder): Find the free objects within a TC_PageMap. (WTF::PageMapFreeObjectFinder::visit): Called once per allocated span. Record whether the span or any subobjects are free. (WTF::PageMapMemoryUsageRecorder::PageMapMemoryUsageRecorder): (WTF::PageMapMemoryUsageRecorder::visit): Called once per allocated span. Report the range of memory as being allocated, and the span or it's subobjects as being used if they do not appear on the free list. (WTF::FastMallocZone::zoneEnumerator): Map the key remote TCMalloc data structures into our address space. We then locate all free memory ranges before reporting the other ranges as being in use. (WTF::FastMallocZone::zoneObjectSize): Determine whether the given pointer originates from within our allocation zone. If so, we return its allocation size. (WTF::FastMallocZone::zoneMalloc): (WTF::FastMallocZone::zoneCalloc): (WTF::FastMallocZone::zoneFree): (WTF::FastMallocZone::zoneRealloc): (WTF::): (WTF::FastMallocZone::FastMallocZone): Create and register our zone with the system. (WTF::FastMallocZone::registerZone):
  • wtf/MallocZoneSupport.h: Added. (WTF::RemoteMemoryReader::RemoteMemoryReader): A helper class to ease the process of mapping memory in a different process into our local address space (WTF::RemoteMemoryReader::operator()):
  • wtf/TCPageMap.h: (TCMalloc_PageMap2::visit): Walk over the heap and visit each allocated span. (TCMalloc_PageMap3::visit): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r24457 r24843  
    8282                1CAF34890A6C421700ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34880A6C421700ABE06E /* WebScriptObject.h */; };
    8383                51F648D70BB4E2CA0033D760 /* RetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F648D60BB4E2CA0033D760 /* RetainPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
     84                5DBD18AC0C54018700C15EAE /* CollectorHeapIntrospector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DBD18AA0C54018700C15EAE /* CollectorHeapIntrospector.h */; };
     85                5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */; };
    8486                65400C120A69BAF200509887 /* PropertyNameArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 65400C100A69BAF200509887 /* PropertyNameArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8587                6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6E08E80A17002CBEE7 /* TCPageMap.h */; };
     
    481483                51F0EC9705C88DC700E6DF1B /* objc_utility.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = objc_utility.mm; path = bindings/objc/objc_utility.mm; sourceTree = "<group>"; tabWidth = 8; };
    482484                51F648D60BB4E2CA0033D760 /* RetainPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RetainPtr.h; sourceTree = "<group>"; };
     485                5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectorHeapIntrospector.cpp; sourceTree = "<group>"; };
     486                5DBD18AA0C54018700C15EAE /* CollectorHeapIntrospector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectorHeapIntrospector.h; sourceTree = "<group>"; };
     487                5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocZoneSupport.h; sourceTree = "<group>"; };
    483488                651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; tabWidth = 8; };
    484489                651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; tabWidth = 8; };
     
    908913                                657EB7450B708F540063461B /* ListHashSet.h */,
    909914                                148A1626095D16BB00666D0D /* ListRefPtr.h */,
     915                                5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */,
    910916                                BCF6553B0A2048DE0038A194 /* MathExtras.h */,
    911917                                9303F5690991190000AD71B8 /* Noncopyable.h */,
     
    947953                                F692A8520255597D01FF60F7 /* collector.cpp */,
    948954                                F692A8530255597D01FF60F7 /* collector.h */,
     955                                5DBD18AA0C54018700C15EAE /* CollectorHeapIntrospector.h */,
     956                                5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */,
    949957                                F5BB2BC5030F772101FCFE1D /* completion.h */,
    950958                                F68EBB8C0255D4C601FF60F7 /* config.h */,
     
    12401248                                65EA73650BAE35D1001BB560 /* CommonIdentifiers.h in Headers */,
    12411249                                51F648D70BB4E2CA0033D760 /* RetainPtr.h in Headers */,
     1250                                5DBD18AC0C54018700C15EAE /* CollectorHeapIntrospector.h in Headers */,
     1251                                5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */,
    12421252                        );
    12431253                        runOnlyForDeploymentPostprocessing = 0;
     
    13531363                        isa = PBXProject;
    13541364                        buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
     1365                        compatibilityVersion = "Xcode 2.4";
    13551366                        hasScannedForEncodings = 1;
    13561367                        mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
Note: See TracChangeset for help on using the changeset viewer.