1/* 2 * Copyright (c) 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 16#ifndef ECMASCRIPT_MEM_SHARED_HEAP_SHARED_FULL_GC_H 17#define ECMASCRIPT_MEM_SHARED_HEAP_SHARED_FULL_GC_H 18 19#include "ecmascript/mem/garbage_collector.h" 20#include "ecmascript/mem/heap.h" 21#include "ecmascript/mem/mark_stack.h" 22#include "ecmascript/mem/mark_word.h" 23#include "ecmascript/mem/mem.h" 24#include "ecmascript/mem/work_manager.h" 25 26namespace panda::ecmascript { 27class SharedFullGC : public GarbageCollector { 28public: 29 explicit SharedFullGC(SharedHeap *heap) : sHeap_(heap), sWorkManager_(heap->GetWorkManager()) {} 30 ~SharedFullGC() override = default; 31 NO_COPY_SEMANTIC(SharedFullGC); 32 NO_MOVE_SEMANTIC(SharedFullGC); 33 34 void RunPhases() override; 35 void ResetWorkManager(SharedGCWorkManager *workManager); 36 void SetForAppSpawn(bool flag) 37 { 38 isAppspawn_ = flag; 39 } 40protected: 41 void Initialize() override; 42 void Mark() override; 43 void Sweep() override; 44 void Finish() override; 45 46private: 47 void UpdateRecordWeakReference(); 48 bool HasEvacuated(Region *region); 49 50 SharedHeap *sHeap_ {nullptr}; 51 SharedGCWorkManager *sWorkManager_ {nullptr}; 52 bool isAppspawn_ {false}; 53}; 54} // namespace panda::ecmascript 55 56#endif // ECMASCRIPT_MEM_SHARED_HEAP_SHARED_FULL_GC_H 57