1 /* 2 * Copyright (c) 2024 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 OHOS_ARKCOMPILER_AOTCOMPILER_CONSTANTS_H 17 #define OHOS_ARKCOMPILER_AOTCOMPILER_CONSTANTS_H 18 19 #include <string> 20 #include <unordered_map> 21 #include <unordered_set> 22 23 #include "aot_compiler_error_utils.h" 24 25 namespace OHOS::ArkCompiler { 26 namespace Cmds { 27 constexpr const char* ARK_AOT_COMPILER = "/system/bin/ark_aot_compiler"; 28 } // namespace Cmds 29 30 namespace ArgsIdx { 31 const std::string BUNDLE_UID = "BundleUid"; 32 const std::string BUNDLE_GID = "BundleGid"; 33 const std::string AN_FILE_NAME = "anFileName"; 34 const std::string APP_SIGNATURE = "appIdentifier"; 35 const std::string ABC_PATH = "ABC-Path"; 36 const std::string TARGET_COMPILER_MODE = "target-compiler-mode"; 37 const std::string COMPILER_PKG_INFO = "compiler-pkg-info"; 38 const std::string COMPILER_ENABLE_AOT_CODE_COMMENT = "compiler-enable-aot-code-comment"; 39 const std::string COMPILER_LOG_OPT = "compiler-log"; 40 const std::string COMPILER_AN_FILE_MAX_SIZE = "compiler-an-file-max-size"; 41 42 } // namespace ArgsIdx 43 44 namespace Symbols { 45 constexpr const char* PREFIX = "--"; 46 constexpr const char* EQ = "="; 47 } // namespace Symbols 48 49 std::unordered_set<std::string> AotArgsSet { 50 "aot-file", 51 "ark-properties", 52 "ark-bundleName", 53 "asm-interpreter", 54 "asm-opcode-disable-range", 55 "builtins-lazy", 56 "compiler-log", 57 "compiler-log-methods", 58 "compiler-log-snapshot", 59 "compiler-log-time", 60 "compiler-type-threshold", 61 "enable-ark-tools", 62 "compiler-trace-bc", 63 "compiler-trace-deopt", 64 "compiler-trace-inline", 65 "compiler-trace-value-numbering", 66 "compiler-trace-instruction-combine", 67 "compiler-max-inline-bytecodes", 68 "compiler-deopt-threshold", 69 "compiler-device-state", 70 "compiler-thermal-level", 71 "compiler-stress-deopt", 72 "compiler-opt-code-profiler", 73 "compiler-opt-bc-range", 74 "compiler-opt-bc-range-help", 75 "enable-force-gc", 76 "enable-ic", 77 "enable-runtime-stat", 78 "compiler-opt-constant-folding", 79 "compiler-opt-array-bounds-check-elimination", 80 "compiler-opt-type-lowering", 81 "compiler-opt-early-elimination", 82 "compiler-opt-later-elimination", 83 "compiler-opt-instr-combine", 84 "compiler-opt-string", 85 "compiler-opt-value-numbering", 86 "compiler-opt-new-value-numbering", 87 "compiler-opt-inlining", 88 "compiler-opt-pgotype", 89 "compiler-opt-track-field", 90 "entry-point", 91 "force-full-gc", 92 "force-shared-gc-frequency", 93 "gc-thread-num", 94 "heap-size-limit", 95 "icu-data-path", 96 "enable-worker", 97 "log-components", 98 "log-debug", 99 "log-error", 100 "log-fatal", 101 "log-info", 102 "log-level", 103 "log-warning", 104 "gc-long-paused-time", 105 "compiler-opt-max-method", 106 "compiler-module-methods", 107 "max-unmovable-space", 108 "merge-abc", 109 "enable-context", 110 "compiler-opt-level", 111 "reloc-mode", 112 "serializer-buffer-size-limit", 113 "startup-time", 114 "stub-file", 115 "compiler-target-triple", 116 "enable-print-execute-time", 117 "enable-pgo-profiler", 118 "enable-mutant-array", 119 "enable-elements-kind", 120 "compiler-pgo-profiler-path", 121 "compiler-pgo-hotness-threshold", 122 "compiler-pgo-save-min-interval", 123 "compiler-verify-vtable", 124 "compiler-select-methods", 125 "compiler-skip-methods", 126 "target-compiler-mode", 127 "hap-path", 128 "hap-abc-offset", 129 "hap-abc-size", 130 "compiler-no-check", 131 "compiler-pipeline-host-aot", 132 "compiler-fast-compile", 133 "compiler-opt-loop-peeling", 134 "compiler-opt-array-onheap-check", 135 "compiler-pkg-info", 136 "compiler-external-pkg-info", 137 "compiler-enable-external-pkg", 138 "compiler-framework-abc-path", 139 "compiler-enable-lexenv-specialization", 140 "compiler-enable-native-inline", 141 "compiler-enable-lowering-builtin", 142 "compiler-enable-litecg", 143 "compiler-enable-jit", 144 "compiler-enable-osr", 145 "compiler-trace-jit", 146 "compiler-jit-hotness-threshold", 147 "compiler-osr-hotness-threshold", 148 "compiler-force-jit-compile-main", 149 "compiler-enable-jit-pgo", 150 "compiler-enable-aot-pgo", 151 "compiler-enable-framework-aot", 152 "compiler-enable-profile-dump", 153 "compiler-typed-op-profiler", 154 "compiler-opt-branch-profiling", 155 "test-assert", 156 "compiler-methods-range", 157 "compiler-codegen-options", 158 "compiler-opt-escape-analysis", 159 "compiler-trace-escape-analysis", 160 "compiler-opt-induction-variable", 161 "compiler-trace-induction-variable", 162 "compiler-memory-analysis", 163 "compiler-check-pgo-version", 164 "compiler-enable-baselinejit", 165 "compiler-baselinejit-hotness-threshold", 166 "compiler-force-baselinejit-compile-main", 167 "compiler-baseline-pgo", 168 "compiler-trace-builtins", 169 }; 170 171 /** 172 * @param RetStatusOfCompiler return code of ark_aot_compiler 173 * @attention it must sync with ErrCode of "ets_runtime/ecmascript/aot_compiler.cpp" 174 */ 175 enum class RetStatusOfCompiler { 176 ERR_OK = (0), // IMPORTANT: Only if aot compiler SUCCESS and save an/ai SUCCESS, return ERR_OK. 177 ERR_FAIL = (-1), 178 ERR_HELP = (1), 179 ERR_NO_AP = (2), 180 ERR_MERGE_AP = (3), 181 ERR_CHECK_VERSION = (4), 182 ERR_AN_EMPTY = (5), 183 ERR_AN_FAIL = (6), 184 ERR_AI_FAIL = (7), 185 }; 186 187 struct InfoOfCompiler { 188 int32_t retCode { -1 }; 189 std::string mesg; 190 }; 191 192 const std::unordered_map<int, InfoOfCompiler> RetInfoOfCompiler { 193 {static_cast<int>(RetStatusOfCompiler::ERR_OK), {ERR_OK, "AOT compiler success"}}, 194 {static_cast<int>(RetStatusOfCompiler::ERR_NO_AP), {ERR_OK_NO_AOT_FILE, "AOT compiler not run: no ap file"}}, 195 {static_cast<int>(RetStatusOfCompiler::ERR_CHECK_VERSION), 196 {ERR_OK_NO_AOT_FILE, "AOT compiler not run: check version"}}, 197 {static_cast<int>(RetStatusOfCompiler::ERR_MERGE_AP), 198 {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: merge ap error"}}, 199 {static_cast<int>(RetStatusOfCompiler::ERR_AN_EMPTY), 200 {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: empty an file"}}, 201 {static_cast<int>(RetStatusOfCompiler::ERR_AN_FAIL), 202 {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: save an error"}}, 203 {static_cast<int>(RetStatusOfCompiler::ERR_AI_FAIL), 204 {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: save ai error"}}, 205 }; 206 207 const InfoOfCompiler OtherInfoOfCompiler = {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: other error"}; 208 } // namespace OHOS::ArkCompiler 209 #endif // OHOS_ARKCOMPILER_AOTCOMPILER_CONSTANTS_H