• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 ECMASCRIPT_SNAPSHOT_MEM_CONSTANTS_H
17 #define ECMASCRIPT_SNAPSHOT_MEM_CONSTANTS_H
18 
19 #include "ecmascript/mem/mem_common.h"
20 
21 namespace panda::ecmascript {
22 class Constants final {
23 public:
24     explicit Constants() = default;
25     ~Constants() = default;
26     NO_COPY_SEMANTIC(Constants);
27     NO_MOVE_SEMANTIC(Constants);
28 
29     static constexpr int MAX_C_POINTER_BITS_COUNT = 10;
30     static constexpr int MAX_REGION_INDEX_BITS_COUNT = 10;
31     static constexpr int MAX_OBJECT_OFFSET_BITS_COUNT = 18;
32     static constexpr int MAX_C_POINTER_INDEX = (1U << MAX_C_POINTER_BITS_COUNT) - 1;
33     static constexpr int MAX_REGION_INDEX = (1U << MAX_REGION_INDEX_BITS_COUNT) - 1;
34     static constexpr int MAX_OBJECT_OFFSET = (1U << MAX_OBJECT_OFFSET_BITS_COUNT) - 1;
35 
36     // object or space align up
37     static constexpr size_t PAGE_SIZE_ALIGN_UP = 4_KB;
38     static constexpr size_t FREE_OBJECT_MIN_SIZE = 16;
39     static constexpr size_t MAX_UINT_16 = 0xFFFF;
40     static constexpr size_t MAX_UINT_32 = 0xFFFFFFFF;
41     static constexpr size_t MAX_OBJECT_INDEX = 0x0FFFFFFF;
42     static constexpr size_t REGION_INDEX_MASK = 0x3FF; // 10 bits
43     static constexpr int UINT_32_BITS_COUNT = 32;
44     static constexpr int UINT_64_BITS_COUNT = 64;
45 
46     // serialize use constants
47     static constexpr uint8_t MASK_METHOD_SPACE_BEGIN = 0xFF;
48 };
49 }  // namespace panda::ecmascript
50 
51 #endif  // ECMASCRIPT_SNAPSHOT_MEM_CONSTANTS_H
52