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