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
8
#include "
src/heap/cppgc/compaction-worklists.h
"
9
#include "
src/heap/cppgc/garbage-collector.h
"
10
#include "
src/heap/cppgc/raw-heap.h
"
11
12
namespace
cppgc
{
13
namespace
internal
{
14
15
class
NormalPageSpace;
16
17
class
V8_EXPORT_PRIVATE
Compactor
final {
18
using
CompactableSpaceHandling
=
SweepingConfig::CompactableSpaceHandling
;
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
33
CompactionWorklists
*
compaction_worklists
() {
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
43
RawHeap
&
heap_
;
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_
cppgc::Heap::MarkingType
MarkingType
Definition
heap.h:60
cppgc::internal::CompactionWorklists
Definition
compaction-worklists.h:15
cppgc::internal::Compactor
Definition
compactor.h:17
cppgc::internal::Compactor::compaction_worklists
CompactionWorklists * compaction_worklists()
Definition
compactor.h:33
cppgc::internal::Compactor::compaction_worklists_
std::unique_ptr< CompactionWorklists > compaction_worklists_
Definition
compactor.h:47
cppgc::internal::Compactor::heap_
RawHeap & heap_
Definition
compactor.h:43
cppgc::internal::Compactor::compactable_spaces_
std::vector< NormalPageSpace * > compactable_spaces_
Definition
compactor.h:45
cppgc::internal::Compactor::operator=
Compactor & operator=(const Compactor &)=delete
cppgc::internal::Compactor::Compactor
Compactor(const Compactor &)=delete
cppgc::internal::Compactor::IsEnabledForTesting
bool IsEnabledForTesting() const
Definition
compactor.h:38
cppgc::internal::Compactor::~Compactor
~Compactor()
Definition
compactor.h:22
cppgc::internal::RawHeap
Definition
raw-heap.h:23
compaction-worklists.h
garbage-collector.h
cppgc
Definition
cross-heap-remembered-set.h:14
cppgc::EmbedderStackState
EmbedderStackState
Definition
common.h:15
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
raw-heap.h
DCHECK
#define DCHECK(condition)
Definition
logging.h:482
V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE
Definition
macros.h:460
cppgc::internal::SweepingConfig::CompactableSpaceHandling
CompactableSpaceHandling
Definition
heap-config.h:49
src
heap
cppgc
compactor.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0