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

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

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

Powered by Google App Engine
This is Rietveld 408576698