heap-write-barrier.h 2.69 KB
Newer Older
1 2 3 4 5 6 7
// 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_

8
#include "include/v8-internal.h"
9
#include "src/base/optional.h"
10
#include "src/common/globals.h"
11

12 13 14
namespace v8 {
namespace internal {

15
class ArrayBufferExtension;
16
class Code;
17 18
class DescriptorArray;
class EphemeronHashTable;
19 20
class FixedArray;
class Heap;
21 22 23
class JSArrayBuffer;
class Map;
class MarkCompactCollector;
24
class RelocInfo;
25 26 27 28

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

29
// Combined write barriers.
30
void WriteBarrierForCode(Code host, RelocInfo* rinfo, Object value);
31
void WriteBarrierForCode(Code host, RelocInfo* rinfo, HeapObject value);
32
void WriteBarrierForCode(Code host);
33

34
// Generational write barrier.
35
void GenerationalBarrier(HeapObject object, ObjectSlot slot, Object value);
36
void GenerationalBarrier(HeapObject object, ObjectSlot slot, HeapObject value);
37
void GenerationalBarrier(HeapObject object, MaybeObjectSlot slot,
38
                         MaybeObject value);
39 40
void GenerationalEphemeronKeyBarrier(EphemeronHashTable table, ObjectSlot slot,
                                     Object value);
41
void GenerationalBarrierForCode(Code host, RelocInfo* rinfo, HeapObject object);
42

43
inline bool IsReadOnlyHeapObject(HeapObject object);
44

45 46 47 48 49 50 51 52 53 54 55 56
class V8_EXPORT_PRIVATE WriteBarrier {
 public:
  static inline void Marking(HeapObject host, ObjectSlot, Object value);
  static inline void Marking(HeapObject host, HeapObjectSlot, HeapObject value);
  static inline void Marking(HeapObject host, MaybeObjectSlot,
                             MaybeObject value);
  static inline void Marking(Code host, RelocInfo*, HeapObject value);
  static inline void Marking(JSArrayBuffer host, ArrayBufferExtension*);
  static inline void Marking(Map host, DescriptorArray,
                             int number_of_own_descriptors);
  // It is invoked from generated code and has to take raw addresses.
  static int MarkingFromCode(Address raw_host, Address raw_slot);
57

58 59 60 61 62 63 64 65 66 67
 private:
  static void MarkingSlow(Heap* heap, HeapObject host, HeapObjectSlot,
                          HeapObject value);
  static void MarkingSlow(Heap* heap, Code host, RelocInfo*, HeapObject value);
  static void MarkingSlow(Heap* heap, JSArrayBuffer host,
                          ArrayBufferExtension*);
  static void MarkingSlow(Heap* heap, Map host, DescriptorArray,
                          int number_of_own_descriptors);
  static inline base::Optional<Heap*> GetHeapIfMarking(HeapObject object);
};
68

69 70 71 72
}  // namespace internal
}  // namespace v8

#endif  // V8_HEAP_HEAP_WRITE_BARRIER_H_