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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( ))) | 92 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( ))) |
| 93 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) ) | 93 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) ) |
| 94 , m_safePointScopeMarker(nullptr) | 94 , m_safePointScopeMarker(nullptr) |
| 95 , m_atSafePoint(false) | 95 , m_atSafePoint(false) |
| 96 , m_interruptors() | 96 , m_interruptors() |
| 97 , m_sweepForbidden(false) | 97 , m_sweepForbidden(false) |
| 98 , m_noAllocationCount(0) | 98 , m_noAllocationCount(0) |
| 99 , m_gcForbiddenCount(0) | 99 , m_gcForbiddenCount(0) |
| 100 , m_persistentAllocated(0) | 100 , m_persistentAllocated(0) |
| 101 , m_persistentFreed(0) | 101 , m_persistentFreed(0) |
| 102 , m_pageNavigationCount(0) | |
| 102 , m_vectorBackingHeapIndex(Vector1HeapIndex) | 103 , m_vectorBackingHeapIndex(Vector1HeapIndex) |
| 103 , m_currentHeapAges(0) | 104 , m_currentHeapAges(0) |
| 104 , m_isTerminating(false) | 105 , m_isTerminating(false) |
| 105 , m_gcMixinMarker(nullptr) | 106 , m_gcMixinMarker(nullptr) |
| 106 , m_shouldFlushHeapDoesNotContainCache(false) | 107 , m_shouldFlushHeapDoesNotContainCache(false) |
| 107 , m_gcState(NoGCScheduled) | 108 , m_gcState(NoGCScheduled) |
| 108 , m_traceDOMWrappers(nullptr) | 109 , m_traceDOMWrappers(nullptr) |
| 109 #if defined(ADDRESS_SANITIZER) | 110 #if defined(ADDRESS_SANITIZER) |
| 110 , m_asanFakeStack(__asan_get_current_fake_stack()) | 111 , m_asanFakeStack(__asan_get_current_fake_stack()) |
| 111 #endif | 112 #endif |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 if (isGCForbidden()) | 697 if (isGCForbidden()) |
| 697 return; | 698 return; |
| 698 | 699 |
| 699 // Finish on-going lazy sweeping. | 700 // Finish on-going lazy sweeping. |
| 700 // TODO(haraken): It might not make sense to force completeSweep() for all | 701 // TODO(haraken): It might not make sense to force completeSweep() for all |
| 701 // page navigations. | 702 // page navigations. |
| 702 completeSweep(); | 703 completeSweep(); |
| 703 ASSERT(!isSweepingInProgress()); | 704 ASSERT(!isSweepingInProgress()); |
| 704 ASSERT(!sweepForbidden()); | 705 ASSERT(!sweepForbidden()); |
| 705 | 706 |
| 707 ++m_pageNavigationCount; | |
| 708 if (m_pageNavigationCount >= 5) { | |
| 709 // A frame retains a lot of memory in the V8 side. V8's GC cannot | |
| 710 // collect the memory until Oilpan's GC collects the frame. So we | |
| 711 // force a conservative GC if no Oilpan's GC has been observed in | |
| 712 // the past 5 frame navigations. | |
| 713 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva tiveGC); | |
| 714 return; | |
| 715 } | |
| 716 | |
| 706 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) | 717 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) |
| 707 schedulePageNavigationGC(); | 718 schedulePageNavigationGC(); |
| 708 } | 719 } |
| 709 | 720 |
| 710 void ThreadState::schedulePageNavigationGC() | 721 void ThreadState::schedulePageNavigationGC() |
| 711 { | 722 { |
| 712 ASSERT(checkThread()); | 723 ASSERT(checkThread()); |
| 713 ASSERT(!isSweepingInProgress()); | 724 ASSERT(!isSweepingInProgress()); |
| 714 setGCState(PageNavigationGCScheduled); | 725 setGCState(PageNavigationGCScheduled); |
| 715 } | 726 } |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 | 1401 |
| 1391 if (isMainThread()) | 1402 if (isMainThread()) |
| 1392 ScriptForbiddenScope::exit(); | 1403 ScriptForbiddenScope::exit(); |
| 1393 } | 1404 } |
| 1394 | 1405 |
| 1395 void ThreadState::clearHeapAges() | 1406 void ThreadState::clearHeapAges() |
| 1396 { | 1407 { |
| 1397 memset(m_heapAges, 0, sizeof(size_t) * NumberOfHeaps); | 1408 memset(m_heapAges, 0, sizeof(size_t) * NumberOfHeaps); |
| 1398 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF reedArraySize); | 1409 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF reedArraySize); |
| 1399 m_currentHeapAges = 0; | 1410 m_currentHeapAges = 0; |
| 1411 m_pageNavigationCount = 0; | |
|
keishi
2015/09/19 06:12:15
nit: I'm not sure if this belongs here because it
haraken
2015/09/19 08:17:14
Moved this to preGC.
| |
| 1400 } | 1412 } |
| 1401 | 1413 |
| 1402 int ThreadState::heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHeapIndex) | 1414 int ThreadState::heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHeapIndex) |
| 1403 { | 1415 { |
| 1404 size_t minHeapAge = m_heapAges[beginHeapIndex]; | 1416 size_t minHeapAge = m_heapAges[beginHeapIndex]; |
| 1405 int heapIndexWithMinHeapAge = beginHeapIndex; | 1417 int heapIndexWithMinHeapAge = beginHeapIndex; |
| 1406 for (int heapIndex = beginHeapIndex + 1; heapIndex <= endHeapIndex; heapInde x++) { | 1418 for (int heapIndex = beginHeapIndex + 1; heapIndex <= endHeapIndex; heapInde x++) { |
| 1407 if (m_heapAges[heapIndex] < minHeapAge) { | 1419 if (m_heapAges[heapIndex] < minHeapAge) { |
| 1408 minHeapAge = m_heapAges[heapIndex]; | 1420 minHeapAge = m_heapAges[heapIndex]; |
| 1409 heapIndexWithMinHeapAge = heapIndex; | 1421 heapIndexWithMinHeapAge = heapIndex; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1609 json->beginArray(it->key.ascii().data()); | 1621 json->beginArray(it->key.ascii().data()); |
| 1610 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1622 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1611 json->pushInteger(it->value.ages[age]); | 1623 json->pushInteger(it->value.ages[age]); |
| 1612 json->endArray(); | 1624 json->endArray(); |
| 1613 } | 1625 } |
| 1614 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1626 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
| 1615 } | 1627 } |
| 1616 #endif | 1628 #endif |
| 1617 | 1629 |
| 1618 } // namespace blink | 1630 } // namespace blink |
| OLD | NEW |