• 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 #include "common_components/serialize/serialize_utils.h"
17 
18 #include "common_components/heap/allocator/region_desc.h"
19 #include "common_interfaces/base_runtime.h"
20 
21 namespace common {
GetSerializeObjectSpace(uintptr_t obj)22 SerializedBaseObjectSpace SerializeUtils::GetSerializeObjectSpace(uintptr_t obj)
23 {
24     RegionDesc::RegionType type = RegionDesc::GetAliveRegionType(obj);
25     switch (type) {
26         case RegionDesc::RegionType::THREAD_LOCAL_REGION:
27         case RegionDesc::RegionType::THREAD_LOCAL_OLD_REGION:
28         case RegionDesc::RegionType::RECENT_FULL_REGION:
29         case RegionDesc::RegionType::FROM_REGION:
30         case RegionDesc::RegionType::LONE_FROM_REGION:
31         case RegionDesc::RegionType::EXEMPTED_FROM_REGION:
32         case RegionDesc::RegionType::TO_REGION:
33         case RegionDesc::RegionType::OLD_REGION:
34             return SerializedBaseObjectSpace::REGULAR_SPACE;
35         case RegionDesc::RegionType::FULL_PINNED_REGION:
36         case RegionDesc::RegionType::RECENT_PINNED_REGION:
37         case RegionDesc::RegionType::FIXED_PINNED_REGION:
38         case RegionDesc::RegionType::FULL_FIXED_PINNED_REGION:
39         case RegionDesc::RegionType::READ_ONLY_REGION:
40         case RegionDesc::RegionType::APPSPAWN_REGION:
41             return SerializedBaseObjectSpace::PIN_SPACE;
42         case RegionDesc::RegionType::RECENT_LARGE_REGION:
43         case RegionDesc::RegionType::LARGE_REGION:
44             return SerializedBaseObjectSpace::LARGE_SPACE;
45         default:
46             return SerializedBaseObjectSpace::OTHER;
47     }
48 }
49 }  // namespace common
50