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