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

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: 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1383
1370 void ThreadState::promptlyFreed(size_t gcInfoIndex) 1384 void ThreadState::promptlyFreed(size_t gcInfoIndex)
1371 { 1385 {
1372 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; 1386 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask;
1373 // See the comment in vectorBackingHeap() for why this is +3. 1387 // See the comment in vectorBackingHeap() for why this is +3.
1374 m_likelyToBePromptlyFreed[entryIndex] += 3; 1388 m_likelyToBePromptlyFreed[entryIndex] += 3;
1375 } 1389 }
1376 1390
1377 void ThreadState::takeSnapshot() 1391 void ThreadState::takeSnapshot()
1378 { 1392 {
1393 GCSnapshotInfo info;
1379 ASSERT(isInGC()); 1394 ASSERT(isInGC());
1380 1395
1381 int numberOfHeapsReported = 0; 1396 int numberOfHeapsReported = 0;
1382 #define SNAPSHOT_HEAP(HeapType) \ 1397 #define SNAPSHOT_HEAP(HeapType) \
1383 { \ 1398 { \
1384 numberOfHeapsReported++; \ 1399 numberOfHeapsReported++; \
1385 String allocatorBaseName; \ 1400 String allocatorBaseName; \
1386 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp e, (unsigned long)(m_thread)); \ 1401 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp e, (unsigned long)(m_thread)); \
1387 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName); \ 1402 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName, info); \
1403 m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName); \
1388 } 1404 }
1389 1405
1390 SNAPSHOT_HEAP(NormalPage1); 1406 SNAPSHOT_HEAP(NormalPage1);
1391 SNAPSHOT_HEAP(NormalPage2); 1407 SNAPSHOT_HEAP(NormalPage2);
1392 SNAPSHOT_HEAP(NormalPage3); 1408 SNAPSHOT_HEAP(NormalPage3);
1393 SNAPSHOT_HEAP(NormalPage4); 1409 SNAPSHOT_HEAP(NormalPage4);
1394 SNAPSHOT_HEAP(EagerSweep); 1410 SNAPSHOT_HEAP(EagerSweep);
1395 SNAPSHOT_HEAP(Vector1); 1411 SNAPSHOT_HEAP(Vector1);
1396 SNAPSHOT_HEAP(Vector2); 1412 SNAPSHOT_HEAP(Vector2);
1397 SNAPSHOT_HEAP(Vector3); 1413 SNAPSHOT_HEAP(Vector3);
1398 SNAPSHOT_HEAP(Vector4); 1414 SNAPSHOT_HEAP(Vector4);
1399 SNAPSHOT_HEAP(InlineVector); 1415 SNAPSHOT_HEAP(InlineVector);
1400 SNAPSHOT_HEAP(HashTable); 1416 SNAPSHOT_HEAP(HashTable);
1401 SNAPSHOT_HEAP(LargeObject); 1417 SNAPSHOT_HEAP(LargeObject);
1402 FOR_EACH_TYPED_HEAP(SNAPSHOT_HEAP); 1418 FOR_EACH_TYPED_HEAP(SNAPSHOT_HEAP);
1403 1419
1404 ASSERT(numberOfHeapsReported == NumberOfHeaps); 1420 ASSERT(numberOfHeapsReported == NumberOfHeaps);
1405 1421
1406 #undef SNAPSHOT_HEAP 1422 #undef SNAPSHOT_HEAP
1423
1424 Vector<String> classNameVector(info.classTags.size());
1425 for (GCSnapshotInfo::ClassTagMap::iterator it = info.classTags.begin(); it ! = info.classTags.end(); ++it)
1426 classNameVector[it->value] = it->key->m_className;
1427
1428 for (size_t i = 0; i < classNameVector.size(); ++i) {
1429 String classDumpName = classNameVector[i].isolatedCopy();
1430 classDumpName.insert(String("blink_gc/classes/"), 0);
1431 WebMemoryAllocatorDump* classDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(classDumpName);
1432 classDump->AddScalar("live_count", "objects", info.liveCount[i]);
1433 classDump->AddScalar("dead_count", "objects", info.deadCount[i]);
1434 classDump->AddScalar("live_size", "bytes", info.liveSize[i]);
1435 classDump->AddScalar("dead_size", "bytes", info.deadSize[i]);
1436 }
1407 } 1437 }
1408 1438
1409 #if ENABLE(GC_PROFILING) 1439 #if ENABLE(GC_PROFILING)
1410 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) 1440 const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address)
1411 { 1441 {
1412 bool needLockForIteration = !ThreadState::current()->isInGC(); 1442 bool needLockForIteration = !ThreadState::current()->isInGC();
1413 if (needLockForIteration) 1443 if (needLockForIteration)
1414 threadAttachMutex().lock(); 1444 threadAttachMutex().lock();
1415 1445
1416 for (ThreadState* state : attachedThreads()) { 1446 for (ThreadState* state : attachedThreads()) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 json->beginArray(it->key.ascii().data()); 1526 json->beginArray(it->key.ascii().data());
1497 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1527 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1498 json->pushInteger(it->value.ages[age]); 1528 json->pushInteger(it->value.ages[age]);
1499 json->endArray(); 1529 json->endArray();
1500 } 1530 }
1501 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1531 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1502 } 1532 }
1503 #endif 1533 #endif
1504 1534
1505 } // namespace blink 1535 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698