v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
compactor.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_CPPGC_COMPACTOR_H_
6#define V8_HEAP_CPPGC_COMPACTOR_H_
7
11
12namespace cppgc {
13namespace internal {
14
15class NormalPageSpace;
16
19
20 public:
21 explicit Compactor(RawHeap&);
22 ~Compactor() { DCHECK(!is_enabled_); }
23
24 Compactor(const Compactor&) = delete;
25 Compactor& operator=(const Compactor&) = delete;
26
27 void InitializeIfShouldCompact(GCConfig::MarkingType, StackState);
28 void CancelIfShouldNotCompact(GCConfig::MarkingType, StackState);
29 // Returns whether spaces need to be processed by the Sweeper after
30 // compaction.
31 CompactableSpaceHandling CompactSpacesIfEnabled();
32
34 return compaction_worklists_.get();
35 }
36
37 void EnableForNextGCForTesting();
38 bool IsEnabledForTesting() const { return is_enabled_; }
39
40 private:
41 bool ShouldCompact(GCConfig::MarkingType, StackState) const;
42
44 // Compactor does not own the compactable spaces. The heap owns all spaces.
45 std::vector<NormalPageSpace*> compactable_spaces_;
46
47 std::unique_ptr<CompactionWorklists> compaction_worklists_;
48
49 bool is_enabled_ = false;
50 bool is_cancelled_ = false;
51 bool enable_for_next_gc_for_testing_ = false;
52};
53
54} // namespace internal
55} // namespace cppgc
56
57#endif // V8_HEAP_CPPGC_COMPACTOR_H_
MarkingType
Definition heap.h:60
CompactionWorklists * compaction_worklists()
Definition compactor.h:33
std::unique_ptr< CompactionWorklists > compaction_worklists_
Definition compactor.h:47
std::vector< NormalPageSpace * > compactable_spaces_
Definition compactor.h:45
Compactor & operator=(const Compactor &)=delete
Compactor(const Compactor &)=delete
bool IsEnabledForTesting() const
Definition compactor.h:38
EmbedderStackState
Definition common.h:15
#define DCHECK(condition)
Definition logging.h:482
#define V8_EXPORT_PRIVATE
Definition macros.h:460