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

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

Issue 1670463002: [Oilpan] Unify memory usage reporters of Oilpan (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #endif 56 #endif
57 57
58 #if defined(MEMORY_SANITIZER) 58 #if defined(MEMORY_SANITIZER)
59 #include <sanitizer/msan_interface.h> 59 #include <sanitizer/msan_interface.h>
60 #endif 60 #endif
61 61
62 #if OS(FREEBSD) 62 #if OS(FREEBSD)
63 #include <pthread_np.h> 63 #include <pthread_np.h>
64 #endif 64 #endif
65 65
66 #include <v8.h>
67
66 namespace blink { 68 namespace blink {
67 69
68 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; 70 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr;
69 uintptr_t ThreadState::s_mainThreadStackStart = 0; 71 uintptr_t ThreadState::s_mainThreadStackStart = 0;
70 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; 72 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0;
71 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; 73 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
72 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr; 74 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr;
73 75
74 RecursiveMutex& ThreadState::threadAttachMutex() 76 RecursiveMutex& ThreadState::threadAttachMutex()
75 { 77 {
(...skipping 15 matching lines...) Expand all
91 , m_sweepForbidden(false) 93 , m_sweepForbidden(false)
92 , m_noAllocationCount(0) 94 , m_noAllocationCount(0)
93 , m_gcForbiddenCount(0) 95 , m_gcForbiddenCount(0)
94 , m_accumulatedSweepingTime(0) 96 , m_accumulatedSweepingTime(0)
95 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex) 97 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex)
96 , m_currentHeapAges(0) 98 , m_currentHeapAges(0)
97 , m_isTerminating(false) 99 , m_isTerminating(false)
98 , m_gcMixinMarker(nullptr) 100 , m_gcMixinMarker(nullptr)
99 , m_shouldFlushHeapDoesNotContainCache(false) 101 , m_shouldFlushHeapDoesNotContainCache(false)
100 , m_gcState(NoGCScheduled) 102 , m_gcState(NoGCScheduled)
103 , m_isolate(nullptr)
101 , m_traceDOMWrappers(nullptr) 104 , m_traceDOMWrappers(nullptr)
102 #if defined(ADDRESS_SANITIZER) 105 #if defined(ADDRESS_SANITIZER)
103 , m_asanFakeStack(__asan_get_current_fake_stack()) 106 , m_asanFakeStack(__asan_get_current_fake_stack())
104 #endif 107 #endif
105 #if defined(LEAK_SANITIZER) 108 #if defined(LEAK_SANITIZER)
106 , m_disabledStaticPersistentsRegistration(0) 109 , m_disabledStaticPersistentsRegistration(0)
107 #endif 110 #endif
111 , m_allocatedObjectSize(0)
112 , m_markedObjectSize(0)
113 , m_reportedMemoryToV8(0)
108 { 114 {
109 ASSERT(checkThread()); 115 ASSERT(checkThread());
110 ASSERT(!**s_threadSpecific); 116 ASSERT(!**s_threadSpecific);
111 **s_threadSpecific = this; 117 **s_threadSpecific = this;
112 118
113 if (isMainThread()) { 119 if (isMainThread()) {
114 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); 120 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*);
115 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size(); 121 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size();
116 if (underestimatedStackSize > sizeof(void*)) 122 if (underestimatedStackSize > sizeof(void*))
117 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*); 123 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*);
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 688
683 // Allocation is allowed during sweeping, but those allocations should not 689 // Allocation is allowed during sweeping, but those allocations should not
684 // trigger nested GCs. 690 // trigger nested GCs.
685 if (isGCForbidden()) 691 if (isGCForbidden())
686 return; 692 return;
687 693
688 if (isSweepingInProgress()) 694 if (isSweepingInProgress())
689 return; 695 return;
690 ASSERT(!sweepForbidden()); 696 ASSERT(!sweepForbidden());
691 697
698 reportMemoryToV8();
699
692 if (shouldForceMemoryPressureGC()) { 700 if (shouldForceMemoryPressureGC()) {
693 completeSweep(); 701 completeSweep();
694 if (shouldForceMemoryPressureGC()) { 702 if (shouldForceMemoryPressureGC()) {
695 #if PRINT_HEAP_STATS 703 #if PRINT_HEAP_STATS
696 dataLogF("Scheduled MemoryPressureGC\n"); 704 dataLogF("Scheduled MemoryPressureGC\n");
697 #endif 705 #endif
698 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithou tSweep, BlinkGC::MemoryPressureGC); 706 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithou tSweep, BlinkGC::MemoryPressureGC);
699 return; 707 return;
700 } 708 }
701 } 709 }
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 { 1249 {
1242 ASSERT(checkThread()); 1250 ASSERT(checkThread());
1243 ASSERT(m_atSafePoint); 1251 ASSERT(m_atSafePoint);
1244 s_safePointBarrier->leaveSafePoint(this, locker); 1252 s_safePointBarrier->leaveSafePoint(this, locker);
1245 m_atSafePoint = false; 1253 m_atSafePoint = false;
1246 m_stackState = BlinkGC::HeapPointersOnStack; 1254 m_stackState = BlinkGC::HeapPointersOnStack;
1247 clearSafePointScopeMarker(); 1255 clearSafePointScopeMarker();
1248 preSweep(); 1256 preSweep();
1249 } 1257 }
1250 1258
1259 void ThreadState::reportMemoryToV8()
1260 {
1261 if (!m_isolate)
1262 return;
1263
1264 size_t currentHeapSize = m_allocatedObjectSize + m_markedObjectSize;
1265 int64_t diff = static_cast<int64_t>(currentHeapSize) - static_cast<int64_t>( m_reportedMemoryToV8);
1266 m_isolate->AdjustAmountOfExternalAllocatedMemory(diff);
1267 m_reportedMemoryToV8 = currentHeapSize;
1268 }
1269
1270 void ThreadState::resetHeapCounters()
1271 {
1272 m_allocatedObjectSize = 0;
1273 m_markedObjectSize = 0;
1274 }
1275
1276 void ThreadState::increaseAllocatedObjectSize(size_t delta)
1277 {
1278 m_allocatedObjectSize += delta;
1279 Heap::increaseAllocatedObjectSize(delta);
1280 }
1281
1282 void ThreadState::decreaseAllocatedObjectSize(size_t delta)
1283 {
1284 m_allocatedObjectSize -= delta;
1285 Heap::decreaseAllocatedObjectSize(delta);
1286 }
1287
1288 void ThreadState::increaseMarkedObjectSize(size_t delta)
1289 {
1290 m_markedObjectSize += delta;
1291 Heap::increaseMarkedObjectSize(delta);
1292 }
1293
1251 void ThreadState::copyStackUntilSafePointScope() 1294 void ThreadState::copyStackUntilSafePointScope()
1252 { 1295 {
1253 if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStac k) 1296 if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStac k)
1254 return; 1297 return;
1255 1298
1256 Address* to = reinterpret_cast<Address*>(m_safePointScopeMarker); 1299 Address* to = reinterpret_cast<Address*>(m_safePointScopeMarker);
1257 Address* from = reinterpret_cast<Address*>(m_endOfStack); 1300 Address* from = reinterpret_cast<Address*>(m_endOfStack);
1258 RELEASE_ASSERT(from < to); 1301 RELEASE_ASSERT(from < to);
1259 RELEASE_ASSERT(to <= reinterpret_cast<Address*>(m_startOfStack)); 1302 RELEASE_ASSERT(to <= reinterpret_cast<Address*>(m_startOfStack));
1260 size_t slotCount = static_cast<size_t>(to - from); 1303 size_t slotCount = static_cast<size_t>(to - from);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 threadDump->addScalar("dead_count", "objects", totalDeadCount); 1541 threadDump->addScalar("dead_count", "objects", totalDeadCount);
1499 threadDump->addScalar("live_size", "bytes", totalLiveSize); 1542 threadDump->addScalar("live_size", "bytes", totalLiveSize);
1500 threadDump->addScalar("dead_size", "bytes", totalDeadSize); 1543 threadDump->addScalar("dead_size", "bytes", totalDeadSize);
1501 1544
1502 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1545 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1503 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1546 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1504 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1547 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid());
1505 } 1548 }
1506 1549
1507 } // namespace blink 1550 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698