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

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

Issue 2355193002: Use enum for per thread heap enabled flag (Closed)
Patch Set: fix 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
« 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // and we need to resume the other threads. 138 // and we need to resume the other threads.
139 if (m_shouldResumeThreads) 139 if (m_shouldResumeThreads)
140 m_state->heap().resume(); 140 m_state->heap().resume();
141 } 141 }
142 142
143 private: 143 private:
144 ThreadState* m_state; 144 ThreadState* m_state;
145 bool m_shouldResumeThreads; 145 bool m_shouldResumeThreads;
146 }; 146 };
147 147
148 ThreadState::ThreadState(bool perThreadHeapEnabled) 148 ThreadState::ThreadState(BlinkGC::ThreadHeapMode threadHeapMode)
149 : m_thread(currentThread()) 149 : m_thread(currentThread())
150 , m_persistentRegion(wrapUnique(new PersistentRegion())) 150 , m_persistentRegion(wrapUnique(new PersistentRegion()))
151 #if OS(WIN) && COMPILER(MSVC) 151 #if OS(WIN) && COMPILER(MSVC)
152 , m_threadStackSize(0) 152 , m_threadStackSize(0)
153 #endif 153 #endif
154 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( ))) 154 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( )))
155 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) ) 155 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) )
156 , m_safePointScopeMarker(nullptr) 156 , m_safePointScopeMarker(nullptr)
157 , m_atSafePoint(false) 157 , m_atSafePoint(false)
158 , m_interruptors() 158 , m_interruptors()
159 , m_sweepForbidden(false) 159 , m_sweepForbidden(false)
160 , m_noAllocationCount(0) 160 , m_noAllocationCount(0)
161 , m_gcForbiddenCount(0) 161 , m_gcForbiddenCount(0)
162 , m_accumulatedSweepingTime(0) 162 , m_accumulatedSweepingTime(0)
163 , m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex) 163 , m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex)
164 , m_currentArenaAges(0) 164 , m_currentArenaAges(0)
165 , m_perThreadHeapEnabled(perThreadHeapEnabled) 165 , m_threadHeapMode(threadHeapMode)
166 , m_isTerminating(false) 166 , m_isTerminating(false)
167 , m_gcMixinMarker(nullptr) 167 , m_gcMixinMarker(nullptr)
168 , m_shouldFlushHeapDoesNotContainCache(false) 168 , m_shouldFlushHeapDoesNotContainCache(false)
169 , m_gcState(NoGCScheduled) 169 , m_gcState(NoGCScheduled)
170 , m_threadLocalWeakCallbackStack(CallbackStack::create()) 170 , m_threadLocalWeakCallbackStack(CallbackStack::create())
171 , m_isolate(nullptr) 171 , m_isolate(nullptr)
172 , m_traceDOMWrappers(nullptr) 172 , m_traceDOMWrappers(nullptr)
173 , m_invalidateDeadObjectsInWrappersMarkingDeque(nullptr) 173 , m_invalidateDeadObjectsInWrappersMarkingDeque(nullptr)
174 #if defined(ADDRESS_SANITIZER) 174 #if defined(ADDRESS_SANITIZER)
175 , m_asanFakeStack(__asan_get_current_fake_stack()) 175 , m_asanFakeStack(__asan_get_current_fake_stack())
176 #endif 176 #endif
177 #if defined(LEAK_SANITIZER) 177 #if defined(LEAK_SANITIZER)
178 , m_disabledStaticPersistentsRegistration(0) 178 , m_disabledStaticPersistentsRegistration(0)
179 #endif 179 #endif
180 , m_allocatedObjectSize(0) 180 , m_allocatedObjectSize(0)
181 , m_markedObjectSize(0) 181 , m_markedObjectSize(0)
182 , m_reportedMemoryToV8(0) 182 , m_reportedMemoryToV8(0)
183 { 183 {
184 ASSERT(checkThread()); 184 ASSERT(checkThread());
185 ASSERT(!**s_threadSpecific); 185 ASSERT(!**s_threadSpecific);
186 **s_threadSpecific = this; 186 **s_threadSpecific = this;
187 187
188 if (m_perThreadHeapEnabled) { 188 switch (m_threadHeapMode) {
189 case BlinkGC::MainThreadHeapMode:
190 if (isMainThread()) {
191 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - sizeof(void*);
192 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedS tackSize();
193 if (underestimatedStackSize > sizeof(void*))
194 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - sizeof(void*);
195 m_heap = new ThreadHeap();
196 } else {
197 m_heap = &ThreadState::mainThreadState()->heap();
198 }
199 break;
200 case BlinkGC::PerThreadHeapMode:
189 m_heap = new ThreadHeap(); 201 m_heap = new ThreadHeap();
190 } else if (isMainThread()) { 202 break;
191 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*);
192 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size();
193 if (underestimatedStackSize > sizeof(void*))
194 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*);
195 m_heap = new ThreadHeap();
196 } else {
197 m_heap = &ThreadState::mainThreadState()->heap();
198 } 203 }
199 ASSERT(m_heap); 204 ASSERT(m_heap);
200 m_heap->attach(this); 205 m_heap->attach(this);
201 206
202 for (int arenaIndex = 0; arenaIndex < BlinkGC::LargeObjectArenaIndex; arenaI ndex++) 207 for (int arenaIndex = 0; arenaIndex < BlinkGC::LargeObjectArenaIndex; arenaI ndex++)
203 m_arenas[arenaIndex] = new NormalPageArena(this, arenaIndex); 208 m_arenas[arenaIndex] = new NormalPageArena(this, arenaIndex);
204 m_arenas[BlinkGC::LargeObjectArenaIndex] = new LargeObjectArena(this, BlinkG C::LargeObjectArenaIndex); 209 m_arenas[BlinkGC::LargeObjectArenaIndex] = new LargeObjectArena(this, BlinkG C::LargeObjectArenaIndex);
205 210
206 m_likelyToBePromptlyFreed = wrapArrayUnique(new int[likelyToBePromptlyFreedA rraySize]); 211 m_likelyToBePromptlyFreed = wrapArrayUnique(new int[likelyToBePromptlyFreedA rraySize]);
207 clearArenaAges(); 212 clearArenaAges();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000); 257 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000);
253 m_threadStackSize -= 4 * 0x1000; 258 m_threadStackSize -= 4 * 0x1000;
254 return m_threadStackSize; 259 return m_threadStackSize;
255 } 260 }
256 #endif 261 #endif
257 262
258 void ThreadState::attachMainThread() 263 void ThreadState::attachMainThread()
259 { 264 {
260 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 265 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
261 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); 266 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
262 new (s_mainThreadStateStorage) ThreadState(false); 267 new (s_mainThreadStateStorage) ThreadState(BlinkGC::MainThreadHeapMode);
263 } 268 }
264 269
265 void ThreadState::attachCurrentThread(bool perThreadHeapEnabled) 270 void ThreadState::attachCurrentThread(BlinkGC::ThreadHeapMode threadHeapMode)
266 { 271 {
267 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 272 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
268 new ThreadState(perThreadHeapEnabled); 273 new ThreadState(threadHeapMode);
269 } 274 }
270 275
271 void ThreadState::cleanupPages() 276 void ThreadState::cleanupPages()
272 { 277 {
273 ASSERT(checkThread()); 278 ASSERT(checkThread());
274 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) 279 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i)
275 m_arenas[i]->cleanupPages(); 280 m_arenas[i]->cleanupPages();
276 } 281 }
277 282
278 void ThreadState::runTerminationGC() 283 void ThreadState::runTerminationGC()
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 for (int i = 0; i < 5; ++i) { 1752 for (int i = 0; i < 5; ++i) {
1748 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); 1753 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC);
1749 size_t liveObjects = heap().heapStats().markedObjectSize(); 1754 size_t liveObjects = heap().heapStats().markedObjectSize();
1750 if (liveObjects == previousLiveObjects) 1755 if (liveObjects == previousLiveObjects)
1751 break; 1756 break;
1752 previousLiveObjects = liveObjects; 1757 previousLiveObjects = liveObjects;
1753 } 1758 }
1754 } 1759 }
1755 1760
1756 } // namespace blink 1761 } // 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