v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
marking-barrier.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_HEAP_MARKING_BARRIER_H_
6#define V8_HEAP_MARKING_BARRIER_H_
7
8#include <optional>
9
10#include "include/v8-internal.h"
11#include "src/base/hashing.h"
12#include "src/common/globals.h"
16
17namespace v8 {
18namespace internal {
19
20class Heap;
21class IncrementalMarking;
22class LocalHeap;
23class PagedSpace;
24class NewSpace;
25
27 public:
28 explicit MarkingBarrier(LocalHeap*);
30
31 void Activate(bool is_compacting, MarkingMode marking_mode);
32 void Deactivate();
33 void PublishIfNeeded();
34
35 void ActivateShared();
36 void DeactivateShared();
38
39 static void ActivateAll(Heap* heap, bool is_compacting);
40 static void DeactivateAll(Heap* heap);
42
43 static void ActivateYoung(Heap* heap);
44 static void DeactivateYoung(Heap* heap);
46
47 template <typename TSlot>
48 void Write(Tagged<HeapObject> host, TSlot slot, Tagged<HeapObject> value);
51 Tagged<HeapObject> value);
53 void Write(Tagged<DescriptorArray>, int number_of_own_descriptors);
54 // Only usable when there's no valid JS host object for this write, e.g., when
55 // value is held alive from a global handle.
57
58 inline void MarkValue(Tagged<HeapObject> host, Tagged<HeapObject> value);
59
61
62 bool is_not_major() const {
63 switch (marking_mode_) {
65 return false;
68 return true;
69 }
70 }
71
72 Heap* heap() const { return heap_; }
73
74#if DEBUG
75 void AssertMarkingIsActivated() const;
76 void AssertSharedMarkingIsActivated() const;
77 bool IsMarked(const Tagged<HeapObject> value) const;
78#endif // DEBUG
79
80 private:
81 inline void MarkValueShared(Tagged<HeapObject> value);
82 inline void MarkValueLocal(Tagged<HeapObject> value);
83
85 Tagged<HeapObject> target);
86
87 bool IsCurrentMarkingBarrier(Tagged<HeapObject> verification_candidate);
88
89 template <typename TSlot>
90 inline void MarkRange(Tagged<HeapObject> value, TSlot start, TSlot end);
91
92 inline bool IsCompacting(Tagged<HeapObject> object) const;
93
95
96 Isolate* isolate() const;
97
102 std::unique_ptr<MarkingWorklists::Local> current_worklists_;
103 std::optional<MarkingWorklists::Local> shared_heap_worklists_;
105 std::unordered_map<MutablePageMetadata*, std::unique_ptr<TypedSlots>,
108 bool is_compacting_ = false;
109 bool is_activated_ = false;
114};
115
116} // namespace internal
117} // namespace v8
118
119#endif // V8_HEAP_MARKING_BARRIER_H_
static V8_EXPORT_PRIVATE void PublishAll(Heap *heap)
void MarkValue(Tagged< HeapObject > host, Tagged< HeapObject > value)
static V8_EXPORT_PRIVATE void PublishYoung(Heap *heap)
IncrementalMarking * incremental_marking_
std::optional< MarkingWorklists::Local > shared_heap_worklists_
void Activate(bool is_compacting, MarkingMode marking_mode)
void MarkValueLocal(Tagged< HeapObject > value)
void Write(Tagged< HeapObject > host, TSlot slot, Tagged< HeapObject > value)
std::unique_ptr< MarkingWorklists::Local > current_worklists_
bool IsCurrentMarkingBarrier(Tagged< HeapObject > verification_candidate)
void WriteWithoutHost(Tagged< HeapObject > value)
void RecordRelocSlot(Tagged< InstructionStream > host, RelocInfo *rinfo, Tagged< HeapObject > target)
void MarkRange(Tagged< HeapObject > value, TSlot start, TSlot end)
std::unordered_map< MutablePageMetadata *, std::unique_ptr< TypedSlots >, base::hash< MutablePageMetadata * > > typed_slots_map_
MarkCompactCollector * major_collector_
MinorMarkSweepCollector * minor_collector_
void MarkValueShared(Tagged< HeapObject > value)
static void DeactivateAll(Heap *heap)
static void DeactivateYoung(Heap *heap)
static void ActivateAll(Heap *heap, bool is_compacting)
static void ActivateYoung(Heap *heap)
bool IsCompacting(Tagged< HeapObject > object) const
int start
int end
#define V8_EXPORT_PRIVATE
Definition macros.h:460