| OLD | NEW |
| 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 STACK_ALLOCATED(); |
| 15 WTF_MAKE_NONCOPYABLE(SafePointScope); | 15 WTF_MAKE_NONCOPYABLE(SafePointScope); |
| 16 | 16 |
| 17 public: | 17 public: |
| 18 explicit SafePointScope(BlinkGC::StackState stackState, | 18 explicit SafePointScope(BlinkGC::StackState stackState, |
| 19 ThreadState* state = ThreadState::current()) | 19 ThreadState* state = ThreadState::current()) |
| 20 : m_state(state) { | 20 : m_state(state) { |
| 21 if (m_state) { | 21 if (m_state) { |
| 22 RELEASE_ASSERT(!m_state->isAtSafePoint()); | |
| 23 m_state->enterSafePoint(stackState, this); | 22 m_state->enterSafePoint(stackState, this); |
| 24 } | 23 } |
| 25 } | 24 } |
| 26 | 25 |
| 27 ~SafePointScope() { | 26 ~SafePointScope() { |
| 28 if (m_state) | 27 if (m_state) |
| 29 m_state->leaveSafePoint(); | 28 m_state->leaveSafePoint(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 private: | 31 private: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 ThreadState* state, | 50 ThreadState* state, |
| 52 intptr_t* stackEnd) { | 51 intptr_t* stackEnd) { |
| 53 barrier->doEnterSafePoint(state, stackEnd); | 52 barrier->doEnterSafePoint(state, stackEnd); |
| 54 } | 53 } |
| 55 Mutex m_mutex; | 54 Mutex m_mutex; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 } // namespace blink | 57 } // namespace blink |
| 59 | 58 |
| 60 #endif | 59 #endif |
| OLD | NEW |