5 #ifndef INCLUDE_CPPGC_INTERNAL_WRITE_BARRIER_H_
6 #define INCLUDE_CPPGC_INTERNAL_WRITE_BARRIER_H_
8 #include "cppgc/internal/api-constants.h"
9 #include "cppgc/internal/process-heap.h"
12 #if defined(CPPGC_CAGED_HEAP)
13 #include "cppgc/internal/caged-heap-local-data.h"
22 #if defined(CPPGC_CAGED_HEAP)
23 const uintptr_t start =
24 reinterpret_cast<uintptr_t>(value) &
25 ~(api_constants::kCagedHeapReservationAlignment - 1);
26 const uintptr_t slot_offset =
reinterpret_cast<uintptr_t>(slot) - start;
27 if (slot_offset > api_constants::kCagedHeapReservationSize) {
33 CagedHeapLocalData* local_data =
34 reinterpret_cast<CagedHeapLocalData*>(start);
35 if (V8_UNLIKELY(local_data->is_marking_in_progress)) {
36 MarkingBarrierSlow(value);
39 #if defined(CPPGC_YOUNG_GENERATION)
40 GenerationalBarrier(local_data, slot, slot_offset,
41 reinterpret_cast<uintptr_t>(value) - start);
46 MarkingBarrierSlowWithSentinelCheck(value);
51 WriteBarrier() =
delete;
53 static void MarkingBarrierSlow(
const void* value);
54 static void MarkingBarrierSlowWithSentinelCheck(
const void* value);
56 #if defined(CPPGC_YOUNG_GENERATION)
57 static V8_INLINE
void GenerationalBarrier(CagedHeapLocalData* local_data,
59 uintptr_t slot_offset,
60 uintptr_t value_offset) {
61 const AgeTable& age_table = local_data->age_table;
64 if (V8_LIKELY(age_table[slot_offset] == AgeTable::Age::kYoung))
return;
66 GenerationalBarrierSlow(local_data, age_table, slot, value_offset);
69 static void GenerationalBarrierSlow(CagedHeapLocalData* local_data,
70 const AgeTable& ageTable,
71 const void* slot, uintptr_t value_offset);