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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(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 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 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*); | 203 default: |
192 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size(); | 204 NOTREACHED(); |
nhiroki
2016/09/21 05:15:26
Is "default" case necessary?
keishi
2016/09/21 07:06:37
Removed.
| |
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 } | 205 } |
199 ASSERT(m_heap); | 206 ASSERT(m_heap); |
200 m_heap->attach(this); | 207 m_heap->attach(this); |
201 | 208 |
202 for (int arenaIndex = 0; arenaIndex < BlinkGC::LargeObjectArenaIndex; arenaI ndex++) | 209 for (int arenaIndex = 0; arenaIndex < BlinkGC::LargeObjectArenaIndex; arenaI ndex++) |
203 m_arenas[arenaIndex] = new NormalPageArena(this, arenaIndex); | 210 m_arenas[arenaIndex] = new NormalPageArena(this, arenaIndex); |
204 m_arenas[BlinkGC::LargeObjectArenaIndex] = new LargeObjectArena(this, BlinkG C::LargeObjectArenaIndex); | 211 m_arenas[BlinkGC::LargeObjectArenaIndex] = new LargeObjectArena(this, BlinkG C::LargeObjectArenaIndex); |
205 | 212 |
206 m_likelyToBePromptlyFreed = wrapArrayUnique(new int[likelyToBePromptlyFreedA rraySize]); | 213 m_likelyToBePromptlyFreed = wrapArrayUnique(new int[likelyToBePromptlyFreedA rraySize]); |
207 clearArenaAges(); | 214 clearArenaAges(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000); | 259 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000); |
253 m_threadStackSize -= 4 * 0x1000; | 260 m_threadStackSize -= 4 * 0x1000; |
254 return m_threadStackSize; | 261 return m_threadStackSize; |
255 } | 262 } |
256 #endif | 263 #endif |
257 | 264 |
258 void ThreadState::attachMainThread() | 265 void ThreadState::attachMainThread() |
259 { | 266 { |
260 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); | 267 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); |
261 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); | 268 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); |
262 new (s_mainThreadStateStorage) ThreadState(false); | 269 new (s_mainThreadStateStorage) ThreadState(MainThreadHeapMode); |
263 } | 270 } |
264 | 271 |
265 void ThreadState::attachCurrentThread(bool perThreadHeapEnabled) | 272 void ThreadState::attachCurrentThread(ThreadHeapMode threadHeapMode) |
266 { | 273 { |
267 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); | 274 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); |
268 new ThreadState(perThreadHeapEnabled); | 275 new ThreadState(threadHeapMode); |
269 } | 276 } |
270 | 277 |
271 void ThreadState::cleanupPages() | 278 void ThreadState::cleanupPages() |
272 { | 279 { |
273 ASSERT(checkThread()); | 280 ASSERT(checkThread()); |
274 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) | 281 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) |
275 m_arenas[i]->cleanupPages(); | 282 m_arenas[i]->cleanupPages(); |
276 } | 283 } |
277 | 284 |
278 void ThreadState::runTerminationGC() | 285 void ThreadState::runTerminationGC() |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 for (int i = 0; i < 5; ++i) { | 1754 for (int i = 0; i < 5; ++i) { |
1748 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); | 1755 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, Bli nkGC::ForcedGC); |
1749 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1756 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1750 if (liveObjects == previousLiveObjects) | 1757 if (liveObjects == previousLiveObjects) |
1751 break; | 1758 break; |
1752 previousLiveObjects = liveObjects; | 1759 previousLiveObjects = liveObjects; |
1753 } | 1760 } |
1754 } | 1761 } |
1755 | 1762 |
1756 } // namespace blink | 1763 } // namespace blink |
OLD | NEW |