5#ifndef V8_HEAP_CPPGC_HEAP_OBJECT_HEADER_H_
6#define V8_HEAP_CPPGC_HEAP_OBJECT_HEADER_H_
22#if defined(CPPGC_CAGED_HEAP)
71 template <AccessMode mode = AccessMode::kNonAtomic>
74 template <AccessMode mode = AccessMode::kNonAtomic>
77 template <AccessMode mode = AccessMode::kNonAtomic>
81 template <AccessMode mode = AccessMode::kNonAtomic>
84 template <AccessMode mode = AccessMode::kNonAtomic>
87 template <AccessMode = AccessMode::kNonAtomic>
92 template <AccessMode = AccessMode::kNonAtomic>
94 template <AccessMode = AccessMode::kNonAtomic>
100 template <AccessMode = AccessMode::kNonAtomic>
103 template <AccessMode = AccessMode::kNonAtomic>
109#if defined(CPPGC_CAGED_HEAP)
122 template <AccessMode = AccessMode::kNonAtomic>
150 std::memory_order memory_order = std::memory_order_seq_cst>
153 std::memory_order memory_order = std::memory_order_seq_cst>
156#if defined(V8_HOST_ARCH_64_BIT)
159#if defined(CPPGC_CAGED_HEAP)
160 uint32_t next_unfinalized_ = 0;
162 uint32_t padding_ = 0;
170 "sizeof(HeapObjectHeader) must match allocation granularity to "
171 "guarantee alignment");
186#if defined(V8_HOST_ARCH_64_BIT) && !defined(CPPGC_CAGED_HEAP)
201 std::memory_order_relaxed);
213template <AccessMode mode>
220template <AccessMode mode>
222 const uint16_t encoded =
227template <AccessMode mode>
231 uint16_t encoded_low_value =
233 const size_t size =
DecodeSize(encoded_low_value);
238#if !defined(CPPGC_YOUNG_GENERATION)
250template <AccessMode mode>
257template <AccessMode mode>
262template <AccessMode mode>
264 const uint16_t encoded =
269template <AccessMode mode>
271 const uint16_t encoded =
276template <AccessMode mode>
285 uint16_t old_value = atomic_encoded->load(std::memory_order_relaxed);
287 if (new_value == old_value) {
290 return atomic_encoded->compare_exchange_strong(old_value, new_value,
291 std::memory_order_relaxed);
299template <AccessMode mode>
304template <AccessMode mode>
314#if defined(CPPGC_CAGED_HEAP)
316#if defined(CPPGC_POINTER_COMPRESSION)
317 next_unfinalized_ = CompressedPointer::Compress(next);
323HeapObjectHeader* HeapObjectHeader::GetNextUnfinalized(
324 uintptr_t cage_base_or_mask)
const {
325 DCHECK(cage_base_or_mask);
326#if defined(CPPGC_POINTER_COMPRESSION)
328 api_constants::kCagedHeapReservationAlignment - 1,
331 CompressedPointer::Decompress(next_unfinalized_, cage_base_or_mask));
334 reinterpret_cast<void*
>(cage_base_or_mask)));
336 cage_base_or_mask + next_unfinalized_)
342template <AccessMode mode>
350 std::memory_order memory_order>
352 const uint16_t& half =
359 std::memory_order memory_order>
369 half = (half & ~mask) | bits;
375 uint16_t value = atomic_encoded->load(std::memory_order_relaxed);
376 value = (value & ~mask) | bits;
377 atomic_encoded->store(value, memory_order);
static RetType OffsetFromAddress(const void *address)
static constexpr GCInfoIndex kMaxIndex
static const GCInfo & GCInfoFromIndex(GCInfoIndex index)
static constexpr T decode(U value)
static constexpr U encode(T value)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
const uint8_t * ConstAddress
HeapObjectNameForUnnamedObject
constexpr size_t kAllocationGranularity
constexpr GCInfoIndex kFreeListGCInfoIndex
V8_INLINE std::atomic< T > * AsAtomicPtr(T *t)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
#define V8_EXPORT_PRIVATE
FinalizationCallback finalize