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_ALLOCATOR_H 17 #define COMMON_INTERFACES_HEAP_ALLOCATOR_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include "objects/base_state_word.h" 22 23 namespace common { 24 using Address32 = uint32_t; 25 using Address = uint64_t; 26 27 class HeapAllocator { 28 public: 29 static Address AllocateInYoungOrHuge(size_t size, LanguageType language); 30 static Address AllocateInNonmoveOrHuge(size_t size, LanguageType language); 31 static Address32 Allocate32(size_t size, LanguageType language); 32 static Address AllocateInOldOrHuge(size_t size, LanguageType language); 33 static Address AllocateInHuge(size_t size, LanguageType language); 34 static Address AllocateInReadOnly(size_t size, LanguageType language); 35 static uintptr_t AllocateLargeJitFortRegion(size_t size, LanguageType language); 36 // below are interfaces used for serialize 37 static Address AllocateNoGC(size_t size); 38 static Address AllocateOldOrLargeNoGC(size_t size); 39 static Address AllocatePinNoGC(size_t size); 40 static Address AllocateOldRegion(); 41 static Address AllocatePinnedRegion(); 42 static Address AllocateLargeRegion(size_t size); 43 }; 44 } // namespace common 45 #endif // COMMON_INTERFACES_HEAP_ALLOCATOR_H 46