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 // for a conservative GC if no Oilpan's GC has been observed in |
| 712 // the past 5 frame navigations. |
| 713 // |
| 714 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); |
| 715 return; |
| 716 } |
| 717 |
706 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) | 718 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) |
707 schedulePageNavigationGC(); | 719 schedulePageNavigationGC(); |
708 } | 720 } |
709 | 721 |
710 void ThreadState::schedulePageNavigationGC() | 722 void ThreadState::schedulePageNavigationGC() |
711 { | 723 { |
712 ASSERT(checkThread()); | 724 ASSERT(checkThread()); |
713 ASSERT(!isSweepingInProgress()); | 725 ASSERT(!isSweepingInProgress()); |
714 setGCState(PageNavigationGCScheduled); | 726 setGCState(PageNavigationGCScheduled); |
715 } | 727 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 991 } |
980 | 992 |
981 void ThreadState::preGC() | 993 void ThreadState::preGC() |
982 { | 994 { |
983 ASSERT(!isInGC()); | 995 ASSERT(!isInGC()); |
984 setGCState(GCRunning); | 996 setGCState(GCRunning); |
985 makeConsistentForGC(); | 997 makeConsistentForGC(); |
986 flushHeapDoesNotContainCacheIfNeeded(); | 998 flushHeapDoesNotContainCacheIfNeeded(); |
987 clearHeapAges(); | 999 clearHeapAges(); |
988 updatePersistentCounters(); | 1000 updatePersistentCounters(); |
| 1001 m_pageNavigationCount = 0; |
989 } | 1002 } |
990 | 1003 |
991 void ThreadState::postGC(GCType gcType) | 1004 void ThreadState::postGC(GCType gcType) |
992 { | 1005 { |
993 ASSERT(isInGC()); | 1006 ASSERT(isInGC()); |
994 | 1007 |
995 #if ENABLE(GC_PROFILING) | 1008 #if ENABLE(GC_PROFILING) |
996 // We snapshot the heap prior to sweeping to get numbers for both resources | 1009 // 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 | 1010 // that have been allocated since the last GC and for resources that are |
998 // going to be freed. | 1011 // going to be freed. |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 json->beginArray(it->key.ascii().data()); | 1622 json->beginArray(it->key.ascii().data()); |
1610 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1623 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1611 json->pushInteger(it->value.ages[age]); | 1624 json->pushInteger(it->value.ages[age]); |
1612 json->endArray(); | 1625 json->endArray(); |
1613 } | 1626 } |
1614 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1627 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
1615 } | 1628 } |
1616 #endif | 1629 #endif |
1617 | 1630 |
1618 } // namespace blink | 1631 } // namespace blink |
OLD | NEW |