1 /* 2 * Copyright (c) 2023 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_PGO_PROFILER_PGO_UTILS_H 17 #define ECMASCRIPT_PGO_PROFILER_PGO_UTILS_H 18 19 #include <string> 20 21 #include "mem/mem.h" 22 #include "libpandafile/file.h" 23 24 namespace panda::ecmascript::pgo { 25 static constexpr Alignment ALIGN_SIZE = Alignment::LOG_ALIGN_4; 26 using PGOMethodId = panda_file::File::EntityId; 27 using ApEntityId = uint32_t; 28 29 class DumpUtils { 30 public: 31 static const std::string ELEMENT_SEPARATOR; 32 static const std::string BLOCK_SEPARATOR; 33 static const std::string TYPE_SEPARATOR; 34 static const std::string BLOCK_START; 35 static const std::string ARRAY_START; 36 static const std::string ARRAY_END; 37 static const std::string NEW_LINE; 38 static const std::string SPACE; 39 static const std::string BLOCK_AND_ARRAY_START; 40 static const std::string VERSION_HEADER; 41 static const std::string PANDA_FILE_INFO_HEADER; 42 static const uint32_t HEX_FORMAT_WIDTH_FOR_32BITS; 43 }; 44 45 class ApNameUtils { 46 public: 47 static const std::string AP_SUFFIX; 48 static const std::string RUNTIME_AP_PREFIX; 49 static const std::string MERGED_AP_PREFIX; 50 static const std::string DEFAULT_AP_NAME; 51 static std::string GetRuntimeApName(const std::string &ohosModuleName); 52 static std::string GetMergedApName(const std::string &ohosModuleName); 53 static std::string GetOhosPkgApName(const std::string &ohosModuleName); 54 55 private: 56 static std::string GetBriefApName(const std::string &ohosModuleName); 57 }; 58 } // namespace panda::ecmascript::pgo 59 #endif // ECMASCRIPT_PGO_PROFILER_PGO_UTILS_H