Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
v8::CppHeap Class Reference

#include <v8-cppgc.h>

Public Member Functions

virtual ~CppHeap ()=default
 
cppgc::AllocationHandle & GetAllocationHandle ()
 
cppgc::HeapHandleGetHeapHandle ()
 
cppgc::HeapStatistics CollectStatistics (cppgc::HeapStatistics::DetailLevel detail_level)
 
void CollectCustomSpaceStatisticsAtLastGC (std::vector< cppgc::CustomSpaceIndex > custom_spaces, std::unique_ptr< CustomSpaceStatisticsReceiver > receiver)
 
void EnableDetachedGarbageCollectionsForTesting ()
 
void CollectGarbageForTesting (cppgc::EmbedderStackState stack_state)
 
void CollectGarbageInYoungGenerationForTesting (cppgc::EmbedderStackState stack_state)
 
void SetForceIncrementalSweepingForTesting (bool value)
 
void FinishSweepingForTesting ()
 

Static Public Member Functions

static std::unique_ptr< CppHeapCreate (v8::Platform *platform, const CppHeapCreateParams &params)
 

Friends

class internal::CppHeap
 

Detailed Description

A heap for allocating managed C++ objects.

Similar to v8::Isolate, the heap may only be accessed from one thread at a time. The heap may be used from different threads using the v8::Locker/v8::Unlocker APIs which is different from generic Oilpan.

Constructor & Destructor Documentation

◆ ~CppHeap()

virtual v8::CppHeap::~CppHeap ( )
virtualdefault

Member Function Documentation

◆ CollectCustomSpaceStatisticsAtLastGC()

void v8::CppHeap::CollectCustomSpaceStatisticsAtLastGC ( std::vector< cppgc::CustomSpaceIndex custom_spaces,
std::unique_ptr< CustomSpaceStatisticsReceiver receiver 
)

Collects statistics for the given spaces and reports them to the receiver.

Parameters
custom_spacesa collection of custom space indices.
receiveran object that gets the results.

◆ CollectGarbageForTesting()

void v8::CppHeap::CollectGarbageForTesting ( cppgc::EmbedderStackState  stack_state)

Performs a stop-the-world garbage collection for testing purposes.

Parameters
stack_stateThe stack state to assume for the garbage collection.

◆ CollectGarbageInYoungGenerationForTesting()

void v8::CppHeap::CollectGarbageInYoungGenerationForTesting ( cppgc::EmbedderStackState  stack_state)

Performs a stop-the-world minor garbage collection for testing purposes.

Parameters
stack_stateThe stack state to assume for the garbage collection.

◆ CollectStatistics()

cppgc::HeapStatistics v8::CppHeap::CollectStatistics ( cppgc::HeapStatistics::DetailLevel  detail_level)
Parameters
detail_levelspecifies whether should return detailed statistics or only brief summary statistics.
Returns
current CppHeap statistics regarding memory consumption and utilization.

◆ Create()

static std::unique_ptr< CppHeap > v8::CppHeap::Create ( v8::Platform platform,
const CppHeapCreateParams params 
)
static

◆ EnableDetachedGarbageCollectionsForTesting()

void v8::CppHeap::EnableDetachedGarbageCollectionsForTesting ( )

Enables a detached mode that allows testing garbage collection using cppgc::testing APIs. Once used, the heap cannot be attached to an Isolate anymore.

◆ FinishSweepingForTesting()

void v8::CppHeap::FinishSweepingForTesting ( )

Finishes any in-progress sweeping, running the finalizers it discovers.

◆ GetAllocationHandle()

cppgc::AllocationHandle & v8::CppHeap::GetAllocationHandle ( )
Returns
the opaque handle for allocating objects using MakeGarbageCollected().

◆ GetHeapHandle()

cppgc::HeapHandle & v8::CppHeap::GetHeapHandle ( )
Returns
the opaque heap handle which may be used to refer to this heap in other APIs. Valid as long as the underlying CppHeap is alive.

◆ SetForceIncrementalSweepingForTesting()

void v8::CppHeap::SetForceIncrementalSweepingForTesting ( bool  value)

Controls whether forced garbage collections sweep atomically.

A forced garbage collection (including Isolate::RequestGarbageCollectionForTesting()) normally sweeps atomically, so finalizers have already run by the time the collection returns. When this is enabled, forced collections instead sweep according to the heap's sweeping support, leaving finalization deferred as it would be in a natural garbage collection. This lets a test observe an object in the window between being discovered unreachable and being finalized.

Note that sweeping may then be concurrent; pass --single-threaded-gc for sweeping that only makes progress on the main thread, and use FinishSweepingForTesting() to close the window deterministically.

Friends And Related Function Documentation

◆ internal::CppHeap

friend class internal::CppHeap
friend

The documentation for this class was generated from the following file: