1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "common_components/heap/collector/collector.h"
16
17 #include "common_components/heap/heap.h"
18 #include "common_components/mutator/mutator.h"
19
20 namespace common {
21 namespace {
22 const char* const COLLECTOR_NAME[] = { "No Collector", "Proxy Collector", "Regional-Copying Collector",
23 "Smooth Collector" };
24 }
25
GetGCPhaseName(GCPhase phase)26 const char* Collector::GetGCPhaseName(GCPhase phase)
27 {
28 static const char* phaseNames[] = {
29 "undefined phase", // GC_PHASE_UNDEF
30 "idle phase", // GC_PHASE_IDLE
31 "stub phase", // reserved
32 "stub phase", // reserved
33 "stub phase", // reserved
34 "stub phase", // reserved
35 "stub phase", // reserved
36 "stub phase", // reserved
37 "start phase", // GC_PHASE_START
38 "enum phase", // GC_PHASE_ENUM
39 "marking phase", // GC_PHASE_MARK
40 "remark-satb phase", // GC_PHASE_REMARK_SATB
41 "final-mark phase", // GC_PHASE_FINAL_MARK
42 "post-marking phase", // GC_PHASE_POST_MARK
43 "pre-copy phase", // GC_PHASE_PRECOPY
44 "copy phase", // GC_PHASE_COPY
45 "fix phase", // GC_PHASE_FIX
46 };
47 return phaseNames[phase];
48 }
49
Collector()50 Collector::Collector() {}
51
GetCollectorName() const52 const char* Collector::GetCollectorName() const { return COLLECTOR_NAME[collectorType_]; }
53
RequestGC(GCReason reason,bool async,GCType gcType)54 void Collector::RequestGC(GCReason reason, bool async, GCType gcType)
55 {
56 RequestGCInternal(reason, async, gcType);
57 return;
58 }
59 } // namespace common.
60