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

Side by Side Diff: third_party/WebKit/Source/platform/heap/SafePoint.h

Issue 1609943003: Make platform/heap to use USING_FAST_MALLOC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compile error Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef SafePoint_h 5 #ifndef SafePoint_h
6 #define SafePoint_h 6 #define SafePoint_h
7 7
8 #include "platform/heap/ThreadState.h" 8 #include "platform/heap/ThreadState.h"
9 #include "wtf/ThreadingPrimitives.h" 9 #include "wtf/ThreadingPrimitives.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class SafePointScope final { 13 class SafePointScope final {
14 STACK_ALLOCATED();
14 WTF_MAKE_NONCOPYABLE(SafePointScope); 15 WTF_MAKE_NONCOPYABLE(SafePointScope);
15 public: 16 public:
16 explicit SafePointScope(BlinkGC::StackState stackState, ThreadState* state = ThreadState::current()) 17 explicit SafePointScope(BlinkGC::StackState stackState, ThreadState* state = ThreadState::current())
17 : m_state(state) 18 : m_state(state)
18 { 19 {
19 if (m_state) { 20 if (m_state) {
20 RELEASE_ASSERT(!m_state->isAtSafePoint()); 21 RELEASE_ASSERT(!m_state->isAtSafePoint());
21 m_state->enterSafePoint(stackState, this); 22 m_state->enterSafePoint(stackState, this);
22 } 23 }
23 } 24 }
24 25
25 ~SafePointScope() 26 ~SafePointScope()
26 { 27 {
27 if (m_state) 28 if (m_state)
28 m_state->leaveSafePoint(); 29 m_state->leaveSafePoint();
29 } 30 }
30 31
31 private: 32 private:
32 ThreadState* m_state; 33 ThreadState* m_state;
33 }; 34 };
34 35
35 // The SafePointAwareMutexLocker is used to enter a safepoint while waiting for 36 // The SafePointAwareMutexLocker is used to enter a safepoint while waiting for
36 // a mutex lock. It also ensures that the lock is not held while waiting for a G C 37 // a mutex lock. It also ensures that the lock is not held while waiting for a G C
37 // to complete in the leaveSafePoint method, by releasing the lock if the 38 // to complete in the leaveSafePoint method, by releasing the lock if the
38 // leaveSafePoint method cannot complete without blocking, see 39 // leaveSafePoint method cannot complete without blocking, see
39 // SafePointBarrier::checkAndPark. 40 // SafePointBarrier::checkAndPark.
40 class SafePointAwareMutexLocker final { 41 class SafePointAwareMutexLocker final {
42 STACK_ALLOCATED();
41 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker); 43 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker);
42 public: 44 public:
43 explicit SafePointAwareMutexLocker(MutexBase& mutex, BlinkGC::StackState sta ckState = BlinkGC::HeapPointersOnStack) 45 explicit SafePointAwareMutexLocker(MutexBase& mutex, BlinkGC::StackState sta ckState = BlinkGC::HeapPointersOnStack)
44 : m_mutex(mutex) 46 : m_mutex(mutex)
45 , m_locked(false) 47 , m_locked(false)
46 { 48 {
47 ThreadState* state = ThreadState::current(); 49 ThreadState* state = ThreadState::current();
48 do { 50 do {
49 bool leaveSafePoint = false; 51 bool leaveSafePoint = false;
50 // We cannot enter a safepoint if we are currently sweeping. In that 52 // We cannot enter a safepoint if we are currently sweeping. In that
(...skipping 30 matching lines...) Expand all
81 ASSERT(m_locked); 83 ASSERT(m_locked);
82 m_mutex.unlock(); 84 m_mutex.unlock();
83 m_locked = false; 85 m_locked = false;
84 } 86 }
85 87
86 MutexBase& m_mutex; 88 MutexBase& m_mutex;
87 bool m_locked; 89 bool m_locked;
88 }; 90 };
89 91
90 class SafePointBarrier final { 92 class SafePointBarrier final {
93 USING_FAST_MALLOC(SafePointBarrier);
91 WTF_MAKE_NONCOPYABLE(SafePointBarrier); 94 WTF_MAKE_NONCOPYABLE(SafePointBarrier);
92 public: 95 public:
93 SafePointBarrier(); 96 SafePointBarrier();
94 ~SafePointBarrier(); 97 ~SafePointBarrier();
95 98
96 // Request other attached threads that are not at safe points to park 99 // Request other attached threads that are not at safe points to park
97 // themselves on safepoints. 100 // themselves on safepoints.
98 bool parkOthers(); 101 bool parkOthers();
99 102
100 // Resume executions of other attached threads that are parked at 103 // Resume executions of other attached threads that are parked at
(...skipping 22 matching lines...) Expand all
123 volatile int m_canResume; 126 volatile int m_canResume;
124 volatile int m_unparkedThreadCount; 127 volatile int m_unparkedThreadCount;
125 Mutex m_mutex; 128 Mutex m_mutex;
126 ThreadCondition m_parked; 129 ThreadCondition m_parked;
127 ThreadCondition m_resume; 130 ThreadCondition m_resume;
128 }; 131 };
129 132
130 } // namespace blink 133 } // namespace blink
131 134
132 #endif 135 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698