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

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

Issue 2688383003: Remove unnecessary SafePointScope (Closed)
Patch Set: temp Created 3 years, 10 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"
(...skipping 21 matching lines...) Expand all
32 WTF::willCreateThread(); 32 WTF::willCreateThread();
33 #endif 33 #endif
34 if (!m_thread) { 34 if (!m_thread) {
35 // 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.
36 m_owningThread = WTF::wrapUnique(Platform::current()->createThread(name)); 36 m_owningThread = WTF::wrapUnique(Platform::current()->createThread(name));
37 m_thread = m_owningThread.get(); 37 m_thread = m_owningThread.get();
38 } 38 }
39 } 39 }
40 40
41 WebThreadSupportingGC::~WebThreadSupportingGC() { 41 WebThreadSupportingGC::~WebThreadSupportingGC() {
42 if (ThreadState::current() && m_owningThread) { 42 // WebThread's destructor blocks until all the tasks are processed.
43 // WebThread's destructor blocks until all the tasks are processed. 43 m_owningThread.reset();
44 SafePointScope scope(BlinkGC::HeapPointersOnStack);
45 m_owningThread.reset();
46 }
47 } 44 }
48 45
49 void WebThreadSupportingGC::initialize() { 46 void WebThreadSupportingGC::initialize() {
50 ThreadState::attachCurrentThread(); 47 ThreadState::attachCurrentThread();
51 m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread); 48 m_gcTaskRunner = WTF::makeUnique<GCTaskRunner>(m_thread);
52 } 49 }
53 50
54 void WebThreadSupportingGC::shutdown() { 51 void WebThreadSupportingGC::shutdown() {
55 #if defined(LEAK_SANITIZER) 52 #if defined(LEAK_SANITIZER)
56 ThreadState::current()->releaseStaticPersistentNodes(); 53 ThreadState::current()->releaseStaticPersistentNodes();
57 #endif 54 #endif
58 // Ensure no posted tasks will run from this point on. 55 // Ensure no posted tasks will run from this point on.
59 m_gcTaskRunner.reset(); 56 m_gcTaskRunner.reset();
60 57
61 // Shutdown the thread (via its scheduler) only when the thread is created 58 // Shutdown the thread (via its scheduler) only when the thread is created
62 // and is owned by this instance. 59 // and is owned by this instance.
63 if (m_owningThread) 60 if (m_owningThread)
64 m_owningThread->scheduler()->shutdown(); 61 m_owningThread->scheduler()->shutdown();
65 62
66 ThreadState::detachCurrentThread(); 63 ThreadState::detachCurrentThread();
67 } 64 }
68 65
69 } // namespace blink 66 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/WaitableEvent.cpp ('k') | third_party/WebKit/Source/web/WebHeap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698