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

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

Issue 1358813002: Oilpan: We shouldn't trigger too many conservative GCs when detaching iframes Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_disposedV8ContextCount(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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 schedulePageNavigationGC(); 725 schedulePageNavigationGC();
725 } 726 }
726 727
727 void ThreadState::schedulePageNavigationGC() 728 void ThreadState::schedulePageNavigationGC()
728 { 729 {
729 ASSERT(checkThread()); 730 ASSERT(checkThread());
730 ASSERT(!isSweepingInProgress()); 731 ASSERT(!isSweepingInProgress());
731 setGCState(PageNavigationGCScheduled); 732 setGCState(PageNavigationGCScheduled);
732 } 733 }
733 734
735 void ThreadState::v8ContextCreated()
736 {
737 if (m_disposedV8ContextCount >= 5) {
738 // A frame retains a lot of memory in the V8 side. V8's GC cannot
739 // collect the memory until Oilpan's GC collects the frame. So we
740 // force a conservative GC if no Oilpan's GC has been observed in
741 // the past 5 frame navigations.
742 //
743 // We force a conservative GC not in v8ContextDisposed but in
744 // v8ContextCreated. This avoids triggering too many conservative
745 // GCs when a frame that has a lot of iframes gets detached.
746 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva tiveGC);
747 return;
748 }
749 }
750
751 void ThreadState::v8ContextDisposed()
752 {
753 ++m_disposedV8ContextCount;
754 }
755
734 void ThreadState::scheduleGCIfNeeded() 756 void ThreadState::scheduleGCIfNeeded()
735 { 757 {
736 ASSERT(checkThread()); 758 ASSERT(checkThread());
737 Heap::reportMemoryUsageForTracing(); 759 Heap::reportMemoryUsageForTracing();
738 760
739 if (isGCForbidden()) 761 if (isGCForbidden())
740 return; 762 return;
741 763
742 // Allocation is allowed during sweeping, but those allocations should not 764 // Allocation is allowed during sweeping, but those allocations should not
743 // trigger nested GCs. 765 // trigger nested GCs.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 } 1018 }
997 1019
998 void ThreadState::preGC() 1020 void ThreadState::preGC()
999 { 1021 {
1000 ASSERT(!isInGC()); 1022 ASSERT(!isInGC());
1001 setGCState(GCRunning); 1023 setGCState(GCRunning);
1002 makeConsistentForGC(); 1024 makeConsistentForGC();
1003 flushHeapDoesNotContainCacheIfNeeded(); 1025 flushHeapDoesNotContainCacheIfNeeded();
1004 clearHeapAges(); 1026 clearHeapAges();
1005 updatePersistentCounters(); 1027 updatePersistentCounters();
1028 m_disposedV8ContextCount = 0;
1006 } 1029 }
1007 1030
1008 void ThreadState::postGC(GCType gcType) 1031 void ThreadState::postGC(GCType gcType)
1009 { 1032 {
1010 ASSERT(isInGC()); 1033 ASSERT(isInGC());
1011 1034
1012 #if ENABLE(GC_PROFILING) 1035 #if ENABLE(GC_PROFILING)
1013 // We snapshot the heap prior to sweeping to get numbers for both resources 1036 // We snapshot the heap prior to sweeping to get numbers for both resources
1014 // that have been allocated since the last GC and for resources that are 1037 // that have been allocated since the last GC and for resources that are
1015 // going to be freed. 1038 // going to be freed.
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 json->beginArray(it->key.ascii().data()); 1645 json->beginArray(it->key.ascii().data());
1623 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1646 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1624 json->pushInteger(it->value.ages[age]); 1647 json->pushInteger(it->value.ages[age]);
1625 json->endArray(); 1648 json->endArray();
1626 } 1649 }
1627 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1650 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1628 } 1651 }
1629 #endif 1652 #endif
1630 1653
1631 } // namespace blink 1654 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698