chromium/v8/src/heap/heap-write-barrier.h

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_HEAP_HEAP_WRITE_BARRIER_H_
#define V8_HEAP_HEAP_WRITE_BARRIER_H_

#include "include/v8-internal.h"
#include "src/common/globals.h"
#include "src/objects/heap-object.h"

namespace v8 {
namespace internal {

class ArrayBufferExtension;
class InstructionStream;
class DescriptorArray;
class EphemeronHashTable;
class FixedArray;
class Heap;
class JSArrayBuffer;
class Map;
class MarkCompactCollector;
class MarkingBarrier;
class RelocInfo;

// Note: In general it is preferred to use the macros defined in
// object-macros.h.

// Combined write barriers.
void WriteBarrierForCode(Tagged<InstructionStream> host, RelocInfo* rinfo,
                         Tagged<Object> value,
                         WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
void WriteBarrierForCode(Tagged<InstructionStream> host, RelocInfo* rinfo,
                         Tagged<HeapObject> value,
                         WriteBarrierMode mode = UPDATE_WRITE_BARRIER);

void CombinedWriteBarrier(Tagged<HeapObject> object, ObjectSlot slot,
                          Tagged<Object> value, WriteBarrierMode mode);
void CombinedWriteBarrier(Tagged<HeapObject> object, MaybeObjectSlot slot,
                          Tagged<MaybeObject> value, WriteBarrierMode mode);

void CombinedWriteBarrier(HeapObjectLayout* object, TaggedMemberBase* slot,
                          Tagged<Object> value, WriteBarrierMode mode);

void CombinedEphemeronWriteBarrier(Tagged<EphemeronHashTable> object,
                                   ObjectSlot slot, Tagged<Object> value,
                                   WriteBarrierMode mode);

void IndirectPointerWriteBarrier(Tagged<HeapObject> host,
                                 IndirectPointerSlot slot,
                                 Tagged<HeapObject> value,
                                 WriteBarrierMode mode);

void JSDispatchHandleWriteBarrier(Tagged<HeapObject> host,
                                  JSDispatchHandle handle,
                                  WriteBarrierMode mode);

// Generational write barrier.
void GenerationalBarrierForCode(Tagged<InstructionStream> host,
                                RelocInfo* rinfo, Tagged<HeapObject> object);

inline bool IsReadOnlyHeapObject(Tagged<HeapObject> object);

class V8_EXPORT_PRIVATE WriteBarrier {};

}  // namespace internal
}  // namespace v8

#endif  // V8_HEAP_HEAP_WRITE_BARRIER_H_