1 /* 2 * Copyright (c) 2022 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_VISITOR_H 17 #define ECMASCRIPT_MEM_VISITOR_H 18 19 #include <functional> 20 21 #include <ecmascript/mem/slots.h> 22 #include <ecmascript/mem/tagged_object.h> 23 24 namespace panda::ecmascript { 25 enum class Root { 26 ROOT_FRAME, 27 ROOT_HANDLE, 28 ROOT_VM, 29 ROOT_STRING, 30 ROOT_INTERNAL_CALL_PARAMS, 31 }; 32 33 enum class VisitObjectArea { 34 NORMAL, 35 NATIVE_POINTER, 36 IN_OBJECT 37 }; 38 39 enum class VisitType : size_t { SEMI_GC_VISIT, OLD_GC_VISIT, SNAPSHOT_VISIT }; 40 41 using RootVisitor = std::function<void(Root type, ObjectSlot p)>; 42 using RootRangeVisitor = std::function<void(Root type, ObjectSlot start, ObjectSlot end)>; 43 using RootBaseAndDerivedVisitor = 44 std::function<void(Root type, ObjectSlot base, ObjectSlot derived, uintptr_t baseOldObject)>; 45 using EcmaObjectRangeVisitor = std::function<void(TaggedObject *root, ObjectSlot start, ObjectSlot end, 46 VisitObjectArea area)>; 47 using WeakRootVisitor = std::function<TaggedObject *(TaggedObject *p)>; 48 } // namespace panda::ecmascript 49 #endif // ECMASCRIPT_MEM_VISITOR_H 50