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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 990 } |
980 | 991 |
981 void ThreadState::preGC() | 992 void ThreadState::preGC() |
982 { | 993 { |
983 ASSERT(!isInGC()); | 994 ASSERT(!isInGC()); |
984 setGCState(GCRunning); | 995 setGCState(GCRunning); |
985 makeConsistentForGC(); | 996 makeConsistentForGC(); |
986 flushHeapDoesNotContainCacheIfNeeded(); | 997 flushHeapDoesNotContainCacheIfNeeded(); |
987 clearHeapAges(); | 998 clearHeapAges(); |
988 updatePersistentCounters(); | 999 updatePersistentCounters(); |
| 1000 m_pageNavigationCount = 0; |
989 } | 1001 } |
990 | 1002 |
991 void ThreadState::postGC(GCType gcType) | 1003 void ThreadState::postGC(GCType gcType) |
992 { | 1004 { |
993 ASSERT(isInGC()); | 1005 ASSERT(isInGC()); |
994 | 1006 |
995 #if ENABLE(GC_PROFILING) | 1007 #if ENABLE(GC_PROFILING) |
996 // We snapshot the heap prior to sweeping to get numbers for both resources | 1008 // We snapshot the heap prior to sweeping to get numbers for both resources |
997 // that have been allocated since the last GC and for resources that are | 1009 // that have been allocated since the last GC and for resources that are |
998 // going to be freed. | 1010 // going to be freed. |
(...skipping 610 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 |