Changeset 142618 in webkit
- Timestamp:
- Feb 12, 2013 6:53:34 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142614 r142618 1 2013-02-12 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: Native Memory Instrumentation: reportLeaf method doesn't report the leaf node properly. 4 https://bugs.webkit.org/show_bug.cgi?id=109554 5 6 In some cases leaves have no pointer so with the old schema we can't generate nodeId for them because we 7 can't insert 0 into hashmap. It happens when we call addPrivateBuffer method. 8 9 Drive by fix: I introduced a client interface for the HeapGraphSerializer. 10 It helps me to do the tests for the serializer. 11 12 Reviewed by Yury Semikhatsky. 13 14 It is covered by newly added tests in TestWebKitAPI. 15 16 * inspector/HeapGraphSerializer.cpp: 17 (WebCore::HeapGraphSerializer::HeapGraphSerializer): 18 (WebCore::HeapGraphSerializer::pushUpdate): 19 (WebCore::HeapGraphSerializer::reportNode): 20 (WebCore::HeapGraphSerializer::toNodeId): 21 (WebCore::HeapGraphSerializer::addRootNode): 22 * inspector/HeapGraphSerializer.h: 23 (HeapGraphSerializerClient): 24 (WebCore::HeapGraphSerializerClient::~HeapGraphSerializerClient): 25 (HeapGraphSerializer): 26 * inspector/InspectorMemoryAgent.cpp: 27 (WebCore::InspectorMemoryAgent::getProcessMemoryDistributionImpl): 28 1 29 2013-02-12 Vsevolod Vlasov <vsevik@chromium.org> 2 30 -
trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp
r142241 r142618 44 44 namespace WebCore { 45 45 46 HeapGraphSerializer::HeapGraphSerializer( InspectorFrontend::Memory* frontend)47 : m_ frontend(frontend)46 HeapGraphSerializer::HeapGraphSerializer(Client* client) 47 : m_client(client) 48 48 , m_strings(Strings::create()) 49 49 , m_edges(Edges::create()) … … 51 51 , m_nodes(Nodes::create()) 52 52 , m_baseToRealNodeIdMap(BaseToRealNodeIdMap::create()) 53 { 54 ASSERT(m_frontend); 53 , m_leafCount(0) 54 { 55 ASSERT(m_client); 55 56 m_strings->addItem(String()); // An empty string with 0 index. 56 57 … … 92 93 .setBaseToRealNodeId(m_baseToRealNodeIdMap.release()); 93 94 94 m_ frontend->addNativeSnapshotChunk(chunk);95 m_client->addNativeSnapshotChunk(chunk.release()); 95 96 96 97 m_strings = Strings::create(); … … 102 103 void HeapGraphSerializer::reportNode(const WTF::MemoryObjectInfo& info) 103 104 { 105 ASSERT(info.reportedPointer()); 104 106 reportNodeImpl(info, m_nodeEdgesCount); 105 107 m_nodeEdgesCount = 0; … … 183 185 int HeapGraphSerializer::toNodeId(const void* to) 184 186 { 185 ASSERT(to); 186 Address2NodeId::AddResult result = m_address2NodeIdMap.add(to, m_address2NodeIdMap.size()); 187 if (!to) 188 return s_firstNodeId + m_address2NodeIdMap.size() + m_leafCount++; 189 190 Address2NodeId::AddResult result = m_address2NodeIdMap.add(to, s_firstNodeId + m_leafCount + m_address2NodeIdMap.size()); 187 191 return result.iterator->value; 188 192 } … … 195 199 m_nodes->addItem(addString("Root")); 196 200 m_nodes->addItem(0); 197 m_nodes->addItem( m_address2NodeIdMap.size());201 m_nodes->addItem(s_firstNodeId + m_address2NodeIdMap.size() + m_leafCount); 198 202 m_nodes->addItem(0); 199 203 m_nodes->addItem(m_roots.size()); -
trunk/Source/WebCore/inspector/HeapGraphSerializer.h
r142074 r142618 44 44 namespace WebCore { 45 45 46 class HeapGraphEdge;47 class HeapGraphNode;48 class InspectorObject;49 50 46 class HeapGraphSerializer { 51 47 WTF_MAKE_NONCOPYABLE(HeapGraphSerializer); 52 48 public: 53 explicit HeapGraphSerializer(InspectorFrontend::Memory*); 49 50 class Client { 51 public: 52 virtual ~Client() { } 53 virtual void addNativeSnapshotChunk(PassRefPtr<TypeBuilder::Memory::HeapSnapshotChunk>) = 0; 54 }; 55 56 explicit HeapGraphSerializer(Client*); 54 57 ~HeapGraphSerializer(); 55 58 void reportNode(const WTF::MemoryObjectInfo&); … … 74 77 int reportNodeImpl(const WTF::MemoryObjectInfo&, int edgesCount); 75 78 76 InspectorFrontend::Memory* m_frontend;79 Client* m_client; 77 80 78 81 typedef HashMap<String, int> StringMap; … … 101 104 size_t m_edgeTypes[WTF::LastMemberTypeEntry]; 102 105 int m_unknownClassNameId; 106 int m_leafCount; 107 108 static const int s_firstNodeId = 1; 103 109 }; 104 110 -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r142281 r142618 331 331 } 332 332 333 namespace { 334 335 class FrontendWrapper : public HeapGraphSerializer::Client { 336 public: 337 explicit FrontendWrapper(InspectorFrontend::Memory* frontend) : m_frontend(frontend) { } 338 virtual void addNativeSnapshotChunk(PassRefPtr<TypeBuilder::Memory::HeapSnapshotChunk> heapSnapshotChunk) OVERRIDE 339 { 340 m_frontend->addNativeSnapshotChunk(heapSnapshotChunk); 341 } 342 private: 343 InspectorFrontend::Memory* m_frontend; 344 }; 345 346 } 347 333 348 void InspectorMemoryAgent::getProcessMemoryDistributionImpl(bool reportGraph, TypeNameToSizeMap* memoryInfo) 334 349 { 335 350 OwnPtr<HeapGraphSerializer> graphSerializer; 336 if (reportGraph) 337 graphSerializer = adoptPtr(new HeapGraphSerializer(m_frontend)); 351 OwnPtr<FrontendWrapper> frontendWrapper; 352 353 if (reportGraph) { 354 frontendWrapper = adoptPtr(new FrontendWrapper(m_frontend)); 355 graphSerializer = adoptPtr(new HeapGraphSerializer(frontendWrapper.get())); 356 } 357 338 358 MemoryInstrumentationClientImpl memoryInstrumentationClient(graphSerializer.get()); 339 359 m_inspectorClient->getAllocatedObjects(memoryInstrumentationClient.allocatedObjects()); … … 353 373 memoryInstrumentation.addRootObject(graphSerializer.get()); 354 374 graphSerializer->finish(); 375 graphSerializer.release(); // Release it earlier than frontendWrapper 376 frontendWrapper.release(); 355 377 } 356 378 -
trunk/Tools/ChangeLog
r142617 r142618 1 2013-02-12 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: Native Memory Instrumentation: reportLeaf method doesn't report the leaf node properly. 4 https://bugs.webkit.org/show_bug.cgi?id=109554 5 6 In some cases leaves have no pointer. As example when we report a leaf via addPrivateBuffer. 7 This patch has new set of tests for HeapGraphSerializer. 8 9 Reviewed by Yury Semikhatsky. 10 11 * TestWebKitAPI/TestWebKitAPI.gypi: 12 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 13 * TestWebKitAPI/Tests/WebCore/HeapGraphSerializerTest.cpp: Added. 14 * TestWebKitAPI/win/TestWebKitAPI.vcproj: 15 1 16 2013-02-12 Zan Dobersek <zdobersek@igalia.com> 2 17 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi
r137924 r142618 32 32 'variables': { 33 33 'TestWebKitAPI_files': [ 34 'Tests/WebCore/HeapGraphSerializerTest.cpp', 34 35 'Tests/WebCore/LayoutUnit.cpp', 35 36 'Tests/WTF/AtomicString.cpp', -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r142381 r142618 15 15 0FC6C4CF141034AD005B7F0C /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */; }; 16 16 14464013167A8305000BD218 /* LayoutUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14464012167A8305000BD218 /* LayoutUnit.cpp */; }; 17 788CB4AE348F4040827FCCD0 /* HeapGraphGeneratorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 788CB4AE348F4040827FCCD0 /* HeapGraphGeneratorTest.cpp */; }; 17 18 14F3B11315E45EAB00210069 /* SaturatedArithmeticOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */; }; 18 19 1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; }; … … 273 274 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MetaAllocator.cpp; path = WTF/MetaAllocator.cpp; sourceTree = "<group>"; }; 274 275 14464012167A8305000BD218 /* LayoutUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutUnit.cpp; sourceTree = "<group>"; }; 276 788CB4AE348F4040827FCCD0 /* HeapGraphGeneratorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapGraphGeneratorTest.cpp; sourceTree = "<group>"; }; 275 277 14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SaturatedArithmeticOperations.cpp; path = WTF/SaturatedArithmeticOperations.cpp; sourceTree = "<group>"; }; 276 278 1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; }; … … 565 567 440A1D3814A0103A008A66F2 /* KURL.cpp */, 566 568 14464012167A8305000BD218 /* LayoutUnit.cpp */, 569 788CB4AE348F4040827FCCD0 /* HeapGraphGeneratorTest.cpp */, 567 570 ); 568 571 path = WebCore; … … 1015 1018 440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */, 1016 1019 14464013167A8305000BD218 /* LayoutUnit.cpp in Sources */, 1020 788CB4AE348F4040827FCCD0 /* HeapGraphGeneratorTest.cpp in Sources */, 1017 1021 26300B1816755CD90066886D /* ListHashSet.cpp in Sources */, 1018 1022 52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */, -
trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj
r137924 r142618 417 417 </Filter> 418 418 <File 419 RelativePath="..\Tests\WebCore\HeapGraphGeneratorTest.cpp" 420 > 421 </File> 422 <File 419 423 RelativePath="..\Tests\WebCore\LayoutUnit.cpp" 420 424 >
Note: See TracChangeset
for help on using the changeset viewer.