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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 ThreadState::init(); | 116 ThreadState::init(); |
| 117 ProcessHeap::init(); | 117 ProcessHeap::init(); |
| 118 s_markingStack = new CallbackStack(); | 118 s_markingStack = new CallbackStack(); |
| 119 s_postMarkingCallbackStack = new CallbackStack(); | 119 s_postMarkingCallbackStack = new CallbackStack(); |
| 120 s_globalWeakCallbackStack = new CallbackStack(); | 120 s_globalWeakCallbackStack = new CallbackStack(); |
| 121 // Use smallest supported block size for ephemerons. | 121 // Use smallest supported block size for ephemerons. |
| 122 s_ephemeronStack = new CallbackStack(CallbackStack::kMinimalBlockSize); | 122 s_ephemeronStack = new CallbackStack(CallbackStack::kMinimalBlockSize); |
| 123 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 123 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
| 124 s_freePagePool = new FreePagePool(); | 124 s_freePagePool = new FreePagePool(); |
| 125 s_orphanedPagePool = new OrphanedPagePool(); | 125 s_orphanedPagePool = new OrphanedPagePool(); |
| 126 s_allocatedSpace = 0; | |
| 127 s_allocatedObjectSize = 0; | |
| 128 s_objectSizeAtLastGC = 0; | |
| 129 s_markedObjectSizeAtLastCompleteSweep = 0; | |
| 130 s_wrapperCount = 0; | |
| 131 s_wrapperCountAtLastGC = 0; | |
| 132 s_collectedWrapperCount = 0; | |
| 133 s_partitionAllocSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); | |
| 134 s_estimatedMarkingTimePerByte = 0.0; | |
| 135 s_lastGCReason = BlinkGC::NumberOfGCReason; | 126 s_lastGCReason = BlinkGC::NumberOfGCReason; |
| 136 | 127 |
| 137 GCInfoTable::init(); | 128 GCInfoTable::init(); |
| 138 | 129 |
| 139 if (Platform::current() && Platform::current()->currentThread()) | 130 if (Platform::current() && Platform::current()->currentThread()) |
| 140 Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvide r::instance(), "BlinkGC"); | 131 Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvide r::instance(), "BlinkGC"); |
| 141 } | 132 } |
| 142 | 133 |
| 143 void Heap::shutdown() | 134 void Heap::shutdown() |
| 144 { | 135 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 159 delete s_globalWeakCallbackStack; | 150 delete s_globalWeakCallbackStack; |
| 160 s_globalWeakCallbackStack = nullptr; | 151 s_globalWeakCallbackStack = nullptr; |
| 161 delete s_postMarkingCallbackStack; | 152 delete s_postMarkingCallbackStack; |
| 162 s_postMarkingCallbackStack = nullptr; | 153 s_postMarkingCallbackStack = nullptr; |
| 163 delete s_markingStack; | 154 delete s_markingStack; |
| 164 s_markingStack = nullptr; | 155 s_markingStack = nullptr; |
| 165 delete s_ephemeronStack; | 156 delete s_ephemeronStack; |
| 166 s_ephemeronStack = nullptr; | 157 s_ephemeronStack = nullptr; |
| 167 GCInfoTable::shutdown(); | 158 GCInfoTable::shutdown(); |
| 168 ThreadState::shutdown(); | 159 ThreadState::shutdown(); |
| 169 ASSERT(Heap::allocatedSpace() == 0); | 160 ASSERT(Heap::heapStats().allocatedSpace() == 0); |
| 170 } | 161 } |
| 171 | 162 |
| 172 CrossThreadPersistentRegion& ProcessHeap::crossThreadPersistentRegion() | 163 CrossThreadPersistentRegion& ProcessHeap::crossThreadPersistentRegion() |
| 173 { | 164 { |
| 174 DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion, persistentRegio n, new CrossThreadPersistentRegion()); | 165 DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion, persistentRegio n, new CrossThreadPersistentRegion()); |
| 175 return persistentRegion; | 166 return persistentRegion; |
| 176 } | 167 } |
| 177 | 168 |
| 178 bool ProcessHeap::s_isLowEndDevice = false; | 169 bool ProcessHeap::s_isLowEndDevice = false; |
| 179 size_t ProcessHeap::s_totalAllocatedSpace = 0; | 170 size_t ProcessHeap::s_totalAllocatedSpace = 0; |
| 180 size_t ProcessHeap::s_totalAllocatedObjectSize = 0; | 171 size_t ProcessHeap::s_totalAllocatedObjectSize = 0; |
| 181 size_t ProcessHeap::s_totalMarkedObjectSize = 0; | 172 size_t ProcessHeap::s_totalMarkedObjectSize = 0; |
| 182 | 173 |
| 174 ThreadHeapStats::ThreadHeapStats() | |
| 175 : m_allocatedSpace(0) | |
| 176 , m_allocatedObjectSize(0) | |
| 177 , m_objectSizeAtLastGC(0) | |
| 178 , m_markedObjectSize(0) | |
| 179 , m_markedObjectSizeAtLastCompleteSweep(0) | |
| 180 , m_wrapperCount(0) | |
| 181 , m_wrapperCountAtLastGC(0) | |
| 182 , m_collectedWrapperCount(0) | |
| 183 , m_partitionAllocSizeAtLastGC(WTF::Partitions::totalSizeOfCommittedPages()) | |
| 184 , m_estimatedMarkingTimePerByte(0.0) | |
| 185 { | |
| 186 } | |
| 187 | |
| 188 double ThreadHeapStats::estimatedMarkingTime() | |
| 189 { | |
| 190 // Use 8 ms as initial estimated marking time. | |
| 191 // 8 ms is long enough for low-end mobile devices to mark common | |
| 192 // real-world object graphs. | |
| 193 if (m_estimatedMarkingTimePerByte == 0) | |
| 194 return 0.008; | |
| 195 | |
| 196 // Assuming that the collection rate of this GC will be mostly equal to | |
| 197 // the collection rate of the last GC, estimate the marking time of this GC. | |
| 198 return m_estimatedMarkingTimePerByte * (allocatedObjectSize() + markedObject Size()); | |
| 199 } | |
| 200 | |
| 201 void ThreadHeapStats::reset() | |
| 202 { | |
| 203 m_objectSizeAtLastGC = m_allocatedObjectSize + m_markedObjectSize; | |
| 204 m_partitionAllocSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); | |
| 205 m_allocatedObjectSize = 0; | |
| 206 m_markedObjectSize = 0; | |
| 207 m_wrapperCountAtLastGC = m_wrapperCount; | |
| 208 m_collectedWrapperCount = 0; | |
| 209 } | |
| 210 | |
| 211 void ThreadHeapStats::increaseAllocatedObjectSize(size_t delta) | |
| 212 { | |
| 213 atomicAdd(&m_allocatedObjectSize, static_cast<long>(delta)); | |
| 214 ProcessHeap::increaseTotalAllocatedObjectSize(delta); | |
| 215 } | |
| 216 | |
| 217 void ThreadHeapStats::decreaseAllocatedObjectSize(size_t delta) | |
| 218 { | |
| 219 atomicSubtract(&m_allocatedObjectSize, static_cast<long>(delta)); | |
| 220 ProcessHeap::decreaseTotalAllocatedObjectSize(delta); | |
| 221 } | |
| 222 | |
| 223 void ThreadHeapStats::increaseMarkedObjectSize(size_t delta) | |
| 224 { | |
| 225 atomicAdd(&m_markedObjectSize, static_cast<long>(delta)); | |
| 226 ProcessHeap::increaseTotalMarkedObjectSize(delta); | |
| 227 } | |
| 228 | |
| 229 void ThreadHeapStats::increaseAllocatedSpace(size_t delta) | |
| 230 { | |
| 231 atomicAdd(&m_allocatedSpace, static_cast<long>(delta)); | |
| 232 ProcessHeap::increaseTotalAllocatedSpace(delta); | |
| 233 } | |
| 234 | |
| 235 void ThreadHeapStats::decreaseAllocatedSpace(size_t delta) | |
| 236 { | |
| 237 atomicSubtract(&m_allocatedSpace, static_cast<long>(delta)); | |
| 238 ProcessHeap::decreaseTotalAllocatedSpace(delta); | |
| 239 } | |
| 240 | |
| 183 #if ENABLE(ASSERT) | 241 #if ENABLE(ASSERT) |
| 184 BasePage* Heap::findPageFromAddress(Address address) | 242 BasePage* Heap::findPageFromAddress(Address address) |
| 185 { | 243 { |
| 186 MutexLocker lock(ThreadState::threadAttachMutex()); | 244 MutexLocker lock(ThreadState::threadAttachMutex()); |
| 187 for (ThreadState* state : ThreadState::attachedThreads()) { | 245 for (ThreadState* state : ThreadState::attachedThreads()) { |
| 188 if (BasePage* page = state->findPageFromAddress(address)) | 246 if (BasePage* page = state->findPageFromAddress(address)) |
| 189 return page; | 247 return page; |
| 190 } | 248 } |
| 191 return nullptr; | 249 return nullptr; |
| 192 } | 250 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); | 440 BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC(); |
| 383 | 441 |
| 384 // Disallow allocation during garbage collection (but not during the | 442 // Disallow allocation during garbage collection (but not during the |
| 385 // finalization that happens when the visitorScope is torn down). | 443 // finalization that happens when the visitorScope is torn down). |
| 386 ThreadState::NoAllocationScope noAllocationScope(state); | 444 ThreadState::NoAllocationScope noAllocationScope(state); |
| 387 | 445 |
| 388 preGC(); | 446 preGC(); |
| 389 | 447 |
| 390 StackFrameDepthScope stackDepthScope; | 448 StackFrameDepthScope stackDepthScope; |
| 391 | 449 |
| 392 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz e(); | 450 size_t totalObjectSize = Heap::heapStats().allocatedObjectSize() + Heap::hea pStats().markedObjectSize(); |
| 393 if (gcType != BlinkGC::TakeSnapshot) | 451 if (gcType != BlinkGC::TakeSnapshot) |
| 394 Heap::resetHeapCounters(); | 452 Heap::resetHeapCounters(); |
| 395 | 453 |
| 396 // 1. Trace persistent roots. | 454 // 1. Trace persistent roots. |
| 397 ThreadState::visitPersistentRoots(visitor.get()); | 455 ThreadState::visitPersistentRoots(visitor.get()); |
| 398 | 456 |
| 399 // 2. Trace objects reachable from the stack. We do this independent of the | 457 // 2. Trace objects reachable from the stack. We do this independent of the |
| 400 // given stackState since other threads might have a different stack state. | 458 // given stackState since other threads might have a different stack state. |
| 401 ThreadState::visitStackRoots(visitor.get()); | 459 ThreadState::visitStackRoots(visitor.get()); |
| 402 | 460 |
| 403 // 3. Transitive closure to trace objects including ephemerons. | 461 // 3. Transitive closure to trace objects including ephemerons. |
| 404 processMarkingStack(visitor.get()); | 462 processMarkingStack(visitor.get()); |
| 405 | 463 |
| 406 postMarkingProcessing(visitor.get()); | 464 postMarkingProcessing(visitor.get()); |
| 407 globalWeakProcessing(visitor.get()); | 465 globalWeakProcessing(visitor.get()); |
| 408 | 466 |
| 409 // Now we can delete all orphaned pages because there are no dangling | 467 // Now we can delete all orphaned pages because there are no dangling |
| 410 // pointers to the orphaned pages. (If we have such dangling pointers, | 468 // pointers to the orphaned pages. (If we have such dangling pointers, |
| 411 // we should have crashed during marking before getting here.) | 469 // we should have crashed during marking before getting here.) |
| 412 getOrphanedPagePool()->decommitOrphanedPages(); | 470 getOrphanedPagePool()->decommitOrphanedPages(); |
| 413 | 471 |
| 414 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; | 472 double markingTimeInMilliseconds = WTF::currentTimeMS() - startTime; |
| 415 s_estimatedMarkingTimePerByte = totalObjectSize ? (markingTimeInMilliseconds / 1000 / totalObjectSize) : 0; | 473 Heap::heapStats().setEstimatedMarkingTimePerByte(totalObjectSize ? (markingT imeInMilliseconds / 1000 / totalObjectSize) : 0); |
| 416 | 474 |
| 417 #if PRINT_HEAP_STATS | 475 #if PRINT_HEAP_STATS |
| 418 dataLogF("Heap::collectGarbage (gcReason=%s, lazySweeping=%d, time=%.1lfms)\ n", gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, markingTimeInMill iseconds); | 476 dataLogF("Heap::collectGarbage (gcReason=%s, lazySweeping=%d, time=%.1lfms)\ n", gcReasonString(reason), gcType == BlinkGC::GCWithoutSweep, markingTimeInMill iseconds); |
| 419 #endif | 477 #endif |
| 420 | 478 |
| 421 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, markingTimeHistogram, new CustomCountHistogram("BlinkGC.CollectGarbage", 0, 10 * 1000, 50)); | 479 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, markingTimeHistogram, new CustomCountHistogram("BlinkGC.CollectGarbage", 0, 10 * 1000, 50)); |
| 422 markingTimeHistogram.count(markingTimeInMilliseconds); | 480 markingTimeHistogram.count(markingTimeInMilliseconds); |
| 423 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalObjectSpaceHistog ram, new CustomCountHistogram("BlinkGC.TotalObjectSpace", 0, 4 * 1024 * 1024, 50 )); | 481 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalObjectSpaceHistog ram, new CustomCountHistogram("BlinkGC.TotalObjectSpace", 0, 4 * 1024 * 1024, 50 )); |
| 424 totalObjectSpaceHistogram.count(ProcessHeap::totalAllocatedObjectSize() / 10 24); | 482 totalObjectSpaceHistogram.count(ProcessHeap::totalAllocatedObjectSize() / 10 24); |
| 425 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalAllocatedSpaceHis togram, new CustomCountHistogram("BlinkGC.TotalAllocatedSpace", 0, 4 * 1024 * 10 24, 50)); | 483 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalAllocatedSpaceHis togram, new CustomCountHistogram("BlinkGC.TotalAllocatedSpace", 0, 4 * 1024 * 10 24, 50)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, globalWeakTimeHistogra m, new CustomCountHistogram("BlinkGC.TimeForGlobalWeakProcessing", 1, 10 * 1000, 50)); | 586 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, globalWeakTimeHistogra m, new CustomCountHistogram("BlinkGC.TimeForGlobalWeakProcessing", 1, 10 * 1000, 50)); |
| 529 globalWeakTimeHistogram.count(timeForGlobalWeakProcessing); | 587 globalWeakTimeHistogram.count(timeForGlobalWeakProcessing); |
| 530 } | 588 } |
| 531 | 589 |
| 532 void Heap::collectAllGarbage() | 590 void Heap::collectAllGarbage() |
| 533 { | 591 { |
| 534 // We need to run multiple GCs to collect a chain of persistent handles. | 592 // We need to run multiple GCs to collect a chain of persistent handles. |
| 535 size_t previousLiveObjects = 0; | 593 size_t previousLiveObjects = 0; |
| 536 for (int i = 0; i < 5; ++i) { | 594 for (int i = 0; i < 5; ++i) { |
| 537 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); | 595 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); |
| 538 size_t liveObjects = Heap::markedObjectSize(); | 596 size_t liveObjects = Heap::heapStats().markedObjectSize(); |
| 539 if (liveObjects == previousLiveObjects) | 597 if (liveObjects == previousLiveObjects) |
| 540 break; | 598 break; |
| 541 previousLiveObjects = liveObjects; | 599 previousLiveObjects = liveObjects; |
| 542 } | 600 } |
| 543 } | 601 } |
| 544 | 602 |
| 545 double Heap::estimatedMarkingTime() | |
| 546 { | |
| 547 ASSERT(ThreadState::current()->isMainThread()); | |
| 548 | |
| 549 // Use 8 ms as initial estimated marking time. | |
| 550 // 8 ms is long enough for low-end mobile devices to mark common | |
| 551 // real-world object graphs. | |
| 552 if (s_estimatedMarkingTimePerByte == 0) | |
| 553 return 0.008; | |
| 554 | |
| 555 // Assuming that the collection rate of this GC will be mostly equal to | |
| 556 // the collection rate of the last GC, estimate the marking time of this GC. | |
| 557 return s_estimatedMarkingTimePerByte * (Heap::allocatedObjectSize() + Heap:: markedObjectSize()); | |
| 558 } | |
| 559 | |
| 560 void Heap::reportMemoryUsageHistogram() | 603 void Heap::reportMemoryUsageHistogram() |
| 561 { | 604 { |
| 562 static size_t supportedMaxSizeInMB = 4 * 1024; | 605 static size_t supportedMaxSizeInMB = 4 * 1024; |
| 563 static size_t observedMaxSizeInMB = 0; | 606 static size_t observedMaxSizeInMB = 0; |
| 564 | 607 |
| 565 // We only report the memory in the main thread. | 608 // We only report the memory in the main thread. |
| 566 if (!isMainThread()) | 609 if (!isMainThread()) |
| 567 return; | 610 return; |
| 568 // +1 is for rounding up the sizeInMB. | 611 // +1 is for rounding up the sizeInMB. |
| 569 size_t sizeInMB = Heap::allocatedSpace() / 1024 / 1024 + 1; | 612 size_t sizeInMB = Heap::heapStats().allocatedSpace() / 1024 / 1024 + 1; |
| 570 if (sizeInMB >= supportedMaxSizeInMB) | 613 if (sizeInMB >= supportedMaxSizeInMB) |
| 571 sizeInMB = supportedMaxSizeInMB - 1; | 614 sizeInMB = supportedMaxSizeInMB - 1; |
| 572 if (sizeInMB > observedMaxSizeInMB) { | 615 if (sizeInMB > observedMaxSizeInMB) { |
| 573 // Send a UseCounter only when we see the highest memory usage | 616 // Send a UseCounter only when we see the highest memory usage |
| 574 // we've ever seen. | 617 // we've ever seen. |
| 575 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, commitedSizeHistog ram, new EnumerationHistogram("BlinkGC.CommittedSize", supportedMaxSizeInMB)); | 618 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, commitedSizeHistog ram, new EnumerationHistogram("BlinkGC.CommittedSize", supportedMaxSizeInMB)); |
| 576 commitedSizeHistogram.count(sizeInMB); | 619 commitedSizeHistogram.count(sizeInMB); |
| 577 observedMaxSizeInMB = sizeInMB; | 620 observedMaxSizeInMB = sizeInMB; |
| 578 } | 621 } |
| 579 } | 622 } |
| 580 | 623 |
| 581 void Heap::reportMemoryUsageForTracing() | 624 void Heap::reportMemoryUsageForTracing() |
| 582 { | 625 { |
| 583 #if PRINT_HEAP_STATS | 626 #if PRINT_HEAP_STATS |
| 584 // dataLogF("allocatedSpace=%ldMB, allocatedObjectSize=%ldMB, markedObjectSi ze=%ldMB, partitionAllocSize=%ldMB, wrapperCount=%ld, collectedWrapperCount=%ld\ n", Heap::allocatedSpace() / 1024 / 1024, Heap::allocatedObjectSize() / 1024 / 1 024, Heap::markedObjectSize() / 1024 / 1024, WTF::Partitions::totalSizeOfCommitt edPages() / 1024 / 1024, Heap::wrapperCount(), Heap::collectedWrapperCount()); | 627 // dataLogF("allocatedSpace=%ldMB, allocatedObjectSize=%ldMB, markedObjectSi ze=%ldMB, partitionAllocSize=%ldMB, wrapperCount=%ld, collectedWrapperCount=%ld\ n", Heap::allocatedSpace() / 1024 / 1024, Heap::allocatedObjectSize() / 1024 / 1 024, Heap::markedObjectSize() / 1024 / 1024, WTF::Partitions::totalSizeOfCommitt edPages() / 1024 / 1024, Heap::wrapperCount(), Heap::collectedWrapperCount()); |
| 585 #endif | 628 #endif |
| 586 | 629 |
| 587 bool gcTracingEnabled; | 630 bool gcTracingEnabled; |
| 588 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); | 631 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); |
| 589 if (!gcTracingEnabled) | 632 if (!gcTracingEnabled) |
| 590 return; | 633 return; |
| 591 | 634 |
| 592 // These values are divided by 1024 to avoid overflow in practical cases (TR ACE_COUNTER values are 32-bit ints). | 635 // These values are divided by 1024 to avoid overflow in practical cases (TR ACE_COUNTER values are 32-bit ints). |
| 593 // They are capped to INT_MAX just in case. | 636 // They are capped to INT_MAX just in case. |
| 594 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::allocatedObject SizeKB", std::min(Heap::allocatedObjectSize() / 1024, static_cast<size_t>(INT_MA X))); | 637 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::allocatedObject SizeKB", std::min(Heap::heapStats().allocatedObjectSize() / 1024, static_cast<si ze_t>(INT_MAX))); |
| 595 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::markedObjectSiz eKB", std::min(Heap::markedObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | 638 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::markedObjectSiz eKB", std::min(Heap::heapStats().markedObjectSize() / 1024, static_cast<size_t>( INT_MAX))); |
| 596 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::markedObjectSiz eAtLastCompleteSweepKB", std::min(Heap::markedObjectSizeAtLastCompleteSweep() / 1024, static_cast<size_t>(INT_MAX))); | 639 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::markedObjectSiz eAtLastCompleteSweepKB", std::min(Heap::heapStats().markedObjectSizeAtLastComple teSweep() / 1024, static_cast<size_t>(INT_MAX))); |
| 597 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::allocatedSpaceK B", std::min(Heap::allocatedSpace() / 1024, static_cast<size_t>(INT_MAX))); | 640 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::allocatedSpaceK B", std::min(Heap::heapStats().allocatedSpace() / 1024, static_cast<size_t>(INT_ MAX))); |
| 598 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::objectSizeAtLas tGCKB", std::min(Heap::objectSizeAtLastGC() / 1024, static_cast<size_t>(INT_MAX) )); | 641 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::objectSizeAtLas tGCKB", std::min(Heap::heapStats().objectSizeAtLastGC() / 1024, static_cast<size _t>(INT_MAX))); |
| 599 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::wrapperCount", std::min(Heap::wrapperCount(), static_cast<size_t>(INT_MAX))); | 642 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::wrapperCount", std::min(Heap::heapStats().wrapperCount(), static_cast<size_t>(INT_MAX))); |
| 600 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::wrapperCountAtL astGC", std::min(Heap::wrapperCountAtLastGC(), static_cast<size_t>(INT_MAX))); | 643 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::heapStats().wra pperCountAtLastGC", std::min(Heap::heapStats().wrapperCountAtLastGC(), static_ca st<size_t>(INT_MAX))); |
| 601 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::collectedWrappe rCount", std::min(Heap::collectedWrapperCount(), static_cast<size_t>(INT_MAX))); | 644 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::collectedWrappe rCount", std::min(Heap::heapStats().collectedWrapperCount(), static_cast<size_t> (INT_MAX))); |
| 602 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::partitionAllocS izeAtLastGCKB", std::min(Heap::partitionAllocSizeAtLastGC() / 1024, static_cast< size_t>(INT_MAX))); | 645 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Heap::partitionAllocS izeAtLastGCKB", std::min(Heap::heapStats().partitionAllocSizeAtLastGC() / 1024, static_cast<size_t>(INT_MAX))); |
| 603 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Partitions::totalSize OfCommittedPagesKB", std::min(WTF::Partitions::totalSizeOfCommittedPages() / 102 4, static_cast<size_t>(INT_MAX))); | 646 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "Partitions::totalSize OfCommittedPagesKB", std::min(WTF::Partitions::totalSizeOfCommittedPages() / 102 4, static_cast<size_t>(INT_MAX))); |
| 604 } | 647 } |
| 605 | 648 |
| 606 size_t Heap::objectPayloadSizeForTesting() | 649 size_t Heap::objectPayloadSizeForTesting() |
| 607 { | 650 { |
| 608 size_t objectPayloadSize = 0; | 651 size_t objectPayloadSize = 0; |
| 609 for (ThreadState* state : ThreadState::attachedThreads()) { | 652 for (ThreadState* state : ThreadState::attachedThreads()) { |
| 610 state->setGCState(ThreadState::GCRunning); | 653 state->setGCState(ThreadState::GCRunning); |
| 611 state->makeConsistentForGC(); | 654 state->makeConsistentForGC(); |
| 612 objectPayloadSize += state->objectPayloadSizeForTesting(); | 655 objectPayloadSize += state->objectPayloadSizeForTesting(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 632 } | 675 } |
| 633 return nullptr; | 676 return nullptr; |
| 634 } | 677 } |
| 635 | 678 |
| 636 void Heap::resetHeapCounters() | 679 void Heap::resetHeapCounters() |
| 637 { | 680 { |
| 638 ASSERT(ThreadState::current()->isInGC()); | 681 ASSERT(ThreadState::current()->isInGC()); |
| 639 | 682 |
| 640 Heap::reportMemoryUsageForTracing(); | 683 Heap::reportMemoryUsageForTracing(); |
| 641 | 684 |
| 642 s_objectSizeAtLastGC = s_allocatedObjectSize + s_markedObjectSize; | 685 Heap::heapStats().reset(); |
| 643 s_partitionAllocSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); | |
| 644 s_allocatedObjectSize = 0; | |
| 645 s_markedObjectSize = 0; | |
| 646 s_wrapperCountAtLastGC = s_wrapperCount; | |
| 647 s_collectedWrapperCount = 0; | |
| 648 for (ThreadState* state : ThreadState::attachedThreads()) | 686 for (ThreadState* state : ThreadState::attachedThreads()) |
| 649 state->resetHeapCounters(); | 687 state->resetHeapCounters(); |
| 650 } | 688 } |
| 651 | 689 |
| 690 ThreadHeapStats& Heap::heapStats() | |
|
haraken
2016/03/30 04:37:20
Add a TODO and mention that this should be moved t
keishi
2016/03/31 09:29:45
Done.
| |
| 691 { | |
| 692 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadHeapStats, stats, new ThreadHeapStats( )); | |
| 693 return stats; | |
| 694 } | |
| 695 | |
| 652 CallbackStack* Heap::s_markingStack; | 696 CallbackStack* Heap::s_markingStack; |
| 653 CallbackStack* Heap::s_postMarkingCallbackStack; | 697 CallbackStack* Heap::s_postMarkingCallbackStack; |
| 654 CallbackStack* Heap::s_globalWeakCallbackStack; | 698 CallbackStack* Heap::s_globalWeakCallbackStack; |
| 655 CallbackStack* Heap::s_ephemeronStack; | 699 CallbackStack* Heap::s_ephemeronStack; |
| 656 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 700 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
| 657 FreePagePool* Heap::s_freePagePool; | 701 FreePagePool* Heap::s_freePagePool; |
| 658 OrphanedPagePool* Heap::s_orphanedPagePool; | 702 OrphanedPagePool* Heap::s_orphanedPagePool; |
| 659 size_t Heap::s_allocatedSpace = 0; | |
| 660 size_t Heap::s_allocatedObjectSize = 0; | |
| 661 size_t Heap::s_objectSizeAtLastGC = 0; | |
| 662 size_t Heap::s_markedObjectSize = 0; | |
| 663 size_t Heap::s_markedObjectSizeAtLastCompleteSweep = 0; | |
| 664 size_t Heap::s_wrapperCount = 0; | |
| 665 size_t Heap::s_wrapperCountAtLastGC = 0; | |
| 666 size_t Heap::s_collectedWrapperCount = 0; | |
| 667 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | |
| 668 double Heap::s_estimatedMarkingTimePerByte = 0.0; | |
| 669 | 703 |
| 670 BlinkGC::GCReason Heap::s_lastGCReason = BlinkGC::NumberOfGCReason; | 704 BlinkGC::GCReason Heap::s_lastGCReason = BlinkGC::NumberOfGCReason; |
| 671 | 705 |
| 672 } // namespace blink | 706 } // namespace blink |
| OLD | NEW |