• 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_COMMON_TYPE_DEF_H
17 #define COMMON_COMPONENTS_COMMON_TYPE_DEF_H
18 
19 #include <climits>
20 #include <cstdint>
21 #include <limits>
22 
23 namespace common {
24 class BaseObject;
25 }
26 
27 // commonly agreed type interfaces for a managed runtime:
28 //    they're opaque across modules, but we still want it provides a degree
29 //    of type safety.
30 namespace common {
31 // Those are mostly managed pointer types for GC
32 using HeapAddress = uint64_t; // Managed address
33 constexpr uintptr_t NULL_ADDRESS = 0;
34 
35 // object model related types
36 using common::BaseObject;
37 
38 // basic types for managed world: modify them together
39 using MIndex = uint64_t;  // index of array
40 
41 // at first glance, there is no need to expose this type or at least RAW_POINTER_OBJECT.
42 // however in consideration that there are lots of differences for runtime apis to support different gc,
43 // this is acceptable.
44 enum class AllocType {
45     MOVEABLE_OBJECT = 0,
46     MOVEABLE_OLD_OBJECT,
47     PINNED_OBJECT,
48     RAW_POINTER_OBJECT,
49     READ_ONLY_OBJECT,
50 };
51 } // namespace common
52 
53 #endif // COMMON_COMPONENTS_COMMON_TYPE_DEF_H
54