• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 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 ark::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,
30     GC_PHASE_CLEANUP,
31     GC_PHASE_LAST
32 };
33 
ToIndex(GCPhase phase)34 constexpr size_t ToIndex(GCPhase phase)
35 {
36     return static_cast<size_t>(phase);
37 }
38 
ToGCPhase(uint8_t index)39 constexpr GCPhase ToGCPhase(uint8_t index)
40 {
41     return static_cast<GCPhase>(index);
42 }
43 
IsMarking(GCPhase phase)44 constexpr bool IsMarking(GCPhase phase)
45 {
46     return phase == GCPhase::GC_PHASE_MARK_YOUNG || phase == GCPhase::GC_PHASE_MARK ||
47            phase == GCPhase::GC_PHASE_INITIAL_MARK || phase == GCPhase::GC_PHASE_REMARK;
48 }
49 
50 }  // namespace ark::mem
51 
52 #endif  // PANDA_RUNTIME_MEM_GC_GC_PHASE_H
53