• 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_COMMON_H
17 #define ECMASCRIPT_COMMON_H
18 
19 #include <limits>
20 
21 #include "libpandabase/macros.h"
22 
23 #include "ecmascript/common_enum.h"
24 namespace panda {
25 namespace ecmascript {
26 
27 #define SCOPE_LIST(V)                    \
28     V(TotalGC)                           \
29     V(Initialize)                        \
30     V(ConcurrentMark)                    \
31     V(WaitConcurrentMarkFinished)        \
32     V(ReMark)                            \
33     V(Mark)                              \
34     V(MarkRoots)                         \
35     V(ProcessSharedGCRSetWorkList)       \
36     V(Sweep)                             \
37     V(ClearNativeObject)                 \
38     V(Evacuate)                          \
39     V(Finish)                            \
40     V(UpdateReference)                   \
41     V(EvacuateSpace)                     \
42     V(SuspendAll)                        \
43     V(ResumeAll)                         \
44     V(ProceeWorkload)                    \
45     V(UpdateRoot)                        \
46     V(UpdateWeekRef)                     \
47     V(EvacuateRegion)                    \
48     V(WaitFinish)
49 
50 #define RECORD_DATA(V)                   \
51     V(START_OBJ_SIZE)                    \
52     V(END_OBJ_SIZE)                      \
53     V(START_COMMIT_SIZE)                 \
54     V(END_COMMIT_SIZE)                   \
55     V(START_EDEN_OBJ_SIZE)               \
56     V(START_YOUNG_OBJ_SIZE)              \
57     V(SEMI_ALIVE_SIZE)                   \
58     V(SEMI_COMMIT_SIZE)                  \
59     V(SEMI_PROMOTE_SIZE)                 \
60     V(EDEN_ALIVE_SIZE)                   \
61     V(EDEN_COMMIT_SIZE)                  \
62     V(EDEN_PROMOTE_SIZE)                 \
63     V(YOUNG_ALIVE_SIZE)                  \
64     V(YOUNG_COMMIT_SIZE)                 \
65     V(YOUNG_PROMOTE_SIZE)                \
66     V(OLD_ALIVE_SIZE)                    \
67     V(OLD_COMMIT_SIZE)                   \
68     V(COMPRESS_ALIVE_SIZE)               \
69     V(COMPRESS_COMMIT_SIZE)              \
70     V(START_NATIVE_POINTER_NUM)          \
71     V(COLLECT_REGION_SET_SIZE)           \
72     SEMI_RECORD_DATA(V)                  \
73     PARTIAL_RECORD_DATA(V)               \
74     FULL_RECORD_DATA(V)                  \
75     SHARED_RECORD_DATA(V)
76 
77 #define RECORD_DURATION(V)               \
78     V(SEMI_MIN_PAUSE)                    \
79     V(SEMI_MAX_PAUSE)                    \
80     V(SEMI_TOTAL_PAUSE)                  \
81     V(EDEN_MIN_PAUSE)                    \
82     V(EDEN_MAX_PAUSE)                    \
83     V(EDEN_TOTAL_PAUSE)                  \
84     V(YOUNG_MIN_PAUSE)                   \
85     V(YOUNG_MAX_PAUSE)                   \
86     V(YOUNG_TOTAL_PAUSE)                 \
87     V(OLD_MIN_PAUSE)                     \
88     V(OLD_MAX_PAUSE)                     \
89     V(OLD_TOTAL_PAUSE)                   \
90     V(COMPRESS_MIN_PAUSE)                \
91     V(COMPRESS_MAX_PAUSE)                \
92     V(COMPRESS_TOTAL_PAUSE)              \
93     V(SHARED_MIN_PAUSE)                  \
94     V(SHARED_MAX_PAUSE)                  \
95     V(SHARED_TOTAL_PAUSE)
96 
97 #define SEMI_RECORD_DATA(V)              \
98     V(SEMI_COUNT)                        \
99     V(SEMI_TOTAL_ALIVE)                  \
100     V(SEMI_TOTAL_COMMIT)                 \
101     V(SEMI_TOTAL_PROMOTE)
102 
103 #define PARTIAL_RECORD_DATA(V)           \
104     V(EDEN_COUNT)                        \
105     V(EDEN_TOTAL_ALIVE)                  \
106     V(EDEN_TOTAL_COMMIT)                 \
107     V(EDEN_TOTAL_PROMOTE)                \
108     V(YOUNG_COUNT)                       \
109     V(YOUNG_TOTAL_ALIVE)                 \
110     V(YOUNG_TOTAL_COMMIT)                \
111     V(YOUNG_TOTAL_PROMOTE)               \
112     V(OLD_COUNT)                         \
113     V(OLD_TOTAL_ALIVE)                   \
114     V(OLD_TOTAL_COMMIT)
115 
116 #define FULL_RECORD_DATA(V)              \
117     V(COMPRESS_COUNT)                    \
118     V(COMPRESS_TOTAL_ALIVE)              \
119     V(COMPRESS_TOTAL_COMMIT)
120 
121 #define SHARED_RECORD_DATA(V)            \
122     V(SHARED_COUNT)                      \
123     V(SHARED_ALIVE_SIZE)                 \
124     V(SHARED_TOTAL_ALIVE)                \
125     V(SHARED_COMMIT_SIZE)                \
126     V(SHARED_TOTAL_COMMIT)
127 
128 #define TRACE_GC_SPEED(V)                \
129     V(UPDATE_REFERENCE_SPEED)            \
130     V(OLD_CLEAR_NATIVE_OBJ_SPEED)        \
131     V(OLD_EVACUATE_SPACE_SPEED)          \
132     V(EDEN_CLEAR_NATIVE_OBJ_SPEED)       \
133     V(EDEN_UPDATE_REFERENCE_SPEED)       \
134     V(EDEN_EVACUATE_SPACE_SPEED)         \
135     V(YOUNG_CLEAR_NATIVE_OBJ_SPEED)      \
136     V(YOUNG_UPDATE_REFERENCE_SPEED)      \
137     V(YOUNG_EVACUATE_SPACE_SPEED)        \
138     V(MARK_SPEED)                        \
139     V(SWEEP_SPEED)
140 
141 constexpr uint32_t NUM_MANDATORY_JSFUNC_ARGS = 3;
142 constexpr uint32_t INVALID_INDEX = std::numeric_limits<uint32_t>::max();
143 
144 using Address = uintptr_t;
145 
146 #define PUBLIC_API PANDA_PUBLIC_API
147 
148 #ifdef NDEBUG
149 #define DUMP_API_ATTR __attribute__((unused))
150 #else
151 #ifndef PANDA_TARGET_WINDOWS
152 #define DUMP_API_ATTR __attribute__((visibility ("default"), used))
153 #else
154 #define DUMP_API_ATTR __attribute__((unused))
155 #endif
156 #endif
157 
158 #ifdef PANDA_TARGET_32
159 #define STATIC_ASSERT_EQ_ARCH32(a, b) static_assert(a == b)
160 #else
161 #define STATIC_ASSERT_EQ_ARCH32(a, b) static_assert(true)
162 #endif
163 
164 #ifdef PANDA_TARGET_64
165 #define STATIC_ASSERT_EQ_ARCH64(a, b) static_assert(a == b)
166 #else
167 #define STATIC_ASSERT_EQ_ARCH64(a, b) static_assert(true)
168 #endif
169 
170 #if defined(PANDA_TARGET_WINDOWS) || defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS)
171 #define WIN_OR_MAC_OR_IOS_PLATFORM true
172 #else
173 #define WIN_OR_MAC_OR_IOS_PLATFORM false
174 #endif
175 
176 #define STATIC_ASSERT_EQ_ARCH(expect, valueArch32, valueArch64) \
177     STATIC_ASSERT_EQ_ARCH32(expect, valueArch32);               \
178     STATIC_ASSERT_EQ_ARCH64(expect, valueArch64)
179 }  // namespace ecmascript
180 }  // namespace panda
181 
182 #endif  // ECMASCRIPT_COMMON_H
183