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

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

Issue 1910753002: Add enablePerThreadHeap flag to ThreadState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 #include <v8.h> 67 #include <v8.h>
68 68
69 namespace blink { 69 namespace blink {
70 70
71 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; 71 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr;
72 uintptr_t ThreadState::s_mainThreadStackStart = 0; 72 uintptr_t ThreadState::s_mainThreadStackStart = 0;
73 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; 73 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0;
74 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; 74 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
75 75
76 ThreadState::ThreadState() 76 ThreadState::ThreadState(bool perThreadHeapEnabled)
77 : m_thread(currentThread()) 77 : m_thread(currentThread())
78 , m_persistentRegion(adoptPtr(new PersistentRegion())) 78 , m_persistentRegion(adoptPtr(new PersistentRegion()))
79 #if OS(WIN) && COMPILER(MSVC) 79 #if OS(WIN) && COMPILER(MSVC)
80 , m_threadStackSize(0) 80 , m_threadStackSize(0)
81 #endif 81 #endif
82 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( ))) 82 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( )))
83 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) ) 83 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) )
84 , m_safePointScopeMarker(nullptr) 84 , m_safePointScopeMarker(nullptr)
85 , m_atSafePoint(false) 85 , m_atSafePoint(false)
86 , m_interruptors() 86 , m_interruptors()
87 , m_sweepForbidden(false) 87 , m_sweepForbidden(false)
88 , m_noAllocationCount(0) 88 , m_noAllocationCount(0)
89 , m_gcForbiddenCount(0) 89 , m_gcForbiddenCount(0)
90 , m_accumulatedSweepingTime(0) 90 , m_accumulatedSweepingTime(0)
91 , m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex) 91 , m_vectorBackingArenaIndex(BlinkGC::Vector1ArenaIndex)
92 , m_currentArenaAges(0) 92 , m_currentArenaAges(0)
93 , m_perThreadHeapEnabled(perThreadHeapEnabled)
93 , m_isTerminating(false) 94 , m_isTerminating(false)
94 , m_gcMixinMarker(nullptr) 95 , m_gcMixinMarker(nullptr)
95 , m_shouldFlushHeapDoesNotContainCache(false) 96 , m_shouldFlushHeapDoesNotContainCache(false)
96 , m_gcState(NoGCScheduled) 97 , m_gcState(NoGCScheduled)
97 , m_isolate(nullptr) 98 , m_isolate(nullptr)
98 , m_traceDOMWrappers(nullptr) 99 , m_traceDOMWrappers(nullptr)
99 #if defined(ADDRESS_SANITIZER) 100 #if defined(ADDRESS_SANITIZER)
100 , m_asanFakeStack(__asan_get_current_fake_stack()) 101 , m_asanFakeStack(__asan_get_current_fake_stack())
101 #endif 102 #endif
102 #if defined(LEAK_SANITIZER) 103 #if defined(LEAK_SANITIZER)
103 , m_disabledStaticPersistentsRegistration(0) 104 , m_disabledStaticPersistentsRegistration(0)
104 #endif 105 #endif
105 , m_allocatedObjectSize(0) 106 , m_allocatedObjectSize(0)
106 , m_markedObjectSize(0) 107 , m_markedObjectSize(0)
107 , m_reportedMemoryToV8(0) 108 , m_reportedMemoryToV8(0)
108 { 109 {
109 ASSERT(checkThread()); 110 ASSERT(checkThread());
110 ASSERT(!**s_threadSpecific); 111 ASSERT(!**s_threadSpecific);
111 **s_threadSpecific = this; 112 **s_threadSpecific = this;
112 113
113 if (isMainThread()) { 114 // TODO(keishi) Remove when per thread heap is ready.
115 RELEASE_ASSERT(!m_perThreadHeapEnabled);
haraken 2016/04/25 06:57:12 CHECK
keishi 2016/04/25 08:00:26 Done.
116
117 if (m_perThreadHeapEnabled) {
118 m_heap = new ThreadHeap();
119 } else if (isMainThread()) {
114 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); 120 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*);
115 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size(); 121 size_t underestimatedStackSize = StackFrameDepth::getUnderestimatedStack Size();
116 if (underestimatedStackSize > sizeof(void*)) 122 if (underestimatedStackSize > sizeof(void*))
117 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*); 123 s_mainThreadUnderestimatedStackSize = underestimatedStackSize - size of(void*);
118 m_heap = new ThreadHeap(); 124 m_heap = new ThreadHeap();
119 } else { 125 } else {
120 m_heap = &ThreadState::mainThreadState()->heap(); 126 m_heap = &ThreadState::mainThreadState()->heap();
121 } 127 }
122 ASSERT(m_heap); 128 ASSERT(m_heap);
123 m_heap->attach(this); 129 m_heap->attach(this);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000); 188 RELEASE_ASSERT(m_threadStackSize > 4 * 0x1000);
183 m_threadStackSize -= 4 * 0x1000; 189 m_threadStackSize -= 4 * 0x1000;
184 return m_threadStackSize; 190 return m_threadStackSize;
185 } 191 }
186 #endif 192 #endif
187 193
188 void ThreadState::attachMainThread() 194 void ThreadState::attachMainThread()
189 { 195 {
190 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 196 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
191 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); 197 s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>();
192 new (s_mainThreadStateStorage) ThreadState(); 198 new (s_mainThreadStateStorage) ThreadState(false);
193 } 199 }
194 200
195 void ThreadState::attachCurrentThread() 201 void ThreadState::attachCurrentThread(bool perThreadHeapEnabled)
196 { 202 {
197 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete); 203 RELEASE_ASSERT(!ProcessHeap::s_shutdownComplete);
198 new ThreadState(); 204 new ThreadState(perThreadHeapEnabled);
199 } 205 }
200 206
201 void ThreadState::cleanupPages() 207 void ThreadState::cleanupPages()
202 { 208 {
203 ASSERT(checkThread()); 209 ASSERT(checkThread());
204 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) 210 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i)
205 m_arenas[i]->cleanupPages(); 211 m_arenas[i]->cleanupPages();
206 } 212 }
207 213
208 void ThreadState::runTerminationGC() 214 void ThreadState::runTerminationGC()
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 threadDump->addScalar("dead_count", "objects", totalDeadCount); 1515 threadDump->addScalar("dead_count", "objects", totalDeadCount);
1510 threadDump->addScalar("live_size", "bytes", totalLiveSize); 1516 threadDump->addScalar("live_size", "bytes", totalLiveSize);
1511 threadDump->addScalar("dead_size", "bytes", totalDeadSize); 1517 threadDump->addScalar("dead_size", "bytes", totalDeadSize);
1512 1518
1513 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1519 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1514 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1520 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1515 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1521 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid());
1516 } 1522 }
1517 1523
1518 } // namespace blink 1524 } // 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