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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 TRACE_EVENT0("blink_gc", "BaseHeap::lazySweepPages"); | 438 TRACE_EVENT0("blink_gc", "BaseHeap::lazySweepPages"); |
| 439 ThreadState::SweepForbiddenScope scope(threadState()); | 439 ThreadState::SweepForbiddenScope scope(threadState()); |
| 440 | 440 |
| 441 if (threadState()->isMainThread()) | 441 if (threadState()->isMainThread()) |
| 442 ScriptForbiddenScope::enter(); | 442 ScriptForbiddenScope::enter(); |
| 443 | 443 |
| 444 Address result = lazySweepPages(allocationSize, gcInfoIndex); | 444 Address result = lazySweepPages(allocationSize, gcInfoIndex); |
| 445 | 445 |
| 446 if (threadState()->isMainThread()) | 446 if (threadState()->isMainThread()) |
| 447 ScriptForbiddenScope::exit(); | 447 ScriptForbiddenScope::exit(); |
| 448 | |
| 449 Heap::reportMemoryUsageForTracing(); | |
| 450 | |
| 448 return result; | 451 return result; |
| 449 } | 452 } |
| 450 | 453 |
| 451 void BaseHeap::sweepUnsweptPage() | 454 void BaseHeap::sweepUnsweptPage() |
| 452 { | 455 { |
| 453 BasePage* page = m_firstUnsweptPage; | 456 BasePage* page = m_firstUnsweptPage; |
| 454 if (page->isEmpty()) { | 457 if (page->isEmpty()) { |
| 455 page->unlink(&m_firstUnsweptPage); | 458 page->unlink(&m_firstUnsweptPage); |
| 456 page->removeFromHeap(); | 459 page->removeFromHeap(); |
| 457 } else { | 460 } else { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 474 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | 477 RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
| 475 ASSERT(threadState()->sweepForbidden()); | 478 ASSERT(threadState()->sweepForbidden()); |
| 476 ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbi dden()); | 479 ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbi dden()); |
| 477 | 480 |
| 478 int pageCount = 1; | 481 int pageCount = 1; |
| 479 while (m_firstUnsweptPage) { | 482 while (m_firstUnsweptPage) { |
| 480 sweepUnsweptPage(); | 483 sweepUnsweptPage(); |
| 481 if (pageCount % deadlineCheckInterval == 0) { | 484 if (pageCount % deadlineCheckInterval == 0) { |
| 482 if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingT ime()) { | 485 if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingT ime()) { |
| 483 // Deadline has come. | 486 // Deadline has come. |
| 487 Heap::reportMemoryUsageForTracing(); | |
| 484 return !m_firstUnsweptPage; | 488 return !m_firstUnsweptPage; |
| 485 } | 489 } |
| 486 } | 490 } |
| 487 pageCount++; | 491 pageCount++; |
| 488 } | 492 } |
| 493 Heap::reportMemoryUsageForTracing(); | |
| 489 return true; | 494 return true; |
| 490 } | 495 } |
| 491 | 496 |
| 492 void BaseHeap::completeSweep() | 497 void BaseHeap::completeSweep() |
| 493 { | 498 { |
| 494 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | 499 RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
| 495 ASSERT(threadState()->sweepForbidden()); | 500 ASSERT(threadState()->sweepForbidden()); |
| 496 ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbi dden()); | 501 ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbi dden()); |
| 497 | 502 |
| 498 while (m_firstUnsweptPage) { | 503 while (m_firstUnsweptPage) { |
| 499 sweepUnsweptPage(); | 504 sweepUnsweptPage(); |
| 500 } | 505 } |
| 506 | |
| 507 Heap::reportMemoryUsageForTracing(); | |
|
haraken
2015/06/22 04:28:51
I think it's better to put Heap::reportMemoryUsage
Yuta Kitamura
2015/06/22 08:31:52
Correct me if I'm wrong, but I think no ThreadStat
| |
| 501 } | 508 } |
| 502 | 509 |
| 503 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) | 510 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) |
| 504 : BaseHeap(state, index) | 511 : BaseHeap(state, index) |
| 505 , m_currentAllocationPoint(nullptr) | 512 , m_currentAllocationPoint(nullptr) |
| 506 , m_remainingAllocationSize(0) | 513 , m_remainingAllocationSize(0) |
| 507 , m_lastRemainingAllocationSize(0) | 514 , m_lastRemainingAllocationSize(0) |
| 508 , m_promptlyFreedSize(0) | 515 , m_promptlyFreedSize(0) |
| 509 #if ENABLE(GC_PROFILING) | 516 #if ENABLE(GC_PROFILING) |
| 510 , m_cumulativeAllocationSize(0) | 517 , m_cumulativeAllocationSize(0) |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2183 if (sizeInMB >= supportedMaxSizeInMB) | 2190 if (sizeInMB >= supportedMaxSizeInMB) |
| 2184 sizeInMB = supportedMaxSizeInMB - 1; | 2191 sizeInMB = supportedMaxSizeInMB - 1; |
| 2185 if (sizeInMB > observedMaxSizeInMB) { | 2192 if (sizeInMB > observedMaxSizeInMB) { |
| 2186 // Send a UseCounter only when we see the highest memory usage | 2193 // Send a UseCounter only when we see the highest memory usage |
| 2187 // we've ever seen. | 2194 // we've ever seen. |
| 2188 Platform::current()->histogramEnumeration("BlinkGC.CommittedSize", sizeI nMB, supportedMaxSizeInMB); | 2195 Platform::current()->histogramEnumeration("BlinkGC.CommittedSize", sizeI nMB, supportedMaxSizeInMB); |
| 2189 observedMaxSizeInMB = sizeInMB; | 2196 observedMaxSizeInMB = sizeInMB; |
| 2190 } | 2197 } |
| 2191 } | 2198 } |
| 2192 | 2199 |
| 2200 #if ENABLE(GC_PROFILING) | |
| 2201 void Heap::reportMemoryUsageForTracing() | |
| 2202 { | |
| 2203 // These values are divided by 1024 to avoid overflow in practical cases (TR ACE_COUNTER values are 32-bit ints). | |
| 2204 // They are capped to INT_MAX just in case. | |
| 2205 TRACE_COUNTER1("blink_gc", "Heap::estimatedLiveObjectSizeKB", std::min(Heap: :estimatedLiveObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 2206 TRACE_COUNTER1("blink_gc", "Heap::allocatedObjectSizeKB", std::min(Heap::all ocatedObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 2207 TRACE_COUNTER1("blink_gc", "Heap::markedObjectSizeKB", std::min(Heap::marked ObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 2208 TRACE_COUNTER1("blink_gc", "Partitions::totalSizeOfCommittedPagesKB", std::m in(WTF::Partitions::totalSizeOfCommittedPages() / 1024, static_cast<size_t>(INT_ MAX))); | |
| 2209 } | |
| 2210 #endif | |
| 2211 | |
| 2193 size_t Heap::objectPayloadSizeForTesting() | 2212 size_t Heap::objectPayloadSizeForTesting() |
| 2194 { | 2213 { |
| 2195 size_t objectPayloadSize = 0; | 2214 size_t objectPayloadSize = 0; |
| 2196 for (ThreadState* state : ThreadState::attachedThreads()) { | 2215 for (ThreadState* state : ThreadState::attachedThreads()) { |
| 2197 state->setGCState(ThreadState::GCRunning); | 2216 state->setGCState(ThreadState::GCRunning); |
| 2198 state->makeConsistentForGC(); | 2217 state->makeConsistentForGC(); |
| 2199 objectPayloadSize += state->objectPayloadSizeForTesting(); | 2218 objectPayloadSize += state->objectPayloadSizeForTesting(); |
| 2200 state->setGCState(ThreadState::EagerSweepScheduled); | 2219 state->setGCState(ThreadState::EagerSweepScheduled); |
| 2201 state->setGCState(ThreadState::Sweeping); | 2220 state->setGCState(ThreadState::Sweeping); |
| 2202 state->setGCState(ThreadState::NoGCScheduled); | 2221 state->setGCState(ThreadState::NoGCScheduled); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2316 size_t Heap::s_allocatedObjectSize = 0; | 2335 size_t Heap::s_allocatedObjectSize = 0; |
| 2317 size_t Heap::s_allocatedSpace = 0; | 2336 size_t Heap::s_allocatedSpace = 0; |
| 2318 size_t Heap::s_markedObjectSize = 0; | 2337 size_t Heap::s_markedObjectSize = 0; |
| 2319 // We don't want to use 0 KB for the initial value because it may end up | 2338 // We don't want to use 0 KB for the initial value because it may end up |
| 2320 // triggering the first GC of some thread too prematurely. | 2339 // triggering the first GC of some thread too prematurely. |
| 2321 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2340 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2322 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2341 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2323 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2342 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2324 | 2343 |
| 2325 } // namespace blink | 2344 } // namespace blink |
| OLD | NEW |