Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 #if defined(MEMORY_SANITIZER) | 57 #if defined(MEMORY_SANITIZER) |
| 58 #include <sanitizer/msan_interface.h> | 58 #include <sanitizer/msan_interface.h> |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if OS(FREEBSD) | 61 #if OS(FREEBSD) |
| 62 #include <pthread_np.h> | 62 #include <pthread_np.h> |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 #include <v8.h> | |
| 66 | |
| 65 namespace blink { | 67 namespace blink { |
| 66 | 68 |
| 67 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; | 69 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; |
| 68 uintptr_t ThreadState::s_mainThreadStackStart = 0; | 70 uintptr_t ThreadState::s_mainThreadStackStart = 0; |
| 69 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; | 71 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; |
| 70 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; | 72 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; |
| 71 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr; | 73 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr; |
| 72 | 74 |
| 73 RecursiveMutex& ThreadState::threadAttachMutex() | 75 RecursiveMutex& ThreadState::threadAttachMutex() |
| 74 { | 76 { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 90 , m_sweepForbidden(false) | 92 , m_sweepForbidden(false) |
| 91 , m_noAllocationCount(0) | 93 , m_noAllocationCount(0) |
| 92 , m_gcForbiddenCount(0) | 94 , m_gcForbiddenCount(0) |
| 93 , m_accumulatedSweepingTime(0) | 95 , m_accumulatedSweepingTime(0) |
| 94 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex) | 96 , m_vectorBackingHeapIndex(BlinkGC::Vector1HeapIndex) |
| 95 , m_currentHeapAges(0) | 97 , m_currentHeapAges(0) |
| 96 , m_isTerminating(false) | 98 , m_isTerminating(false) |
| 97 , m_gcMixinMarker(nullptr) | 99 , m_gcMixinMarker(nullptr) |
| 98 , m_shouldFlushHeapDoesNotContainCache(false) | 100 , m_shouldFlushHeapDoesNotContainCache(false) |
| 99 , m_gcState(NoGCScheduled) | 101 , m_gcState(NoGCScheduled) |
| 102 , m_isolate(nullptr) | |
| 100 , m_traceDOMWrappers(nullptr) | 103 , m_traceDOMWrappers(nullptr) |
| 101 #if defined(ADDRESS_SANITIZER) | 104 #if defined(ADDRESS_SANITIZER) |
| 102 , m_asanFakeStack(__asan_get_current_fake_stack()) | 105 , m_asanFakeStack(__asan_get_current_fake_stack()) |
| 103 #endif | 106 #endif |
| 104 #if defined(LEAK_SANITIZER) | 107 #if defined(LEAK_SANITIZER) |
| 105 , m_disabledStaticPersistentsRegistration(0) | 108 , m_disabledStaticPersistentsRegistration(0) |
| 106 #endif | 109 #endif |
| 110 , m_allocatedObjectSize(0) | |
| 111 , m_markedObjectSize(0) | |
| 112 , m_prevReportedSize(0) | |
| 107 { | 113 { |
| 108 ASSERT(checkThread()); | 114 ASSERT(checkThread()); |
| 109 ASSERT(!**s_threadSpecific); | 115 ASSERT(!**s_threadSpecific); |
| 110 **s_threadSpecific = this; | 116 **s_threadSpecific = this; |
| 111 | 117 |
| 112 if (isMainThread()) { | 118 if (isMainThread()) { |
| 113 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); | 119 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); |
| 114 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size(); | 120 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size(); |
| 115 if (underestimatedStackSize > sizeof(void*)) | 121 if (underestimatedStackSize > sizeof(void*)) |
| 116 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*); | 122 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 | 697 |
| 692 // Allocation is allowed during sweeping, but those allocations should not | 698 // Allocation is allowed during sweeping, but those allocations should not |
| 693 // trigger nested GCs. | 699 // trigger nested GCs. |
| 694 if (isGCForbidden()) | 700 if (isGCForbidden()) |
| 695 return; | 701 return; |
| 696 | 702 |
| 697 if (isSweepingInProgress()) | 703 if (isSweepingInProgress()) |
| 698 return; | 704 return; |
| 699 ASSERT(!sweepForbidden()); | 705 ASSERT(!sweepForbidden()); |
| 700 | 706 |
| 707 adjustAmountOfMemory(); | |
|
haraken
2016/02/12 09:30:54
adjustAmountOfMemory => reportMemoryToV8 ?
peria
2016/02/15 04:16:59
Done.
| |
| 708 | |
| 701 if (shouldForceMemoryPressureGC()) { | 709 if (shouldForceMemoryPressureGC()) { |
| 702 completeSweep(); | 710 completeSweep(); |
| 703 if (shouldForceMemoryPressureGC()) { | 711 if (shouldForceMemoryPressureGC()) { |
| 704 #if PRINT_HEAP_STATS | 712 #if PRINT_HEAP_STATS |
| 705 dataLogF("Scheduled MemoryPressureGC\n"); | 713 dataLogF("Scheduled MemoryPressureGC\n"); |
| 706 #endif | 714 #endif |
| 707 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithou tSweep, BlinkGC::MemoryPressureGC); | 715 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithou tSweep, BlinkGC::MemoryPressureGC); |
| 708 return; | 716 return; |
| 709 } | 717 } |
| 710 } | 718 } |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 { | 1252 { |
| 1245 ASSERT(checkThread()); | 1253 ASSERT(checkThread()); |
| 1246 ASSERT(m_atSafePoint); | 1254 ASSERT(m_atSafePoint); |
| 1247 s_safePointBarrier->leaveSafePoint(this, locker); | 1255 s_safePointBarrier->leaveSafePoint(this, locker); |
| 1248 m_atSafePoint = false; | 1256 m_atSafePoint = false; |
| 1249 m_stackState = BlinkGC::HeapPointersOnStack; | 1257 m_stackState = BlinkGC::HeapPointersOnStack; |
| 1250 clearSafePointScopeMarker(); | 1258 clearSafePointScopeMarker(); |
| 1251 preSweep(); | 1259 preSweep(); |
| 1252 } | 1260 } |
| 1253 | 1261 |
| 1262 void ThreadState::adjustAmountOfMemory() | |
| 1263 { | |
| 1264 if (!m_isolate) | |
| 1265 return; | |
| 1266 | |
| 1267 size_t currentHeapSize = heapSize(); | |
|
haraken
2016/02/12 09:30:54
size_t currentHeapSize = m_allocatedObjectSize + m
peria
2016/02/15 04:16:59
Done.
| |
| 1268 int64_t diff = static_cast<int64_t>(currentHeapSize) - static_cast<int64_t>( m_prevReportedSize); | |
| 1269 m_isolate->AdjustAmountOfExternalAllocatedMemory(diff); | |
| 1270 m_prevReportedSize = currentHeapSize; | |
|
haraken
2016/02/12 09:30:54
m_prevReportedSize => m_reportedMemoryToV8 ?
peria
2016/02/15 04:16:59
Done.
| |
| 1271 } | |
| 1272 | |
| 1273 void ThreadState::resetHeapSizes() | |
| 1274 { | |
| 1275 m_allocatedObjectSize = 0; | |
| 1276 m_markedObjectSize = 0; | |
| 1277 } | |
| 1278 | |
| 1279 size_t ThreadState::heapSize() | |
|
haraken
2016/02/12 09:30:54
This method won't be needed.
peria
2016/02/15 04:16:59
Done.
| |
| 1280 { | |
| 1281 return allocatedObjectSize() + markedObjectSize(); | |
| 1282 } | |
| 1283 | |
| 1284 void ThreadState::increaseAllocatedObjectSize(size_t delta) | |
| 1285 { | |
| 1286 atomicAdd(&m_allocatedObjectSize, delta); | |
| 1287 Heap::increaseAllocatedObjectSize(delta); | |
| 1288 } | |
| 1289 | |
| 1290 void ThreadState::decreaseAllocatedObjectSize(size_t delta) | |
| 1291 { | |
| 1292 atomicSubtract(&m_allocatedObjectSize, delta); | |
| 1293 Heap::decreaseAllocatedObjectSize(delta); | |
| 1294 } | |
| 1295 | |
| 1296 void ThreadState::increaseMarkedObjectSize(size_t delta) | |
| 1297 { | |
| 1298 atomicAdd(&m_markedObjectSize, delta); | |
| 1299 Heap::increaseMarkedObjectSize(delta); | |
| 1300 } | |
| 1301 | |
| 1254 void ThreadState::copyStackUntilSafePointScope() | 1302 void ThreadState::copyStackUntilSafePointScope() |
| 1255 { | 1303 { |
| 1256 if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStac k) | 1304 if (!m_safePointScopeMarker || m_stackState == BlinkGC::NoHeapPointersOnStac k) |
| 1257 return; | 1305 return; |
| 1258 | 1306 |
| 1259 Address* to = reinterpret_cast<Address*>(m_safePointScopeMarker); | 1307 Address* to = reinterpret_cast<Address*>(m_safePointScopeMarker); |
| 1260 Address* from = reinterpret_cast<Address*>(m_endOfStack); | 1308 Address* from = reinterpret_cast<Address*>(m_endOfStack); |
| 1261 RELEASE_ASSERT(from < to); | 1309 RELEASE_ASSERT(from < to); |
| 1262 RELEASE_ASSERT(to <= reinterpret_cast<Address*>(m_startOfStack)); | 1310 RELEASE_ASSERT(to <= reinterpret_cast<Address*>(m_startOfStack)); |
| 1263 size_t slotCount = static_cast<size_t>(to - from); | 1311 size_t slotCount = static_cast<size_t>(to - from); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1500 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1548 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
| 1501 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1549 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
| 1502 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1550 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
| 1503 | 1551 |
| 1504 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1552 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
| 1505 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1553 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
| 1506 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); | 1554 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); |
| 1507 } | 1555 } |
| 1508 | 1556 |
| 1509 } // namespace blink | 1557 } // namespace blink |
| OLD | NEW |