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