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

Side by Side Diff: third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp

Issue 1919793002: Revert of 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/WebThreadSupportingGC.h" 5 #include "platform/WebThreadSupportingGC.h"
6 6
7 #include "platform/heap/SafePoint.h" 7 #include "platform/heap/SafePoint.h"
8 #include "public/platform/WebScheduler.h" 8 #include "public/platform/WebScheduler.h"
9 #include "wtf/Threading.h" 9 #include "wtf/Threading.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name , bool perThreadHeapEnabled) 13 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::create(const char* name )
14 { 14 {
15 return adoptPtr(new WebThreadSupportingGC(name, nullptr, perThreadHeapEnable d)); 15 return adoptPtr(new WebThreadSupportingGC(name, nullptr));
16 } 16 }
17 17
18 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread(WebThre ad* thread, bool perThreadHeapEnabled) 18 PassOwnPtr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread(WebThre ad* thread)
19 { 19 {
20 return adoptPtr(new WebThreadSupportingGC(nullptr, thread, perThreadHeapEnab led)); 20 return adoptPtr(new WebThreadSupportingGC(nullptr, thread));
21 } 21 }
22 22
23 WebThreadSupportingGC::WebThreadSupportingGC(const char* name, WebThread* thread , bool perThreadHeapEnabled) 23 WebThreadSupportingGC::WebThreadSupportingGC(const char* name, WebThread* thread )
24 : m_thread(thread) 24 : m_thread(thread)
25 , m_perThreadHeapEnabled(perThreadHeapEnabled)
26 { 25 {
27 #if ENABLE(ASSERT) 26 #if ENABLE(ASSERT)
28 ASSERT(!name || !thread); 27 ASSERT(!name || !thread);
29 // We call this regardless of whether an existing thread is given or not, 28 // We call this regardless of whether an existing thread is given or not,
30 // as it means that blink is going to run with more than one thread. 29 // as it means that blink is going to run with more than one thread.
31 WTF::willCreateThread(); 30 WTF::willCreateThread();
32 #endif 31 #endif
33 if (!m_thread) { 32 if (!m_thread) {
34 // If |thread| is not given, create a new one and own it. 33 // If |thread| is not given, create a new one and own it.
35 m_owningThread = adoptPtr(Platform::current()->createThread(name)); 34 m_owningThread = adoptPtr(Platform::current()->createThread(name));
36 m_thread = m_owningThread.get(); 35 m_thread = m_owningThread.get();
37 } 36 }
38 } 37 }
39 38
40 WebThreadSupportingGC::~WebThreadSupportingGC() 39 WebThreadSupportingGC::~WebThreadSupportingGC()
41 { 40 {
42 if (ThreadState::current() && m_owningThread) { 41 if (ThreadState::current() && m_owningThread) {
43 // WebThread's destructor blocks until all the tasks are processed. 42 // WebThread's destructor blocks until all the tasks are processed.
44 SafePointScope scope(BlinkGC::HeapPointersOnStack); 43 SafePointScope scope(BlinkGC::HeapPointersOnStack);
45 m_owningThread.clear(); 44 m_owningThread.clear();
46 } 45 }
47 } 46 }
48 47
49 void WebThreadSupportingGC::initialize() 48 void WebThreadSupportingGC::initialize()
50 { 49 {
51 ThreadState::attachCurrentThread(m_perThreadHeapEnabled); 50 ThreadState::attachCurrentThread();
52 m_gcTaskRunner = adoptPtr(new GCTaskRunner(m_thread)); 51 m_gcTaskRunner = adoptPtr(new GCTaskRunner(m_thread));
53 } 52 }
54 53
55 void WebThreadSupportingGC::shutdown() 54 void WebThreadSupportingGC::shutdown()
56 { 55 {
57 #if defined(LEAK_SANITIZER) 56 #if defined(LEAK_SANITIZER)
58 ThreadState::current()->releaseStaticPersistentNodes(); 57 ThreadState::current()->releaseStaticPersistentNodes();
59 #endif 58 #endif
60 // Ensure no posted tasks will run from this point on. 59 // Ensure no posted tasks will run from this point on.
61 m_gcTaskRunner.clear(); 60 m_gcTaskRunner.clear();
62 61
63 // Shutdown the thread (via its scheduler) only when the thread is created 62 // Shutdown the thread (via its scheduler) only when the thread is created
64 // and is owned by this instance. 63 // and is owned by this instance.
65 if (m_owningThread) 64 if (m_owningThread)
66 m_owningThread->scheduler()->shutdown(); 65 m_owningThread->scheduler()->shutdown();
67 66
68 ThreadState::detachCurrentThread(); 67 ThreadState::detachCurrentThread();
69 } 68 }
70 69
71 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/WebThreadSupportingGC.h ('k') | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698