14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMMON_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMMON_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include <limits> 204514f5e3Sopenharmony_ci 214514f5e3Sopenharmony_ci#include "libpandabase/macros.h" 224514f5e3Sopenharmony_ci#include "ecmascript/common_enum.h" 234514f5e3Sopenharmony_cinamespace panda { 244514f5e3Sopenharmony_cinamespace ecmascript { 254514f5e3Sopenharmony_ci 264514f5e3Sopenharmony_ci#define SCOPE_LIST(V) \ 274514f5e3Sopenharmony_ci V(TotalGC) \ 284514f5e3Sopenharmony_ci V(Initialize) \ 294514f5e3Sopenharmony_ci V(ConcurrentMark) \ 304514f5e3Sopenharmony_ci V(WaitConcurrentMarkFinished) \ 314514f5e3Sopenharmony_ci V(ReMark) \ 324514f5e3Sopenharmony_ci V(Mark) \ 334514f5e3Sopenharmony_ci V(MarkRoots) \ 344514f5e3Sopenharmony_ci V(ProcessSharedGCRSetWorkList) \ 354514f5e3Sopenharmony_ci V(Sweep) \ 364514f5e3Sopenharmony_ci V(ClearNativeObject) \ 374514f5e3Sopenharmony_ci V(Evacuate) \ 384514f5e3Sopenharmony_ci V(Finish) \ 394514f5e3Sopenharmony_ci V(UpdateReference) \ 404514f5e3Sopenharmony_ci V(EvacuateSpace) \ 414514f5e3Sopenharmony_ci V(SuspendAll) \ 424514f5e3Sopenharmony_ci V(ResumeAll) \ 434514f5e3Sopenharmony_ci V(ProceeWorkload) \ 444514f5e3Sopenharmony_ci V(UpdateRoot) \ 454514f5e3Sopenharmony_ci V(UpdateWeekRef) \ 464514f5e3Sopenharmony_ci V(EvacuateRegion) \ 474514f5e3Sopenharmony_ci V(WaitFinish) 484514f5e3Sopenharmony_ci 494514f5e3Sopenharmony_ci#define RECORD_DATA(V) \ 504514f5e3Sopenharmony_ci V(START_OBJ_SIZE) \ 514514f5e3Sopenharmony_ci V(END_OBJ_SIZE) \ 524514f5e3Sopenharmony_ci V(START_COMMIT_SIZE) \ 534514f5e3Sopenharmony_ci V(END_COMMIT_SIZE) \ 544514f5e3Sopenharmony_ci V(START_EDEN_OBJ_SIZE) \ 554514f5e3Sopenharmony_ci V(START_YOUNG_OBJ_SIZE) \ 564514f5e3Sopenharmony_ci V(SEMI_ALIVE_SIZE) \ 574514f5e3Sopenharmony_ci V(SEMI_COMMIT_SIZE) \ 584514f5e3Sopenharmony_ci V(SEMI_PROMOTE_SIZE) \ 594514f5e3Sopenharmony_ci V(EDEN_ALIVE_SIZE) \ 604514f5e3Sopenharmony_ci V(EDEN_COMMIT_SIZE) \ 614514f5e3Sopenharmony_ci V(EDEN_PROMOTE_SIZE) \ 624514f5e3Sopenharmony_ci V(YOUNG_ALIVE_SIZE) \ 634514f5e3Sopenharmony_ci V(YOUNG_COMMIT_SIZE) \ 644514f5e3Sopenharmony_ci V(YOUNG_PROMOTE_SIZE) \ 654514f5e3Sopenharmony_ci V(OLD_ALIVE_SIZE) \ 664514f5e3Sopenharmony_ci V(OLD_COMMIT_SIZE) \ 674514f5e3Sopenharmony_ci V(COMPRESS_ALIVE_SIZE) \ 684514f5e3Sopenharmony_ci V(COMPRESS_COMMIT_SIZE) \ 694514f5e3Sopenharmony_ci V(START_NATIVE_POINTER_NUM) \ 704514f5e3Sopenharmony_ci V(COLLECT_REGION_SET_SIZE) \ 714514f5e3Sopenharmony_ci SEMI_RECORD_DATA(V) \ 724514f5e3Sopenharmony_ci PARTIAL_RECORD_DATA(V) \ 734514f5e3Sopenharmony_ci FULL_RECORD_DATA(V) \ 744514f5e3Sopenharmony_ci SHARED_RECORD_DATA(V) 754514f5e3Sopenharmony_ci 764514f5e3Sopenharmony_ci#define RECORD_DURATION(V) \ 774514f5e3Sopenharmony_ci V(SEMI_MIN_PAUSE) \ 784514f5e3Sopenharmony_ci V(SEMI_MAX_PAUSE) \ 794514f5e3Sopenharmony_ci V(SEMI_TOTAL_PAUSE) \ 804514f5e3Sopenharmony_ci V(EDEN_MIN_PAUSE) \ 814514f5e3Sopenharmony_ci V(EDEN_MAX_PAUSE) \ 824514f5e3Sopenharmony_ci V(EDEN_TOTAL_PAUSE) \ 834514f5e3Sopenharmony_ci V(YOUNG_MIN_PAUSE) \ 844514f5e3Sopenharmony_ci V(YOUNG_MAX_PAUSE) \ 854514f5e3Sopenharmony_ci V(YOUNG_TOTAL_PAUSE) \ 864514f5e3Sopenharmony_ci V(OLD_MIN_PAUSE) \ 874514f5e3Sopenharmony_ci V(OLD_MAX_PAUSE) \ 884514f5e3Sopenharmony_ci V(OLD_TOTAL_PAUSE) \ 894514f5e3Sopenharmony_ci V(COMPRESS_MIN_PAUSE) \ 904514f5e3Sopenharmony_ci V(COMPRESS_MAX_PAUSE) \ 914514f5e3Sopenharmony_ci V(COMPRESS_TOTAL_PAUSE) \ 924514f5e3Sopenharmony_ci V(SHARED_MIN_PAUSE) \ 934514f5e3Sopenharmony_ci V(SHARED_MAX_PAUSE) \ 944514f5e3Sopenharmony_ci V(SHARED_TOTAL_PAUSE) 954514f5e3Sopenharmony_ci 964514f5e3Sopenharmony_ci#define SEMI_RECORD_DATA(V) \ 974514f5e3Sopenharmony_ci V(SEMI_COUNT) \ 984514f5e3Sopenharmony_ci V(SEMI_TOTAL_ALIVE) \ 994514f5e3Sopenharmony_ci V(SEMI_TOTAL_COMMIT) \ 1004514f5e3Sopenharmony_ci V(SEMI_TOTAL_PROMOTE) 1014514f5e3Sopenharmony_ci 1024514f5e3Sopenharmony_ci#define PARTIAL_RECORD_DATA(V) \ 1034514f5e3Sopenharmony_ci V(EDEN_COUNT) \ 1044514f5e3Sopenharmony_ci V(EDEN_TOTAL_ALIVE) \ 1054514f5e3Sopenharmony_ci V(EDEN_TOTAL_COMMIT) \ 1064514f5e3Sopenharmony_ci V(EDEN_TOTAL_PROMOTE) \ 1074514f5e3Sopenharmony_ci V(YOUNG_COUNT) \ 1084514f5e3Sopenharmony_ci V(YOUNG_TOTAL_ALIVE) \ 1094514f5e3Sopenharmony_ci V(YOUNG_TOTAL_COMMIT) \ 1104514f5e3Sopenharmony_ci V(YOUNG_TOTAL_PROMOTE) \ 1114514f5e3Sopenharmony_ci V(OLD_COUNT) \ 1124514f5e3Sopenharmony_ci V(OLD_TOTAL_ALIVE) \ 1134514f5e3Sopenharmony_ci V(OLD_TOTAL_COMMIT) 1144514f5e3Sopenharmony_ci 1154514f5e3Sopenharmony_ci#define FULL_RECORD_DATA(V) \ 1164514f5e3Sopenharmony_ci V(COMPRESS_COUNT) \ 1174514f5e3Sopenharmony_ci V(COMPRESS_TOTAL_ALIVE) \ 1184514f5e3Sopenharmony_ci V(COMPRESS_TOTAL_COMMIT) 1194514f5e3Sopenharmony_ci 1204514f5e3Sopenharmony_ci#define SHARED_RECORD_DATA(V) \ 1214514f5e3Sopenharmony_ci V(SHARED_COUNT) \ 1224514f5e3Sopenharmony_ci V(SHARED_ALIVE_SIZE) \ 1234514f5e3Sopenharmony_ci V(SHARED_TOTAL_ALIVE) \ 1244514f5e3Sopenharmony_ci V(SHARED_COMMIT_SIZE) \ 1254514f5e3Sopenharmony_ci V(SHARED_TOTAL_COMMIT) 1264514f5e3Sopenharmony_ci 1274514f5e3Sopenharmony_ci#define TRACE_GC_SPEED(V) \ 1284514f5e3Sopenharmony_ci V(UPDATE_REFERENCE_SPEED) \ 1294514f5e3Sopenharmony_ci V(OLD_CLEAR_NATIVE_OBJ_SPEED) \ 1304514f5e3Sopenharmony_ci V(OLD_EVACUATE_SPACE_SPEED) \ 1314514f5e3Sopenharmony_ci V(EDEN_CLEAR_NATIVE_OBJ_SPEED) \ 1324514f5e3Sopenharmony_ci V(EDEN_UPDATE_REFERENCE_SPEED) \ 1334514f5e3Sopenharmony_ci V(EDEN_EVACUATE_SPACE_SPEED) \ 1344514f5e3Sopenharmony_ci V(YOUNG_CLEAR_NATIVE_OBJ_SPEED) \ 1354514f5e3Sopenharmony_ci V(YOUNG_UPDATE_REFERENCE_SPEED) \ 1364514f5e3Sopenharmony_ci V(YOUNG_EVACUATE_SPACE_SPEED) \ 1374514f5e3Sopenharmony_ci V(MARK_SPEED) \ 1384514f5e3Sopenharmony_ci V(SWEEP_SPEED) 1394514f5e3Sopenharmony_ci 1404514f5e3Sopenharmony_ciconstexpr uint32_t NUM_MANDATORY_JSFUNC_ARGS = 3; 1414514f5e3Sopenharmony_ciconstexpr uint32_t INVALID_INDEX = std::numeric_limits<uint32_t>::max(); 1424514f5e3Sopenharmony_ci 1434514f5e3Sopenharmony_ciusing Address = uintptr_t; 1444514f5e3Sopenharmony_ci 1454514f5e3Sopenharmony_ci#define PUBLIC_API PANDA_PUBLIC_API 1464514f5e3Sopenharmony_ci 1474514f5e3Sopenharmony_ci#ifdef NDEBUG 1484514f5e3Sopenharmony_ci#define DUMP_API_ATTR __attribute__((unused)) 1494514f5e3Sopenharmony_ci#else 1504514f5e3Sopenharmony_ci#ifndef PANDA_TARGET_WINDOWS 1514514f5e3Sopenharmony_ci#define DUMP_API_ATTR __attribute__((visibility ("default"), used)) 1524514f5e3Sopenharmony_ci#else 1534514f5e3Sopenharmony_ci#define DUMP_API_ATTR __attribute__((unused)) 1544514f5e3Sopenharmony_ci#endif 1554514f5e3Sopenharmony_ci#endif 1564514f5e3Sopenharmony_ci 1574514f5e3Sopenharmony_ci#ifdef PANDA_TARGET_32 1584514f5e3Sopenharmony_ci#define STATIC_ASSERT_EQ_ARCH32(a, b) static_assert(a == b) 1594514f5e3Sopenharmony_ci#else 1604514f5e3Sopenharmony_ci#define STATIC_ASSERT_EQ_ARCH32(a, b) static_assert(true) 1614514f5e3Sopenharmony_ci#endif 1624514f5e3Sopenharmony_ci 1634514f5e3Sopenharmony_ci#ifdef PANDA_TARGET_64 1644514f5e3Sopenharmony_ci#define STATIC_ASSERT_EQ_ARCH64(a, b) static_assert(a == b) 1654514f5e3Sopenharmony_ci#else 1664514f5e3Sopenharmony_ci#define STATIC_ASSERT_EQ_ARCH64(a, b) static_assert(true) 1674514f5e3Sopenharmony_ci#endif 1684514f5e3Sopenharmony_ci 1694514f5e3Sopenharmony_ci#if defined(PANDA_TARGET_WINDOWS) || defined(PANDA_TARGET_MACOS) || defined(PANDA_TARGET_IOS) 1704514f5e3Sopenharmony_ci#define WIN_OR_MAC_OR_IOS_PLATFORM true 1714514f5e3Sopenharmony_ci#else 1724514f5e3Sopenharmony_ci#define WIN_OR_MAC_OR_IOS_PLATFORM false 1734514f5e3Sopenharmony_ci#endif 1744514f5e3Sopenharmony_ci 1754514f5e3Sopenharmony_ci#define STATIC_ASSERT_EQ_ARCH(expect, valueArch32, valueArch64) \ 1764514f5e3Sopenharmony_ci STATIC_ASSERT_EQ_ARCH32(expect, valueArch32); \ 1774514f5e3Sopenharmony_ci STATIC_ASSERT_EQ_ARCH64(expect, valueArch64) 1784514f5e3Sopenharmony_ci} // namespace ecmascript 1794514f5e3Sopenharmony_ci} // namespace panda 1804514f5e3Sopenharmony_ci 1814514f5e3Sopenharmony_ci#endif // ECMASCRIPT_COMMON_H 182