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

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

Issue 2384213003: reflow comments in platform/heap (Closed)
Patch Set: Created 4 years, 2 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 oldCount = currentCount; 324 oldCount = currentCount;
325 currentCount = getPersistentRegion()->numberOfPersistents(); 325 currentCount = getPersistentRegion()->numberOfPersistents();
326 } 326 }
327 // We should not have any persistents left when getting to this point, 327 // We should not have any persistents left when getting to this point,
328 // if we have it is probably a bug so adding a debug ASSERT to catch this. 328 // if we have it is probably a bug so adding a debug ASSERT to catch this.
329 ASSERT(!currentCount); 329 ASSERT(!currentCount);
330 // All of pre-finalizers should be consumed. 330 // All of pre-finalizers should be consumed.
331 ASSERT(m_orderedPreFinalizers.isEmpty()); 331 ASSERT(m_orderedPreFinalizers.isEmpty());
332 RELEASE_ASSERT(gcState() == NoGCScheduled); 332 RELEASE_ASSERT(gcState() == NoGCScheduled);
333 333
334 // Add pages to the orphaned page pool to ensure any global GCs from this poin t 334 // Add pages to the orphaned page pool to ensure any global GCs from this
335 // on will not trace objects on this thread's arenas. 335 // point on will not trace objects on this thread's arenas.
336 cleanupPages(); 336 cleanupPages();
337 } 337 }
338 338
339 void ThreadState::cleanupMainThread() { 339 void ThreadState::cleanupMainThread() {
340 ASSERT(isMainThread()); 340 ASSERT(isMainThread());
341 341
342 #if defined(LEAK_SANITIZER) 342 #if defined(LEAK_SANITIZER)
343 // See comment below, clear out most garbage before releasing static 343 // See comment below, clear out most garbage before releasing static
344 // persistents should some of the finalizers depend on touching 344 // persistents should some of the finalizers depend on touching
345 // these persistents. 345 // these persistents.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 WTF::Partitions::totalSizeOfCommittedPages(); 537 WTF::Partitions::totalSizeOfCommittedPages();
538 } 538 }
539 539
540 size_t ThreadState::estimatedLiveSize(size_t estimationBaseSize, 540 size_t ThreadState::estimatedLiveSize(size_t estimationBaseSize,
541 size_t sizeAtLastGC) { 541 size_t sizeAtLastGC) {
542 if (m_heap->heapStats().wrapperCountAtLastGC() == 0) { 542 if (m_heap->heapStats().wrapperCountAtLastGC() == 0) {
543 // We'll reach here only before hitting the first GC. 543 // We'll reach here only before hitting the first GC.
544 return 0; 544 return 0;
545 } 545 }
546 546
547 // (estimated size) = (estimation base size) - (heap size at the last GC) / (# of persistent handles at the last GC) * (# of persistent handles collected sinc e the last GC); 547 // (estimated size) = (estimation base size) - (heap size at the last GC) /
548 // (# of persistent handles at the last GC) *
549 // (# of persistent handles collected since the last GC);
548 size_t sizeRetainedByCollectedPersistents = static_cast<size_t>( 550 size_t sizeRetainedByCollectedPersistents = static_cast<size_t>(
549 1.0 * sizeAtLastGC / m_heap->heapStats().wrapperCountAtLastGC() * 551 1.0 * sizeAtLastGC / m_heap->heapStats().wrapperCountAtLastGC() *
550 m_heap->heapStats().collectedWrapperCount()); 552 m_heap->heapStats().collectedWrapperCount());
551 if (estimationBaseSize < sizeRetainedByCollectedPersistents) 553 if (estimationBaseSize < sizeRetainedByCollectedPersistents)
552 return 0; 554 return 0;
553 return estimationBaseSize - sizeRetainedByCollectedPersistents; 555 return estimationBaseSize - sizeRetainedByCollectedPersistents;
554 } 556 }
555 557
556 double ThreadState::heapGrowingRate() { 558 double ThreadState::heapGrowingRate() {
557 size_t currentSize = m_heap->heapStats().allocatedObjectSize() + 559 size_t currentSize = m_heap->heapStats().allocatedObjectSize() +
(...skipping 29 matching lines...) Expand all
587 "ThreadState::partitionAllocGrowingRate", 589 "ThreadState::partitionAllocGrowingRate",
588 static_cast<int>(100 * growingRate)); 590 static_cast<int>(100 * growingRate));
589 return growingRate; 591 return growingRate;
590 } 592 }
591 593
592 // TODO(haraken): We should improve the GC heuristics. The heuristics affect 594 // TODO(haraken): We should improve the GC heuristics. The heuristics affect
593 // performance significantly. 595 // performance significantly.
594 bool ThreadState::judgeGCThreshold(size_t allocatedObjectSizeThreshold, 596 bool ThreadState::judgeGCThreshold(size_t allocatedObjectSizeThreshold,
595 size_t totalMemorySizeThreshold, 597 size_t totalMemorySizeThreshold,
596 double heapGrowingRateThreshold) { 598 double heapGrowingRateThreshold) {
597 // If the allocated object size or the total memory size is small, don't trigg er a GC. 599 // If the allocated object size or the total memory size is small, don't
600 // trigger a GC.
598 if (m_heap->heapStats().allocatedObjectSize() < 601 if (m_heap->heapStats().allocatedObjectSize() <
599 allocatedObjectSizeThreshold || 602 allocatedObjectSizeThreshold ||
600 totalMemorySize() < totalMemorySizeThreshold) 603 totalMemorySize() < totalMemorySizeThreshold)
601 return false; 604 return false;
602 // If the growing rate of Oilpan's heap or PartitionAlloc is high enough, 605 // If the growing rate of Oilpan's heap or PartitionAlloc is high enough,
603 // trigger a GC. 606 // trigger a GC.
604 #if PRINT_HEAP_STATS 607 #if PRINT_HEAP_STATS
605 dataLogF("heapGrowingRate=%.1lf, partitionAllocGrowingRate=%.1lf\n", 608 dataLogF("heapGrowingRate=%.1lf, partitionAllocGrowingRate=%.1lf\n",
606 heapGrowingRate(), partitionAllocGrowingRate()); 609 heapGrowingRate(), partitionAllocGrowingRate());
607 #endif 610 #endif
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 ASSERT(!m_atSafePoint); 1321 ASSERT(!m_atSafePoint);
1319 m_stackState = stackState; 1322 m_stackState = stackState;
1320 m_atSafePoint = true; 1323 m_atSafePoint = true;
1321 m_heap->checkAndPark(this, nullptr); 1324 m_heap->checkAndPark(this, nullptr);
1322 m_atSafePoint = false; 1325 m_atSafePoint = false;
1323 m_stackState = BlinkGC::HeapPointersOnStack; 1326 m_stackState = BlinkGC::HeapPointersOnStack;
1324 preSweep(); 1327 preSweep();
1325 } 1328 }
1326 1329
1327 #ifdef ADDRESS_SANITIZER 1330 #ifdef ADDRESS_SANITIZER
1328 // When we are running under AddressSanitizer with detect_stack_use_after_return =1 1331 // When we are running under AddressSanitizer with
1329 // then stack marker obtained from SafePointScope will point into a fake stack. 1332 // detect_stack_use_after_return=1 then stack marker obtained from
1330 // Detect this case by checking if it falls in between current stack frame 1333 // SafePointScope will point into a fake stack. Detect this case by checking if
1331 // and stack start and use an arbitrary high enough value for it. 1334 // it falls in between current stack frame and stack start and use an arbitrary
1332 // Don't adjust stack marker in any other case to match behavior of code running 1335 // high enough value for it. Don't adjust stack marker in any other case to
1333 // without AddressSanitizer. 1336 // match behavior of code running without AddressSanitizer.
1334 NO_SANITIZE_ADDRESS static void* adjustScopeMarkerForAdressSanitizer( 1337 NO_SANITIZE_ADDRESS static void* adjustScopeMarkerForAdressSanitizer(
1335 void* scopeMarker) { 1338 void* scopeMarker) {
1336 Address start = reinterpret_cast<Address>(StackFrameDepth::getStackStart()); 1339 Address start = reinterpret_cast<Address>(StackFrameDepth::getStackStart());
1337 Address end = reinterpret_cast<Address>(&start); 1340 Address end = reinterpret_cast<Address>(&start);
1338 RELEASE_ASSERT(end < start); 1341 RELEASE_ASSERT(end < start);
1339 1342
1340 if (end <= scopeMarker && scopeMarker < start) 1343 if (end <= scopeMarker && scopeMarker < start)
1341 return scopeMarker; 1344 return scopeMarker;
1342 1345
1343 // 256 is as good an approximation as any else. 1346 // 256 is as good an approximation as any else.
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, 1822 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep,
1820 BlinkGC::ForcedGC); 1823 BlinkGC::ForcedGC);
1821 size_t liveObjects = heap().heapStats().markedObjectSize(); 1824 size_t liveObjects = heap().heapStats().markedObjectSize();
1822 if (liveObjects == previousLiveObjects) 1825 if (liveObjects == previousLiveObjects)
1823 break; 1826 break;
1824 previousLiveObjects = liveObjects; 1827 previousLiveObjects = liveObjects;
1825 } 1828 }
1826 } 1829 }
1827 1830
1828 } // namespace blink 1831 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | third_party/WebKit/Source/platform/heap/TraceTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698