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