1 /*
2 * Copyright (c) 2022 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 #include "ecmascript/js_runtime_options.h"
17
18 #include <cerrno>
19 #include <cstdlib>
20 #include <iostream>
21 #include <getopt.h>
22
23 #include "ecmascript/compiler/aot_file/an_file_data_manager.h"
24 #include "ecmascript/mem/mem_common.h"
25
26 namespace panda::ecmascript {
27 const std::string PUBLIC_API COMMON_HELP_HEAD_MSG =
28 "Usage: jsvm <option> <filename.abc>\n"
29 "\n"
30 "Options:\n";
31
32 const std::string PUBLIC_API COMPILER_HELP_HEAD_MSG =
33 "Usage: ark_aot_compiler <option> --aot-file=<filename> <filename.abc>\n"
34 "\n"
35 "Options:\n";
36
37 const std::string PUBLIC_API STUB_HELP_HEAD_MSG =
38 "Usage: ark_stub_compiler <option>\n"
39 "\n"
40 "Options:\n";
41
42 const std::string PUBLIC_API HELP_OPTION_MSG =
43 "--aot-file: Path (file suffix not needed) to AOT output file. Default: 'aot_file'\n"
44 "--ark-properties: Set ark properties\n"
45 "--ark-bundle-name: Set ark bundle name\n"
46 "--asm-interpreter: Enable asm interpreter. Default: 'true'\n"
47 "--asm-opcode-disable-range: Opcode range when asm interpreter is enabled.\n"
48 "--compiler-assert-types: Enable type assertion for type inference tests. Default: 'false'\n"
49 "--builtins-dts: Builtins.d.abc file path for AOT.\n"
50 "--builtins-lazy: Load some builtins function later.This option is only valid in workervm.\n"
51 "--compiler-log: Log Option For aot compiler and stub compiler,\n"
52 " 'none': no log,\n"
53 " 'allllircirasm' or 'all012': print all log for all methods,\n"
54 " 'allcir' or 'all0': print IR info for all methods,\n"
55 " 'allllir' or 'all1': print llir info for all methods,\n"
56 " 'allasm' or 'all2': print asm log for all methods,\n"
57 " 'alltype' or 'all3': print type infer log for all methods,\n"
58 " 'cerllircirasm' or 'cer0112': print all log for certain method defined "
59 "in 'mlist-for-log',\n"
60 " 'cercir' or 'cer0': print IR for methods in 'mlist-for-log',\n"
61 " 'cerasm' or 'cer2': print log for methods in 'mlist-for-log',\n"
62 " Default: 'none'\n"
63 "--compiler-log-methods: Specific method list for compiler log, only used when compiler-log. "
64 "Default: 'none'\n"
65 "--compiler-type-threshold: enable to skip methods whose type is no more than threshold. Default: -1\n"
66 "--compiler-log-snapshot: Enable to print snapshot information. Default: 'false'\n"
67 "--compiler-opt-global-typeinfer: Enable global typeinfer for aot compiler: Default: 'false'\n"
68 "--compiler-log-time: Enable to print pass compiler time. Default: 'false'\n"
69 "--enable-ark-tools: Enable ark tools to debug. Default: 'false'\n"
70 "--compiler-trace-bc: Enable tracing bytecode for aot runtime. Default: 'false'\n"
71 "--compiler-trace-deopt: Enable tracing deopt for aot runtime. Default: 'false'\n"
72 "--compiler-trace-inline: Enable tracing inline function for aot runtime. Default: 'false'\n"
73 "--compiler-trace-value-numbering: Enable tracing value numbering for aot runtime. Default: 'false'\n"
74 "--compiler-max-inline-bytecodes Set max bytecodes count which aot function can be inlined. Default: '25'\n"
75 "--compiler-deopt-threshold: Set max count which aot function can occur deoptimization. Default: '10'\n"
76 "--compiler-stress-deopt: Enable stress deopt for aot compiler. Default: 'false'\n"
77 "--compiler-opt-code-profiler: Enable opt code Bytecode Statistics for aot runtime. Default: 'false'\n"
78 "--enable-force-gc: Enable force gc when allocating object. Default: 'true'\n"
79 "--enable-ic: Switch of inline cache. Default: 'true'\n"
80 "--enable-runtime-stat: Enable statistics of runtime state. Default: 'false'\n"
81 "--compiler-opt-array-bounds-check-elimination: Enable Index Check elimination. Default: 'true'\n"
82 "--compiler-opt-constant-folding: Enable constant folding. Default: 'true'\n"
83 "--compiler-opt-type-lowering: Enable all type optimization pass for aot compiler. Default: 'true'\n"
84 "--compiler-opt-early-elimination: Enable EarlyElimination for aot compiler. Default: 'true'\n"
85 "--compiler-opt-later-elimination: Enable LaterElimination for aot compiler. Default: 'true'\n"
86 "--compiler-opt-string: Enable string optimization pass for aot compiler. Default: 'true'\n"
87 "--compiler-opt-value-numbering: Enable ValueNumbering for aot compiler. Default: 'true'\n"
88 "--compiler-opt-inlining: Enable inlining function for aot compiler: Default: 'true'\n"
89 "--compiler-opt-pgotype: Enable pgo type for aot compiler: Default: 'true'\n"
90 "--compiler-opt-track-field: Enable track field for aot compiler: Default: 'false'\n"
91 "--entry-point: Full name of entrypoint function. Default: '_GLOBAL::func_main_0'\n"
92 "--force-full-gc: If true trigger full gc, else trigger semi and old gc. Default: 'true'\n"
93 "--framework-abc-file: Snapshot file. Default: 'strip.native.min.abc'\n"
94 "--gc-long-paused-time: Set gc's longPauseTime in millisecond. Default: '40'\n"
95 "--gc-thread-num: Set gc thread number. Default: '7'\n"
96 "--heap-size-limit: Max heap size (MB). Default: '512'\n"
97 "--help: Print this message and exit\n"
98 "--icu-data-path: Path to generated icu data file. Default: 'default'\n"
99 "--enable-worker: Whether is worker vm. Default: 'false'\n"
100 "--log-level: Log level: ['debug', 'info', 'warning', 'error', 'fatal'].\n"
101 "--log-components: Enable logs from specified components: ['all', 'gc', 'ecma','interpreter',\n"
102 " 'debugger', 'compiler', 'builtins', 'trace', 'jit', 'all']. \n"
103 " Default: 'all'\n"
104 "--log-debug: Enable debug or above logs for components: ['all', 'gc', 'ecma',\n"
105 " 'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit', 'all'].\n"
106 " Default: 'all'\n"
107 "--log-error: Enable error log for components: ['all', 'gc', 'ecma',\n"
108 " 'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit', 'all'].\n"
109 " Default: 'all'\n"
110 "--log-fatal: Enable fatal log for components: ['all', 'gc', 'ecma',\n"
111 " 'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit', 'all'].\n"
112 " Default: 'all'\n"
113 "--log-info: Enable info log for components: ['all', 'gc', 'ecma',\n"
114 " 'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit', 'all'].\n"
115 " Default: 'all'\n"
116 "--log-warning: Enable warning log for components: ['all', 'gc', 'ecma',\n"
117 " 'interpreter', 'debugger', 'compiler', 'trace', 'jit', 'builtins', \n"
118 " 'all']. Default: 'all'\n"
119 "--compiler-opt-max-method: Enable aot compiler to skip method larger than limit (KB). Default: '32'\n"
120 "--compiler-module-methods: The number of max compiled methods in a module. Default: '100'\n"
121 "--max-unmovable-space: Set max unmovable space capacity\n"
122 "--merge-abc: ABC file is merge abc. Default: 'false'\n"
123 "--compiler-opt-level: Optimization level configuration of aot compiler. Default: '3'\n"
124 "--options: Print compiler and runtime options\n"
125 "--compiler-print-type-info: Enable print type info. Default: 'false'\n"
126 "--serializer-buffer-size-limit: Max serializer buffer size used by the VM in Byte. Default size is 2GB\n"
127 "--snapshot-file: Snapshot file. Default: '/system/etc/snapshot'\n"
128 "--startup-time: Print the start time of command execution. Default: 'false'\n"
129 "--stub-file: Path of file includes common stubs module compiled by stub compiler. "
130 "Default: 'stub.an'\n"
131 "--enable-pgo-profiler: Enable pgo profiler to sample jsfunction call and output to file. "
132 "Default: 'false'\n"
133 "--enable-elements-kind: Enable elementsKind sampling and usage. Default: 'false'\n"
134 "--compiler-pgo-hotness-threshold: Set hotness threshold for pgo in aot compiler. Default: '2'\n"
135 "--compiler-pgo-profiler-path: The pgo file output dir or the pgo file dir of AOT compiler. Default: ''\n"
136 "--compiler-pgo-save-min-interval: Set the minimum time interval for automatically saving profile, "
137 "Unit seconds. Default: '30s'\n"
138 "--compiler-target-triple: CPU triple for aot compiler or stub compiler. \n"
139 " values: ['x86_64-unknown-linux-gnu', 'arm-unknown-linux-gnu', \n"
140 " 'aarch64-unknown-linux-gnu'], Default: 'x86_64-unknown-linux-gnu'\n"
141 "--enable-print-execute-time: Enable print execute panda file spent time\n"
142 "--compiler-verify-vtable: Verify vtable result for aot compiler. Default: 'false'\n"
143 "--compiler-select-methods Compiler selected methods for aot. Only work in full compiling mode\n"
144 " Format:--compile-methods=record1:m1,m2,record2:m3\n"
145 "--compiler-skip-methods Compiler skpped methods for aot. Only work in full compiling mode\n"
146 " Format:--compile-skip-methods=record1:m1,m2,record2:m3\n"
147 "--target-compiler-mode The compilation mode at the device side, including partial, full and none."
148 " Default: ''\n"
149 "--hap-path(Deprecated) The path of the app hap. Default: ''\n"
150 "--hap-abc-offset(Deprecated) The offset of the abc file in app hap. Default: '0'\n"
151 "--hap-abc-size(Deprecated) The size of the abc file in app hap. Default: '0'\n"
152 "--compiler-fast-compile Disable some time-consuming pass. Default: 'true'\n"
153 "--compiler-no-check Enable remove checks for aot compiler. Default: 'false'\n"
154 "--compiler-opt-loop-peeling: Enable loop peeling for aot compiler: Default: 'false'\n"
155 "--compiler-pkg-info Specify the package json info for ark aot compiler\n"
156 "--compiler-external-pkg-info Specify the external package json info for ark aot compiler\n"
157 "--compiler-enable-external-pkg Enable compile with external package for ark aot compiler\n"
158 "--compiler-enable-lexenv-specialization: Enable replace ldlexvar with specific values: Default: 'true'\n"
159 "--compiler-enable-native-inline: Enable inline native function: Default: 'false'\n"
160 "--compiler-enable-lowering-builtin: Enable lowering global object: Default: 'false'\n"
161 "--compiler-opt-array-onheap-check: Enable TypedArray on heap check for aot compiler: Default: 'false'\n"
162 "--compiler-enable-litecg: Enable LiteCG: Default: 'false'\n"
163 "--compiler-enable-jit: Enable jit: Default: 'false'\n"
164 "--compiler-jit-hotness-threshold: Set hotness threshold for jit. Default: '2'\n"
165 "--compiler-force-jit-compile-main: Enable jit compile main function: Default: 'false'\n"
166 "--compiler-trace-jit: Enable trace jit: Default: 'false'\n\n"
167 "--compiler-typed-op-profiler: Enable Typed Opcode Statistics for aot runtime. Default: 'false'\n"
168 "--compiler-opt-branch-profiling: Enable branch profiling for aot compiler. Default: 'true'\n";
169
ParseCommand(const int argc,const char ** argv)170 bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
171 {
172 const struct option longOptions[] = {
173 {"aot-file", required_argument, nullptr, OPTION_AOT_FILE},
174 {"ark-properties", required_argument, nullptr, OPTION_ARK_PROPERTIES},
175 {"ark-bundleName", required_argument, nullptr, OPTION_ARK_BUNDLENAME},
176 {"asm-interpreter", required_argument, nullptr, OPTION_ENABLE_ASM_INTERPRETER},
177 {"asm-opcode-disable-range", required_argument, nullptr, OPTION_ASM_OPCODE_DISABLE_RANGE},
178 {"compiler-assert-types", required_argument, nullptr, OPTION_COMPILER_ASSERT_TYPES},
179 {"builtins-dts", required_argument, nullptr, OPTION_BUILTINS_DTS},
180 {"builtins-lazy", required_argument, nullptr, OPTION_ENABLE_BUILTINS_LAZY},
181 {"compiler-log", required_argument, nullptr, OPTION_COMPILER_LOG_OPT},
182 {"compiler-log-methods", required_argument, nullptr, OPTION_COMPILER_LOG_METHODS},
183 {"compiler-log-snapshot", required_argument, nullptr, OPTION_COMPILER_LOG_SNAPSHOT},
184 {"compiler-log-time", required_argument, nullptr, OPTION_COMPILER_LOG_TIME},
185 {"compiler-opt-global-typeinfer", required_argument, nullptr, OPTION_COMPILER_OPT_GLOBAL_TYPEINFER},
186 {"compiler-type-threshold", required_argument, nullptr, OPTION_COMPILER_TYPE_THRESHOLD},
187 {"enable-ark-tools", required_argument, nullptr, OPTION_ENABLE_ARK_TOOLS},
188 {"compiler-trace-bc", required_argument, nullptr, OPTION_COMPILER_TRACE_BC},
189 {"compiler-trace-deopt", required_argument, nullptr, OPTION_COMPILER_TRACE_DEOPT},
190 {"compiler-trace-inline", required_argument, nullptr, OPTION_COMPILER_TRACE_INLINE},
191 {"compiler-trace-value-numbering", required_argument, nullptr, OPTION_COMPILER_TRACE_VALUE_NUMBERING},
192 {"compiler-trace-instruction-combine", required_argument, nullptr, OPTION_COMPILER_TRACE_INSTRUCTION_COMBINE},
193 {"compiler-max-inline-bytecodes", required_argument, nullptr, OPTION_COMPILER_MAX_INLINE_BYTECODES},
194 {"compiler-deopt-threshold", required_argument, nullptr, OPTION_COMPILER_DEOPT_THRESHOLD},
195 {"compiler-stress-deopt", required_argument, nullptr, OPTION_COMPILER_STRESS_DEOPT},
196 {"compiler-opt-code-profiler", required_argument, nullptr, OPTION_COMPILER_OPT_CODE_PROFILER},
197 {"enable-force-gc", required_argument, nullptr, OPTION_ENABLE_FORCE_GC},
198 {"enable-ic", required_argument, nullptr, OPTION_ENABLE_IC},
199 {"enable-runtime-stat", required_argument, nullptr, OPTION_ENABLE_RUNTIME_STAT},
200 {"compiler-opt-constant-folding", required_argument, nullptr, OPTION_COMPILER_OPT_CONSTANT_FOLDING},
201 {"compiler-opt-array-bounds-check-elimination",
202 required_argument,
203 nullptr,
204 OPTION_COMPILER_OPT_ARRAY_BOUNDS_CHECK_ELIMINATION},
205 {"compiler-opt-type-lowering", required_argument, nullptr, OPTION_COMPILER_OPT_TYPE_LOWERING},
206 {"compiler-opt-early-elimination", required_argument, nullptr, OPTION_COMPILER_OPT_EARLY_ELIMINATION},
207 {"compiler-opt-later-elimination", required_argument, nullptr, OPTION_COMPILER_OPT_LATER_ELIMINATION},
208 {"compiler-opt-instr-combine", required_argument, nullptr, OPTION_COMPILER_OPT_INSTRUCTIONE_COMBINE},
209 {"compiler-opt-string", required_argument, nullptr, OPTION_COMPILER_OPT_STRING},
210 {"compiler-opt-value-numbering", required_argument, nullptr, OPTION_COMPILER_OPT_VALUE_NUMBERING},
211 {"compiler-opt-new-value-numbering", required_argument, nullptr, OPTION_COMPILER_OPT_NEW_VALUE_NUMBERING},
212 {"compiler-opt-inlining", required_argument, nullptr, OPTION_COMPILER_OPT_INLINING},
213 {"compiler-opt-pgotype", required_argument, nullptr, OPTION_COMPILER_OPT_PGOTYPE},
214 {"compiler-opt-track-field", required_argument, nullptr, OPTION_COMPILER_OPT_TRACK_FIELD},
215 {"entry-point", required_argument, nullptr, OPTION_ENTRY_POINT},
216 {"force-full-gc", required_argument, nullptr, OPTION_FORCE_FULL_GC},
217 {"gc-thread-num", required_argument, nullptr, OPTION_GC_THREADNUM},
218 {"heap-size-limit", required_argument, nullptr, OPTION_HEAP_SIZE_LIMIT},
219 {"help", no_argument, nullptr, OPTION_HELP},
220 {"icu-data-path", required_argument, nullptr, OPTION_ICU_DATA_PATH},
221 {"enable-worker", required_argument, nullptr, OPTION_ENABLE_WORKER},
222 {"log-components", required_argument, nullptr, OPTION_LOG_COMPONENTS},
223 {"log-debug", required_argument, nullptr, OPTION_LOG_DEBUG},
224 {"log-error", required_argument, nullptr, OPTION_LOG_ERROR},
225 {"log-fatal", required_argument, nullptr, OPTION_LOG_FATAL},
226 {"log-info", required_argument, nullptr, OPTION_LOG_INFO},
227 {"log-level", required_argument, nullptr, OPTION_LOG_LEVEL},
228 {"log-warning", required_argument, nullptr, OPTION_LOG_WARNING},
229 {"gc-long-paused-time", required_argument, nullptr, OPTION_GC_LONG_PAUSED_TIME},
230 {"compiler-opt-max-method", required_argument, nullptr, OPTION_COMPILER_OPT_MAX_METHOD},
231 {"compiler-module-methods", required_argument, nullptr, OPTION_COMPILER_MODULE_METHODS},
232 {"max-unmovable-space", required_argument, nullptr, OPTION_MAX_UNMOVABLE_SPACE},
233 {"merge-abc", required_argument, nullptr, OPTION_MERGE_ABC},
234 {"enable-context", required_argument, nullptr, OPTION_ENABLE_CONTEXT},
235 {"compiler-opt-level", required_argument, nullptr, OPTION_ASM_OPT_LEVEL},
236 {"options", no_argument, nullptr, OPTION_OPTIONS},
237 {"compiler-print-type-info", required_argument, nullptr, OPTION_COMPILER_PRINT_TYPE_INFO},
238 {"reloc-mode", required_argument, nullptr, OPTION_RELOCATION_MODE},
239 {"serializer-buffer-size-limit", required_argument, nullptr, OPTION_SERIALIZER_BUFFER_SIZE_LIMIT},
240 {"startup-time", required_argument, nullptr, OPTION_STARTUP_TIME},
241 {"stub-file", required_argument, nullptr, OPTION_STUB_FILE},
242 {"compiler-target-triple", required_argument, nullptr, OPTION_COMPILER_TARGET_TRIPLE},
243 {"enable-print-execute-time", required_argument, nullptr, OPTION_PRINT_EXECUTE_TIME},
244 {"enable-pgo-profiler", required_argument, nullptr, OPTION_ENABLE_PGO_PROFILER},
245 {"enable-elements-kind", required_argument, nullptr, OPTION_ENABLE_ELEMENTSKIND},
246 {"compiler-pgo-profiler-path", required_argument, nullptr, OPTION_COMPILER_PGO_PROFILER_PATH},
247 {"compiler-pgo-hotness-threshold", required_argument, nullptr, OPTION_COMPILER_PGO_HOTNESS_THRESHOLD},
248 {"compiler-pgo-save-min-interval", required_argument, nullptr, OPTION_COMPILER_PGO_SAVE_MIN_INTERVAL},
249 {"compiler-verify-vtable", required_argument, nullptr, OPTION_COMPILER_VERIFY_VTABLE},
250 {"compiler-select-methods", required_argument, nullptr, OPTION_COMPILER_SELECT_METHODS},
251 {"compiler-skip-methods", required_argument, nullptr, OPTION_COMPILER_SKIP_METHODS},
252 {"target-compiler-mode", required_argument, nullptr, OPTION_TARGET_COMPILER_MODE},
253 {"hap-path", required_argument, nullptr, OPTION_HAP_PATH},
254 {"hap-abc-offset", required_argument, nullptr, OPTION_HAP_ABC_OFFSET},
255 {"hap-abc-size", required_argument, nullptr, OPTION_HAP_ABC_SIZE},
256 {"compiler-no-check", required_argument, nullptr, OPTION_COMPILER_NOCHECK},
257 {"compiler-fast-compile", required_argument, nullptr, OPTION_FAST_AOT_COMPILE_MODE},
258 {"compiler-opt-loop-peeling", required_argument, nullptr, OPTION_COMPILER_OPT_LOOP_PEELING},
259 {"compiler-opt-array-onheap-check", required_argument, nullptr, OPTION_COMPILER_OPT_ON_HEAP_CHECK},
260 {"compiler-pkg-info", required_argument, nullptr, OPTION_COMPILER_PKG_INFO},
261 {"compiler-external-pkg-info", required_argument, nullptr, OPTION_COMPILER_EXTERNAL_PKG_INFO},
262 {"compiler-enable-external-pkg", required_argument, nullptr, OPTION_COMPILER_ENABLE_EXTERNAL_PKG},
263 {"compiler-enable-lexenv-specialization",
264 required_argument,
265 nullptr,
266 OPTION_COMPILER_ENABLE_LEXENV_SPECIALIZATION},
267 {"compiler-enable-native-inline", required_argument, nullptr, OPTION_COMPILER_ENABLE_NATIVE_INLINE},
268 {"compiler-enable-lowering-builtin", required_argument, nullptr, OPTION_COMPILER_ENABLE_LOWERING_BUILTIN},
269 {"compiler-enable-litecg", required_argument, nullptr, OPTION_COMPILER_ENABLE_LITECG},
270 {"compiler-enable-jit", required_argument, nullptr, OPTION_COMPILER_ENABLE_JIT},
271 {"compiler-jit-hotness-threshold", required_argument, nullptr, OPTION_COMPILER_JIT_HOTNESS_THRESHOLD},
272 {"compiler-force-jit-compile-main", required_argument, nullptr, OPTION_COMPILER_FORCE_JIT_COMPILE_MAIN},
273 {"compiler-typed-op-profiler", required_argument, nullptr, OPTION_COMPILER_TYPED_OP_PROFILER},
274 {"compiler-opt-branch-profiling", required_argument, nullptr, OPTION_COMPILER_OPT_BRANCH_PROFILING},
275 {nullptr, 0, nullptr, 0},
276 };
277
278 int index = 0;
279 opterr = 0;
280 bool ret = false;
281 int option = 0;
282 arg_list_t argListStr;
283 uint32_t argUint32 = 0;
284 uint64_t argUInt64 = 0;
285 int argInt = 0;
286 bool argBool = false;
287 double argDouble = 0.0;
288 static std::string COLON = ":";
289
290 if (argc <= 1) {
291 return true;
292 }
293
294 while (true) {
295 option = getopt_long_only(argc, const_cast<char **>(argv), "", longOptions, &index);
296 LOG_ECMA(INFO) << "option: " << option << ", optopt: " << optopt << ", optind: " << optind;
297
298 if (optind <= 0 || optind > argc) {
299 return false;
300 }
301
302 if (option == -1) {
303 return true;
304 }
305
306 // unknown option or required_argument option has no argument
307 if (option == OPTION_DEFAULT) {
308 ret = SetDefaultValue(const_cast<char *>(argv[optind - 1]));
309 if (ret) {
310 continue;
311 } else {
312 return ret;
313 }
314 }
315
316 WasSet(option);
317 switch (option) {
318 case OPTION_AOT_FILE:
319 SetAOTOutputFile(optarg);
320 ecmascript::AnFileDataManager::GetInstance()->SetEnable(true);
321 break;
322 case OPTION_ARK_PROPERTIES:
323 ret = ParseIntParam("ark-properties", &argInt);
324 if (ret) {
325 SetArkProperties(argInt);
326 } else {
327 return false;
328 }
329 break;
330 case OPTION_ARK_BUNDLENAME:
331 SetArkBundleName(optarg);
332 break;
333 case OPTION_ENABLE_ASM_INTERPRETER:
334 ret = ParseBoolParam(&argBool);
335 if (ret) {
336 SetEnableAsmInterpreter(argBool);
337 } else {
338 return false;
339 }
340 break;
341 case OPTION_ASM_OPCODE_DISABLE_RANGE:
342 SetAsmOpcodeDisableRange(optarg);
343 break;
344 case OPTION_COMPILER_ASSERT_TYPES:
345 ret = ParseBoolParam(&argBool);
346 if (ret) {
347 SetAssertTypes(argBool);
348 } else {
349 return false;
350 }
351 break;
352 case OPTION_BUILTINS_DTS:
353 SetBuiltinsDTS(optarg);
354 break;
355 case OPTION_ENABLE_BUILTINS_LAZY:
356 ret = ParseBoolParam(&argBool);
357 if (ret) {
358 SetEnableBuiltinsLazy(argBool);
359 } else {
360 return false;
361 }
362 break;
363 case OPTION_COMPILER_LOG_OPT:
364 SetCompilerLogOption(optarg);
365 break;
366 case OPTION_COMPILER_LOG_SNAPSHOT:
367 ret = ParseBoolParam(&argBool);
368 if (ret) {
369 SetCompilerLogSnapshot(argBool);
370 } else {
371 return false;
372 }
373 break;
374 case OPTION_COMPILER_LOG_TIME:
375 ret = ParseBoolParam(&argBool);
376 if (ret) {
377 SetCompilerLogTime(argBool);
378 } else {
379 return false;
380 }
381 break;
382 case OPTION_ENABLE_ARK_TOOLS:
383 ret = ParseBoolParam(&argBool);
384 if (ret) {
385 SetEnableArkTools(argBool);
386 } else {
387 return false;
388 }
389 break;
390 case OPTION_COMPILER_TRACE_BC:
391 ret = ParseBoolParam(&argBool);
392 if (ret) {
393 SetTraceBc(argBool);
394 } else {
395 return false;
396 }
397 break;
398 case OPTION_COMPILER_TRACE_DEOPT:
399 ret = ParseBoolParam(&argBool);
400 if (ret) {
401 SetTraceDeopt(argBool);
402 } else {
403 return false;
404 }
405 break;
406 case OPTION_COMPILER_TRACE_INLINE:
407 ret = ParseBoolParam(&argBool);
408 if (ret) {
409 SetTraceInline(argBool);
410 } else {
411 return false;
412 }
413 break;
414 case OPTION_COMPILER_TRACE_VALUE_NUMBERING:
415 ret = ParseBoolParam(&argBool);
416 if (ret) {
417 SetTraceValueNumbering(argBool);
418 } else {
419 return false;
420 }
421 break;
422 case OPTION_COMPILER_TRACE_INSTRUCTION_COMBINE:
423 ret = ParseBoolParam(&argBool);
424 if (ret) {
425 SetTraceInstructionCombine(argBool);
426 } else {
427 return false;
428 }
429 break;
430 case OPTION_COMPILER_MAX_INLINE_BYTECODES:
431 ret = ParseUint32Param("max-inline-bytecodes", &argUint32);
432 if (ret) {
433 SetMaxInlineBytecodes(argUint32);
434 } else {
435 return false;
436 }
437 break;
438 case OPTION_COMPILER_DEOPT_THRESHOLD:
439 ret = ParseUint32Param("deopt-threshol", &argUint32);
440 if (ret) {
441 SetDeoptThreshold(argUint32);
442 } else {
443 return false;
444 }
445 break;
446 case OPTION_COMPILER_STRESS_DEOPT:
447 ret = ParseBoolParam(&argBool);
448 if (ret) {
449 SetStressDeopt(argBool);
450 } else {
451 return false;
452 }
453 break;
454 case OPTION_COMPILER_OPT_CODE_PROFILER:
455 ret = ParseBoolParam(&argBool);
456 if (ret) {
457 SetOptCodeProfiler(argBool);
458 } else {
459 return false;
460 }
461 break;
462 case OPTION_ENABLE_FORCE_GC:
463 ret = ParseBoolParam(&argBool);
464 if (ret) {
465 SetEnableForceGC(argBool);
466 } else {
467 return false;
468 }
469 break;
470 case OPTION_FORCE_FULL_GC:
471 ret = ParseBoolParam(&argBool);
472 if (ret) {
473 SetForceFullGC(argBool);
474 } else {
475 return false;
476 }
477 break;
478 case OPTION_ENABLE_IC:
479 ret = ParseBoolParam(&argBool);
480 if (ret) {
481 SetEnableIC(argBool);
482 } else {
483 return false;
484 }
485 break;
486 case OPTION_ENABLE_RUNTIME_STAT:
487 ret = ParseBoolParam(&argBool);
488 if (ret) {
489 SetEnableRuntimeStat(argBool);
490 } else {
491 return false;
492 }
493 break;
494 case OPTION_GC_THREADNUM:
495 ret = ParseUint32Param("gc-thread-num", &argUint32);
496 if (ret) {
497 SetGcThreadNum(argUint32);
498 } else {
499 return false;
500 }
501 break;
502 case OPTION_HEAP_SIZE_LIMIT:
503 ret = ParseUint32Param("heap-size-limit", &argUint32);
504 if (ret) {
505 SetHeapSizeLimit(argUint32);
506 } else {
507 return false;
508 }
509 break;
510 case OPTION_HELP:
511 return false;
512 case OPTION_ICU_DATA_PATH:
513 SetIcuDataPath(optarg);
514 break;
515 case OPTION_ENABLE_WORKER:
516 ret = ParseBoolParam(&argBool);
517 if (ret) {
518 SetIsWorker(argBool);
519 } else {
520 return false;
521 }
522 break;
523 case OPTION_LOG_COMPONENTS:
524 ParseListArgParam(optarg, &argListStr, COLON);
525 SetLogComponents(argListStr);
526 break;
527 case OPTION_LOG_DEBUG:
528 ParseListArgParam(optarg, &argListStr, COLON);
529 SetLogDebug(argListStr);
530 break;
531 case OPTION_LOG_ERROR:
532 ParseListArgParam(optarg, &argListStr, COLON);
533 SetLogError(argListStr);
534 break;
535 case OPTION_LOG_FATAL:
536 ParseListArgParam(optarg, &argListStr, COLON);
537 SetLogFatal(argListStr);
538 break;
539 case OPTION_LOG_INFO:
540 ParseListArgParam(optarg, &argListStr, COLON);
541 SetLogInfo(argListStr);
542 break;
543 case OPTION_LOG_LEVEL:
544 SetLogLevel(optarg);
545 break;
546 case OPTION_LOG_WARNING:
547 ParseListArgParam(optarg, &argListStr, COLON);
548 SetLogWarning(argListStr);
549 break;
550 case OPTION_GC_LONG_PAUSED_TIME:
551 ret = ParseUint32Param("gc-long-paused-time", &argUint32);
552 if (ret) {
553 SetLongPauseTime(argUint32);
554 } else {
555 return false;
556 }
557 break;
558 case OPTION_COMPILER_OPT_MAX_METHOD:
559 ret = ParseUint32Param("compiler-opt-max-method", &argUint32);
560 if (ret) {
561 SetMaxAotMethodSize(argUint32);
562 } else {
563 return false;
564 }
565 break;
566 case OPTION_COMPILER_MODULE_METHODS:
567 ret = ParseUint32Param("compiler-module-methods", &argUint32);
568 if (!ret) {
569 return false;
570 }
571 SetCompilerModuleMethods(argUint32);
572 break;
573 case OPTION_COMPILER_TYPE_THRESHOLD:
574 ret = ParseDoubleParam("compiler-type-threshold", &argDouble);
575 if (ret) {
576 SetTypeThreshold(argDouble);
577 } else {
578 return false;
579 }
580 break;
581 case OPTION_MAX_UNMOVABLE_SPACE:
582 ret = ParseUint32Param("max-unmovable-space", &argUint32);
583 if (ret) {
584 SetMaxNonmovableSpaceCapacity(argUint32);
585 } else {
586 return false;
587 }
588 break;
589 case OPTION_COMPILER_LOG_METHODS:
590 SetMethodsListForLog(optarg);
591 break;
592 case OPTION_ASM_OPT_LEVEL:
593 ret = ParseUint32Param("compiler-opt-level", &argUint32);
594 if (ret) {
595 SetOptLevel(argUint32);
596 } else {
597 return false;
598 }
599 break;
600 case OPTION_COMPILER_PRINT_TYPE_INFO:
601 ret = ParseBoolParam(&argBool);
602 if (ret) {
603 SetPrintTypeInfo(argBool);
604 } else {
605 return false;
606 }
607 break;
608 case OPTION_PRINT_EXECUTE_TIME:
609 ret = ParseBoolParam(&argBool);
610 if (ret) {
611 SetEnablePrintExecuteTime(argBool);
612 } else {
613 return false;
614 }
615 break;
616 case OPTION_ENABLE_PGO_PROFILER:
617 ret = ParseBoolParam(&argBool);
618 if (ret) {
619 SetEnablePGOProfiler(argBool);
620 } else {
621 return false;
622 }
623 break;
624 case OPTION_ENABLE_ELEMENTSKIND:
625 ret = ParseBoolParam(&argBool);
626 if (ret) {
627 SetEnableElementsKind(argBool);
628 } else {
629 return false;
630 }
631 break;
632 case OPTION_COMPILER_PGO_PROFILER_PATH:
633 if (*optarg == '\0') {
634 return false;
635 }
636 SetPGOProfilerPath(optarg);
637 break;
638 case OPTION_COMPILER_PGO_HOTNESS_THRESHOLD:
639 ret = ParseUint32Param("pgo-hotness-threshold", &argUint32);
640 if (ret) {
641 SetPGOHotnessThreshold(argUint32);
642 } else {
643 return false;
644 }
645 break;
646 case OPTION_COMPILER_PGO_SAVE_MIN_INTERVAL:
647 ret = ParseUint32Param("compiler-pgo-save-min-interval)", &argUint32);
648 if (ret) {
649 SetPGOSaveMinInterval(argUint32);
650 } else {
651 return false;
652 }
653 break;
654 case OPTION_RELOCATION_MODE:
655 ret = ParseUint32Param("reloc-mode", &argUint32);
656 if (ret) {
657 SetRelocMode(argUint32);
658 } else {
659 return false;
660 }
661 break;
662 case OPTION_SERIALIZER_BUFFER_SIZE_LIMIT:
663 ret = ParseUint64Param("serializer-buffer-size-limit", &argUInt64);
664 if (ret) {
665 SetSerializerBufferSizeLimit(argUInt64);
666 } else {
667 return false;
668 }
669 break;
670 case OPTION_STARTUP_TIME:
671 ret = ParseBoolParam(&argBool);
672 if (ret) {
673 SetStartupTime(argBool);
674 } else {
675 return false;
676 }
677 break;
678 case OPTION_STUB_FILE:
679 SetStubFile(optarg);
680 break;
681 case OPTION_COMPILER_TARGET_TRIPLE:
682 SetTargetTriple(optarg);
683 break;
684 case OPTION_ENTRY_POINT:
685 SetEntryPoint(optarg);
686 break;
687 case OPTION_MERGE_ABC:
688 ret = ParseBoolParam(&argBool);
689 if (ret) {
690 SetMergeAbc(argBool);
691 } else {
692 return false;
693 }
694 break;
695 case OPTION_ENABLE_CONTEXT:
696 ret = ParseBoolParam(&argBool);
697 if (ret) {
698 SetEnableContext(argBool);
699 } else {
700 return false;
701 }
702 break;
703 case OPTION_COMPILER_OPT_TYPE_LOWERING:
704 ret = ParseBoolParam(&argBool);
705 if (ret) {
706 SetEnableTypeLowering(argBool);
707 } else {
708 return false;
709 }
710 break;
711 case OPTION_COMPILER_OPT_ARRAY_BOUNDS_CHECK_ELIMINATION:
712 ret = ParseBoolParam(&argBool);
713 if (ret) {
714 SetEnableArrayBoundsCheckElimination(argBool);
715 } else {
716 return false;
717 }
718 break;
719 case OPTION_COMPILER_OPT_EARLY_ELIMINATION:
720 ret = ParseBoolParam(&argBool);
721 if (ret) {
722 SetEnableEarlyElimination(argBool);
723 } else {
724 return false;
725 }
726 break;
727 case OPTION_COMPILER_OPT_LATER_ELIMINATION:
728 ret = ParseBoolParam(&argBool);
729 if (ret) {
730 SetEnableLaterElimination(argBool);
731 } else {
732 return false;
733 }
734 break;
735 case OPTION_COMPILER_OPT_INSTRUCTIONE_COMBINE:
736 ret = ParseBoolParam(&argBool);
737 if (ret) {
738 SetEnableInstrcutionCombine(argBool);
739 } else {
740 return false;
741 }
742 break;
743 case OPTION_COMPILER_OPT_STRING:
744 ret = ParseBoolParam(&argBool);
745 if (ret) {
746 SetEnableOptString(argBool);
747 } else {
748 return false;
749 }
750 break;
751 case OPTION_COMPILER_OPT_VALUE_NUMBERING:
752 ret = ParseBoolParam(&argBool);
753 if (ret) {
754 SetEnableValueNumbering(argBool);
755 } else {
756 return false;
757 }
758 break;
759 case OPTION_COMPILER_OPT_NEW_VALUE_NUMBERING:
760 ret = ParseBoolParam(&argBool);
761 if (ret) {
762 SetEnableNewValueNumbering(argBool);
763 } else {
764 return false;
765 }
766 break;
767 case OPTION_COMPILER_OPT_INLINING:
768 ret = ParseBoolParam(&argBool);
769 if (ret) {
770 SetEnableOptInlining(argBool);
771 } else {
772 return false;
773 }
774 break;
775 case OPTION_COMPILER_OPT_PGOTYPE:
776 ret = ParseBoolParam(&argBool);
777 if (ret) {
778 SetEnableOptPGOType(argBool);
779 } else {
780 return false;
781 }
782 break;
783 case OPTION_COMPILER_OPT_TRACK_FIELD:
784 ret = ParseBoolParam(&argBool);
785 if (ret) {
786 SetEnableOptTrackField(argBool);
787 } else {
788 return false;
789 }
790 break;
791 case OPTION_COMPILER_OPT_GLOBAL_TYPEINFER:
792 ret = ParseBoolParam(&argBool);
793 if (ret) {
794 SetEnableGlobalTypeInfer(argBool);
795 } else {
796 return false;
797 }
798 break;
799 case OPTION_COMPILER_VERIFY_VTABLE:
800 ret = ParseBoolParam(&argBool);
801 if (ret) {
802 SetVerifyVTable(argBool);
803 } else {
804 return false;
805 }
806 break;
807 case OPTION_COMPILER_SELECT_METHODS:
808 SetCompilerSelectMethods(optarg);
809 break;
810 case OPTION_COMPILER_SKIP_METHODS:
811 SetCompilerSkipMethods(optarg);
812 break;
813 case OPTION_TARGET_COMPILER_MODE:
814 SetTargetCompilerMode(optarg);
815 break;
816 case OPTION_HAP_PATH:
817 SetHapPath(optarg);
818 break;
819 case OPTION_HAP_ABC_OFFSET:
820 ret = ParseUint32Param("hap-abc-offset", &argUint32);
821 if (!ret) {
822 return false;
823 }
824 SetHapAbcOffset(argUint32);
825 break;
826 case OPTION_HAP_ABC_SIZE:
827 ret = ParseUint32Param("hap-abc-size", &argUint32);
828 if (!ret) {
829 return false;
830 }
831 SetHapAbcSize(argUint32);
832 break;
833 case OPTION_COMPILER_NOCHECK:
834 ret = ParseBoolParam(&argBool);
835 if (!ret) {
836 return false;
837 }
838 SetCompilerNoCheck(argBool);
839 break;
840 case OPTION_FAST_AOT_COMPILE_MODE:
841 ret = ParseBoolParam(&argBool);
842 if (!ret) {
843 return false;
844 }
845 SetFastAOTCompileMode(argBool);
846 break;
847 case OPTION_COMPILER_OPT_CONSTANT_FOLDING:
848 ret = ParseBoolParam(&argBool);
849 if (ret) {
850 SetEnableOptConstantFolding(argBool);
851 } else {
852 return false;
853 }
854 break;
855 case OPTION_COMPILER_OPT_LOOP_PEELING:
856 ret = ParseBoolParam(&argBool);
857 if (ret) {
858 SetEnableOptLoopPeeling(argBool);
859 } else {
860 return false;
861 }
862 break;
863 case OPTION_COMPILER_OPT_ON_HEAP_CHECK:
864 ret = ParseBoolParam(&argBool);
865 if (ret) {
866 SetEnableOptOnHeapCheck(argBool);
867 } else {
868 return false;
869 }
870 break;
871 case OPTION_COMPILER_PKG_INFO:
872 SetCompilerPkgJsonInfo(optarg);
873 break;
874 case OPTION_COMPILER_EXTERNAL_PKG_INFO:
875 SetCompilerExternalPkgJsonInfo(optarg);
876 break;
877 case OPTION_COMPILER_ENABLE_EXTERNAL_PKG:
878 ret = ParseBoolParam(&argBool);
879 if (ret) {
880 SetCompilerEnableExternalPkg(argBool);
881 } else {
882 return false;
883 }
884 break;
885 case OPTION_COMPILER_ENABLE_LEXENV_SPECIALIZATION:
886 ret = ParseBoolParam(&argBool);
887 if (ret) {
888 SetEnableLexenvSpecialization(argBool);
889 } else {
890 return false;
891 }
892 break;
893 case OPTION_COMPILER_ENABLE_NATIVE_INLINE:
894 ret = ParseBoolParam(&argBool);
895 if (ret) {
896 SetEnableNativeInline(argBool);
897 } else {
898 return false;
899 }
900 break;
901 case OPTION_COMPILER_ENABLE_LOWERING_BUILTIN:
902 ret = ParseBoolParam(&argBool);
903 if (ret) {
904 SetEnableLoweringBuiltin(argBool);
905 } else {
906 return false;
907 }
908 break;
909 case OPTION_COMPILER_ENABLE_LITECG:
910 ret = ParseBoolParam(&argBool);
911 if (ret) {
912 SetCompilerEnableLiteCG(argBool);
913 } else {
914 return false;
915 }
916 break;
917 case OPTION_COMPILER_ENABLE_JIT:
918 ret = ParseBoolParam(&argBool);
919 if (ret) {
920 SetEnableJIT(argBool);
921 } else {
922 return false;
923 }
924 break;
925 case OPTION_COMPILER_JIT_HOTNESS_THRESHOLD:
926 ret = ParseUint32Param("compiler-jit-hotness-threshold", &argUint32);
927 if (ret) {
928 uint16_t val = argUint32 > std::numeric_limits<uint16_t>::max() ?
929 std::numeric_limits<uint16_t>::max() : static_cast<uint16_t>(argUint32);
930 SetJitHotnessThreshold(val);
931 } else {
932 return false;
933 }
934 break;
935 case OPTION_COMPILER_FORCE_JIT_COMPILE_MAIN:
936 ret = ParseBoolParam(&argBool);
937 if (ret) {
938 SetForceJitCompileMain(argBool);
939 } else {
940 return false;
941 }
942 break;
943 case OPTION_COMPILER_TRACE_JIT:
944 ret = ParseBoolParam(&argBool);
945 if (ret) {
946 SetTraceJIT(argBool);
947 } else {
948 return false;
949 }
950 break;
951 case OPTION_COMPILER_TYPED_OP_PROFILER:
952 ret = ParseBoolParam(&argBool);
953 if (ret) {
954 SetTypedOpProfiler(argBool);
955 } else {
956 return false;
957 }
958 break;
959 case OPTION_COMPILER_OPT_BRANCH_PROFILING:
960 ret = ParseBoolParam(&argBool);
961 if (ret) {
962 SetEnableBranchProfiling(argBool);
963 } else {
964 return false;
965 }
966 break;
967 default:
968 LOG_ECMA(ERROR) << "Invalid option\n";
969 return false;
970 }
971 }
972 }
973
SetDefaultValue(char * argv)974 bool JSRuntimeOptions::SetDefaultValue(char* argv)
975 {
976 WasSet(optopt);
977
978 if (optopt == OPTION_DEFAULT) { // unknown option
979 LOG_ECMA(ERROR) << " Invalid option \"" << argv << "\"";
980 return false;
981 }
982
983 if (optopt > OPTION_OPTIONS) { // unknown argument
984 LOG_ECMA(ERROR) << "getopt: \"" << argv <<"\" argument has invalid parameter value \n";
985 return false;
986 }
987 return true;
988 }
989
ParseBoolParam(bool * argBool)990 bool JSRuntimeOptions::ParseBoolParam(bool* argBool)
991 {
992 if ((strcmp(optarg, "false") == 0) || (strcmp(optarg, "0") == 0)) {
993 *argBool = false;
994 } else {
995 *argBool = true;
996 }
997 return true;
998 }
999
ParseDoubleParam(const std::string & option,double * argDouble)1000 bool JSRuntimeOptions::ParseDoubleParam(const std::string &option, double *argDouble)
1001 {
1002 *argDouble = std::stod(optarg, nullptr);
1003 if (errno == ERANGE) {
1004 LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1005 return false;
1006 }
1007 return true;
1008 }
1009
ParseIntParam(const std::string & option,int * argInt)1010 bool JSRuntimeOptions::ParseIntParam(const std::string &option, int *argInt)
1011 {
1012 if (StartsWith(optarg, "0x")) {
1013 const int HEX = 16;
1014 *argInt = std::stoi(optarg, nullptr, HEX);
1015 } else {
1016 *argInt = std::stoi(optarg);
1017 }
1018
1019 if (errno == ERANGE) {
1020 LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1021 return false;
1022 }
1023 return true;
1024 }
1025
ParseUint32Param(const std::string & option,uint32_t * argUInt32)1026 bool JSRuntimeOptions::ParseUint32Param(const std::string &option, uint32_t *argUInt32)
1027 {
1028 if (StartsWith(optarg, "0x")) {
1029 const int HEX = 16;
1030 *argUInt32 = std::strtoull(optarg, nullptr, HEX);
1031 } else {
1032 const int DEC = 10;
1033 *argUInt32 = std::strtoull(optarg, nullptr, DEC);
1034 }
1035
1036 if (errno == ERANGE) {
1037 LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1038 return false;
1039 }
1040 return true;
1041 }
1042
ParseUint64Param(const std::string & option,uint64_t * argUInt64)1043 bool JSRuntimeOptions::ParseUint64Param(const std::string &option, uint64_t *argUInt64)
1044 {
1045 if (StartsWith(optarg, "0x")) {
1046 const int HEX = 16;
1047 *argUInt64 = std::strtoull(optarg, nullptr, HEX);
1048 } else {
1049 const int DEC = 10;
1050 *argUInt64 = std::strtoull(optarg, nullptr, DEC);
1051 }
1052
1053 if (errno == ERANGE) {
1054 LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1055 return false;
1056 }
1057 return true;
1058 }
1059
ParseListArgParam(const std::string & option,arg_list_t * argListStr,std::string delimiter)1060 void JSRuntimeOptions::ParseListArgParam(const std::string &option, arg_list_t *argListStr, std::string delimiter)
1061 {
1062 argListStr->clear();
1063 std::size_t strIndex = 0;
1064 std::size_t pos = option.find_first_of(delimiter, strIndex);
1065 while ((pos < option.size()) && (pos > strIndex)) {
1066 argListStr->push_back(option.substr(strIndex, pos - strIndex));
1067 strIndex = pos;
1068 strIndex = option.find_first_not_of(delimiter, strIndex);
1069 pos = option.find_first_of(delimiter, strIndex);
1070 }
1071 if (pos > strIndex) {
1072 argListStr->push_back(option.substr(strIndex, pos - strIndex));
1073 }
1074 return;
1075 }
1076
SetTargetBuiltinsDtsPath()1077 void JSRuntimeOptions::SetTargetBuiltinsDtsPath()
1078 {
1079 WasSet(CommandValues::OPTION_BUILTINS_DTS);
1080 std::string builtinsDtsPath = TARGET_BUILTINS_DTS_PATH;
1081 SetBuiltinsDTS(builtinsDtsPath);
1082 }
1083
SetOptionsForTargetCompilation()1084 void JSRuntimeOptions::SetOptionsForTargetCompilation()
1085 {
1086 if (IsTargetCompilerMode()) {
1087 SetTargetBuiltinsDtsPath();
1088 SetTargetTriple("aarch64-unknown-linux-gnu");
1089 SetEnableOptTrackField(false);
1090 SetEnableOptInlining(false);
1091 if (IsPartialCompilerMode()) {
1092 SetEnableOptPGOType(true);
1093 if (IsPGOProfilerPathEmpty()) {
1094 LOG_ECMA(DEBUG) << "no pgo profile file in partial mode!";
1095 }
1096 } else {
1097 SetEnableOptPGOType(false);
1098 SetPGOProfilerPath("");
1099 }
1100 }
1101 }
1102 }
1103