• 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_COMPONENTS_HEAP_HEAP_MANAGER_H
17 #define COMMON_COMPONENTS_HEAP_HEAP_MANAGER_H
18 
19 #include "common_components/common/type_def.h"
20 #include "common_components/heap/collector/gc_request.h"
21 #include "common_interfaces/base/runtime_param.h"
22 
23 namespace common {
24 class BaseObject;
25 // replace this for Heap.
26 class HeapManager {
27 public:
28     HeapManager();
29     ~HeapManager() = default;
30 
31     // runtime required lifecycle interfaces
32     void Init(const RuntimeParam& param);
33     void Fini();
34 
35     static void RequestGC(GCReason reason, bool async, GCType gcType);
36     static void MarkJitFortMemInstalled(void *vm, void *obj);
37 
38     // alloc return memory address, not "object" pointers, since they're not
39     // initialized yet
40     static HeapAddress Allocate(size_t allocSize, AllocType allocType = AllocType::MOVEABLE_OBJECT,
41                                 bool allowGC = true);
42 
43     // For PostFork and Prefork.
44     static void StartRuntimeThreads();
45     static void StopRuntimeThreads();
46 
47     void SetReadOnlyToROSpace();
48     void ClearReadOnlyFromROSpace();
49     bool IsInROSpace(BaseObject *obj);
50 };
51 } // namespace common
52 #endif // COMMON_COMPONENTS_HEAP_HEAP_MANAGER_H
53