Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: Source/platform/heap/ThreadState.cpp

Issue 1203493004: [tracing] Adding class-wise memory statistics to blink gc memory dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase errors. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/heap/ThreadState.h" 32 #include "platform/heap/ThreadState.h"
33 33
34 #include "platform/ScriptForbiddenScope.h" 34 #include "platform/ScriptForbiddenScope.h"
35 #include "platform/TraceEvent.h" 35 #include "platform/TraceEvent.h"
36 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
36 #include "platform/heap/CallbackStack.h" 37 #include "platform/heap/CallbackStack.h"
37 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
38 #include "platform/heap/Heap.h" 39 #include "platform/heap/Heap.h"
39 #include "platform/heap/MarkingVisitor.h" 40 #include "platform/heap/MarkingVisitor.h"
40 #include "platform/heap/SafePoint.h" 41 #include "platform/heap/SafePoint.h"
41 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
43 #include "public/platform/WebMemoryAllocatorDump.h"
42 #include "public/platform/WebScheduler.h" 44 #include "public/platform/WebScheduler.h"
43 #include "public/platform/WebThread.h" 45 #include "public/platform/WebThread.h"
44 #include "public/platform/WebTraceLocation.h" 46 #include "public/platform/WebTraceLocation.h"
45 #include "wtf/Partitions.h" 47 #include "wtf/Partitions.h"
46 #include "wtf/ThreadingPrimitives.h" 48 #include "wtf/ThreadingPrimitives.h"
47 #if ENABLE(GC_PROFILING) 49 #if ENABLE(GC_PROFILING)
48 #include "platform/TracedValue.h" 50 #include "platform/TracedValue.h"
49 #include "wtf/text/StringHash.h" 51 #include "wtf/text/StringHash.h"
50 #endif 52 #endif
51 53
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 375
374 void ThreadState::visitPersistents(Visitor* visitor) 376 void ThreadState::visitPersistents(Visitor* visitor)
375 { 377 {
376 m_persistents->tracePersistentNodes(visitor); 378 m_persistents->tracePersistentNodes(visitor);
377 if (m_traceDOMWrappers) { 379 if (m_traceDOMWrappers) {
378 TRACE_EVENT0("blink_gc", "V8GCController::traceDOMWrappers"); 380 TRACE_EVENT0("blink_gc", "V8GCController::traceDOMWrappers");
379 m_traceDOMWrappers(m_isolate, visitor); 381 m_traceDOMWrappers(m_isolate, visitor);
380 } 382 }
381 } 383 }
382 384
385 size_t ThreadState::GCSnapshotInfo::getClassTag(const GCInfo* gcInfo)
386 {
387 ClassTagMap::AddResult result = classTags.add(gcInfo, classTags.size());
388 if (result.isNewEntry) {
389 liveCount.append(0);
390 deadCount.append(0);
391 liveSize.append(0);
392 deadSize.append(0);
393 }
394 return result.storedValue->value;
395 }
396
383 #if ENABLE(GC_PROFILING) 397 #if ENABLE(GC_PROFILING)
384 const GCInfo* ThreadState::findGCInfo(Address address) 398 const GCInfo* ThreadState::findGCInfo(Address address)
385 { 399 {
386 if (BasePage* page = findPageFromAddress(address)) 400 if (BasePage* page = findPageFromAddress(address))
387 return page->findGCInfo(address); 401 return page->findGCInfo(address);
388 return nullptr; 402 return nullptr;
389 } 403 }
390 404
391 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcInfo) 405 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcInfo)
392 { 406 {
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 1385
1372 void ThreadState::promptlyFreed(size_t gcInfoIndex) 1386 void ThreadState::promptlyFreed(size_t gcInfoIndex)
1373 { 1387 {
1374 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; 1388 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask;
1375 // See the comment in vectorBackingHeap() for why this is +3. 1389 // See the comment in vectorBackingHeap() for why this is +3.
1376 m_likelyToBePromptlyFreed[entryIndex] += 3; 1390 m_likelyToBePromptlyFreed[entryIndex] += 3;
1377 } 1391 }
1378 1392
1379 void ThreadState::takeSnapshot(SnapshotType type) 1393 void ThreadState::takeSnapshot(SnapshotType type)
1380 { 1394 {
1395 GCSnapshotInfo info;
1381 ASSERT(isInGC()); 1396 ASSERT(isInGC());
1382 1397
1383 int numberOfHeapsReported = 0; 1398 int numberOfHeapsReported = 0;
1384 #define SNAPSHOT_HEAP(HeapType) \ 1399 #define SNAPSHOT_HEAP(HeapType) \
1385 { \ 1400 { \
1386 numberOfHeapsReported++; \ 1401 numberOfHeapsReported++; \
1387 String allocatorBaseName; \ 1402 String allocatorBaseName; \
1388 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp e, (unsigned long)(m_thread)); \ 1403 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp e, (unsigned long)(m_thread)); \
1389 switch (type) { \ 1404 switch (type) { \
1390 case SnapshotType::HeapSnapshot: \ 1405 case SnapshotType::HeapSnapshot: \
1391 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName); \ 1406 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName, info); \
1392 break; \ 1407 break; \
1393 case SnapshotType::FreelistSnapshot: \ 1408 case SnapshotType::FreelistSnapshot: \
1394 m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName ); \ 1409 m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName ); \
1395 break; \ 1410 break; \
1396 default: \ 1411 default: \
1397 ASSERT_NOT_REACHED(); \ 1412 ASSERT_NOT_REACHED(); \
1398 } \ 1413 } \
1399 } 1414 }
1400 1415
1401 SNAPSHOT_HEAP(NormalPage1); 1416 SNAPSHOT_HEAP(NormalPage1);
1402 SNAPSHOT_HEAP(NormalPage2); 1417 SNAPSHOT_HEAP(NormalPage2);
1403 SNAPSHOT_HEAP(NormalPage3); 1418 SNAPSHOT_HEAP(NormalPage3);
1404 SNAPSHOT_HEAP(NormalPage4); 1419 SNAPSHOT_HEAP(NormalPage4);
1405 SNAPSHOT_HEAP(EagerSweep); 1420 SNAPSHOT_HEAP(EagerSweep);
1406 SNAPSHOT_HEAP(Vector1); 1421 SNAPSHOT_HEAP(Vector1);
1407 SNAPSHOT_HEAP(Vector2); 1422 SNAPSHOT_HEAP(Vector2);
1408 SNAPSHOT_HEAP(Vector3); 1423 SNAPSHOT_HEAP(Vector3);
1409 SNAPSHOT_HEAP(Vector4); 1424 SNAPSHOT_HEAP(Vector4);
1410 SNAPSHOT_HEAP(InlineVector); 1425 SNAPSHOT_HEAP(InlineVector);
1411 SNAPSHOT_HEAP(HashTable); 1426 SNAPSHOT_HEAP(HashTable);
1412 SNAPSHOT_HEAP(LargeObject); 1427 SNAPSHOT_HEAP(LargeObject);
1413 FOR_EACH_TYPED_HEAP(SNAPSHOT_HEAP); 1428 FOR_EACH_TYPED_HEAP(SNAPSHOT_HEAP);
1414 1429
1415 ASSERT(numberOfHeapsReported == NumberOfHeaps); 1430 ASSERT(numberOfHeapsReported == NumberOfHeaps);
1416 1431
1417 #undef SNAPSHOT_HEAP 1432 #undef SNAPSHOT_HEAP
1433
1434 Vector<String> classNameVector(info.classTags.size());
1435 for (GCSnapshotInfo::ClassTagMap::iterator it = info.classTags.begin(); it ! = info.classTags.end(); ++it)
1436 classNameVector[it->value] = it->key->m_className;
1437
1438 for (size_t i = 0; i < classNameVector.size(); ++i) {
1439 String dumpName = String::format("blink_gc/thread_%lu/classes/", (unsign ed long)(m_thread)) + classNameVector[i];
1440 WebMemoryAllocatorDump* classDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpName);
1441 classDump->AddScalar("live_count", "objects", info.liveCount[i]);
1442 classDump->AddScalar("dead_count", "objects", info.deadCount[i]);
1443 classDump->AddScalar("live_size", "bytes", info.liveSize[i]);
1444 classDump->AddScalar("dead_size", "bytes", info.deadSize[i]);
1445 }
1418 } 1446 }
1419 1447
1420 #if ENABLE(GC_PROFILING) 1448 #if ENABLE(GC_PROFILING)
1421 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) 1449 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
1422 { 1450 {
1423 bool needLockForIteration = !ThreadState::current()->isInGC(); 1451 bool needLockForIteration = !ThreadState::current()->isInGC();
1424 if (needLockForIteration) 1452 if (needLockForIteration)
1425 threadAttachMutex().lock(); 1453 threadAttachMutex().lock();
1426 1454
1427 for (ThreadState* state : attachedThreads()) { 1455 for (ThreadState* state : attachedThreads()) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 json->beginArray(it->key.ascii().data()); 1535 json->beginArray(it->key.ascii().data());
1508 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1536 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1509 json->pushInteger(it->value.ages[age]); 1537 json->pushInteger(it->value.ages[age]);
1510 json->endArray(); 1538 json->endArray();
1511 } 1539 }
1512 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1540 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1513 } 1541 }
1514 #endif 1542 #endif
1515 1543
1516 } // namespace blink 1544 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698