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_OLD_GC_VISITOR_H 17 #define ECMASCRIPT_MEM_OLD_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 OldGCMarkRootVisitor final : public RootVisitor { 25 public: 26 inline explicit OldGCMarkRootVisitor(WorkNodeHolder *workNodeHolder); 27 ~OldGCMarkRootVisitor() 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 OldGCMarkObjectVisitor final : public EcmaObjectRangeVisitor<OldGCMarkObjectVisitor> { 42 public: 43 inline explicit OldGCMarkObjectVisitor(WorkNodeHolder *workNodeHolder); 44 ~OldGCMarkObjectVisitor() override = default; 45 46 inline void VisitObjectRangeImpl(TaggedObject *root, ObjectSlot start, ObjectSlot end, 47 VisitObjectArea area) override; 48 49 inline void VisitObjectHClassImpl(TaggedObject *hclass) override; 50 private: 51 inline void HandleSlot(ObjectSlot slot, Region *rootRegion, bool rootNeedEvacuate); 52 53 inline void HandleObject(TaggedObject *object, Region *objectRegion); 54 55 inline void MarkAndPush(TaggedObject *object, Region *objectRegion); 56 57 inline void RecordWeakReference(JSTaggedType *weak); 58 59 WorkNodeHolder *workNodeHolder_ {nullptr}; 60 61 friend class NonMovableMarker; 62 }; 63 64 } // namespace panda::ecmascript 65 #endif // ECMASCRIPT_MEM_OLD_GC_VISITOR_H 66