• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 #ifndef PANDA_RUNTIME_MEM_GC_GC_PHASE_H
16 #define PANDA_RUNTIME_MEM_GC_GC_PHASE_H
17 
18 namespace panda::mem {
19 
20 enum class GCPhase {
21     GC_PHASE_IDLE,  // GC waits for trigger event
22     GC_PHASE_RUNNING,
23     GC_PHASE_COLLECT_ROOTS,
24     GC_PHASE_INITIAL_MARK,
25     GC_PHASE_MARK,
26     GC_PHASE_MARK_YOUNG,
27     GC_PHASE_REMARK,
28     GC_PHASE_COLLECT_YOUNG_AND_MOVE,
29     GC_PHASE_SWEEP_STRING_TABLE,
30     GC_PHASE_SWEEP_STRING_TABLE_YOUNG,
31     GC_PHASE_SWEEP,
32     GC_PHASE_CLEANUP,
33     GC_PHASE_LAST
34 };
35 
ToIndex(GCPhase phase)36 constexpr size_t ToIndex(GCPhase phase)
37 {
38     return static_cast<size_t>(phase);
39 }
40 
ToGCPhase(uint8_t index)41 constexpr GCPhase ToGCPhase(uint8_t index)
42 {
43     return static_cast<GCPhase>(index);
44 }
45 
IsMarking(GCPhase phase)46 constexpr bool IsMarking(GCPhase phase)
47 {
48     return phase == GCPhase::GC_PHASE_MARK_YOUNG || phase == GCPhase::GC_PHASE_MARK ||
49            phase == GCPhase::GC_PHASE_INITIAL_MARK || phase == GCPhase::GC_PHASE_REMARK;
50 }
51 
52 }  // namespace panda::mem
53 
54 #endif  // PANDA_RUNTIME_MEM_GC_GC_PHASE_H
55