• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "libpandabase/utils/logger.h"
17 #include "runtime/mark_word.h"
18 #include "runtime/include/runtime.h"
19 #include "runtime/include/panda_vm.h"
20 #include "runtime/mem/gc/cmc-gc-adapter/cmc-gc-adapter.h"
21 
22 namespace ark::mem {
23 template <class LanguageConfig>
CMCGCAdapter(ObjectAllocatorBase * objectAllocator,const GCSettings & settings)24 CMCGCAdapter<LanguageConfig>::CMCGCAdapter(ObjectAllocatorBase *objectAllocator, const GCSettings &settings)
25     : GCLang<LanguageConfig>(objectAllocator, settings)
26 {
27     this->SetType(GCType::CMC_GC);
28 }
29 
30 template <class LanguageConfig>
InitializeImpl()31 void CMCGCAdapter<LanguageConfig>::InitializeImpl()
32 {
33     InternalAllocatorPtr allocator = this->GetInternalAllocator();
34     auto barrierSet = allocator->New<GCDummyBarrierSet>(allocator);
35     ASSERT(barrierSet != nullptr);
36     this->SetGCBarrierSet(barrierSet);
37     LOG(DEBUG, GC) << "CMC GC adapter initialized...";
38 }
39 
40 template <class LanguageConfig>
RunPhasesImpl(GCTask & task)41 void CMCGCAdapter<LanguageConfig>::RunPhasesImpl([[maybe_unused]] GCTask &task)
42 {
43     LOG(DEBUG, GC) << "CMC GC adapter RunPhases...";
44     GCScopedPauseStats scopedPauseStats(this->GetPandaVm()->GetGCStats());
45 }
46 
47 // NOLINTNEXTLINE(misc-unused-parameters)
48 template <class LanguageConfig>
WaitForGC(GCTask task)49 bool CMCGCAdapter<LanguageConfig>::WaitForGC([[maybe_unused]] GCTask task)
50 {
51     return false;
52 }
53 
54 template <class LanguageConfig>
InitGCBits(ObjectHeader * objHeader)55 void CMCGCAdapter<LanguageConfig>::InitGCBits([[maybe_unused]] ObjectHeader *objHeader)
56 {
57 }
58 
59 template <class LanguageConfig>
InitGCBitsForAllocationInTLAB(ObjectHeader * objHeader)60 void CMCGCAdapter<LanguageConfig>::InitGCBitsForAllocationInTLAB([[maybe_unused]] ObjectHeader *objHeader)
61 {
62     LOG(FATAL, GC) << "TLABs are not supported by this GC";
63 }
64 
65 template <class LanguageConfig>
Trigger(PandaUniquePtr<GCTask> task)66 bool CMCGCAdapter<LanguageConfig>::Trigger([[maybe_unused]] PandaUniquePtr<GCTask> task)
67 {
68     return false;
69 }
70 
71 template <class LanguageConfig>
IsPostponeGCSupported() const72 bool CMCGCAdapter<LanguageConfig>::IsPostponeGCSupported() const
73 {
74     return true;
75 }
76 
77 template <class LanguageConfig>
MarkObject(ObjectHeader * object)78 void CMCGCAdapter<LanguageConfig>::MarkObject([[maybe_unused]] ObjectHeader *object)
79 {
80 }
81 
82 template <class LanguageConfig>
IsMarked(const ObjectHeader * object) const83 bool CMCGCAdapter<LanguageConfig>::IsMarked([[maybe_unused]] const ObjectHeader *object) const
84 {
85     return false;
86 }
87 
88 template <class LanguageConfig>
MarkReferences(GCMarkingStackType * references,GCPhase gcPhase)89 void CMCGCAdapter<LanguageConfig>::MarkReferences([[maybe_unused]] GCMarkingStackType *references,
90                                                   [[maybe_unused]] GCPhase gcPhase)
91 {
92 }
93 
94 TEMPLATE_CLASS_LANGUAGE_CONFIG(CMCGCAdapter);
95 
96 }  // namespace ark::mem
97