Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 10:08:50

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_CPPGC_HEAP_STATE_H_
0006 #define INCLUDE_CPPGC_HEAP_STATE_H_
0007 
0008 #include "v8config.h"  // NOLINT(build/include_directory)
0009 
0010 namespace cppgc {
0011 
0012 class HeapHandle;
0013 
0014 namespace subtle {
0015 
0016 /**
0017  * Helpers to peek into heap-internal state.
0018  */
0019 class V8_EXPORT HeapState final {
0020  public:
0021   /**
0022    * Returns whether the garbage collector is marking. This API is experimental
0023    * and is expected to be removed in future.
0024    *
0025    * \param heap_handle The corresponding heap.
0026    * \returns true if the garbage collector is currently marking, and false
0027    *   otherwise.
0028    */
0029   static bool IsMarking(const HeapHandle& heap_handle);
0030 
0031   /*
0032    * Returns whether the garbage collector is sweeping. This API is experimental
0033    * and is expected to be removed in future.
0034    *
0035    * \param heap_handle The corresponding heap.
0036    * \returns true if the garbage collector is currently sweeping, and false
0037    *   otherwise.
0038    */
0039   static bool IsSweeping(const HeapHandle& heap_handle);
0040 
0041   /*
0042    * Returns whether the garbage collector is currently sweeping on the thread
0043    * owning this heap. This API allows the caller to determine whether it has
0044    * been called from a destructor of a managed object. This API is experimental
0045    * and may be removed in future.
0046    *
0047    * \param heap_handle The corresponding heap.
0048    * \returns true if the garbage collector is currently sweeping on this
0049    *   thread, and false otherwise.
0050    */
0051   static bool IsSweepingOnOwningThread(const HeapHandle& heap_handle);
0052 
0053   /**
0054    * Returns whether the garbage collector is in the atomic pause, i.e., the
0055    * mutator is stopped from running. This API is experimental and is expected
0056    * to be removed in future.
0057    *
0058    * \param heap_handle The corresponding heap.
0059    * \returns true if the garbage collector is currently in the atomic pause,
0060    *   and false otherwise.
0061    */
0062   static bool IsInAtomicPause(const HeapHandle& heap_handle);
0063 
0064   /**
0065    * Returns whether the last garbage collection was finalized conservatively
0066    * (i.e., with a non-empty stack). This API is experimental and is expected to
0067    * be removed in future.
0068    *
0069    * \param heap_handle The corresponding heap.
0070    * \returns true if the last garbage collection was finalized conservatively,
0071    * and false otherwise.
0072    */
0073   static bool PreviousGCWasConservative(const HeapHandle& heap_handle);
0074 
0075  private:
0076   HeapState() = delete;
0077 };
0078 
0079 }  // namespace subtle
0080 }  // namespace cppgc
0081 
0082 #endif  // INCLUDE_CPPGC_HEAP_STATE_H_