forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.cc
More file actions
64 lines (51 loc) · 1.89 KB
/
Copy pathtesting.cc
File metadata and controls
64 lines (51 loc) · 1.89 KB
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
57
58
59
60
61
62
63
64
// Copyright 2021 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.
#include "include/cppgc/testing.h"
#include "src/base/logging.h"
#include "src/heap/cppgc/heap-base.h"
namespace cppgc {
namespace testing {
OverrideEmbedderStackStateScope::OverrideEmbedderStackStateScope(
HeapHandle& heap_handle, EmbedderStackState state)
: heap_handle_(heap_handle) {
internal::HeapBase::From(heap_handle_).set_override_stack_state(state);
}
OverrideEmbedderStackStateScope::~OverrideEmbedderStackStateScope() {
internal::HeapBase::From(heap_handle_).clear_overridden_stack_state();
}
StandaloneTestingHeap::StandaloneTestingHeap(HeapHandle& heap_handle)
: heap_handle_(heap_handle) {}
void StandaloneTestingHeap::StartGarbageCollection() {
internal::HeapBase::From(heap_handle_)
.StartIncrementalGarbageCollectionForTesting();
}
bool StandaloneTestingHeap::PerformMarkingStep(EmbedderStackState stack_state) {
return internal::HeapBase::From(heap_handle_)
.marker()
->IncrementalMarkingStepForTesting(stack_state);
}
void StandaloneTestingHeap::FinalizeGarbageCollection(
EmbedderStackState stack_state) {
internal::HeapBase::From(heap_handle_)
.FinalizeIncrementalGarbageCollectionForTesting(stack_state);
}
void StandaloneTestingHeap::ToggleMainThreadMarking(bool should_mark) {
internal::HeapBase::From(heap_handle_)
.marker()
->SetMainThreadMarkingDisabledForTesting(!should_mark);
}
void StandaloneTestingHeap::ForceCompactionForNextGarbageCollection() {
internal::HeapBase::From(heap_handle_)
.compactor()
.EnableForNextGCForTesting();
}
bool IsHeapObjectOld(void* object) {
#if defined(CPPGC_YOUNG_GENERATION)
return internal::HeapObjectHeader::FromObject(object).IsMarked();
#else
return true;
#endif
}
} // namespace testing
} // namespace cppgc