1 // Copyright 2021 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "include/cppgc/heap-state.h" 6 7 #include "src/heap/cppgc/heap-base.h" 8 9 namespace cppgc { 10 namespace subtle { 11 12 // static IsMarking(const HeapHandle & heap_handle)13bool HeapState::IsMarking(const HeapHandle& heap_handle) { 14 const internal::MarkerBase* marker = 15 internal::HeapBase::From(heap_handle).marker(); 16 return marker && marker->IsMarking(); 17 } 18 19 // static IsSweeping(const HeapHandle & heap_handle)20bool HeapState::IsSweeping(const HeapHandle& heap_handle) { 21 return internal::HeapBase::From(heap_handle).sweeper().IsSweepingInProgress(); 22 } 23 24 // static IsSweepingOnOwningThread(const HeapHandle & heap_handle)25bool HeapState::IsSweepingOnOwningThread(const HeapHandle& heap_handle) { 26 return internal::HeapBase::From(heap_handle) 27 .sweeper() 28 .IsSweepingOnMutatorThread(); 29 } 30 31 // static IsInAtomicPause(const HeapHandle & heap_handle)32bool HeapState::IsInAtomicPause(const HeapHandle& heap_handle) { 33 return internal::HeapBase::From(heap_handle).in_atomic_pause(); 34 } 35 36 // static PreviousGCWasConservative(const HeapHandle & heap_handle)37bool HeapState::PreviousGCWasConservative(const HeapHandle& heap_handle) { 38 return internal::HeapBase::From(heap_handle).stack_state_of_prev_gc() == 39 EmbedderStackState::kMayContainHeapPointers; 40 } 41 42 } // namespace subtle 43 } // namespace cppgc 44