• 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 ECMASCRIPT_MEM_MIX_GC_H
17 #define ECMASCRIPT_MEM_MIX_GC_H
18 
19 #include "ecmascript/mem/mem.h"
20 #include "ecmascript/mem/heap.h"
21 #include "ecmascript/mem/allocator.h"
22 #include "ecmascript/mem/mark_stack-inl.h"
23 #include "ecmascript/mem/mark_word.h"
24 #include "ecmascript/mem/parallel_work_helper.h"
25 #include "ecmascript/mem/slots.h"
26 #include "ecmascript/mem/object_xray.h"
27 #include "ecmascript/mem/remembered_set.h"
28 #include "ecmascript/mem/stw_young_gc_for_testing.h"
29 
30 namespace panda {
31 namespace ecmascript {
32 class Heap;
33 class JSHClass;
34 
35 class MixGC : public GarbageCollector {
36 public:
37     explicit MixGC(Heap *heap);
38     ~MixGC() override = default;
39     NO_COPY_SEMANTIC(MixGC);
40     NO_MOVE_SEMANTIC(MixGC);
41     void RunPhases();
42 
GetHeap()43     Heap *GetHeap() const
44     {
45         return heap_;
46     }
47 
48 private:
49     void InitializePhase();
50     void MarkingPhase();
51     void SweepPhases();
52     void ProcessNativeDelete();
53     void EvacuaPhases();
54     void FinishPhase();
55 
56     Heap *heap_;
57     size_t freeSize_ {0};
58     size_t hugeSpaceFreeSize_ = 0;
59     size_t oldSpaceCommitSize_ = 0;
60     size_t nonMoveSpaceCommitSize_ = 0;
61     bool concurrentMark_ {false};
62     // obtain from heap
63     WorkerHelper *workList_ {nullptr};
64 
65     friend class WorkerHelper;
66     friend class Heap;
67 };
68 }  // namespace ecmascript
69 }  // namespace panda
70 
71 #endif  // ECMASCRIPT_MEM_MIX_GC_H
72