• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 COMMON_INTERFACES_HEAP_VISITOR_H
17 #define COMMON_INTERFACES_HEAP_VISITOR_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <functional>
22 #include "base/common.h"
23 #include "objects/ref_field.h"
24 
25 namespace common {
26 class BaseObject;
27 class Mutator;
28 using CommonRootVisitor = void (*)(void *root);
29 using RefFieldVisitor = std::function<void(RefField<> &)>;
30 using WeakRefFieldVisitor = std::function<bool(RefField<> &)>;
31 
32 void VisitRoots(const RefFieldVisitor &visitor);
33 void VisitWeakRoots(const WeakRefFieldVisitor &visitorFunc);
34 void VisitSTWRoots(const RefFieldVisitor &visitor);
35 void VisitConcurrentRoots(const RefFieldVisitor &visitor);
36 
37 // GlobalRoots are subsets of roots which are shared in all mutator threads.
38 void VisitGlobalRoots(const RefFieldVisitor &visitor);
39 void VisitWeakGlobalRoots(const WeakRefFieldVisitor &visitorFunc);
40 void VisitPreforwardRoots(const RefFieldVisitor &visitor);
41 
42 void VisitMutatorRoot(const RefFieldVisitor &visitor, Mutator &mutator);
43 void VisitWeakMutatorRoot(const WeakRefFieldVisitor &visitor, Mutator &mutator);
44 void VisitMutatorPreforwardRoot(const RefFieldVisitor &visitor, Mutator &mutator);
45 // Static VM Roots scanning
46 void VisitStaticRoots(const RefFieldVisitor &visitor);
47 }  // namespace common
48 #endif  // COMMON_INTERFACES_HEAP_VISITOR_H
49