• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <getopt.h>
19 #include <type_traits>
20 
21 #include "common_components/common_runtime/base_runtime_param.h"
22 #include "ecmascript/compiler/aot_file/an_file_data_manager.h"
23 #include "ecmascript/compiler/assembler/assembler.h"
24 #include "ecmascript/compiler/bc_call_signature.h"
25 #include "ecmascript/compiler/ecma_opcode_des.h"
26 #include "ecmascript/platform/os.h"
27 
28 namespace panda::ecmascript {
29 const std::string PUBLIC_API COMMON_HELP_HEAD_MSG =
30     "Usage: jsvm  <option>  <filename.abc>\n"
31     "\n"
32     "Options:\n";
33 
34 const std::string PUBLIC_API COMPILER_HELP_HEAD_MSG =
35     "Usage: ark_aot_compiler  <option>  --aot-file=<filename>  <filename.abc>\n"
36     "\n"
37     "Options:\n";
38 
39 const std::string PUBLIC_API STUB_HELP_HEAD_MSG =
40     "Usage: ark_stub_compiler <option>\n"
41     "\n"
42     "Options:\n";
43 
44 const std::string PUBLIC_API HELP_OPTION_MSG =
45     "--help:                               Print this message and exit\n"
46     "--aot-file:                           Path (file suffix not needed) to AOT output file. Default: 'aot_file'\n"
47     "--ark-properties:                     Set ark properties\n"
48     "--ark-bundle-name:                    Set ark bundle name\n"
49     "--asm-interpreter:                    Enable asm interpreter. Default: 'true'\n"
50     "--asm-opcode-disable-range:           Opcode range when asm interpreter is enabled.\n"
51     "--builtins-lazy:                      Load some builtins function later.This option is only valid in workervm.\n"
52     "--compiler-log:                       Log Option For aot compiler and stub compiler,\n"
53     "                                      'none': no log,\n"
54     "                                      'allllircirasm' or 'all012': print all log for all methods,\n"
55     "                                      'allcir' or 'all0': print IR info for all methods,\n"
56     "                                      'allllir' or 'all1': print llir info for all methods,\n"
57     "                                      'allasm' or 'all2': print asm log for all methods,\n"
58     "                                      'alltype' or 'all3': print type infer log for all methods,\n"
59     "                                      'cerllircirasm' or 'cer0112': print all log for certain method defined\n"
60     "                                       in 'mlist-for-log',\n"
61     "                                      'cercir' or 'cer0': print IR for methods in 'mlist-for-log',\n"
62     "                                      'cerasm' or 'cer2': print log for methods in 'mlist-for-log',\n"
63     "                                      Default: 'none'\n"
64     "--compiler-log-methods:               Specific method list for compiler log, only used when compiler-log. "
65     "                                      Default: 'none'\n"
66     "--compiler-type-threshold:            enable to skip methods whose type is no more than threshold. Default: -1\n"
67     "--compiler-log-snapshot:              Enable to print snapshot information. 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     "--open-ark-tools:                     Open ark tools to return specific implementation. Default: 'false'\n"
71     "--pgo-trace:                          Enable pgo trace for JS runtime. Default: 'false'\n"
72     "--compiler-trace-bc:                  Enable tracing bytecode for aot runtime. Default: 'false'\n"
73     "--compiler-trace-deopt:               Enable tracing deopt for aot runtime. Default: 'false'\n"
74     "--compiler-trace-inline:              Enable tracing inline function for aot runtime. Default: 'false'\n"
75     "--compiler-trace-builtins:            Enable tracing builtins function for aot runtime. Default: 'false'\n"
76     "--compiler-trace-value-numbering:     Enable tracing value numbering for aot runtime. Default: 'false'\n"
77     "--compiler-max-inline-bytecodes       Set max bytecodes count which aot function can be inlined. Default: '25'\n"
78     "--compiler-deopt-threshold:           Set max count which aot function can occur deoptimization. Default: '10'\n"
79     "--compiler-stress-deopt:              Enable stress deopt for aot compiler. Default: 'false'\n"
80     "--compiler-opt-code-profiler:         Enable opt code Bytecode Statistics for aot runtime. Default: 'false'\n"
81     "--compiler-opt-bc-range:              Range list for EcmaOpCode range Example '1:2,5:8'\n"
82     "--compiler-opt-bc-range-help:         Range list for EcmaOpCode range help. Default: 'false''\n"
83     "--enable-loading-stubs-log:           Enable Loading Stubs Log. Default: 'false'\n"
84     "--enable-force-gc:                    Enable force gc when allocating object. Default: 'true'\n"
85 #ifdef USE_CMC_GC
86     "--enable-cmc-gc:                      Enable cmc gc. Default: 'true'\n"
87 #else
88     "--enable-cmc-gc:                      Enable cmc gc. Default: 'false'\n"
89 #endif
90     "--cmc-max-garbage-cache-size:         Max size of cmc gc garbage cache.. Default: 16M\n"
91     "--enable-cmc-gc-concurrent-root-marking:         Enable concurrent root marking in cmc gc. Default: 'true'\n"
92     "--force-shared-gc-frequency:          How frequency force shared gc . Default: '1'\n"
93     "--enable-ic:                          Switch of inline cache. Default: 'true'\n"
94     "--enable-runtime-stat:                Enable statistics of runtime state. Default: 'false'\n"
95     "--compiler-opt-array-bounds-check-elimination: Enable Index Check elimination. Default: 'true'\n"
96     "--compiler-opt-constant-folding:      Enable constant folding. Default: 'true'\n"
97     "--compiler-opt-type-lowering:         Enable all type optimization pass for aot compiler. Default: 'true'\n"
98     "--compiler-opt-early-elimination:     Enable EarlyElimination for aot compiler. Default: 'true'\n"
99     "--compiler-opt-later-elimination:     Enable LaterElimination for aot compiler. Default: 'true'\n"
100     "--compiler-opt-string:                Enable string optimization pass for aot compiler. Default: 'true'\n"
101     "--compiler-opt-value-numbering:       Enable ValueNumbering for aot compiler. Default: 'true'\n"
102     "--compiler-opt-inlining:              Enable inlining function for aot compiler: Default: 'true'\n"
103     "--compiler-opt-pgotype:               Enable pgo type for aot compiler: Default: 'true'\n"
104     "--compiler-opt-track-field:           Enable track field for aot compiler: Default: 'false'\n"
105     "--entry-point:                        Full name of entrypoint function. Default: '_GLOBAL::func_main_0'\n"
106     "--force-full-gc:                      If true trigger full gc, else trigger semi and old gc. Default: 'true'\n"
107     "--framework-abc-file:                 Snapshot file. Default: 'strip.native.min.abc'\n"
108     "--gc-long-paused-time:                Set gc's longPauseTime in millisecond. Default: '40'\n"
109     "--gc-thread-num:                      Set gc thread number. Default: '7'\n"
110     "--icu-data-path:                      Path to generated icu data file. Default: 'default'\n"
111     "--enable-worker:                      Whether is worker vm. Default: 'false'\n"
112     "--log-level:                          Log level: ['debug', 'info', 'warning', 'error', 'fatal'].\n"
113     "--log-components:                     Enable logs from specified components: ['all', 'gc', 'ecma','interpreter',\n"
114     "                                      'debugger', 'compiler', 'builtins', 'trace', 'jit', 'baselinejit', 'all'].\n"
115     "                                      Default: 'all'\n"
116     "--log-debug:                          Enable debug or above logs for components: ['all', 'gc', 'ecma',\n"
117     "                                      'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit',\n"
118     "                                      'baselinejit', 'all']. Default: 'all'\n"
119     "--log-error:                          Enable error log for components: ['all', 'gc', 'ecma',\n"
120     "                                      'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit',\n"
121     "                                      'baselinejit', 'all']. Default: 'all'\n"
122     "--log-fatal:                          Enable fatal log for components: ['all', 'gc', 'ecma',\n"
123     "                                      'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit',\n"
124     "                                      'baselinejit', 'all']. Default: 'all'\n"
125     "--log-info:                           Enable info log for components: ['all', 'gc', 'ecma',\n"
126     "                                      'interpreter', 'debugger', 'compiler', 'builtins', 'trace', 'jit',\n"
127     "                                      'baselinejit', 'all']. Default: 'all'\n"
128     "--log-warning:                        Enable warning log for components: ['all', 'gc', 'ecma',\n"
129     "                                      'interpreter', 'debugger', 'compiler', 'trace', 'jit', \n"
130     "                                      'baselinejit', 'builtins', 'all']. Default: 'all'\n"
131     "--compiler-opt-max-method:            Enable aot compiler to skip method larger than limit (KB). Default: '32'\n"
132     "--compiler-module-methods:            The number of max compiled methods in a module. Default: '100'\n"
133     "--max-unmovable-space:                Set max unmovable space capacity\n"
134     "--merge-abc:                          ABC file is merge abc. Default: 'false'\n"
135     "--compiler-opt-level:                 Optimization level configuration of aot compiler. Default: '3'\n"
136     "--options:                            Print compiler and runtime options\n"
137     "--serializer-buffer-size-limit:       Max serializer buffer size used by the VM in Byte. Default size is 2GB\n"
138     "--snapshot-file:                      Snapshot file. Default: '/system/etc/snapshot'\n"
139     "--startup-time:                       Print the start time of command execution. Default: 'false'\n"
140     "--stub-file:                          Path of file includes common stubs module compiled by stub compiler. \n"
141     "                                      Default: 'stub.an'\n"
142     "--enable-pgo-profiler:                Enable pgo profiler to sample jsfunction call and output to file. "
143                                            "Default: 'false'\n"
144     "--enable-mutant-array:                Enable transition between mutant array and tagged array. Default: 'false'\n"
145     "--enable-elements-kind:               Enable initialization of elements kind in array. Default: 'false'\n"
146     "--compiler-pgo-hotness-threshold:     Set hotness threshold for pgo in aot compiler. Default: '2'\n"
147     "--compiler-pgo-profiler-path:         The pgo file output dir or the pgo file dir of AOT compiler. Default: ''\n"
148     "--compiler-pgo-save-min-interval:     Set the minimum time interval for automatically saving profile, "
149     "Unit seconds. Default: '30s'\n"
150     "--compiler-baseline-pgo:              Enable compile the baseline Ap file. \n"
151     "                                      Default: 'false'\n"
152     "--compiler-target-triple:             CPU triple for aot compiler or stub compiler. \n"
153     "                                      values: ['x86_64-unknown-linux-gnu', 'arm-unknown-linux-gnu', \n"
154     "                                      'aarch64-unknown-linux-gnu'], Default: 'x86_64-unknown-linux-gnu'\n"
155     "--enable-print-execute-time:          Enable print execute panda file spent time\n"
156     "--compiler-verify-vtable:             Verify vtable result for aot compiler. Default: 'false'\n"
157     "--compiler-select-methods             Compiler selected methods for aot. Only work in full compiling mode\n"
158     "                                      Format:--compile-methods=record1:m1,m2,record2:m3\n"
159     "--compiler-skip-methods               Compiler skpped methods for aot. Only work in full compiling mode\n"
160     "                                      Format:--compile-skip-methods=record1:m1,m2,record2:m3\n"
161     "--target-compiler-mode                The compilation mode at the device side, including partial, full and none.\n"
162     "                                      Default: ''\n"
163     "--hap-path(Deprecated)                The path of the app hap. Default: ''\n"
164     "--hap-abc-offset(Deprecated)          The offset of the abc file in app hap. Default: '0'\n"
165     "--hap-abc-size(Deprecated)            The size of the abc file in app hap. Default: '0'\n"
166     "--compiler-fast-compile               Disable some time-consuming pass. Default: 'true'\n"
167     "--compiler-no-check                   Enable remove checks for aot compiler. Default: 'false'\n"
168     "--compiler-pipeline-host-aot          Enable pipeline host aot compiler. Default: 'false'\n"
169     "--compiler-opt-loop-peeling:          Enable loop peeling for aot compiler: Default: 'true'\n"
170     "--compiler-pkg-info                   Specify the package json info for ark aot compiler\n"
171     "--compiler-external-pkg-info          Specify the external package json info for ark aot compiler\n"
172     "--compiler-enable-external-pkg        Enable compile with external package for ark aot compiler\n"
173     "--compiler-enable-lexenv-specialization: Enable replace ldlexvar with specific values: Default: 'true'\n"
174     "--compiler-enable-native-inline:      Enable inline native function: Default: 'false'\n"
175     "--compiler-enable-lowering-builtin:   Enable lowering global object: Default: 'false'\n"
176     "--compiler-opt-array-onheap-check:    Enable TypedArray on heap check for aot compiler: Default: 'false'\n"
177     "--compiler-enable-litecg:             Enable LiteCG: Default: 'false'\n"
178     "--compiler-enable-jit:                Enable jit: Default: 'false'\n"
179     "--compiler-enable-osr:                Enable osr: Default: 'false'\n"
180     "--compiler-enable-framework-aot:      Enable frame aot: Default: 'true'\n"
181     "--compiler-enable-pgo-space:          Enable pgo space used for compiler. Default: 'true'\n"
182     "--compiler-jit-hotness-threshold:     Set hotness threshold for jit. Default: '2'\n"
183     "--compiler-jit-call-threshold:        Set call threshold for jit. Default: '0'\n"
184     "--compiler-osr-hotness-threshold:     Set hotness threshold for osr. Default: '2'\n"
185     "--compiler-force-jit-compile-main:    Enable jit compile main function: Default: 'false'\n"
186     "--compiler-trace-jit:                 Enable trace jit: Default: 'false'\n"
187     "--compiler-enable-jit-pgo:            Enable jit pgo: Default: 'true'\n"
188     "--compiler-typed-op-profiler:         Enable Typed Opcode Statistics for aot runtime. Default: 'false'\n"
189     "--compiler-opt-branch-profiling:      Enable branch profiling for aot compiler. Default: 'true'\n"
190     "--test-assert:                        Set Assert Model. Default: 'false'\n"
191     "--compiler-methods-range:             Enable aot compiler to compile only in-range methods.\n"
192     "                                      Default: '0:4294967295'\n"
193     "--compiler-codegen-options:           Compile options passed to codegen. Default: ''\n"
194     "--compiler-opt-escape-analysis:       Enable escape analysis for aot compiler. Default: 'true'\n"
195     "--compiler-trace-escape-analysis:     Enable tracing escape analysis for aot compiler. Default: 'false'\n"
196     "--compiler-opt-induction-variable:    Enable induciton variable analysis for aot compiler. Default: 'false'\n"
197     "--compiler-trace-induction-variable:  Enable tracing induction variable for aot compiler. Default: 'false'\n"
198     "--compiler-memory-analysis:           Enable memory analysis for aot compiler. Default: 'true'\n"
199     "--compiler-enable-jit-fast-compile:   Enable jit fast compile. Default: 'false'\n"
200     "--compiler-enable-jitfort:            Enable jit fort memory space. Default: 'false'\n"
201     "--compiler-codesign-disable:          Disable codesign for jit fort. Default: 'true'\n"
202     "--compiler-enable-async-copytofort:   Enable jit fort allocation and code copy in Jit thread. Default: 'true'\n"
203     "--compiler-pgo-force-dump:            Enable pgo dump not interrupted by GC. Default: 'true'\n"
204     "--async-load-abc:                     Enable asynchronous load abc. Default: 'true'\n"
205     "--async-load-abc-test:                Enable asynchronous load abc test. Default: 'false'\n"
206     "--compiler-enable-store-barrier:      Enable store barrier optimization. Default: 'true'\n"
207     "--compiler-enable-ldobjvalue-opt:     Enable ldobjvalue optimization. Default: 'true'\n"
208     "--compiler-enable-concurrent:         Enable concurrent compile(only support in ark_stub_compiler).\n"
209     "--compile-enable-jit-verify-pass:     Enable jit compile with verify pass. Default: 'false'\n\n"
210     "                                      Default: 'true'\n"
211     "--compiler-opt-frame-state-elimination: Enable frame state elimination. Default: 'true'\n"
212     "--enable-inline-property-optimization:  Enable inline property optimization(also enable slack tracking).\n"
213     "--compiler-enable-aot-code-comment    Enable generate aot_code_comment.txt file during compilation.\n"
214     "                                      Default : 'false'\n"
215     "--compiler-enable-aot-lazy-deopt:     Enable lazy deopt for aot compiler. Default: 'false'\n"
216     "--compiler-enable-jit-lazy-deopt:     Enable lazy deopt for jit compiler. Default: 'false'\n"
217     "--compiler-an-file-max-size:          Max size of compiler .an file in MB. '0' means Default\n"
218     "                                      Default: No limit for Host, '100' for TargetCompilerMode\n"
219     "--compiler-jit-method-dichotomy:      Find problematic method by dichotomy. Default: 'disable'\n"
220     "                                      'collect': collect methods during JIT runtime.\n"
221     "                                      'filter': only compile specified methods during JIT runtime.\n"
222     "--compiler-jit-method-path:           Store method names for jit method dichotomy.\n"
223     "                                      Default: 'method_compiled_by_jit.cfg'\n"
224     "--compiler-enable-merge-poly:         Enable poly-merge optimization for ldobjbyname. Default: 'true'\n"
225     // Please add new options above this line for keep a blank line after help message.
226     "\n";
227 
ParseCommand(const int argc,const char ** argv)228 bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
229 {
230     const struct option longOptions[] = {
231         {"help", no_argument, nullptr, OPTION_HELP},
232         {"aot-file", required_argument, nullptr, OPTION_AOT_FILE},
233         {"ark-properties", required_argument, nullptr, OPTION_ARK_PROPERTIES},
234         {"ark-bundleName", required_argument, nullptr, OPTION_ARK_BUNDLENAME},
235         {"asm-interpreter", required_argument, nullptr, OPTION_ENABLE_ASM_INTERPRETER},
236         {"asm-opcode-disable-range", required_argument, nullptr, OPTION_ASM_OPCODE_DISABLE_RANGE},
237         {"builtins-lazy", required_argument, nullptr, OPTION_ENABLE_BUILTINS_LAZY},
238         {"compiler-log", required_argument, nullptr, OPTION_COMPILER_LOG_OPT},
239         {"compiler-log-methods", required_argument, nullptr, OPTION_COMPILER_LOG_METHODS},
240         {"compiler-log-snapshot", required_argument, nullptr, OPTION_COMPILER_LOG_SNAPSHOT},
241         {"compiler-log-time", required_argument, nullptr, OPTION_COMPILER_LOG_TIME},
242         {"compiler-type-threshold", required_argument, nullptr, OPTION_COMPILER_TYPE_THRESHOLD},
243         {"enable-ark-tools", required_argument, nullptr, OPTION_ENABLE_ARK_TOOLS},
244         {"open-ark-tools", required_argument, nullptr, OPTION_OPEN_ARK_TOOLS},
245         {"pgo-trace", required_argument, nullptr, OPTION_PGO_TRACE},
246         {"compiler-trace-bc", required_argument, nullptr, OPTION_COMPILER_TRACE_BC},
247         {"compiler-trace-deopt", required_argument, nullptr, OPTION_COMPILER_TRACE_DEOPT},
248         {"compiler-trace-inline", required_argument, nullptr, OPTION_COMPILER_TRACE_INLINE},
249         {"compiler-trace-value-numbering", required_argument, nullptr, OPTION_COMPILER_TRACE_VALUE_NUMBERING},
250         {"compiler-trace-instruction-combine", required_argument, nullptr, OPTION_COMPILER_TRACE_INSTRUCTION_COMBINE},
251         {"compiler-max-inline-bytecodes", required_argument, nullptr, OPTION_COMPILER_MAX_INLINE_BYTECODES},
252         {"compiler-deopt-threshold", required_argument, nullptr, OPTION_COMPILER_DEOPT_THRESHOLD},
253         {"compiler-device-state", required_argument, nullptr, OPTION_COMPILER_DEVICE_STATE},
254         {"compiler-thermal-level", required_argument, nullptr, OPTION_COMPILER_THERMAL_LEVEL},
255         {"compiler-stress-deopt", required_argument, nullptr, OPTION_COMPILER_STRESS_DEOPT},
256         {"compiler-opt-code-profiler", required_argument, nullptr, OPTION_COMPILER_OPT_CODE_PROFILER},
257         {"compiler-opt-bc-range", required_argument, nullptr, OPTION_COMPILER_OPT_BC_RANGE},
258         {"compiler-opt-bc-range-help", required_argument, nullptr, OPTION_COMPILER_OPT_BC_RANGE_HELP},
259         {"enable-loading-stubs-log", required_argument, nullptr, OPTION_ENABLE_LOADING_STUBS_LOG},
260         {"enable-force-gc", required_argument, nullptr, OPTION_ENABLE_FORCE_GC},
261         {"enable-cmc-gc", required_argument, nullptr, OPTION_ENABLE_CMC_GC},
262         {"cmc-max-garbage-cache-size", required_argument, nullptr, OPTION_MAX_GARBAGE_CACHE_SIZE},
263         {"enable-cmc-gc-concurrent-root-marking", required_argument, nullptr,
264          OPTION_ENABLE_CMC_GC_CONCURRENT_ROOT_MARKING},
265         {"enable-ic", required_argument, nullptr, OPTION_ENABLE_IC},
266         {"enable-runtime-stat", required_argument, nullptr, OPTION_ENABLE_RUNTIME_STAT},
267         {"compiler-opt-constant-folding", required_argument, nullptr, OPTION_COMPILER_OPT_CONSTANT_FOLDING},
268         {"compiler-opt-array-bounds-check-elimination", required_argument, nullptr,
269          OPTION_COMPILER_OPT_ARRAY_BOUNDS_CHECK_ELIMINATION},
270         {"compiler-opt-type-lowering", required_argument, nullptr, OPTION_COMPILER_OPT_TYPE_LOWERING},
271         {"compiler-opt-early-elimination", required_argument, nullptr, OPTION_COMPILER_OPT_EARLY_ELIMINATION},
272         {"compiler-opt-later-elimination", required_argument, nullptr, OPTION_COMPILER_OPT_LATER_ELIMINATION},
273         {"compiler-opt-instr-combine", required_argument, nullptr, OPTION_COMPILER_OPT_INSTRUCTIONE_COMBINE},
274         {"compiler-opt-string", required_argument, nullptr, OPTION_COMPILER_OPT_STRING},
275         {"compiler-opt-value-numbering", required_argument, nullptr, OPTION_COMPILER_OPT_VALUE_NUMBERING},
276         {"compiler-opt-new-value-numbering", required_argument, nullptr, OPTION_COMPILER_OPT_NEW_VALUE_NUMBERING},
277         {"compiler-opt-inlining", required_argument, nullptr, OPTION_COMPILER_OPT_INLINING},
278         {"compiler-opt-pgotype", required_argument, nullptr, OPTION_COMPILER_OPT_PGOTYPE},
279         {"compiler-opt-track-field", required_argument, nullptr, OPTION_COMPILER_OPT_TRACK_FIELD},
280         {"entry-point", required_argument, nullptr, OPTION_ENTRY_POINT},
281         {"force-full-gc", required_argument, nullptr, OPTION_FORCE_FULL_GC},
282         {"force-shared-gc-frequency", required_argument, nullptr, OPTION_ENABLE_FORCE_SHARED_GC_FREQUENCY},
283         {"enable-heap-verify", required_argument, nullptr, OPTION_ENABLE_HEAP_VERIFY},
284         {"gc-thread-num", required_argument, nullptr, OPTION_GC_THREADNUM},
285         {"icu-data-path", required_argument, nullptr, OPTION_ICU_DATA_PATH},
286         {"enable-worker", required_argument, nullptr, OPTION_ENABLE_WORKER},
287         {"log-components", required_argument, nullptr, OPTION_LOG_COMPONENTS},
288         {"log-debug", required_argument, nullptr, OPTION_LOG_DEBUG},
289         {"log-error", required_argument, nullptr, OPTION_LOG_ERROR},
290         {"log-fatal", required_argument, nullptr, OPTION_LOG_FATAL},
291         {"log-info", required_argument, nullptr, OPTION_LOG_INFO},
292         {"log-level", required_argument, nullptr, OPTION_LOG_LEVEL},
293         {"log-warning", required_argument, nullptr, OPTION_LOG_WARNING},
294         {"gc-long-paused-time", required_argument, nullptr, OPTION_GC_LONG_PAUSED_TIME},
295         {"compiler-opt-max-method", required_argument, nullptr, OPTION_COMPILER_OPT_MAX_METHOD},
296         {"compiler-module-methods", required_argument, nullptr, OPTION_COMPILER_MODULE_METHODS},
297         {"max-unmovable-space", required_argument, nullptr, OPTION_MAX_UNMOVABLE_SPACE},
298         {"merge-abc", required_argument, nullptr, OPTION_MERGE_ABC},
299         {"enable-context", required_argument, nullptr, OPTION_ENABLE_CONTEXT},
300         {"compiler-opt-level", required_argument, nullptr, OPTION_ASM_OPT_LEVEL},
301         {"reloc-mode", required_argument, nullptr, OPTION_RELOCATION_MODE},
302         {"serializer-buffer-size-limit", required_argument, nullptr, OPTION_SERIALIZER_BUFFER_SIZE_LIMIT},
303         {"startup-time", required_argument, nullptr, OPTION_STARTUP_TIME},
304         {"stub-file", required_argument, nullptr, OPTION_STUB_FILE},
305         {"compiler-target-triple", required_argument, nullptr, OPTION_COMPILER_TARGET_TRIPLE},
306         {"enable-print-execute-time", required_argument, nullptr, OPTION_PRINT_EXECUTE_TIME},
307         {"enable-pgo-profiler", required_argument, nullptr, OPTION_ENABLE_PGO_PROFILER},
308         {"enable-mutant-array", required_argument, nullptr, OPTION_ENABLE_MUTANT_ARRAY},
309         {"enable-elements-kind", required_argument, nullptr, OPTION_ENABLE_ELEMENTS_KIND},
310         {"compiler-pgo-profiler-path", required_argument, nullptr, OPTION_COMPILER_PGO_PROFILER_PATH},
311         {"compiler-pgo-hotness-threshold", required_argument, nullptr, OPTION_COMPILER_PGO_HOTNESS_THRESHOLD},
312         {"compiler-pgo-save-min-interval", required_argument, nullptr, OPTION_COMPILER_PGO_SAVE_MIN_INTERVAL},
313         {"compiler-baseline-pgo", required_argument, nullptr, OPTION_COMPILER_BASELINE_PGO},
314         {"compiler-verify-vtable", required_argument, nullptr, OPTION_COMPILER_VERIFY_VTABLE},
315         {"compiler-select-methods", required_argument, nullptr, OPTION_COMPILER_SELECT_METHODS},
316         {"compiler-skip-methods", required_argument, nullptr, OPTION_COMPILER_SKIP_METHODS},
317         {"target-compiler-mode", required_argument, nullptr, OPTION_TARGET_COMPILER_MODE},
318         {"hap-path", required_argument, nullptr, OPTION_HAP_PATH},
319         {"hap-abc-offset", required_argument, nullptr, OPTION_HAP_ABC_OFFSET},
320         {"hap-abc-size", required_argument, nullptr, OPTION_HAP_ABC_SIZE},
321         {"compiler-no-check", required_argument, nullptr, OPTION_COMPILER_NOCHECK},
322         {"compiler-pipeline-host-aot", required_argument, nullptr, OPTION_COMPILER_PIPELINE_HOST_AOT},
323         {"compiler-fast-compile", required_argument, nullptr, OPTION_FAST_AOT_COMPILE_MODE},
324         {"compiler-opt-loop-peeling", required_argument, nullptr, OPTION_COMPILER_OPT_LOOP_PEELING},
325         {"compiler-opt-array-onheap-check", required_argument, nullptr, OPTION_COMPILER_OPT_ON_HEAP_CHECK},
326         {"compiler-pkg-info", required_argument, nullptr, OPTION_COMPILER_PKG_INFO},
327         {"compiler-external-pkg-info", required_argument, nullptr, OPTION_COMPILER_EXTERNAL_PKG_INFO},
328         {"compiler-enable-external-pkg", required_argument, nullptr, OPTION_COMPILER_ENABLE_EXTERNAL_PKG},
329         {"compiler-framework-abc-path", required_argument, nullptr, OPTION_COMPILER_FRAMEWORK_ABC_PATH},
330         {"compiler-enable-lexenv-specialization", required_argument, nullptr,
331          OPTION_COMPILER_ENABLE_LEXENV_SPECIALIZATION},
332         {"compiler-enable-native-inline", required_argument, nullptr, OPTION_COMPILER_ENABLE_NATIVE_INLINE},
333         {"compiler-enable-lowering-builtin", required_argument, nullptr, OPTION_COMPILER_ENABLE_LOWERING_BUILTIN},
334         {"compiler-enable-litecg", required_argument, nullptr, OPTION_COMPILER_ENABLE_LITECG},
335         {"compiler-enable-jit", required_argument, nullptr, OPTION_COMPILER_ENABLE_JIT},
336         {"compiler-enable-dfx-hisys-event", required_argument, nullptr, OPTION_COMPILER_ENABLE_DFX_HISYS_EVENT},
337         {"compiler-enable-osr", required_argument, nullptr, OPTION_COMPILER_ENABLE_OSR},
338         {"compiler-trace-jit", required_argument, nullptr, OPTION_COMPILER_TRACE_JIT},
339         {"compiler-jit-hotness-threshold", required_argument, nullptr, OPTION_COMPILER_JIT_HOTNESS_THRESHOLD},
340         {"compiler-jit-call-threshold", required_argument, nullptr, OPTION_COMPILER_JIT_CALL_THRESHOLD},
341         {"compiler-osr-hotness-threshold", required_argument, nullptr, OPTION_COMPILER_OSR_HOTNESS_THRESHOLD},
342         {"compiler-force-jit-compile-main", required_argument, nullptr, OPTION_COMPILER_FORCE_JIT_COMPILE_MAIN},
343         {"compiler-enable-jit-pgo", required_argument, nullptr, OPTION_COMPILER_ENABLE_JIT_PGO},
344         {"compiler-enable-aot-pgo", required_argument, nullptr, OPTION_COMPILER_ENABLE_AOT_PGO},
345         {"compiler-enable-framework-aot", required_argument, nullptr, OPTION_COMPILER_ENABLE_FRAMEWORK_AOT},
346         {"compiler-enable-profile-dump", required_argument, nullptr, OPTION_COMPILER_ENABLE_PROPFILE_DUMP},
347         {"compiler-typed-op-profiler", required_argument, nullptr, OPTION_COMPILER_TYPED_OP_PROFILER},
348         {"compiler-opt-branch-profiling", required_argument, nullptr, OPTION_COMPILER_OPT_BRANCH_PROFILING},
349         {"test-assert", required_argument, nullptr, OPTION_TEST_ASSERT},
350         {"compiler-methods-range", required_argument, nullptr, OPTION_COMPILER_METHODS_RANGE},
351         {"compiler-codegen-options", required_argument, nullptr, OPTION_COMPILER_CODEGEN_OPT},
352         {"compiler-opt-escape-analysis", required_argument, nullptr, OPTION_COMPILER_OPT_ESCAPE_ANALYSIS},
353         {"compiler-trace-escape-analysis", required_argument, nullptr, OPTION_COMPILER_TRACE_ESCAPE_ANALYSIS},
354         {"compiler-opt-induction-variable", required_argument, nullptr, OPTION_COMPILER_OPT_INDUCTION_VARIABLE},
355         {"compiler-trace-induction-variable", required_argument, nullptr, OPTION_COMPILER_TRACE_INDUCTION_VARIABLE},
356         {"compiler-memory-analysis", required_argument, nullptr, OPTION_COMPILER_MEMORY_ANALYSIS},
357         {"compiler-check-pgo-version", required_argument, nullptr, OPTION_COMPILER_CHECK_PGO_VERSION},
358         {"compiler-enable-mega-ic", required_argument, nullptr, OPTION_COMPILER_ENABLE_MEGA_IC},
359         {"compiler-enable-baselinejit", required_argument, nullptr, OPTION_COMPILER_ENABLE_BASELINEJIT},
360         {"compiler-baselinejit-hotness-threshold", required_argument, nullptr,
361          OPTION_COMPILER_BASELINEJIT_HOTNESS_THRESHOLD},
362         {"compiler-force-baselinejit-compile-main", required_argument, nullptr,
363          OPTION_COMPILER_FORCE_BASELINEJIT_COMPILE_MAIN},
364         {"compiler-enable-jit-fast-compile", required_argument, nullptr, OPTION_COMPILER_ENABLE_JIT_FAST_COMPILE},
365         {"compiler-enable-jitfort", required_argument, nullptr, OPTION_ENABLE_JITFORT},
366         {"compiler-codesign-disable", required_argument, nullptr, OPTION_CODESIGN_DISABLE},
367         {"compiler-enable-async-copytofort", required_argument, nullptr, OPTION_ENABLE_ASYNC_COPYTOFORT},
368         {"compiler-pgo-force-dump", required_argument, nullptr, OPTION_COMPILER_PGO_FORCE_DUMP},
369         {"compiler-enable-pgo-space", required_argument, nullptr, OPTION_COMPILER_ENABLE_PGO_SPACE},
370         {"async-load-abc", required_argument, nullptr, OPTION_ASYNC_LOAD_ABC},
371         {"async-load-abc-test", required_argument, nullptr, OPTION_ASYNC_LOAD_ABC_TEST},
372         {"compiler-enable-store-barrier", required_argument, nullptr, OPTION_COMPILER_ENABLE_STORE_BARRIER_OPT},
373         {"compiler-enable-ldobjvalue-opt", required_argument, nullptr, OPTION_COMPILER_ENABLE_LDOBJVALUE_OPT},
374         {"compiler-enable-concurrent", required_argument, nullptr, OPTION_COMPILER_ENABLE_CONCURRENT},
375         {"compiler-opt-frame-state-elimination", required_argument, nullptr,
376          OPTION_COMPILER_OPT_FRAME_STATE_ELIMINATION},
377         {"enable-inline-property-optimization", required_argument, nullptr, OPTION_ENABLE_INLINE_PROPERTY_OPTIMIZATION},
378         {"compiler-enable-aot-code-comment", required_argument, nullptr, OPTION_COMPILER_ENABLE_AOT_CODE_COMMENT},
379         {"compiler-enable-aot-lazy-deopt", required_argument, nullptr, OPTION_COMPILER_ENABLE_AOT_LAZY_DEOPT},
380         {"compiler-enable-jit-lazy-deopt", required_argument, nullptr, OPTION_COMPILER_ENABLE_JIT_LAZY_DEOPT},
381         {"compiler-enable-lazy-deopt-trace", required_argument, nullptr, OPTION_COMPILER_ENABLE_LAZY_DEOPT_TRACE},
382         {"compiler-an-file-max-size", required_argument, nullptr, OPTION_COMPILER_AN_FILE_MAX_SIZE},
383         {"compiler-trace-builtins", required_argument, nullptr, OPTION_COMPILER_TRACE_BUILTINS},
384         {"compile-enable-jit-verify-pass", required_argument, nullptr, OPTION_ENABLE_JIT_VERIFY_PASS},
385         {"compiler-jit-method-dichotomy", required_argument, nullptr, OPTION_COMPILER_JIT_METHOD_DICHOTOMY},
386         {"compiler-jit-method-path", required_argument, nullptr, OPTION_COMPILER_JIT_METHOD_PATH},
387         {"compiler-enable-merge-poly", required_argument, nullptr, OPTION_COMPILER_ENABLE_MERGE_POLY},
388         {"mem-config", required_argument, nullptr, OPTION_MEM_CONFIG},
389         {"multi-context", required_argument, nullptr, OPTION_MULTI_CONTEXT},
390         {nullptr, 0, nullptr, 0},
391     };
392 
393     int index = 0;
394     opterr = 0;
395     bool ret = false;
396     int option = 0;
397     arg_list_t argListStr;
398     uint32_t argUint32 = 0;
399     uint64_t argUInt64 = 0;
400     int argInt = 0;
401     bool argBool = false;
402     double argDouble = 0.0;
403     static std::string COLON = ":";
404 
405     if (argc <= 1) {
406         return true;
407     }
408 
409     while (true) {
410         option = getopt_long_only(argc, const_cast<char **>(argv), "", longOptions, &index);
411         LOG_ECMA(INFO) << "option: " << option << ", optopt: " << optopt << ", optind: " << optind;
412 
413         if (optind <= 0 || optind > argc) {
414             return false;
415         }
416 
417         if (option == -1) {
418             // set dependency between options at here
419             if (!IsEnableElementsKind() && IsEnableMutantArray()) {
420                 LOG_ECMA(ERROR) << "'enable-mutant-array' must set to false while 'enable-elements-kind' is disabled\n";
421                 return false;
422             }
423             return true;
424         }
425 
426         SetOption(option);
427         // unknown option or required_argument option has no argument
428         if (option == OPTION_DEFAULT) {
429             ret = SetDefaultValue(const_cast<char *>(argv[optind - 1]));
430             if (ret) {
431                 continue;
432             } else {
433                 return ret;
434             }
435         }
436 
437         switch (option) {
438             case OPTION_AOT_FILE:
439                 SetAOTOutputFile(optarg);
440                 ecmascript::AnFileDataManager::GetInstance()->SetEnable(true);
441                 break;
442             case OPTION_ARK_PROPERTIES:
443                 ret = ParseIntParam("ark-properties", &argInt);
444                 if (ret) {
445                     SetArkProperties(argInt);
446                 } else {
447                     return false;
448                 }
449                 break;
450             case OPTION_ARK_BUNDLENAME:
451                 SetArkBundleName(optarg);
452                 break;
453             case OPTION_ENABLE_ASM_INTERPRETER:
454                 ret = ParseBoolParam(&argBool);
455                 if (ret) {
456                     SetEnableAsmInterpreter(argBool);
457                 } else {
458                     return false;
459                 }
460                 break;
461             case OPTION_ASM_OPCODE_DISABLE_RANGE:
462                 SetAsmOpcodeDisableRange(optarg);
463                 break;
464             case OPTION_ENABLE_BUILTINS_LAZY:
465                 ret = ParseBoolParam(&argBool);
466                 if (ret) {
467                     SetEnableBuiltinsLazy(argBool);
468                 } else {
469                     return false;
470                 }
471                 break;
472             case OPTION_COMPILER_LOG_OPT:
473                 SetCompilerLogOption(optarg);
474                 break;
475             case OPTION_COMPILER_LOG_SNAPSHOT:
476                 ret = ParseBoolParam(&argBool);
477                 if (ret) {
478                     SetCompilerLogSnapshot(argBool);
479                 } else {
480                     return false;
481                 }
482                 break;
483             case OPTION_COMPILER_LOG_TIME:
484                 ret = ParseBoolParam(&argBool);
485                 if (ret) {
486                     SetCompilerLogTime(argBool);
487                 } else {
488                     return false;
489                 }
490                 break;
491             case OPTION_ENABLE_ARK_TOOLS:
492                 ret = ParseBoolParam(&argBool);
493                 if (ret) {
494                     SetEnableArkTools(argBool);
495                 } else {
496                     return false;
497                 }
498                 break;
499             case OPTION_OPEN_ARK_TOOLS:
500                 ret = ParseBoolParam(&argBool);
501                 if (ret) {
502                     SetOpenArkTools(argBool);
503                 } else {
504                     return false;
505                 }
506                 break;
507             case OPTION_PGO_TRACE:
508                 ret = ParseBoolParam(&argBool);
509                 if (ret) {
510                     SetPGOTrace(argBool);
511                 } else {
512                     return false;
513                 }
514                 break;
515             case OPTION_COMPILER_TRACE_BC:
516                 ret = ParseBoolParam(&argBool);
517                 if (ret) {
518                     SetTraceBc(argBool);
519                 } else {
520                     return false;
521                 }
522                 break;
523             case OPTION_COMPILER_TRACE_DEOPT:
524                 ret = ParseBoolParam(&argBool);
525                 if (ret) {
526                     SetTraceDeopt(argBool);
527                 } else {
528                     return false;
529                 }
530                 break;
531             case OPTION_COMPILER_TRACE_INLINE:
532                 ret = ParseBoolParam(&argBool);
533                 if (ret) {
534                     SetTraceInline(argBool);
535                 } else {
536                     return false;
537                 }
538                 break;
539             case OPTION_COMPILER_TRACE_VALUE_NUMBERING:
540                 ret = ParseBoolParam(&argBool);
541                 if (ret) {
542                     SetTraceValueNumbering(argBool);
543                 } else {
544                     return false;
545                 }
546                 break;
547             case OPTION_COMPILER_TRACE_INSTRUCTION_COMBINE:
548                 ret = ParseBoolParam(&argBool);
549                 if (ret) {
550                     SetTraceInstructionCombine(argBool);
551                 } else {
552                     return false;
553                 }
554                 break;
555             case OPTION_COMPILER_MAX_INLINE_BYTECODES:
556                 ret = ParseUint32Param("max-inline-bytecodes", &argUint32);
557                 if (ret) {
558                     SetMaxInlineBytecodes(argUint32);
559                 } else {
560                     return false;
561                 }
562                 break;
563             case OPTION_COMPILER_DEOPT_THRESHOLD:
564                 ret = ParseUint32Param("deopt-threshol", &argUint32);
565                 if (ret) {
566                     SetDeoptThreshold(argUint32);
567                 } else {
568                     return false;
569                 }
570                 break;
571             case OPTION_COMPILER_DEVICE_STATE:
572                 ret = ParseBoolParam(&argBool);
573                 if (ret) {
574                     SetDeviceState(argBool);
575                 } else {
576                     return false;
577                 }
578                 break;
579             case OPTION_COMPILER_THERMAL_LEVEL:
580                 ret = ParseIntParam("compiler-thermal-level", &argInt);
581                 if (ret) {
582                     SetThermalLevel(argInt);
583                 } else {
584                     return false;
585                 }
586                 break;
587             case OPTION_COMPILER_STRESS_DEOPT:
588                 ret = ParseBoolParam(&argBool);
589                 if (ret) {
590                     SetStressDeopt(argBool);
591                 } else {
592                     return false;
593                 }
594                 break;
595             case OPTION_COMPILER_OPT_CODE_PROFILER:
596                 ret = ParseBoolParam(&argBool);
597                 if (ret) {
598                     SetOptCodeProfiler(argBool);
599                 } else {
600                     return false;
601                 }
602                 break;
603             case OPTION_COMPILER_OPT_BC_RANGE:
604                 SetOptCodeRange(optarg);
605                 break;
606             case OPTION_COMPILER_OPT_BC_RANGE_HELP:
607                 ret = ParseBoolParam(&argBool);
608                 if (ret) {
609                     std::string helpInfo = kungfu::GetHelpForEcmaCodeListForRange();
610                     LOG_COMPILER(ERROR) << helpInfo.c_str();
611                     exit(1);
612                 }
613                 break;
614             case OPTION_ENABLE_FORCE_GC:
615                 ret = ParseBoolParam(&argBool);
616                 if (ret) {
617                     SetEnableForceGC(argBool);
618                 } else {
619                     return false;
620                 }
621                 break;
622             case OPTION_ENABLE_CMC_GC:
623                 ret = ParseBoolParam(&argBool);
624                 if (ret) {
625                     SetEnableCMCGC(argBool);
626                 } else {
627                     return false;
628                 }
629                 break;
630             case OPTION_MAX_GARBAGE_CACHE_SIZE:
631                 ret = ParseUint64Param("cmc-max-garbage-cache-size", &argUInt64);
632                 if (ret) {
633                     SetCMCMaxGarbageCacheSize(argUInt64);
634                 } else {
635                     return false;
636                 }
637                 break;
638             case OPTION_ENABLE_CMC_GC_CONCURRENT_ROOT_MARKING:
639                 ret = ParseBoolParam(&argBool);
640                 if (ret) {
641                     SetEnableCMCGCConcurrentRootMarking(argBool);
642                 } else {
643                     return false;
644                 }
645                 break;
646             case OPTION_ENABLE_LOADING_STUBS_LOG:
647                 ret = ParseBoolParam(&argBool);
648                 if (ret) {
649                     SetEnableLoadingStubsLog(argBool);
650                 } else {
651                     return false;
652                 }
653                 break;
654             case OPTION_FORCE_FULL_GC:
655                 ret = ParseBoolParam(&argBool);
656                 if (ret) {
657                     SetForceFullGC(argBool);
658                 } else {
659                     return false;
660                 }
661                 break;
662             case OPTION_ENABLE_FORCE_SHARED_GC_FREQUENCY:
663                 ret = ParseUint32Param("force-shared-gc-frequency", &argUint32);
664                 if (ret) {
665                     SetForceSharedGCFrequency(argUint32);
666                 } else {
667                     return false;
668                 }
669                 break;
670             case OPTION_ENABLE_HEAP_VERIFY:
671                 ret = ParseBoolParam(&argBool);
672                 if (ret) {
673                     SetEnableHeapVerify(argBool);
674                 } else {
675                     return false;
676                 }
677                 break;
678             case OPTION_ENABLE_IC:
679                 ret = ParseBoolParam(&argBool);
680                 if (ret) {
681                     SetEnableIC(argBool);
682                 } else {
683                     return false;
684                 }
685                 break;
686             case OPTION_ENABLE_RUNTIME_STAT:
687                 ret = ParseBoolParam(&argBool);
688                 if (ret) {
689                     SetEnableRuntimeStat(argBool);
690                 } else {
691                     return false;
692                 }
693                 break;
694             case OPTION_GC_THREADNUM:
695                 ret = ParseUint32Param("gc-thread-num", &argUint32);
696                 if (ret) {
697                     SetGcThreadNum(argUint32);
698                 } else {
699                     return false;
700                 }
701                 break;
702             case OPTION_HELP:
703                 return false;
704             case OPTION_ICU_DATA_PATH:
705                 SetIcuDataPath(optarg);
706                 break;
707             case OPTION_ENABLE_WORKER:
708                 ret = ParseBoolParam(&argBool);
709                 if (ret) {
710                     SetIsWorker(argBool);
711                 } else {
712                     return false;
713                 }
714                 break;
715             case OPTION_LOG_COMPONENTS:
716                 ParseListArgParam(optarg, &argListStr, COLON);
717                 SetLogComponents(argListStr);
718                 break;
719             case OPTION_LOG_DEBUG:
720                 ParseListArgParam(optarg, &argListStr, COLON);
721                 SetLogDebug(argListStr);
722                 break;
723             case OPTION_LOG_ERROR:
724                 ParseListArgParam(optarg, &argListStr, COLON);
725                 SetLogError(argListStr);
726                 break;
727             case OPTION_LOG_FATAL:
728                 ParseListArgParam(optarg, &argListStr, COLON);
729                 SetLogFatal(argListStr);
730                 break;
731             case OPTION_LOG_INFO:
732                 ParseListArgParam(optarg, &argListStr, COLON);
733                 SetLogInfo(argListStr);
734                 break;
735             case OPTION_LOG_LEVEL:
736                 SetLogLevel(optarg);
737                 break;
738             case OPTION_LOG_WARNING:
739                 ParseListArgParam(optarg, &argListStr, COLON);
740                 SetLogWarning(argListStr);
741                 break;
742             case OPTION_GC_LONG_PAUSED_TIME:
743                 ret = ParseUint32Param("gc-long-paused-time", &argUint32);
744                 if (ret) {
745                     SetLongPauseTime(argUint32);
746                 } else {
747                     return false;
748                 }
749                 break;
750             case OPTION_COMPILER_OPT_MAX_METHOD:
751                 ret = ParseUint32Param("compiler-opt-max-method", &argUint32);
752                 if (ret) {
753                     SetMaxAotMethodSize(argUint32);
754                 } else {
755                     return false;
756                 }
757                 break;
758             case OPTION_COMPILER_MODULE_METHODS:
759                 ret = ParseUint32Param("compiler-module-methods", &argUint32);
760                 if (!ret) {
761                     return false;
762                 }
763                 SetCompilerModuleMethods(argUint32);
764                 break;
765             case OPTION_COMPILER_TYPE_THRESHOLD:
766                 ret = ParseDoubleParam("compiler-type-threshold", &argDouble);
767                 if (ret) {
768                     SetTypeThreshold(argDouble);
769                 } else {
770                     return false;
771                 }
772                 break;
773             case OPTION_MAX_UNMOVABLE_SPACE:
774                 ret = ParseUint32Param("max-unmovable-space", &argUint32);
775                 if (ret) {
776                     SetMaxNonmovableSpaceCapacity(argUint32);
777                 } else {
778                     return false;
779                 }
780                 break;
781             case OPTION_COMPILER_LOG_METHODS:
782                 SetMethodsListForLog(optarg);
783                 break;
784             case OPTION_ASM_OPT_LEVEL:
785                 ret = ParseUint32Param("compiler-opt-level", &argUint32);
786                 if (ret) {
787                     SetOptLevel(argUint32);
788                 } else {
789                     return false;
790                 }
791                 break;
792             case OPTION_PRINT_EXECUTE_TIME:
793                 ret = ParseBoolParam(&argBool);
794                 if (ret) {
795                     SetEnablePrintExecuteTime(argBool);
796                 } else {
797                     return false;
798                 }
799                 break;
800             case OPTION_ENABLE_PGO_PROFILER:
801                 ret = ParseBoolParam(&argBool);
802                 if (ret) {
803                     SetEnablePGOProfiler(argBool);
804                 } else {
805                     return false;
806                 }
807                 break;
808             case OPTION_ENABLE_MUTANT_ARRAY:
809                 ret = ParseBoolParam(&argBool);
810                 if (ret) {
811                     SetEnableMutantArray(argBool);
812                 } else {
813                     return false;
814                 }
815                 break;
816             case OPTION_ENABLE_ELEMENTS_KIND:
817                 ret = ParseBoolParam(&argBool);
818                 if (ret) {
819                     SetEnableElementsKind(argBool);
820                 } else {
821                     return false;
822                 }
823                 break;
824             case OPTION_COMPILER_PGO_PROFILER_PATH:
825                 if (*optarg == '\0') {
826                     return false;
827                 }
828                 SetPGOProfilerPath(optarg);
829                 break;
830             case OPTION_COMPILER_PGO_HOTNESS_THRESHOLD:
831                 ret = ParseUint32Param("pgo-hotness-threshold", &argUint32);
832                 if (ret) {
833                     SetPGOHotnessThreshold(argUint32);
834                 } else {
835                     return false;
836                 }
837                 break;
838             case OPTION_COMPILER_PGO_SAVE_MIN_INTERVAL:
839                 ret = ParseUint32Param("compiler-pgo-save-min-interval", &argUint32);
840                 if (ret) {
841                     SetPGOSaveMinInterval(argUint32);
842                 } else {
843                     return false;
844                 }
845                 break;
846             case OPTION_COMPILER_BASELINE_PGO:
847                 ret = ParseBoolParam(&argBool);
848                 if (ret) {
849                     SetEnableBaselinePgo(argBool);
850                 } else {
851                     return false;
852                 }
853                 break;
854             case OPTION_RELOCATION_MODE:
855                 ret = ParseUint32Param("reloc-mode", &argUint32);
856                 if (ret) {
857                     SetRelocMode(argUint32);
858                 } else {
859                     return false;
860                 }
861                 break;
862             case OPTION_SERIALIZER_BUFFER_SIZE_LIMIT:
863                 ret = ParseUint64Param("serializer-buffer-size-limit", &argUInt64);
864                 if (ret) {
865                     SetSerializerBufferSizeLimit(argUInt64);
866                 } else {
867                     return false;
868                 }
869                 break;
870             case OPTION_STARTUP_TIME:
871                 ret = ParseBoolParam(&argBool);
872                 if (ret) {
873                     SetStartupTime(argBool);
874                 } else {
875                     return false;
876                 }
877                 break;
878             case OPTION_STUB_FILE:
879                 SetStubFile(optarg);
880                 break;
881             case OPTION_COMPILER_TARGET_TRIPLE:
882                 SetTargetTriple(optarg);
883                 break;
884             case OPTION_ENTRY_POINT:
885                 SetEntryPoint(optarg);
886                 break;
887             case OPTION_MERGE_ABC:
888                 ret = ParseBoolParam(&argBool);
889                 if (ret) {
890                     SetMergeAbc(argBool);
891                 } else {
892                     return false;
893                 }
894                 break;
895             case OPTION_ENABLE_CONTEXT:
896                 ret = ParseBoolParam(&argBool);
897                 if (ret) {
898                     SetEnableContext(argBool);
899                 } else {
900                     return false;
901                 }
902                 break;
903             case OPTION_COMPILER_OPT_TYPE_LOWERING:
904                 ret = ParseBoolParam(&argBool);
905                 if (ret) {
906                     SetEnableTypeLowering(argBool);
907                 } else {
908                     return false;
909                 }
910                 break;
911             case OPTION_COMPILER_OPT_ARRAY_BOUNDS_CHECK_ELIMINATION:
912                 ret = ParseBoolParam(&argBool);
913                 if (ret) {
914                     SetEnableArrayBoundsCheckElimination(argBool);
915                 } else {
916                     return false;
917                 }
918                 break;
919             case OPTION_COMPILER_OPT_FRAME_STATE_ELIMINATION:
920                 ret = ParseBoolParam(&argBool);
921                 if (ret) {
922                     SetEnableFrameStateElimination(argBool);
923                 } else {
924                     return false;
925                 }
926                 break;
927             case OPTION_COMPILER_OPT_EARLY_ELIMINATION:
928                 ret = ParseBoolParam(&argBool);
929                 if (ret) {
930                     SetEnableEarlyElimination(argBool);
931                 } else {
932                     return false;
933                 }
934                 break;
935             case OPTION_COMPILER_OPT_LATER_ELIMINATION:
936                 ret = ParseBoolParam(&argBool);
937                 if (ret) {
938                     SetEnableLaterElimination(argBool);
939                 } else {
940                     return false;
941                 }
942                 break;
943             case OPTION_COMPILER_OPT_INSTRUCTIONE_COMBINE:
944                 ret = ParseBoolParam(&argBool);
945                 if (ret) {
946                     SetEnableInstrcutionCombine(argBool);
947                 } else {
948                     return false;
949                 }
950                 break;
951             case OPTION_COMPILER_OPT_STRING:
952                 ret = ParseBoolParam(&argBool);
953                 if (ret) {
954                     SetEnableOptString(argBool);
955                 } else {
956                     return false;
957                 }
958                 break;
959             case OPTION_COMPILER_OPT_VALUE_NUMBERING:
960                 ret = ParseBoolParam(&argBool);
961                 if (ret) {
962                     SetEnableValueNumbering(argBool);
963                 } else {
964                     return false;
965                 }
966                 break;
967             case OPTION_COMPILER_OPT_NEW_VALUE_NUMBERING:
968                 ret = ParseBoolParam(&argBool);
969                 if (ret) {
970                     SetEnableNewValueNumbering(argBool);
971                 } else {
972                     return false;
973                 }
974                 break;
975             case OPTION_COMPILER_OPT_INLINING:
976                 ret = ParseBoolParam(&argBool);
977                 if (ret) {
978                     SetEnableOptInlining(argBool);
979                 } else {
980                     return false;
981                 }
982                 break;
983             case OPTION_COMPILER_OPT_PGOTYPE:
984                 ret = ParseBoolParam(&argBool);
985                 if (ret) {
986                     SetEnableOptPGOType(argBool);
987                 } else {
988                     return false;
989                 }
990                 break;
991             case OPTION_COMPILER_OPT_TRACK_FIELD:
992                 ret = ParseBoolParam(&argBool);
993                 if (ret) {
994                     SetEnableOptTrackField(argBool);
995                 } else {
996                     return false;
997                 }
998                 break;
999             case OPTION_COMPILER_VERIFY_VTABLE:
1000                 ret = ParseBoolParam(&argBool);
1001                 if (ret) {
1002                     SetVerifyVTable(argBool);
1003                 } else {
1004                     return false;
1005                 }
1006                 break;
1007             case OPTION_COMPILER_SELECT_METHODS:
1008                 SetCompilerSelectMethods(optarg);
1009                 break;
1010             case OPTION_COMPILER_SKIP_METHODS:
1011                 SetCompilerSkipMethods(optarg);
1012                 break;
1013             case OPTION_TARGET_COMPILER_MODE:
1014                 SetTargetCompilerMode(optarg);
1015                 break;
1016             case OPTION_COMPILER_FRAMEWORK_ABC_PATH:
1017                 SetCompilerFrameworkAbcPath(optarg);
1018                 break;
1019             case OPTION_HAP_PATH:
1020                 SetHapPath(optarg);
1021                 break;
1022             case OPTION_HAP_ABC_OFFSET:
1023                 ret = ParseUint32Param("hap-abc-offset", &argUint32);
1024                 if (!ret) {
1025                     return false;
1026                 }
1027                 SetHapAbcOffset(argUint32);
1028                 break;
1029             case OPTION_HAP_ABC_SIZE:
1030                 ret = ParseUint32Param("hap-abc-size", &argUint32);
1031                 if (!ret) {
1032                     return false;
1033                 }
1034                 SetHapAbcSize(argUint32);
1035                 break;
1036             case OPTION_COMPILER_NOCHECK:
1037                 ret = ParseBoolParam(&argBool);
1038                 if (!ret) {
1039                     return false;
1040                 }
1041                 SetCompilerNoCheck(argBool);
1042                 break;
1043             case OPTION_COMPILER_PIPELINE_HOST_AOT:
1044                 ret = ParseBoolParam(&argBool);
1045                 if (!ret) {
1046                     return false;
1047                 }
1048                 SetCompilerPipelineHostAOT(argBool);
1049                 break;
1050             case OPTION_FAST_AOT_COMPILE_MODE:
1051                 ret = ParseBoolParam(&argBool);
1052                 if (!ret) {
1053                     return false;
1054                 }
1055                 SetFastAOTCompileMode(argBool);
1056                 break;
1057             case OPTION_COMPILER_OPT_CONSTANT_FOLDING:
1058                 ret = ParseBoolParam(&argBool);
1059                 if (ret) {
1060                     SetEnableOptConstantFolding(argBool);
1061                 } else {
1062                     return false;
1063                 }
1064                 break;
1065             case OPTION_COMPILER_OPT_LOOP_PEELING:
1066                 ret = ParseBoolParam(&argBool);
1067                 if (ret) {
1068                     SetEnableOptLoopPeeling(argBool);
1069                 } else {
1070                     return false;
1071                 }
1072                 break;
1073             case OPTION_COMPILER_OPT_ON_HEAP_CHECK:
1074                 ret = ParseBoolParam(&argBool);
1075                 if (ret) {
1076                     SetEnableOptOnHeapCheck(argBool);
1077                 } else {
1078                     return false;
1079                 }
1080                 break;
1081             case OPTION_COMPILER_PKG_INFO:
1082                 SetCompilerPkgJsonInfo(optarg);
1083                 break;
1084             case OPTION_COMPILER_EXTERNAL_PKG_INFO:
1085                 SetCompilerExternalPkgJsonInfo(optarg);
1086                 break;
1087             case OPTION_COMPILER_ENABLE_EXTERNAL_PKG:
1088                 ret = ParseBoolParam(&argBool);
1089                 if (ret) {
1090                     SetCompilerEnableExternalPkg(argBool);
1091                 } else {
1092                     return false;
1093                 }
1094                 break;
1095             case OPTION_COMPILER_ENABLE_LEXENV_SPECIALIZATION:
1096                 ret = ParseBoolParam(&argBool);
1097                 if (ret) {
1098                     SetEnableLexenvSpecialization(argBool);
1099                 } else {
1100                     return false;
1101                 }
1102                 break;
1103             case OPTION_COMPILER_ENABLE_NATIVE_INLINE:
1104                 ret = ParseBoolParam(&argBool);
1105                 if (ret) {
1106                     SetEnableNativeInline(argBool);
1107                 } else {
1108                     return false;
1109                 }
1110                 break;
1111             case OPTION_COMPILER_ENABLE_LOWERING_BUILTIN:
1112                 ret = ParseBoolParam(&argBool);
1113                 if (ret) {
1114                     SetEnableLoweringBuiltin(argBool);
1115                 } else {
1116                     return false;
1117                 }
1118                 break;
1119             case OPTION_COMPILER_ENABLE_LITECG:
1120                 ret = ParseBoolParam(&argBool);
1121                 if (ret) {
1122                     SetCompilerEnableLiteCG(argBool);
1123                 } else {
1124                     return false;
1125                 }
1126                 break;
1127             case OPTION_COMPILER_ENABLE_JIT:
1128                 ret = ParseBoolParam(&argBool);
1129                 if (ret) {
1130                     SetEnableJIT(argBool);
1131                 } else {
1132                     return false;
1133                 }
1134                 break;
1135             case OPTION_COMPILER_ENABLE_DFX_HISYS_EVENT:
1136                 ret = ParseBoolParam(&argBool);
1137                 if (ret) {
1138                     SetEnableDFXHiSysEvent(argBool);
1139                 } else {
1140                     return false;
1141                 }
1142                 break;
1143             case OPTION_COMPILER_ENABLE_OSR:
1144                 ret = ParseBoolParam(&argBool);
1145                 if (ret) {
1146                     SetEnableOSR(argBool);
1147                 } else {
1148                     return false;
1149                 }
1150                 break;
1151             case OPTION_COMPILER_JIT_HOTNESS_THRESHOLD:
1152                 ret = ParseUint32Param("compiler-jit-hotness-threshold", &argUint32);
1153                 if (ret) {
1154                     uint16_t val = argUint32 > std::numeric_limits<uint16_t>::max() ?
1155                         std::numeric_limits<uint16_t>::max() : static_cast<uint16_t>(argUint32);
1156                     SetJitHotnessThreshold(val);
1157                 } else {
1158                     return false;
1159                 }
1160                 break;
1161             case OPTION_COMPILER_JIT_CALL_THRESHOLD:
1162                 ret = ParseUint32Param("compiler-jit-call-threshold", &argUint32);
1163                 if (ret) {
1164                     uint16_t val =  argUint32 > std::numeric_limits<uint16_t>::max() ?
1165                         std::numeric_limits<uint16_t>::max() : static_cast<uint16_t>(argUint32);
1166                     SetJitCallThreshold(val);
1167                 } else {
1168                     return false;
1169                 }
1170                 break;
1171             case OPTION_COMPILER_OSR_HOTNESS_THRESHOLD:
1172                 ret = ParseUint32Param("compiler-osr-hotness-threshold", &argUint32);
1173                 if (ret) {
1174                     uint16_t val = argUint32 > std::numeric_limits<uint16_t>::max() ?
1175                         std::numeric_limits<uint16_t>::max() : static_cast<uint16_t>(argUint32);
1176                     SetOsrHotnessThreshold(val);
1177                 } else {
1178                     return false;
1179                 }
1180                 break;
1181             case OPTION_COMPILER_FORCE_JIT_COMPILE_MAIN:
1182                 ret = ParseBoolParam(&argBool);
1183                 if (ret) {
1184                     SetForceJitCompileMain(argBool);
1185                 } else {
1186                     return false;
1187                 }
1188                 break;
1189             case OPTION_COMPILER_TRACE_JIT:
1190                 ret = ParseBoolParam(&argBool);
1191                 if (ret) {
1192                     SetTraceJIT(argBool);
1193                 } else {
1194                     return false;
1195                 }
1196                 break;
1197             case OPTION_COMPILER_TYPED_OP_PROFILER:
1198                 ret = ParseBoolParam(&argBool);
1199                 if (ret) {
1200                     SetTypedOpProfiler(argBool);
1201                 } else {
1202                     return false;
1203                 }
1204                 break;
1205             case OPTION_COMPILER_OPT_BRANCH_PROFILING:
1206                 ret = ParseBoolParam(&argBool);
1207                 if (ret) {
1208                     SetEnableBranchProfiling(argBool);
1209                 } else {
1210                     return false;
1211                 }
1212                 break;
1213             case OPTION_TEST_ASSERT:
1214                 ret = ParseBoolParam(&argBool);
1215                 if (ret) {
1216                     SetTestAssert(argBool);
1217                 } else {
1218                     return false;
1219                 }
1220                 break;
1221             case OPTION_COMPILER_ENABLE_JIT_PGO:
1222                 ret = ParseBoolParam(&argBool);
1223                 if (ret) {
1224                     SetEnableJITPGO(argBool);
1225                 } else {
1226                     return false;
1227                 }
1228                 break;
1229             case OPTION_COMPILER_ENABLE_PROPFILE_DUMP:
1230                 ret = ParseBoolParam(&argBool);
1231                 if (ret) {
1232                     SetEnableProfileDump(argBool);
1233                 } else {
1234                     return false;
1235                 }
1236                 break;
1237             case OPTION_COMPILER_ENABLE_AOT_PGO:
1238                 ret = ParseBoolParam(&argBool);
1239                 if (ret) {
1240                     SetEnableAOTPGO(argBool);
1241                 } else {
1242                     return false;
1243                 }
1244                 break;
1245             case OPTION_COMPILER_ENABLE_FRAMEWORK_AOT:
1246                 ret = ParseBoolParam(&argBool);
1247                 if (ret) {
1248                     SetEnableFrameworkAOT(argBool);
1249                 } else {
1250                     return false;
1251                 }
1252                 break;
1253             case OPTION_COMPILER_ENABLE_BASELINEJIT:
1254                 ret = ParseBoolParam(&argBool);
1255                 if (ret) {
1256                     SetEnableBaselineJIT(argBool);
1257                 } else {
1258                     return false;
1259                 }
1260                 break;
1261             case OPTION_COMPILER_METHODS_RANGE:
1262                 ParseListArgParam(optarg, &argListStr, COLON);
1263                 SetCompilerMethodsRange(&argListStr);
1264                 break;
1265             case OPTION_COMPILER_CODEGEN_OPT:
1266                 ParseListArgParam(optarg, &argListStr, " ");
1267                 SetCompilerCodegenOptions(argListStr);
1268                 break;
1269             case OPTION_COMPILER_OPT_ESCAPE_ANALYSIS:
1270                 ret = ParseBoolParam(&argBool);
1271                 if (ret) {
1272                     SetEnableEscapeAnalysis(argBool);
1273                 } else {
1274                     return false;
1275                 }
1276                 break;
1277             case OPTION_COMPILER_TRACE_ESCAPE_ANALYSIS:
1278                 ret = ParseBoolParam(&argBool);
1279                 if (ret) {
1280                     SetEnableTraceEscapeAnalysis(argBool);
1281                 } else {
1282                     return false;
1283                 }
1284                 break;
1285             case OPTION_COMPILER_OPT_INDUCTION_VARIABLE:
1286                 ret = ParseBoolParam(&argBool);
1287                 if (ret) {
1288                     SetEnableInductionVariableAnalysis(argBool);
1289                 } else {
1290                     return false;
1291                 }
1292                 break;
1293             case OPTION_COMPILER_TRACE_INDUCTION_VARIABLE:
1294                 ret = ParseBoolParam(&argBool);
1295                 if (ret) {
1296                     SetEnableTraceInductionVariableAnalysis(argBool);
1297                 } else {
1298                     return false;
1299                 }
1300                 break;
1301             case OPTION_COMPILER_BASELINEJIT_HOTNESS_THRESHOLD:
1302                 ret = ParseUint32Param("compiler-baselinejit-hotness-threshold", &argUint32);
1303                 if (ret) {
1304                     uint16_t val = argUint32 > std::numeric_limits<uint16_t>::max() ?
1305                         std::numeric_limits<uint16_t>::max() : static_cast<uint16_t>(argUint32);
1306                     SetBaselineJitHotnessThreshold(val);
1307                 } else {
1308                     return false;
1309                 }
1310                 break;
1311             case OPTION_COMPILER_MEMORY_ANALYSIS:
1312                 ret = ParseBoolParam(&argBool);
1313                 if (ret) {
1314                     SetEnableMemoryAnalysis(argBool);
1315                 } else {
1316                     return false;
1317                 }
1318                 break;
1319             case OPTION_COMPILER_CHECK_PGO_VERSION:
1320                 ret = ParseBoolParam(&argBool);
1321                 if (ret) {
1322                     SetCheckPgoVersion(argBool);
1323                 } else {
1324                     return false;
1325                 }
1326                 break;
1327             case OPTION_COMPILER_FORCE_BASELINEJIT_COMPILE_MAIN:
1328                 ret = ParseBoolParam(&argBool);
1329                 if (ret) {
1330                     SetForceBaselineCompileMain(argBool);
1331                 } else {
1332                     return false;
1333                 }
1334                 break;
1335             case OPTION_COMPILER_ENABLE_JIT_FAST_COMPILE:
1336                 ret = ParseBoolParam(&argBool);
1337                 if (ret) {
1338                     SetEnableJitFastCompile(argBool);
1339                 } else {
1340                     return false;
1341                 }
1342                 break;
1343             case OPTION_COMPILER_ENABLE_MEGA_IC:
1344                 ret = ParseBoolParam(&argBool);
1345                 if (ret) {
1346                     SetEnableMegaIC(argBool);
1347                 } else {
1348                     return false;
1349                 }
1350                 break;
1351             case OPTION_ASYNC_LOAD_ABC:
1352                 ret = ParseBoolParam(&argBool);
1353                 if (ret) {
1354                     SetAsyncLoadAbc(argBool);
1355                 } else {
1356                     return false;
1357                 }
1358                 break;
1359             case OPTION_ASYNC_LOAD_ABC_TEST:
1360                 ret = ParseBoolParam(&argBool);
1361                 if (ret) {
1362                     SetAsyncLoadAbcTest(argBool);
1363                 } else {
1364                     return false;
1365                 }
1366                 break;
1367             case OPTION_ENABLE_JITFORT:
1368                 ret = ParseBoolParam(&argBool);
1369                 if (ret) {
1370                     SetEnableJitFort(argBool);
1371                 } else {
1372                     return false;
1373                 }
1374                 break;
1375             case OPTION_CODESIGN_DISABLE:
1376                 ret = ParseBoolParam(&argBool);
1377                 if (ret) {
1378                     SetDisableCodeSign(argBool);
1379                 } else {
1380                     return false;
1381                 }
1382                 break;
1383             case OPTION_ENABLE_ASYNC_COPYTOFORT:
1384                 ret = ParseBoolParam(&argBool);
1385                 if (ret) {
1386                     SetEnableAsyncCopyToFort(argBool);
1387                 } else {
1388                     return false;
1389                 }
1390                 break;
1391             case OPTION_COMPILER_ENABLE_CONCURRENT:
1392                 ret = ParseBoolParam(&argBool);
1393                 if (ret) {
1394                     SetConcurrentCompile(argBool);
1395                 } else {
1396                     return false;
1397                 }
1398                 break;
1399             case OPTION_COMPILER_ENABLE_STORE_BARRIER_OPT:
1400                 ret = ParseBoolParam(&argBool);
1401                 if (ret) {
1402                     SetStoreBarrierOpt(argBool);
1403                 } else {
1404                     return false;
1405                 }
1406                 break;
1407             case OPTION_COMPILER_ENABLE_LDOBJVALUE_OPT:
1408                 ret = ParseBoolParam(&argBool);
1409                 if (ret) {
1410                     SetLdObjValueOpt(argBool);
1411                 } else {
1412                     return false;
1413                 }
1414                 break;
1415             case OPTION_COMPILER_PGO_FORCE_DUMP:
1416                 ret = ParseBoolParam(&argBool);
1417                 if (ret) {
1418                     SetPgoForceDump(argBool);
1419                 } else {
1420                     return false;
1421                 }
1422                 break;
1423             case OPTION_COMPILER_ENABLE_PGO_SPACE:
1424                 ret = ParseBoolParam(&argBool);
1425                 if (ret) {
1426                     SetCompilerEnablePgoSpace(argBool);
1427                 } else {
1428                     return false;
1429                 }
1430                 break;
1431             case OPTION_COMPILER_ENABLE_AOT_CODE_COMMENT:
1432                 ret = ParseBoolParam(&argBool);
1433                 if (ret) {
1434                     SetEnableAotCodeComment(argBool);
1435                 } else {
1436                     return false;
1437                 }
1438                 break;
1439             case OPTION_ENABLE_INLINE_PROPERTY_OPTIMIZATION:
1440                  ret = ParseBoolParam(&argBool);
1441                 if (ret) {
1442                     SetEnableInlinePropertyOptimization(argBool);
1443                 } else {
1444                     return false;
1445                 }
1446                 break;
1447             case OPTION_ENABLE_JIT_VERIFY_PASS:
1448                  ret = ParseBoolParam(&argBool);
1449                 if (ret) {
1450                     SetEnableJitVerifyPass(argBool);
1451                 } else {
1452                     return false;
1453                 }
1454                 break;
1455             case OPTION_COMPILER_ENABLE_AOT_LAZY_DEOPT:
1456                 ret = ParseBoolParam(&argBool);
1457                 if (ret) {
1458                     SetEnableAotLazyDeopt(argBool);
1459                 } else {
1460                     return false;
1461                 }
1462                 break;
1463             case OPTION_COMPILER_ENABLE_JIT_LAZY_DEOPT:
1464                 ret = ParseBoolParam(&argBool);
1465                 if (ret) {
1466                     SetEnableJitLazyDeopt(argBool);
1467                 } else {
1468                     return false;
1469                 }
1470                 break;
1471             case OPTION_COMPILER_ENABLE_LAZY_DEOPT_TRACE:
1472                 ret = ParseBoolParam(&argBool);
1473                 if (ret) {
1474                     SetEnableLazyDeoptTrace(argBool);
1475                 } else {
1476                     return false;
1477                 }
1478                 break;
1479             case OPTION_COMPILER_TRACE_BUILTINS:
1480                 ret = ParseBoolParam(&argBool);
1481                 if (ret) {
1482                     SetTraceBuiltins(argBool);
1483                 } else {
1484                     return false;
1485                 }
1486                 break;
1487             case OPTION_COMPILER_AN_FILE_MAX_SIZE:
1488                 ret = ParseUint64Param("compiler-an-file-max-size", &argUInt64);
1489                 if (ret) {
1490                     SetCompilerAnFileMaxByteSize(argUInt64 * 1_MB);
1491                 } else {
1492                     return false;
1493                 }
1494                 break;
1495             case OPTION_COMPILER_ENABLE_MERGE_POLY:
1496                 ret = ParseBoolParam(&argBool);
1497                 if (ret) {
1498                     SetEnableMergePoly(argBool);
1499                 } else {
1500                     return false;
1501                 }
1502                 break;
1503             case OPTION_COMPILER_JIT_METHOD_DICHOTOMY:
1504                 SetJitMethodDichotomy(optarg);
1505                 break;
1506             case OPTION_COMPILER_JIT_METHOD_PATH:
1507                 SetJitMethodPath(optarg);
1508                 break;
1509             case OPTION_MEM_CONFIG:
1510                 SetMemConfigProperty(optarg);
1511                 break;
1512             case OPTION_MULTI_CONTEXT:
1513                 ret = ParseBoolParam(&argBool);
1514                 if (ret) {
1515                     SetMultiContext(argBool);
1516                 } else {
1517                     return false;
1518                 }
1519                 break;
1520             default:
1521                 LOG_ECMA(ERROR) << "Invalid option\n";
1522                 return false;
1523         }
1524     }
1525 #if defined(PANDA_TARGET_32) || defined(CROSS_PLATFORM)
1526     SetEnableAotLazyDeopt(false);
1527     SetEnableJitLazyDeopt(false);
1528     SetEnableLazyDeoptTrace(false);
1529 #endif
1530 }
1531 
SetDefaultValue(char * argv)1532 bool JSRuntimeOptions::SetDefaultValue(char* argv)
1533 {
1534     if (optopt == OPTION_DEFAULT) { // unknown option
1535         LOG_ECMA(ERROR) << " Invalid option \"" << argv << "\"";
1536         return false;
1537     }
1538 
1539     if (optopt >= OPTION_LAST) { // unknown argument
1540         LOG_ECMA(ERROR) << "getopt: \"" << argv <<"\" argument has invalid parameter value \n";
1541         return false;
1542     }
1543     return true;
1544 }
1545 
ParseBool(const std::string & arg,bool * argBool)1546 bool JSRuntimeOptions::ParseBool(const std::string &arg, bool* argBool)
1547 {
1548     if ((strcmp(arg.c_str(), "false") == 0) || (strcmp(arg.c_str(), "0") == 0)) {
1549         *argBool = false;
1550     } else {
1551         *argBool = true;
1552     }
1553     return true;
1554 }
1555 
ParseDouble(const std::string & arg,double * argDouble)1556 bool JSRuntimeOptions::ParseDouble(const std::string &arg, double* argDouble)
1557 {
1558     *argDouble = std::strtod(arg.c_str(), nullptr);
1559     if (errno == ERANGE) {
1560         return false;
1561     }
1562     return true;
1563 }
1564 
ParseInt(const std::string & arg,int * argInt)1565 bool JSRuntimeOptions::ParseInt(const std::string &arg, int* argInt)
1566 {
1567     int64_t val;
1568     if (StartsWith(arg, "0x")) {
1569         const int HEX = 16;
1570         val = std::strtoll(arg.c_str(), nullptr, HEX);
1571     } else {
1572         const int DEC = 10;
1573         val = std::strtoll(arg.c_str(), nullptr, DEC);
1574     }
1575 
1576     if (errno == ERANGE || val < INT_MIN || val > INT_MAX) {
1577         return false;
1578     }
1579     *argInt = static_cast<int>(val);
1580     return true;
1581 }
1582 
ParseUint32(const std::string & arg,uint32_t * argUInt32)1583 bool JSRuntimeOptions::ParseUint32(const std::string &arg, uint32_t* argUInt32)
1584 {
1585     if (StartsWith(arg, "0x")) {
1586         const int HEX = 16;
1587         *argUInt32 = std::strtoull(arg.c_str(), nullptr, HEX);
1588     } else {
1589         const int DEC = 10;
1590         *argUInt32 = std::strtoull(arg.c_str(), nullptr, DEC);
1591     }
1592 
1593     if (errno == ERANGE) {
1594         return false;
1595     }
1596     return true;
1597 }
1598 
ParseUint64(const std::string & arg,uint64_t * argUInt64)1599 bool JSRuntimeOptions::ParseUint64(const std::string &arg, uint64_t* argUInt64)
1600 {
1601     if (StartsWith(arg, "0x")) {
1602         const int HEX = 16;
1603         *argUInt64 = std::strtoull(arg.c_str(), nullptr, HEX);
1604     } else {
1605         const int DEC = 10;
1606         *argUInt64 = std::strtoull(arg.c_str(), nullptr, DEC);
1607     }
1608 
1609     if (errno == ERANGE) {
1610         return false;
1611     }
1612     return true;
1613 }
1614 
ParseBoolParam(bool * argBool)1615 bool JSRuntimeOptions::ParseBoolParam(bool* argBool)
1616 {
1617     return ParseBool(optarg, argBool);
1618 }
1619 
ParseDoubleParam(const std::string & option,double * argDouble)1620 bool JSRuntimeOptions::ParseDoubleParam(const std::string &option, double *argDouble)
1621 {
1622     bool ret = ParseDouble(optarg, argDouble);
1623     if (!ret) {
1624         LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1625     }
1626     return ret;
1627 }
1628 
ParseIntParam(const std::string & option,int * argInt)1629 bool JSRuntimeOptions::ParseIntParam(const std::string &option, int *argInt)
1630 {
1631     bool ret = ParseInt(optarg, argInt);
1632     if (!ret) {
1633         LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1634     }
1635     return ret;
1636 }
1637 
ParseUint32Param(const std::string & option,uint32_t * argUInt32)1638 bool JSRuntimeOptions::ParseUint32Param(const std::string &option, uint32_t *argUInt32)
1639 {
1640     bool ret = ParseUint32(optarg, argUInt32);
1641     if (!ret) {
1642         LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1643     }
1644     return ret;
1645 }
1646 
ParseUint64Param(const std::string & option,uint64_t * argUInt64)1647 bool JSRuntimeOptions::ParseUint64Param(const std::string &option, uint64_t *argUInt64)
1648 {
1649     bool ret = ParseUint64(optarg, argUInt64);
1650     if (!ret) {
1651         LOG_ECMA(ERROR) << "getopt: \"" << option << "\" argument has invalid parameter value \"" << optarg <<"\"\n";
1652     }
1653     return ret;
1654 }
1655 
ParseListArgParam(const std::string & option,arg_list_t * argListStr,std::string delimiter)1656 void JSRuntimeOptions::ParseListArgParam(const std::string &option, arg_list_t *argListStr, std::string delimiter)
1657 {
1658     argListStr->clear();
1659     std::size_t strIndex = 0;
1660     std::size_t pos = option.find_first_of(delimiter, strIndex);
1661     while ((pos < option.size()) && (pos > strIndex)) {
1662         argListStr->push_back(option.substr(strIndex, pos - strIndex));
1663         strIndex = pos;
1664         strIndex = option.find_first_not_of(delimiter, strIndex);
1665         pos = option.find_first_of(delimiter, strIndex);
1666     }
1667     if (pos > strIndex) {
1668         argListStr->push_back(option.substr(strIndex, pos - strIndex));
1669     }
1670     return;
1671 }
1672 
BindCPUCoreForTargetCompilation()1673 void JSRuntimeOptions::BindCPUCoreForTargetCompilation()
1674 {
1675     if (!deviceIsScreenOff_ || deviceThermalLevel_ > 0) {
1676         BindSmallCpuCore();
1677     } else {
1678         BindMidCpuCore();
1679     }
1680 }
1681 
SetOptionsForTargetCompilation()1682 void JSRuntimeOptions::SetOptionsForTargetCompilation()
1683 {
1684     if (IsApplicationCompilation()) {
1685         SetTargetTriple("aarch64-unknown-linux-gnu");
1686         SetMaxAotMethodSize(MAX_APP_COMPILE_METHOD_SIZE);
1687         SetEnableOptTrackField(false);
1688         SetEnableOptInlining(false);
1689         SetEnableArrayBoundsCheckElimination(false);
1690         SetCompilerEnableLiteCG(true);
1691         SetEnableOptPGOType(true);
1692         if (IsCompilerAnFileMaxByteSizeDefault()) {
1693             SetCompilerAnFileMaxByteSize(100_MB);
1694         }
1695     }
1696 
1697     if (IsTargetCompilerMode()) {
1698         if (UNLIKELY(IsFullCompilerMode())) {
1699             SetEnableOptPGOType(false);
1700             SetPGOProfilerPath("");
1701         }
1702         BindCPUCoreForTargetCompilation();
1703     }
1704 
1705     if (IsCompilerPipelineHostAOT()) {
1706         SetFastAOTCompileMode(true);
1707         SetOptLevel(DEFAULT_OPT_LEVEL);
1708         SetEnableLoweringBuiltin(false);
1709     }
1710 }
1711 
ParseAsmInterOption()1712 void JSRuntimeOptions::ParseAsmInterOption()
1713 {
1714     asmInterParsedOption_.enableAsm = enableAsmInterpreter_;
1715     std::string strAsmOpcodeDisableRange = asmOpcodeDisableRange_;
1716     if (strAsmOpcodeDisableRange.empty()) {
1717         return;
1718     }
1719 
1720     // asm interpreter handle disable range
1721     size_t pos = strAsmOpcodeDisableRange.find(",");
1722     if (pos != std::string::npos) {
1723         std::string strStart = strAsmOpcodeDisableRange.substr(0, pos);
1724         std::string strEnd = strAsmOpcodeDisableRange.substr(pos + 1);
1725         int64_t inputStart;
1726         int64_t inputEnd;
1727         if (!StringToInt64(strStart, inputStart)) {
1728             inputStart = 0;
1729             LOG_ECMA_IF(!strStart.empty(), INFO) << "when get start, strStart is " << strStart;
1730         }
1731         if (!StringToInt64(strEnd, inputEnd)) {
1732             inputEnd = kungfu::BYTECODE_STUB_END_ID;
1733             LOG_ECMA_IF(!strEnd.empty(), INFO) << "when get end, strEnd is " << strEnd;
1734         }
1735         int start = static_cast<int>(inputStart);
1736         int end = static_cast<int>(inputEnd);
1737         if (start >= 0 && start < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS && end >= 0 &&
1738             end < kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS && start <= end) {
1739             asmInterParsedOption_.handleStart = start;
1740             asmInterParsedOption_.handleEnd = end;
1741         }
1742     }
1743 }
1744 
JSRuntimeOptions()1745 JSRuntimeOptions::JSRuntimeOptions()
1746 {
1747     param_ = common::BaseRuntimeParam::DefaultRuntimeParam();
1748 }
1749 
SetConfigHeapSize(size_t configHeapSize)1750 void JSRuntimeOptions::SetConfigHeapSize(size_t configHeapSize)
1751 {
1752     common::BaseRuntimeParam::SetConfigHeapSize(param_, configHeapSize);
1753 }
1754 
SetConfigMaxGarbageCacheSize(uint64_t maxGarbageCacheSize)1755 void JSRuntimeOptions::SetConfigMaxGarbageCacheSize(uint64_t maxGarbageCacheSize)
1756 {
1757     common::BaseRuntimeParam::SetMaxGarbageCacheSize(param_, maxGarbageCacheSize);
1758 }
1759 
SetMemConfigProperty(const std::string & configProperty)1760 void JSRuntimeOptions::SetMemConfigProperty(const std::string &configProperty)
1761 {
1762     if (configProperty == "openArkTools") {
1763         openArkTools_ = true;
1764         return;
1765     }
1766 
1767     ParseRuntimeParam(configProperty);
1768 }
1769 
1770 #ifdef ENABLE_CMC_GC
1771 #define PARAM_PAESER_DEFINE(key, subKey, type, minValue, maxValue, defaultValue) \
1772 bool Parse##_##key##_##subKey(const std::string &arg, type *result)              \
1773 {                                                                                \
1774     if constexpr (std::is_floating_point<type>::value) {                         \
1775         double floatVal = 0.0;                                                   \
1776         bool ret = JSRuntimeOptions::ParseDouble(arg, &floatVal);                \
1777         *result = static_cast<type>(floatVal);                                   \
1778         return ret;                                                              \
1779     }                                                                            \
1780     if constexpr (std::is_integral<type>::value) {                               \
1781         uint64_t uint64Val = 0;                                                  \
1782         bool ret = JSRuntimeOptions::ParseUint64(arg, &uint64Val);               \
1783         *result = static_cast<type>(uint64Val);                                  \
1784         return ret;                                                              \
1785     }                                                                            \
1786     return false;                                                                \
1787 }
1788 
RUNTIME_PARAM_LIST(PARAM_PAESER_DEFINE)1789 RUNTIME_PARAM_LIST(PARAM_PAESER_DEFINE)
1790 #endif
1791 
1792 /*
1793  * key value;key value;...
1794  */
1795 void JSRuntimeOptions::ParseRuntimeParam(const std::string &str)
1796 {
1797     if (str.empty()) {
1798         return;
1799     }
1800 
1801     size_t length = str.length();
1802     for (size_t i = 0; i < length;) {
1803         std::string keyStr;
1804         std::string valueStr;
1805         while (i < length && isalpha(str[i])) {
1806             keyStr += str[i++];
1807         }
1808         if (i < length && str[i] == ' ') {
1809             i++;
1810         }
1811         while (i < length && (isdigit(str[i]) || str[i] == '.')) {
1812             valueStr += str[i++];
1813         }
1814         if (i < length && str[i] == ';') {
1815             i++;
1816         }
1817         if (keyStr == "jsHeap") {
1818             uint32_t input = 0;
1819             if (!ParseUint32(valueStr, &input)) {
1820                 return;
1821             }
1822             heapSize_ = input * 1_MB;
1823             return;
1824         }
1825 
1826 #ifdef ENABLE_CMC_GC
1827 #define PARSE_RUNTIME_PARAM(key, subKey, type, minValue, maxValue, defaultValue)                            \
1828         if (keyStr == #subKey) {                                                                            \
1829             type res = static_cast<type>(defaultValue);                                                     \
1830             bool ret = Parse##_##key##_##subKey(valueStr, &res);                                            \
1831             if (!ret) {                                                                                     \
1832                 LOG_ECMA(FATAL) << "Fail parse " << #key << "." << #subKey << " of value: " << valueStr;    \
1833                 UNREACHABLE();                                                                              \
1834             }                                                                                               \
1835             if (res < static_cast<type>(minValue) || res > static_cast<type>(maxValue)) {                   \
1836                 LOG_ECMA(FATAL) << "Set " << keyStr << " to " << res << " is out of range: [" <<            \
1837                     (minValue) << ", " << (maxValue) << "]";                                                \
1838                 UNREACHABLE();                                                                              \
1839             }                                                                                               \
1840             param_.key.subKey = res;                                                                        \
1841             continue;                                                                                       \
1842         }
1843         RUNTIME_PARAM_LIST(PARSE_RUNTIME_PARAM)
1844 #undef PARSE_RUNTIME_PARAM
1845 
1846         LOG_ECMA(FATAL) << "Unknow key: " << keyStr << " of value: " << valueStr;
1847         UNREACHABLE();
1848 #endif
1849     }
1850 }
1851 #undef PAESER_DEFINE
1852 #undef PARAM_MAP
1853 }
1854