summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/marking-barrier.h
blob: 761231b93dc31c34aad1a42fbad3227d2a4775bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2020 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_MARKING_BARRIER_H_
#define V8_HEAP_MARKING_BARRIER_H_

#include "include/v8-internal.h"
#include "src/common/globals.h"
#include "src/heap/mark-compact.h"

namespace v8 {
namespace internal {

class Heap;
class IncrementalMarking;
class PagedSpace;
class NewSpace;

class MarkingBarrier {
 public:
  MarkingBarrier(Heap*, MarkCompactCollector*, IncrementalMarking*);
  void Activate(bool is_compacting);
  void Deactivate();

  void Write(HeapObject host, HeapObjectSlot, HeapObject value);
  void Write(Code host, RelocInfo*, HeapObject value);
  void Write(JSArrayBuffer host, ArrayBufferExtension*);
  void Write(Map host, DescriptorArray, int number_of_own_descriptors);

  // Returns true if the slot needs to be recorded.
  inline bool MarkValue(HeapObject host, HeapObject value);

 private:
  using MarkingState = MarkCompactCollector::MarkingState;

  inline bool WhiteToGreyAndPush(HeapObject value);

  void Activate(PagedSpace*);
  void Activate(NewSpace*);

  void Deactivate(PagedSpace*);
  void Deactivate(NewSpace*);

  MarkingState marking_state_;
  Heap* heap_;
  MarkCompactCollector* collector_;
  IncrementalMarking* incremental_marking_;
  bool is_compacting_ = false;
  bool is_activated_ = false;
};

}  // namespace internal
}  // namespace v8

#endif  // V8_HEAP_MARKING_BARRIER_H_