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

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

Issue 2625293002: Remove ThreadHeapMode (Closed)
Patch Set: Created 3 years, 11 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/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include "wtf/Threading.h" 10 #include "wtf/Threading.h"
11 #include <memory> 11 #include <memory>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::create( 15 std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::create(
16 const char* name, 16 const char* name) {
17 BlinkGC::ThreadHeapMode threadHeapMode) { 17 return WTF::wrapUnique(new WebThreadSupportingGC(name, nullptr));
18 return WTF::wrapUnique(
19 new WebThreadSupportingGC(name, nullptr, threadHeapMode));
20 } 18 }
21 19
22 std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread( 20 std::unique_ptr<WebThreadSupportingGC> WebThreadSupportingGC::createForThread(
23 WebThread* thread, 21 WebThread* thread) {
24 BlinkGC::ThreadHeapMode threadHeapMode) { 22 return WTF::wrapUnique(new WebThreadSupportingGC(nullptr, thread));
25 return WTF::wrapUnique(
26 new WebThreadSupportingGC(nullptr, thread, threadHeapMode));
27 } 23 }
28 24
29 WebThreadSupportingGC::WebThreadSupportingGC( 25 WebThreadSupportingGC::WebThreadSupportingGC(const char* name,
30 const char* name, 26 WebThread* thread)
31 WebThread* thread, 27 : m_thread(thread) {
32 BlinkGC::ThreadHeapMode threadHeapMode)
33 : m_thread(thread), m_threadHeapMode(threadHeapMode) {
34 DCHECK(!name || !thread); 28 DCHECK(!name || !thread);
35 #if DCHECK_IS_ON() 29 #if DCHECK_IS_ON()
36 // We call this regardless of whether an existing thread is given or not, 30 // We call this regardless of whether an existing thread is given or not,
37 // as it means that blink is going to run with more than one thread. 31 // as it means that blink is going to run with more than one thread.
38 WTF::willCreateThread(); 32 WTF::willCreateThread();
39 #endif 33 #endif
40 if (!m_thread) { 34 if (!m_thread) {
41 // If |thread| is not given, create a new one and own it. 35 // If |thread| is not given, create a new one and own it.
42 m_owningThread = WTF::wrapUnique(Platform::current()->createThread(name)); 36 m_owningThread = WTF::wrapUnique(Platform::current()->createThread(name));
43 m_thread = m_owningThread.get(); 37 m_thread = m_owningThread.get();
44 } 38 }
45 } 39 }
46 40
47 WebThreadSupportingGC::~WebThreadSupportingGC() { 41 WebThreadSupportingGC::~WebThreadSupportingGC() {
48 if (ThreadState::current() && m_owningThread) { 42 if (ThreadState::current() && m_owningThread) {
49 // WebThread's destructor blocks until all the tasks are processed. 43 // WebThread's destructor blocks until all the tasks are processed.
50 SafePointScope scope(BlinkGC::HeapPointersOnStack); 44 SafePointScope scope(BlinkGC::HeapPointersOnStack);
51 m_owningThread.reset(); 45 m_owningThread.reset();
52 } 46 }
53 } 47 }
54 48
55 void WebThreadSupportingGC::initialize() { 49 void WebThreadSupportingGC::initialize() {
56 ThreadState::attachCurrentThread(m_threadHeapMode); 50 ThreadState::attachCurrentThread();
57 m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread); 51 m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread);
58 } 52 }
59 53
60 void WebThreadSupportingGC::shutdown() { 54 void WebThreadSupportingGC::shutdown() {
61 #if defined(LEAK_SANITIZER) 55 #if defined(LEAK_SANITIZER)
62 ThreadState::current()->releaseStaticPersistentNodes(); 56 ThreadState::current()->releaseStaticPersistentNodes();
63 #endif 57 #endif
64 // Ensure no posted tasks will run from this point on. 58 // Ensure no posted tasks will run from this point on.
65 m_gcTaskRunner.reset(); 59 m_gcTaskRunner.reset();
66 60
67 // Shutdown the thread (via its scheduler) only when the thread is created 61 // Shutdown the thread (via its scheduler) only when the thread is created
68 // and is owned by this instance. 62 // and is owned by this instance.
69 if (m_owningThread) 63 if (m_owningThread)
70 m_owningThread->scheduler()->shutdown(); 64 m_owningThread->scheduler()->shutdown();
71 65
72 ThreadState::detachCurrentThread(); 66 ThreadState::detachCurrentThread();
73 } 67 }
74 68
75 } // namespace blink 69 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698