• 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_YOUNG_GC_VISITOR_H
17 #define ECMASCRIPT_MEM_YOUNG_GC_VISITOR_H
18 
19 #include "ecmascript/mem/slots.h"
20 #include <ecmascript/mem/visitor.h>
21 #include <ecmascript/mem/work_manager.h>
22 
23 namespace panda::ecmascript {
24 class YoungGCMarkRootVisitor final : public RootVisitor {
25 public:
26     inline explicit YoungGCMarkRootVisitor(WorkNodeHolder *workNodeHolder);
27     ~YoungGCMarkRootVisitor() override = default;
28 
29     inline void VisitRoot([[maybe_unused]] Root type, ObjectSlot slot) override;
30 
31     inline void VisitRangeRoot([[maybe_unused]] Root type, ObjectSlot start, ObjectSlot end) override;
32 
33     inline void VisitBaseAndDerivedRoot([[maybe_unused]] Root type, ObjectSlot base, ObjectSlot derived,
34                                         uintptr_t baseOldObject) override;
35 private:
36     inline void HandleSlot(ObjectSlot slot);
37 
38     WorkNodeHolder *workNodeHolder_ {nullptr};
39 };
40 
41 class YoungGCMarkObjectVisitor final : public EcmaObjectRangeVisitor<YoungGCMarkObjectVisitor> {
42 public:
43     inline explicit YoungGCMarkObjectVisitor(WorkNodeHolder *workNodeHolder);
44     ~YoungGCMarkObjectVisitor() override = default;
45 
46     inline void VisitObjectRangeImpl(TaggedObject *root, ObjectSlot start, ObjectSlot end,
47                                      VisitObjectArea area) override;
48 private:
49     inline void HandleSlot(ObjectSlot slot);
50 
51     WorkNodeHolder *workNodeHolder_ {nullptr};
52 };
53 
54 class YoungGCMarkOldToNewRSetVisitor {
55 public:
56     inline explicit YoungGCMarkOldToNewRSetVisitor(WorkNodeHolder *workNodeHolder);
57     ~YoungGCMarkOldToNewRSetVisitor() = default;
58 
59     inline void operator()(Region *region) const;
60 private:
61     inline bool HandleSlot(ObjectSlot slot) const;
62 
63     WorkNodeHolder *workNodeHolder_ {nullptr};
64 };
65 
66 }  // namespace panda::ecmascript
67 #endif  // ECMASCRIPT_MEM_YOUNG_GC_VISITOR_H
68