• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PARALLEL_EVACUATOR_VISITOR_H
17 #define ECMASCRIPT_MEM_PARALLEL_EVACUATOR_VISITOR_H
18 
19 #include "ecmascript/mem/parallel_evacuator.h"
20 
21 namespace panda::ecmascript {
22 template<TriggerGCType gcType>
23 class SlotUpdateRangeVisitor final : public EcmaObjectRangeVisitor<SlotUpdateRangeVisitor<gcType>> {
24 public:
25     explicit SlotUpdateRangeVisitor(ParallelEvacuator *evacuator);
26     ~SlotUpdateRangeVisitor() override = default;
27 
28     void VisitObjectRangeImpl(TaggedObject *root, ObjectSlot start, ObjectSlot end, VisitObjectArea area) override;
29 private:
30     void UpdateSlot(ObjectSlot slot, Region *rootRegion);
31 
32     ParallelEvacuator *evacuator_ {nullptr};
33 };
34 
35 template<TriggerGCType gcType>
36 class NewToOldEvacuationVisitor {
37 public:
38     explicit NewToOldEvacuationVisitor(Heap *heap, std::unordered_set<JSTaggedType> *set,
39         ParallelEvacuator *evacuator);
40 
41     ~NewToOldEvacuationVisitor() = default;
42 
43     NO_COPY_SEMANTIC(NewToOldEvacuationVisitor);
44     NO_MOVE_SEMANTIC(NewToOldEvacuationVisitor);
45 
46     void operator()(void *mem);
47 
48     void UpdateTrackInfo(TaggedObject *header, JSHClass *klass);
49 
50 private:
51     bool pgoEnabled_ {false};
52     std::shared_ptr<PGOProfiler> pgoProfiler_;
53     std::unordered_set<JSTaggedType> *trackSet_ {nullptr};
54     SlotUpdateRangeVisitor<gcType> slotUpdateRangeVisitor_;
55 };
56 }  // namespace panda::ecmascript
57 #endif  // ECMASCRIPT_MEM_PARALLEL_EVACUATOR_VISITOR_H