• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//arkcompiler/ets_runtime/js_runtime_config.gni")
16import("$build_root/test.gni")
17
18declare_args() {
19  TEST_LLVM_ONLY = false
20}
21
22if (is_standard_system || ark_standalone_build) {
23  _icu_path_ = "thirdparty/icu"
24} else {
25  _icu_path_ = "global/i18n"
26}
27
28common_options = ""
29if (defined(disable_force_gc) && disable_force_gc) {
30  common_options += " --enable-force-gc=false"
31}
32if (defined(timeout)) {
33  _timeout_ = timeout
34} else {
35  _timeout_ = 1200
36}
37template("host_unittest_action") {
38  _target_name_ = "${target_name}"
39
40  # unittest for phone running
41  ohos_unittest(_target_name_) {
42    resource_config_file =
43        "//arkcompiler/ets_runtime/test/resource/js_runtime/ohos_test.xml"
44    forward_variables_from(invoker, "*")
45  }
46
47  _module_out_path_ = invoker.module_out_path
48
49  # unittest for host running
50  action("${_target_name_}ActionWithoutQemu") {
51    testonly = true
52
53    _host_test_target_ = ":${_target_name_}(${host_toolchain})"
54    _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
55
56    deps = [ _host_test_target_ ]
57
58    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
59
60    args = [
61      "--script-file",
62      rebase_path(_root_out_dir_) +
63          "/tests/unittest/${_module_out_path_}/${_target_name_}",
64      "--expect-output",
65      "0",
66      "--env-path",
67      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
68          rebase_path(_root_out_dir_) + "/test/test:" +
69          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
70          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
71          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
72          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
73          rebase_path(_root_out_dir_) +
74          "/thirdparty/bounds_checking_function:" +
75          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
76      "--timeout-limit",
77      "${_timeout_}",
78    ]
79
80    inputs = [
81      "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
82    ]
83    outputs = [ "$target_out_dir/${_target_name_}/" ]
84  }
85  if (ark_standalone_build && host_os == "linux" && target_os == "ohos") {
86    import("$ark_third_party_root/musl/musl_template.gni")
87    import("$build_root/config/qemu/config.gni")
88
89    action("${_target_name_}ActionWithQemu") {
90      testonly = true
91
92      _host_test_target_ = ":${_target_name_}"
93
94      # path of root_out_dir based on root_src_dir
95      _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
96
97      deps = [
98        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
99        _host_test_target_,
100      ]
101
102      script = "${js_root}/script/run_ark_executable.py"
103
104      args = [
105        "--script-file",
106        rebase_path(
107            "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
108            root_build_dir),
109        "--expect-output",
110        "0",
111        "--clang-lib-path",
112        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos",
113                    root_build_dir),
114        "--qemu-binary-path",
115        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
116        "--qemu-ld-prefix",
117        rebase_path(musl_linker_so_out_dir, root_build_dir),
118        "--timeout-limit",
119        "${_timeout_}",
120      ]
121
122      inputs = [
123        "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
124      ]
125      outputs = [ "$target_out_dir/${_target_name_}WithQemu/" ]
126    }
127  }
128  group("${_target_name_}Action") {
129    testonly = true
130
131    deps = []
132    if (ark_standalone_build && host_os == "linux" && target_os == "ohos" &&
133        run_with_qemu) {
134      deps += [ ":${_target_name_}ActionWithQemu" ]
135    } else {
136      deps += [ ":${_target_name_}ActionWithoutQemu" ]
137    }
138  }
139}
140
141template("host_moduletest_action") {
142  _target_name_ = "${target_name}"
143  _deps_ = invoker.deps
144  _is_module_ = false
145  if (defined(invoker.is_module) && invoker.is_module) {
146    _is_module_ = true
147  }
148  _is_commonjs_ = false
149  if (defined(invoker.is_commonjs) && invoker.is_commonjs) {
150    _is_commonjs_ = true
151  }
152  _is_gen_js_ = false
153  if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
154    _is_gen_js_ = true
155  }
156  _is_merge_ = false
157  if (defined(invoker.is_merge) && invoker.is_merge) {
158    _is_merge_ = true
159  }
160  _is_merge_abc_ = false
161  if (defined(invoker.is_merge_abc) && invoker.is_merge_abc) {
162    _is_merge_abc_ = true
163  }
164
165  _src_dir_ = "."
166  if (defined(invoker.src_dir) && invoker.src_dir != "") {
167    _src_dir_ = invoker.src_dir
168  }
169
170  _src_postfix_ = "js"
171  if (defined(invoker.src_postfix) && invoker.src_postfix != "") {
172    _src_postfix_ = invoker.src_postfix
173  }
174
175  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
176  _test_expect_path_ = "${_src_dir_}/expect_output.txt"
177  if (_is_gen_js_) {
178    _test_js_template_path_ = "${_src_dir_}/${_target_name_}.${_src_postfix_}"
179    _test_js_path_ = "$target_out_dir/${_target_name_}.${_src_postfix_}"
180  } else {
181    _test_js_path_ = "${_src_dir_}/${_target_name_}.${_src_postfix_}"
182  }
183
184  if (_is_merge_abc_) {
185    merge_file_raw = "./${_target_name_}.txt"
186    merge_file = "$target_out_dir/${_target_name_}.txt"
187    merge_file_prefix =
188        "//arkcompiler/ets_runtime/test/moduletest/${_target_name_}/"
189
190    action("gen_${_target_name_}_merge_file") {
191      script = "../../quickfix/generate_merge_file.py"
192      args = [
193        "--input",
194        rebase_path(merge_file_raw),
195        "--output",
196        rebase_path(merge_file),
197        "--prefix",
198        rebase_path(merge_file_prefix),
199      ]
200
201      inputs = [ merge_file_raw ]
202      outputs = [ merge_file ]
203    }
204  }
205  if (_is_gen_js_) {
206    action("gen_${_target_name_}_js_file") {
207      script = "../../quickfix/generate_js_and_merge_file.py"
208      src_file = rebase_path(_test_js_template_path_)
209      dst_file = rebase_path(_test_js_path_)
210      args = [
211        "--input=$src_file",
212        "--output=$dst_file",
213      ]
214      inputs = [ _test_js_template_path_ ]
215      outputs = [ _test_js_path_ ]
216    }
217  }
218  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
219    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
220    extra_dependencies = _deps_
221    src_js = rebase_path(_test_js_path_)
222    dst_file = rebase_path(_test_abc_path_)
223    extra_args = []
224    if (_is_gen_js_) {
225      extra_dependencies = [ ":gen_${_target_name_}_js_file" ]
226    }
227    if (_is_module_) {
228      extra_args += [ "--module" ]
229    }
230    if (_is_commonjs_) {
231      extra_args += [ "--commonjs" ]
232    }
233    if (_is_merge_) {
234      extra_args += [ "--merge-abc" ]
235    }
236    if (_is_merge_abc_) {
237      extra_dependencies = [ ":gen_${_target_name_}_merge_file" ]
238      src_js = "@" + rebase_path(merge_file)
239      in_puts = [
240        _test_expect_path_,
241        merge_file,
242      ]
243    } else {
244      in_puts = [
245        _test_expect_path_,
246        _test_js_path_,
247      ]
248    }
249    out_puts = [ _test_abc_path_ ]
250  }
251
252  _extra_modules_ = []
253  if (defined(invoker.extra_modules)) {
254    foreach(module, invoker.extra_modules) {
255      _extra_modules_ += [ "$target_out_dir/${module}.abc" ]
256    }
257  }
258  if (defined(invoker.entry_point)) {
259    _script_args_ = invoker.entry_point
260    _script_args_ += " " + rebase_path(_test_abc_path_)
261  } else {
262    _script_args_ = rebase_path(_test_abc_path_)
263  }
264  foreach(extra_module, _extra_modules_) {
265    _script_args_ += ":" + rebase_path(extra_module)
266  }
267
268  action("${_target_name_}Action") {
269    testonly = true
270
271    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
272    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
273    deps = [
274      ":gen_${_target_name_}_abc",
275      _host_jsvm_target_,
276    ]
277    deps += _deps_
278
279    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
280
281    js_vm_options = " --asm-interpreter=false"
282    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
283        invoker.is_set_maxNonmovableSpaceCapacity) {
284      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
285    }
286
287    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
288      js_vm_options += " --async-load-abc-test=true"
289    }
290
291    if (defined(invoker.is_enable_enableArkTools) &&
292        invoker.is_enable_enableArkTools) {
293      js_vm_options += " --enable-ark-tools=true"
294      js_vm_options += " --enable-force-gc=false"
295    }
296    js_vm_options += common_options
297    _icu_data_path_options_ =
298        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
299    js_vm_options += _icu_data_path_options_
300    args = [
301      "--script-file",
302      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
303      "--script-options",
304      js_vm_options,
305      "--script-args",
306      _script_args_,
307      "--timeout-limit",
308      "${_timeout_}",
309      "--expect-file",
310      rebase_path(_test_expect_path_),
311      "--env-path",
312      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
313          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
314          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
315          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
316          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
317          rebase_path(_root_out_dir_) +
318          "/thirdparty/bounds_checking_function:" +
319          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
320    ]
321
322    inputs = [ _test_abc_path_ ]
323    inputs += _extra_modules_
324
325    outputs = [ "$target_out_dir/${_target_name_}/" ]
326  }
327
328  action("${_target_name_}ContextAction") {
329    testonly = true
330
331    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
332    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
333    deps = [
334      ":gen_${_target_name_}_abc",
335      _host_jsvm_target_,
336    ]
337    deps += _deps_
338
339    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
340
341    js_vm_options = " --asm-interpreter=false"
342    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
343        invoker.is_set_maxNonmovableSpaceCapacity) {
344      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
345    }
346
347    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
348      js_vm_options += " --async-load-abc-test=true"
349    }
350
351    if (defined(invoker.is_enable_enableArkTools) &&
352        invoker.is_enable_enableArkTools) {
353      js_vm_options += " --enable-ark-tools=true"
354      js_vm_options += " --enable-force-gc=false"
355    }
356    js_vm_options += " --enable-context=true"
357    js_vm_options += common_options
358    _icu_data_path_options_ =
359        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
360    js_vm_options += _icu_data_path_options_
361    args = [
362      "--script-file",
363      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
364      "--script-options",
365      js_vm_options,
366      "--script-args",
367      _script_args_,
368      "--timeout-limit",
369      "${_timeout_}",
370      "--expect-file",
371      rebase_path(_test_expect_path_),
372      "--env-path",
373      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
374          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
375          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
376          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
377          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
378          rebase_path(_root_out_dir_) +
379          "/thirdparty/bounds_checking_function:" +
380          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
381    ]
382
383    inputs = [ _test_abc_path_ ]
384    inputs += _extra_modules_
385
386    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
387  }
388
389  action("${_target_name_}AsmAction") {
390    testonly = true
391
392    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
393    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
394    deps = [
395      ":gen_${_target_name_}_abc",
396      _host_jsvm_target_,
397    ]
398    deps += _deps_
399
400    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
401
402    _asm_run_options_ = " --asm-interpreter=true"
403    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
404        invoker.is_set_maxNonmovableSpaceCapacity) {
405      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
406    }
407
408    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
409      _asm_run_options_ += " --async-load-abc-test=true"
410    }
411
412    if (defined(invoker.is_set_elements_kind) && invoker.is_set_elements_kind) {
413      _asm_run_options_ += " --enable-elements-kind=true"
414    }
415
416    if (defined(invoker.is_enable_enableArkTools) &&
417        invoker.is_enable_enableArkTools) {
418      _asm_run_options_ += " --enable-ark-tools=true"
419      _asm_run_options_ += " --enable-force-gc=false"
420    }
421    _asm_run_options_ += " --enable-context=true"
422    _asm_run_options_ += common_options
423    _icu_data_path_options_ =
424        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
425    _asm_run_options_ += _icu_data_path_options_
426    args = [
427      "--script-file",
428      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
429      "--script-options",
430      _asm_run_options_,
431      "--script-args",
432      _script_args_,
433      "--timeout-limit",
434      "${_timeout_}",
435      "--expect-file",
436      rebase_path(_test_expect_path_),
437      "--env-path",
438      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
439          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
440          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
441          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
442          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
443          rebase_path(_root_out_dir_) +
444          "/thirdparty/bounds_checking_function:" +
445          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
446    ]
447
448    inputs = [ _test_abc_path_ ]
449    inputs += _extra_modules_
450
451    outputs = [ "$target_out_dir/${_target_name_}Asm/" ]
452  }
453
454  action("${_target_name_}AsmContextAction") {
455    testonly = true
456
457    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
458    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
459    deps = [
460      ":gen_${_target_name_}_abc",
461      _host_jsvm_target_,
462    ]
463    deps += _deps_
464
465    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
466
467    _asm_run_options_ = " --asm-interpreter=true"
468    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
469        invoker.is_set_maxNonmovableSpaceCapacity) {
470      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
471    }
472
473    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
474      _asm_run_options_ += " --async-load-abc-test=true"
475    }
476
477    if (defined(invoker.is_set_elements_kind) && invoker.is_set_elements_kind) {
478      _asm_run_options_ += " --enable-elements-kind=true"
479    }
480
481    if (defined(invoker.is_enable_enableArkTools) &&
482        invoker.is_enable_enableArkTools) {
483      _asm_run_options_ += " --enable-ark-tools=true"
484      _asm_run_options_ += " --enable-force-gc=false"
485    }
486    _asm_run_options_ += common_options
487    _icu_data_path_options_ =
488        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
489    _asm_run_options_ += _icu_data_path_options_
490    args = [
491      "--script-file",
492      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
493      "--script-options",
494      _asm_run_options_,
495      "--script-args",
496      _script_args_,
497      "--timeout-limit",
498      "${_timeout_}",
499      "--expect-file",
500      rebase_path(_test_expect_path_),
501      "--env-path",
502      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
503          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
504          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
505          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
506          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
507          rebase_path(_root_out_dir_) +
508          "/thirdparty/bounds_checking_function:" +
509          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
510    ]
511
512    inputs = [ _test_abc_path_ ]
513    inputs += _extra_modules_
514
515    outputs = [ "$target_out_dir/${_target_name_}AsmContext/" ]
516  }
517
518  action("${_target_name_}AsmSingleStepAction") {
519    testonly = true
520
521    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
522    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
523    deps = [
524      ":gen_${_target_name_}_abc",
525      _host_jsvm_target_,
526    ]
527    deps += _deps_
528
529    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
530
531    # 214: all bytecodes
532    _asm_run_options_ =
533        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
534    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
535        invoker.is_set_maxNonmovableSpaceCapacity) {
536      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
537    }
538
539    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
540      _asm_run_options_ += " --async-load-abc-test=true"
541    }
542
543    if (defined(invoker.is_enable_enableArkTools) &&
544        invoker.is_enable_enableArkTools) {
545      _asm_run_options_ += " --enable-ark-tools=true"
546      _asm_run_options_ += " --enable-force-gc=false"
547    }
548    _asm_run_options_ += common_options
549    _icu_data_path_options_ =
550        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
551    _asm_run_options_ += _icu_data_path_options_
552    args = [
553      "--script-file",
554      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
555      "--script-options",
556      _asm_run_options_,
557      "--script-args",
558      _script_args_,
559      "--expect-file",
560      rebase_path(_test_expect_path_),
561      "--env-path",
562      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
563          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
564          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
565          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
566          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
567          rebase_path(_root_out_dir_) +
568          "/thirdparty/bounds_checking_function:" +
569          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
570    ]
571
572    inputs = [ _test_abc_path_ ]
573    inputs += _extra_modules_
574
575    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStep/" ]
576  }
577
578  action("${_target_name_}AsmSingleStepContextAction") {
579    testonly = true
580
581    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
582    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
583    deps = [
584      ":gen_${_target_name_}_abc",
585      _host_jsvm_target_,
586    ]
587    deps += _deps_
588
589    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
590
591    # 214: all bytecodes
592    _asm_run_options_ =
593        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
594    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
595        invoker.is_set_maxNonmovableSpaceCapacity) {
596      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
597    }
598
599    if (defined(invoker.async_load_abc_test) && invoker.async_load_abc_test) {
600      _asm_run_options_ += " --async-load-abc-test=true"
601    }
602
603    if (defined(invoker.is_enable_enableArkTools) &&
604        invoker.is_enable_enableArkTools) {
605      _asm_run_options_ += " --enable-ark-tools=true"
606      _asm_run_options_ += " --enable-force-gc=false"
607    }
608    _asm_run_options_ += " --enable-context=true"
609    _asm_run_options_ += common_options
610    _icu_data_path_options_ =
611        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
612    _asm_run_options_ += _icu_data_path_options_
613    args = [
614      "--script-file",
615      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
616      "--script-options",
617      _asm_run_options_,
618      "--script-args",
619      _script_args_,
620      "--expect-file",
621      rebase_path(_test_expect_path_),
622      "--env-path",
623      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
624          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
625          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
626          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
627          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
628          rebase_path(_root_out_dir_) +
629          "/thirdparty/bounds_checking_function:" +
630          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
631    ]
632
633    inputs = [ _test_abc_path_ ]
634    inputs += _extra_modules_
635
636    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStepContext/" ]
637  }
638}
639
640template("host_moduletest_assert_action") {
641  _target_name_ = "${target_name}"
642  _deps_ = invoker.deps
643  _is_module_ = false
644  if (defined(invoker.is_module) && invoker.is_module) {
645    _is_module_ = true
646  }
647  _is_commonjs_ = false
648  if (defined(invoker.is_commonjs) && invoker.is_commonjs) {
649    _is_commonjs_ = true
650  }
651  _is_gen_js_ = false
652  if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
653    _is_gen_js_ = true
654  }
655  _is_merge_ = false
656  if (defined(invoker.is_merge) && invoker.is_merge) {
657    _is_merge_ = true
658  }
659  _is_merge_abc_ = false
660  if (defined(invoker.is_merge_abc) && invoker.is_merge_abc) {
661    _is_merge_abc_ = true
662  }
663
664  _src_dir_ = "."
665  if (defined(invoker.src_dir) && invoker.src_dir != "") {
666    _src_dir_ = invoker.src_dir
667  }
668
669  _src_postfix_ = "js"
670  if (defined(invoker.src_postfix) && invoker.src_postfix != "") {
671    _src_postfix_ = invoker.src_postfix
672  }
673
674  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
675
676  if (_is_gen_js_) {
677    _test_js_template_path_ = "${_src_dir_}/${_target_name_}.${_src_postfix_}"
678    _test_js_path_ = "$target_out_dir/${_target_name_}.${_src_postfix_}"
679  } else {
680    _test_js_path_ = "${_src_dir_}/${_target_name_}.${_src_postfix_}"
681  }
682
683  if (_is_merge_abc_) {
684    merge_file_raw = "./${_target_name_}.txt"
685    merge_file = "$target_out_dir/${_target_name_}.txt"
686    merge_file_prefix =
687        "//arkcompiler/ets_runtime/test/moduletest/${_target_name_}/"
688
689    action("gen_${_target_name_}_merge_file") {
690      script = "../../quickfix/generate_merge_file.py"
691      args = [
692        "--input",
693        rebase_path(merge_file_raw),
694        "--output",
695        rebase_path(merge_file),
696        "--prefix",
697        rebase_path(merge_file_prefix),
698      ]
699
700      inputs = [ merge_file_raw ]
701      outputs = [ merge_file ]
702    }
703  }
704  if (_is_gen_js_) {
705    action("gen_${_target_name_}_js_file") {
706      script = "../../quickfix/generate_js_and_merge_file.py"
707      src_file = rebase_path(_test_js_template_path_)
708      dst_file = rebase_path(_test_js_path_)
709      args = [
710        "--input=$src_file",
711        "--output=$dst_file",
712      ]
713      inputs = [ _test_js_template_path_ ]
714      outputs = [ _test_js_path_ ]
715    }
716  }
717
718  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
719    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
720    extra_dependencies = _deps_
721    src_js = rebase_path(_test_js_path_)
722    dst_file = rebase_path(_test_abc_path_)
723    extra_args = []
724    if (_is_gen_js_) {
725      extra_dependencies = [ ":gen_${_target_name_}_js_file" ]
726    }
727    if (_is_module_) {
728      extra_args += [ "--module" ]
729    }
730    if (_is_commonjs_) {
731      extra_args += [ "--commonjs" ]
732    }
733    if (_is_merge_) {
734      extra_args += [ "--merge-abc" ]
735    }
736    if (_is_merge_abc_) {
737      extra_dependencies = [ ":gen_${_target_name_}_merge_file" ]
738      src_js = "@" + rebase_path(merge_file)
739      in_puts = [ merge_file ]
740    } else {
741      in_puts = [ _test_js_path_ ]
742    }
743    out_puts = [ _test_abc_path_ ]
744  }
745
746  _extra_modules_ = []
747  if (defined(invoker.extra_modules)) {
748    foreach(module, invoker.extra_modules) {
749      _extra_modules_ += [ "$target_out_dir/${module}.abc" ]
750    }
751  }
752  if (defined(invoker.entry_point)) {
753    _script_args_ = invoker.entry_point
754    _script_args_ += " " + rebase_path(_test_abc_path_)
755  } else {
756    _script_args_ = rebase_path(_test_abc_path_)
757  }
758  foreach(extra_module, _extra_modules_) {
759    _script_args_ += ":" + rebase_path(extra_module)
760  }
761
762  action("${_target_name_}AssertAction") {
763    testonly = true
764
765    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
766    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
767    deps = [
768      ":gen_${_target_name_}_abc",
769      _host_jsvm_target_,
770    ]
771    deps += _deps_
772
773    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
774
775    js_vm_options = " --asm-interpreter=false"
776    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
777        invoker.is_set_maxNonmovableSpaceCapacity) {
778      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
779    }
780
781    if (defined(invoker.is_enable_enableArkTools) &&
782        invoker.is_enable_enableArkTools) {
783      js_vm_options += " --enable-ark-tools=true"
784      js_vm_options += " --enable-force-gc=false"
785    }
786    js_vm_options += " --test-assert=true"
787    js_vm_options += common_options
788    args = [
789      "--script-file",
790      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
791      "--script-options",
792      js_vm_options,
793      "--script-args",
794      _script_args_,
795      "--timeout-limit",
796      "${_timeout_}",
797      "--expect-output",
798      "0",
799      "--env-path",
800      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
801          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
802          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
803          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
804          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
805          rebase_path(_root_out_dir_) +
806          "/thirdparty/bounds_checking_function:" +
807          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
808    ]
809
810    inputs = [ _test_abc_path_ ]
811    inputs += _extra_modules_
812
813    outputs = [ "$target_out_dir/${_target_name_}Assert/" ]
814  }
815
816  action("${_target_name_}ContextAssertAction") {
817    testonly = true
818
819    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
820    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
821    deps = [
822      ":gen_${_target_name_}_abc",
823      _host_jsvm_target_,
824    ]
825    deps += _deps_
826
827    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
828
829    js_vm_options = " --asm-interpreter=false"
830    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
831        invoker.is_set_maxNonmovableSpaceCapacity) {
832      js_vm_options += " --max-unmovable-space=524288"  # 0.5M
833    }
834
835    if (defined(invoker.is_enable_enableArkTools) &&
836        invoker.is_enable_enableArkTools) {
837      js_vm_options += " --enable-ark-tools=true"
838      js_vm_options += " --enable-force-gc=false"
839    }
840    js_vm_options += " --enable-context=true"
841    js_vm_options += " --test-assert=true"
842    js_vm_options += common_options
843    args = [
844      "--script-file",
845      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
846      "--script-options",
847      js_vm_options,
848      "--script-args",
849      _script_args_,
850      "--timeout-limit",
851      "${_timeout_}",
852      "--expect-output",
853      "0",
854      "--env-path",
855      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
856          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
857          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
858          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
859          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
860          rebase_path(_root_out_dir_) +
861          "/thirdparty/bounds_checking_function:" +
862          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
863    ]
864
865    inputs = [ _test_abc_path_ ]
866    inputs += _extra_modules_
867
868    outputs = [ "$target_out_dir/${_target_name_}ContextAssert/" ]
869  }
870
871  action("${_target_name_}AsmAssertAction") {
872    testonly = true
873
874    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
875    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
876    deps = [
877      ":gen_${_target_name_}_abc",
878      _host_jsvm_target_,
879    ]
880    deps += _deps_
881
882    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
883
884    _asm_run_options_ = " --asm-interpreter=true"
885    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
886        invoker.is_set_maxNonmovableSpaceCapacity) {
887      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
888    }
889
890    if (defined(invoker.is_set_elements_kind) && invoker.is_set_elements_kind) {
891      _asm_run_options_ += " --enable-elements-kind=true"
892    }
893
894    if (defined(invoker.is_enable_enableArkTools) &&
895        invoker.is_enable_enableArkTools) {
896      _asm_run_options_ += " --enable-ark-tools=true"
897      _asm_run_options_ += " --enable-force-gc=false"
898    }
899    _asm_run_options_ += " --enable-context=true"
900    _asm_run_options_ += " --test-assert=true"
901    _asm_run_options_ += common_options
902    args = [
903      "--script-file",
904      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
905      "--script-options",
906      _asm_run_options_,
907      "--script-args",
908      _script_args_,
909      "--timeout-limit",
910      "${_timeout_}",
911      "--expect-output",
912      "0",
913      "--env-path",
914      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
915          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
916          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
917          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
918          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
919          rebase_path(_root_out_dir_) +
920          "/thirdparty/bounds_checking_function:" +
921          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
922    ]
923
924    inputs = [ _test_abc_path_ ]
925    inputs += _extra_modules_
926
927    outputs = [ "$target_out_dir/${_target_name_}AsmAssert/" ]
928  }
929
930  action("${_target_name_}AsmContextAssertAction") {
931    testonly = true
932
933    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
934    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
935    deps = [
936      ":gen_${_target_name_}_abc",
937      _host_jsvm_target_,
938    ]
939    deps += _deps_
940
941    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
942
943    _asm_run_options_ = " --asm-interpreter=true"
944    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
945        invoker.is_set_maxNonmovableSpaceCapacity) {
946      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
947    }
948
949    if (defined(invoker.is_set_elements_kind) && invoker.is_set_elements_kind) {
950      _asm_run_options_ += " --enable-elements-kind=true"
951    }
952
953    if (defined(invoker.is_enable_enableArkTools) &&
954        invoker.is_enable_enableArkTools) {
955      _asm_run_options_ += " --enable-ark-tools=true"
956      _asm_run_options_ += " --enable-force-gc=false"
957    }
958    _asm_run_options_ = " --test-assert=true"
959    _asm_run_options_ += common_options
960    args = [
961      "--script-file",
962      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
963      "--script-options",
964      _asm_run_options_,
965      "--script-args",
966      _script_args_,
967      "--timeout-limit",
968      "${_timeout_}",
969      "--expect-out",
970      "0",
971      "--env-path",
972      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
973          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
974          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
975          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
976          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
977          rebase_path(_root_out_dir_) +
978          "/thirdparty/bounds_checking_function:" +
979          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
980    ]
981
982    inputs = [ _test_abc_path_ ]
983    inputs += _extra_modules_
984
985    outputs = [ "$target_out_dir/${_target_name_}AsmAssertContext/" ]
986  }
987
988  action("${_target_name_}AsmSingleStepAssertAction") {
989    testonly = true
990
991    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
992    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
993    deps = [
994      ":gen_${_target_name_}_abc",
995      _host_jsvm_target_,
996    ]
997    deps += _deps_
998
999    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1000
1001    # 214: all bytecodes
1002    _asm_run_options_ =
1003        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
1004    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
1005        invoker.is_set_maxNonmovableSpaceCapacity) {
1006      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
1007    }
1008
1009    if (defined(invoker.is_enable_enableArkTools) &&
1010        invoker.is_enable_enableArkTools) {
1011      _asm_run_options_ += " --enable-ark-tools=true"
1012      _asm_run_options_ += " --enable-force-gc=false"
1013    }
1014    _asm_run_options_ += " --test-assert=true"
1015    _asm_run_options_ += common_options
1016    args = [
1017      "--script-file",
1018      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1019      "--script-options",
1020      _asm_run_options_,
1021      "--script-args",
1022      _script_args_,
1023      "--expect-output",
1024      "0",
1025      "--env-path",
1026      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1027          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1028          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1029          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1030          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1031          rebase_path(_root_out_dir_) +
1032          "/thirdparty/bounds_checking_function:" +
1033          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1034    ]
1035
1036    inputs = [ _test_abc_path_ ]
1037    inputs += _extra_modules_
1038
1039    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStepAssert/" ]
1040  }
1041
1042  action("${_target_name_}AsmSingleStepContextAssertAction") {
1043    testonly = true
1044
1045    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1046    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1047    deps = [
1048      ":gen_${_target_name_}_abc",
1049      _host_jsvm_target_,
1050    ]
1051    deps += _deps_
1052
1053    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1054
1055    # 214: all bytecodes
1056    _asm_run_options_ =
1057        " --asm-interpreter=true --asm-opcode-disable-range=0,214"
1058    if (defined(invoker.is_set_maxNonmovableSpaceCapacity) &&
1059        invoker.is_set_maxNonmovableSpaceCapacity) {
1060      _asm_run_options_ += " --max-unmovable-space=524288"  # 0.5M
1061    }
1062
1063    if (defined(invoker.is_enable_enableArkTools) &&
1064        invoker.is_enable_enableArkTools) {
1065      _asm_run_options_ += " --enable-ark-tools=true"
1066      _asm_run_options_ += " --enable-force-gc=false"
1067    }
1068    _asm_run_options_ += " --enable-context=true"
1069    _asm_run_options_ += " --test-assert=true"
1070    _asm_run_options_ += common_options
1071
1072    args = [
1073      "--script-file",
1074      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1075      "--script-options",
1076      _asm_run_options_,
1077      "--script-args",
1078      _script_args_,
1079      "--expect-output",
1080      "0",
1081      "--env-path",
1082      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1083          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1084          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1085          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1086          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1087          rebase_path(_root_out_dir_) +
1088          "/thirdparty/bounds_checking_function:" +
1089          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1090    ]
1091
1092    inputs = [ _test_abc_path_ ]
1093    inputs += _extra_modules_
1094
1095    outputs = [ "$target_out_dir/${_target_name_}AsmSingleStepContextAssert/" ]
1096  }
1097}
1098
1099template("host_aot_js_test_action") {
1100  _target_name_ = "${target_name}"
1101  _deps_ = invoker.deps
1102
1103  _test_ts_path_ = "./${_target_name_}.js"
1104  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
1105  _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
1106  _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
1107  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
1108  _test_aot_log_level = "info"
1109  _test_expect_path_ = "./expect_output.txt"
1110  _test_pgo_expect_path_ = "./pgo_expect_output.txt"
1111  if (target_cpu == "x64" ||
1112      (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1113       target_os == "ohos" && target_cpu == "arm64")) {
1114    _test_aot_path_litecg_ = "$target_out_dir/litecg/${_target_name_}.an"
1115    _test_aot_snapshot_path_litecg_ =
1116        "$target_out_dir/litecg/${_target_name_}.ai"
1117    _test_aot_arg_litecg_ = "$target_out_dir/litecg/${_target_name_}"
1118  }
1119
1120  if (defined(invoker.is_common_js) && invoker.is_common_js) {
1121    extra_args = [ "--commonjs" ]
1122  } else {
1123    extra_args = [ "--module" ]
1124  }
1125  extra_args += [ "--merge-abc" ]
1126
1127  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
1128    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
1129    extra_dependencies = _deps_
1130    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
1131      src_js = rebase_path("./")
1132    } else {
1133      src_js = rebase_path(_test_ts_path_)
1134    }
1135    dst_file = rebase_path(_test_abc_path_)
1136
1137    in_puts = [
1138      _test_ts_path_,
1139      _test_expect_path_,
1140    ]
1141    out_puts = [ _test_abc_path_ ]
1142  }
1143
1144  _script_args_ = rebase_path(_test_abc_path_)
1145
1146  action("${_target_name_}PgoExecute") {
1147    testonly = true
1148    _host_jsvm_target_ =
1149        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1150    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1151
1152    deps = [
1153      ":gen_${_target_name_}_abc",
1154      _host_jsvm_target_,
1155    ]
1156    deps += _deps_
1157
1158    script = "$js_root/script/run_ark_executable.py"
1159
1160    _aot_run_options_ =
1161        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
1162        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
1163        rebase_path(_test_aot_arg_) + "/modules.ap"
1164
1165    if (defined(invoker.is_enable_enableArkTools) &&
1166        invoker.is_enable_enableArkTools) {
1167      _aot_run_options_ += " --enable-ark-tools=true"
1168      _aot_run_options_ += " --enable-force-gc=false"
1169    }
1170
1171    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1172      _aot_run_options_ += " --enable-force-gc=false"
1173    }
1174
1175    _aot_run_options_ += common_options
1176    if (defined(invoker.log_option)) {
1177      _aot_run_options_ += invoker.log_option
1178    }
1179
1180    args = [
1181      "--script-file",
1182      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1183      "--script-options",
1184      _aot_run_options_,
1185      "--script-args",
1186      _script_args_,
1187      "--expect-file",
1188      rebase_path(_test_pgo_expect_path_),
1189      "--env-path",
1190      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1191          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1192          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1193          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1194          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1195          rebase_path(_root_out_dir_) +
1196          "/thirdparty/bounds_checking_function:" +
1197          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1198    ]
1199
1200    inputs = [ _test_abc_path_ ]
1201
1202    outputs = [ "$target_out_dir/${_target_name_}/pgo" ]
1203  }
1204
1205  action("${_target_name_}AotCompileAction") {
1206    testonly = true
1207
1208    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1209    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1210    deps = [
1211      ":gen_${_target_name_}_abc",
1212      _host_aot_target_,
1213    ]
1214    deps += _deps_
1215
1216    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1217      deps += [ ":${_target_name_}PgoExecute" ]
1218    }
1219
1220    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1221
1222    _aot_compile_options_ = " --aot-file=" + rebase_path(_test_aot_arg_) +
1223                            " --log-level=" + _test_aot_log_level + " --log-components=compiler --compiler-opt-type-lowering=false --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=false" + " --compiler-empty-catch-function=true"
1224
1225    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1226      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1227                               rebase_path(_test_aot_arg_) + "/modules.ap"
1228    }
1229    _aot_compile_options_ += common_options
1230    if (defined(invoker.is_enable_trace_deopt) &&
1231        invoker.is_enable_trace_deopt) {
1232      _aot_compile_options_ += " --compiler-trace-deopt=true"
1233    }
1234
1235    if (defined(invoker.is_enable_opt_inlining) &&
1236        invoker.is_enable_opt_inlining) {
1237      _aot_compile_options_ +=
1238          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1239    }
1240
1241    if (defined(invoker.is_enable_typed_op_profiler) &&
1242        invoker.is_enable_typed_op_profiler) {
1243      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
1244    }
1245
1246    if (defined(invoker.is_enable_lowering_builtin) &&
1247        invoker.is_enable_lowering_builtin) {
1248      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1249    }
1250
1251    if (defined(invoker.is_enable_native_inline) &&
1252        invoker.is_enable_native_inline) {
1253      _aot_compile_options_ += " --compiler-enable-native-inline"
1254    }
1255
1256    if (defined(invoker.is_enable_opt_loop_peeling) &&
1257        invoker.is_enable_opt_loop_peeling) {
1258      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1259    }
1260
1261    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1262        invoker.is_enable_opt_array_bounds_check_elimination) {
1263      _aot_compile_options_ +=
1264          " --compiler-opt-array-bounds-check-elimination=true"
1265    }
1266
1267    if (defined(invoker.is_enable_inline_trace) &&
1268        invoker.is_enable_inline_trace) {
1269      _aot_compile_options_ += " --compiler-trace-inline=true"
1270    }
1271
1272    if (defined(invoker.userDefinedMethodsInModule) &&
1273        invoker.userDefinedMethodsInModule) {
1274      _aot_compile_options_ += " --compiler-module-methods=2"
1275    }
1276
1277    args = [
1278      "--script-file",
1279      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
1280      "--script-options",
1281      _aot_compile_options_,
1282      "--script-args",
1283      _script_args_,
1284      "--expect-sub-output",
1285      "ts aot compile success",
1286      "--env-path",
1287      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1288          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1289          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1290          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1291          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1292          rebase_path(_root_out_dir_) +
1293          "/thirdparty/bounds_checking_function:" +
1294          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1295    ]
1296
1297    inputs = [ _test_abc_path_ ]
1298
1299    outputs = [
1300      _test_aot_path_,
1301      _test_aot_snapshot_path_,
1302    ]
1303  }
1304
1305  action("${_target_name_}AotAction") {
1306    testonly = true
1307
1308    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1309    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1310
1311    deps = [
1312      ":${_target_name_}AotCompileAction",
1313      ":gen_${_target_name_}_abc",
1314      _host_jsvm_target_,
1315    ]
1316    deps += _deps_
1317    _is_test_llvm_only_ =
1318        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
1319    if (!_is_test_llvm_only_) {
1320      if (target_cpu == "x64") {
1321        deps += [ ":${_target_name_}AotActionWithLiteCG" ]
1322      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1323                 target_os == "ohos" && target_cpu == "arm64") {
1324        deps += [ ":${_target_name_}AotActionWithLiteCGQemu" ]
1325      }
1326    }
1327
1328    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1329
1330    _aot_run_options_ =
1331        " --aot-file=" + rebase_path(_test_aot_arg_) +
1332        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1333
1334    if (defined(invoker.is_enable_enableArkTools) &&
1335        invoker.is_enable_enableArkTools) {
1336      _aot_run_options_ += " --enable-ark-tools=true"
1337      _aot_run_options_ += " --enable-force-gc=false"
1338    }
1339    _aot_run_options_ += common_options
1340    if (defined(invoker.log_option)) {
1341      _aot_run_options_ += invoker.log_option
1342    }
1343
1344    if (defined(invoker.is_enable_typed_op_profiler) &&
1345        invoker.is_enable_typed_op_profiler) {
1346      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1347    }
1348
1349    if (defined(invoker.is_enable_lowering_builtin) &&
1350        invoker.is_enable_lowering_builtin) {
1351      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1352    }
1353
1354    _icu_data_path_options_ =
1355        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1356    _aot_run_options_ += _icu_data_path_options_
1357
1358    if (defined(invoker.log_option)) {
1359      _aot_run_options_ += invoker.log_option
1360    }
1361
1362    args = [
1363      "--script-file",
1364      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1365      "--script-options",
1366      _aot_run_options_,
1367      "--script-args",
1368      _script_args_,
1369      "--expect-file",
1370      rebase_path(_test_expect_path_),
1371      "--env-path",
1372      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1373          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1374          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1375          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1376          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1377          rebase_path(_root_out_dir_) +
1378          "/thirdparty/bounds_checking_function:" +
1379          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1380    ]
1381
1382    inputs = [ _test_abc_path_ ]
1383
1384    outputs = [ "$target_out_dir/${_target_name_}/" ]
1385  }
1386
1387  action("${_target_name_}AotContextAction") {
1388    testonly = true
1389
1390    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1391    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1392
1393    deps = [
1394      ":${_target_name_}AotCompileAction",
1395      ":gen_${_target_name_}_abc",
1396      _host_jsvm_target_,
1397    ]
1398    deps += _deps_
1399
1400    _is_test_llvm_only_ =
1401        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
1402    if (!_is_test_llvm_only_) {
1403      if (target_cpu == "x64") {
1404        deps += [ ":${_target_name_}AotContextActionWithLiteCG" ]
1405      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1406                 target_os == "ohos" && target_cpu == "arm64") {
1407        deps += [ ":${_target_name_}AotContextActionWithLiteCGQemu" ]
1408      }
1409    }
1410
1411    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1412
1413    _aot_run_options_ =
1414        " --aot-file=" + rebase_path(_test_aot_arg_) +
1415        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1416
1417    _aot_run_options_ += common_options
1418    if (defined(invoker.is_enable_enableArkTools) &&
1419        invoker.is_enable_enableArkTools) {
1420      _aot_run_options_ += " --enable-ark-tools=true"
1421      _aot_run_options_ += " --enable-force-gc=false"
1422    }
1423
1424    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1425      _aot_run_options_ += " --enable-force-gc=false"
1426    }
1427
1428    if (defined(invoker.log_option)) {
1429      _aot_run_options_ += invoker.log_option
1430    }
1431
1432    if (defined(invoker.is_enable_typed_op_profiler) &&
1433        invoker.is_enable_typed_op_profiler) {
1434      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1435    }
1436
1437    if (defined(invoker.is_enable_lowering_builtin) &&
1438        invoker.is_enable_lowering_builtin) {
1439      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1440    }
1441
1442    _icu_data_path_options_ =
1443        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1444    _aot_run_options_ += _icu_data_path_options_
1445    _aot_run_options_ += " --enable-context=true"
1446
1447    args = [
1448      "--script-file",
1449      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1450      "--script-options",
1451      _aot_run_options_,
1452      "--script-args",
1453      _script_args_,
1454      "--expect-file",
1455      rebase_path(_test_expect_path_),
1456      "--env-path",
1457      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1458          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1459          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1460          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1461          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1462          rebase_path(_root_out_dir_) +
1463          "/thirdparty/bounds_checking_function:" +
1464          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1465    ]
1466
1467    inputs = [ _test_abc_path_ ]
1468
1469    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
1470  }
1471
1472  if (target_cpu == "x64") {
1473    action("${_target_name_}AotCompileActionWithLiteCG") {
1474      testonly = true
1475
1476      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1477      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1478      deps = [
1479        ":gen_${_target_name_}_abc",
1480        _host_aot_target_,
1481      ]
1482      deps += _deps_
1483
1484      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1485        deps += [ ":${_target_name_}PgoExecute" ]
1486      }
1487
1488      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1489
1490      _aot_compile_options_ =
1491          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1492          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
1493          " --compiler-opt-type-lowering=false" +
1494          " --compiler-opt-inlining=false" +
1495          " --compiler-opt-loop-peeling=false" +
1496          " --compiler-enable-litecg=true" +
1497          " --compiler-empty-catch-function=true"
1498
1499      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1500        _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1501                                 rebase_path(_test_aot_arg_) + "/modules.ap"
1502      }
1503
1504      if (defined(invoker.is_enable_trace_deopt) &&
1505          invoker.is_enable_trace_deopt) {
1506        _aot_compile_options_ += " --compiler-trace-deopt=true"
1507      }
1508
1509      if (defined(invoker.is_enable_opt_inlining) &&
1510          invoker.is_enable_opt_inlining) {
1511        _aot_compile_options_ +=
1512            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1513      }
1514
1515      if (defined(invoker.is_enable_typed_op_profiler) &&
1516          invoker.is_enable_typed_op_profiler) {
1517        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
1518      }
1519
1520      if (defined(invoker.is_enable_lowering_builtin) &&
1521          invoker.is_enable_lowering_builtin) {
1522        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1523      }
1524
1525      if (defined(invoker.is_enable_native_inline) &&
1526          invoker.is_enable_native_inline) {
1527        _aot_compile_options_ += " --compiler-enable-native-inline"
1528      }
1529
1530      if (defined(invoker.is_enable_opt_loop_peeling) &&
1531          invoker.is_enable_opt_loop_peeling) {
1532        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1533      }
1534
1535      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1536          invoker.is_enable_opt_array_bounds_check_elimination) {
1537        _aot_compile_options_ +=
1538            " --compiler-opt-array-bounds-check-elimination=true"
1539      }
1540
1541      if (defined(invoker.is_enable_inline_trace) &&
1542          invoker.is_enable_inline_trace) {
1543        _aot_compile_options_ += " --compiler-trace-inline=true"
1544      }
1545
1546      if (defined(invoker.userDefinedMethodsInModule) &&
1547          invoker.userDefinedMethodsInModule) {
1548        _aot_compile_options_ += " --compiler-module-methods=2"
1549      }
1550      _aot_compile_options_ += common_options
1551      args = [
1552        "--script-file",
1553        rebase_path(_root_out_dir_) +
1554            "/arkcompiler/ets_runtime/ark_aot_compiler",
1555        "--script-options",
1556        _aot_compile_options_,
1557        "--script-args",
1558        _script_args_,
1559        "--expect-sub-output",
1560        "ts aot compile success",
1561        "--env-path",
1562        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1563            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1564            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1565            rebase_path(_root_out_dir_) +
1566            "/resourceschedule/frame_aware_sched:" +
1567            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1568            rebase_path(_root_out_dir_) +
1569            "/thirdparty/bounds_checking_function:" +
1570            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1571      ]
1572
1573      inputs = [ _test_abc_path_ ]
1574
1575      outputs = [
1576        _test_aot_path_litecg_,
1577        _test_aot_snapshot_path_litecg_,
1578      ]
1579    }
1580
1581    action("${_target_name_}AotActionWithLiteCG") {
1582      testonly = true
1583
1584      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1585      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1586
1587      deps = [
1588        ":${_target_name_}AotCompileActionWithLiteCG",
1589        ":gen_${_target_name_}_abc",
1590        _host_jsvm_target_,
1591      ]
1592      deps += _deps_
1593
1594      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1595
1596      _aot_run_options_ =
1597          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1598          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1599
1600      if (defined(invoker.is_enable_enableArkTools) &&
1601          invoker.is_enable_enableArkTools) {
1602        _aot_run_options_ += " --enable-ark-tools=true"
1603        _aot_run_options_ += " --enable-force-gc=false"
1604      }
1605      _aot_run_options_ += common_options
1606      if (defined(invoker.log_option)) {
1607        _aot_run_options_ += invoker.log_option
1608      }
1609
1610      if (defined(invoker.is_enable_typed_op_profiler) &&
1611          invoker.is_enable_typed_op_profiler) {
1612        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1613      }
1614
1615      if (defined(invoker.is_enable_lowering_builtin) &&
1616          invoker.is_enable_lowering_builtin) {
1617        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1618      }
1619
1620      _icu_data_path_options_ =
1621          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1622      _aot_run_options_ += _icu_data_path_options_
1623
1624      args = [
1625        "--script-file",
1626        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1627        "--script-options",
1628        _aot_run_options_,
1629        "--script-args",
1630        _script_args_,
1631        "--expect-file",
1632        rebase_path(_test_expect_path_),
1633        "--env-path",
1634        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1635            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1636            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1637            rebase_path(_root_out_dir_) +
1638            "/resourceschedule/frame_aware_sched:" +
1639            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1640            rebase_path(_root_out_dir_) +
1641            "/thirdparty/bounds_checking_function:" +
1642            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1643      ]
1644
1645      inputs = [ _test_abc_path_ ]
1646
1647      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
1648    }
1649
1650    action("${_target_name_}AotContextActionWithLiteCG") {
1651      testonly = true
1652
1653      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1654      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1655
1656      deps = [
1657        ":${_target_name_}AotCompileActionWithLiteCG",
1658        ":gen_${_target_name_}_abc",
1659        _host_jsvm_target_,
1660      ]
1661      deps += _deps_
1662
1663      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1664
1665      _aot_run_options_ =
1666          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1667          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1668
1669      if (defined(invoker.is_enable_enableArkTools) &&
1670          invoker.is_enable_enableArkTools) {
1671        _aot_run_options_ += " --enable-ark-tools=true"
1672        _aot_run_options_ += " --enable-force-gc=false"
1673      }
1674
1675      if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1676        _aot_run_options_ += " --enable-force-gc=false"
1677      }
1678      _aot_run_options_ += common_options
1679
1680      if (defined(invoker.log_option)) {
1681        _aot_run_options_ += invoker.log_option
1682      }
1683
1684      if (defined(invoker.is_enable_typed_op_profiler) &&
1685          invoker.is_enable_typed_op_profiler) {
1686        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1687      }
1688
1689      if (defined(invoker.is_enable_lowering_builtin) &&
1690          invoker.is_enable_lowering_builtin) {
1691        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1692      }
1693
1694      _icu_data_path_options_ =
1695          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1696      _aot_run_options_ += _icu_data_path_options_
1697      _aot_run_options_ += " --enable-context=true"
1698
1699      args = [
1700        "--script-file",
1701        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1702        "--script-options",
1703        _aot_run_options_,
1704        "--script-args",
1705        _script_args_,
1706        "--expect-file",
1707        rebase_path(_test_expect_path_),
1708        "--env-path",
1709        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1710            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1711            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1712            rebase_path(_root_out_dir_) +
1713            "/resourceschedule/frame_aware_sched:" +
1714            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1715            rebase_path(_root_out_dir_) +
1716            "/thirdparty/bounds_checking_function:" +
1717            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1718      ]
1719
1720      inputs = [ _test_abc_path_ ]
1721
1722      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
1723    }
1724  } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1725             target_os == "ohos" && target_cpu == "arm64") {
1726    import("$ark_third_party_root/musl/musl_template.gni")
1727    import("$build_root/config/qemu/config.gni")
1728
1729    action("${_target_name_}AotCompileActionWithLiteCGQemu") {
1730      testonly = true
1731
1732      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1733      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1734      deps = [
1735        ":gen_${_target_name_}_abc",
1736        _host_aot_target_,
1737      ]
1738      deps += _deps_
1739
1740      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1741        deps += [ ":${_target_name_}PgoExecute" ]
1742      }
1743
1744      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1745
1746      _aot_compile_options_ =
1747          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1748          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
1749          " --compiler-opt-type-lowering=false" +
1750          " --compiler-opt-inlining=false" +
1751          " --compiler-opt-loop-peeling=false" +
1752          " --compiler-enable-litecg=true" +
1753          " --compiler-target-triple=aarch64-unknown-linux-gnu" +
1754          " --compiler-empty-catch-function=true"
1755
1756      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1757        _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1758                                 rebase_path(_test_aot_arg_) + "/modules.ap"
1759      }
1760
1761      if (defined(invoker.is_enable_trace_deopt) &&
1762          invoker.is_enable_trace_deopt) {
1763        _aot_compile_options_ += " --compiler-trace-deopt=true"
1764      }
1765
1766      if (defined(invoker.is_enable_opt_inlining) &&
1767          invoker.is_enable_opt_inlining) {
1768        _aot_compile_options_ +=
1769            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1770      }
1771
1772      if (defined(invoker.is_enable_typed_op_profiler) &&
1773          invoker.is_enable_typed_op_profiler) {
1774        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
1775      }
1776
1777      if (defined(invoker.is_enable_lowering_builtin) &&
1778          invoker.is_enable_lowering_builtin) {
1779        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1780      }
1781
1782      if (defined(invoker.is_enable_native_inline) &&
1783          invoker.is_enable_native_inline) {
1784        _aot_compile_options_ += " --compiler-enable-native-inline"
1785      }
1786
1787      if (defined(invoker.is_enable_opt_loop_peeling) &&
1788          invoker.is_enable_opt_loop_peeling) {
1789        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1790      }
1791
1792      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1793          invoker.is_enable_opt_array_bounds_check_elimination) {
1794        _aot_compile_options_ +=
1795            " --compiler-opt-array-bounds-check-elimination=true"
1796      }
1797
1798      if (defined(invoker.is_enable_inline_trace) &&
1799          invoker.is_enable_inline_trace) {
1800        _aot_compile_options_ += " --compiler-trace-inline=true"
1801      }
1802
1803      if (defined(invoker.userDefinedMethodsInModule) &&
1804          invoker.userDefinedMethodsInModule) {
1805        _aot_compile_options_ += " --compiler-module-methods=2"
1806      }
1807      _aot_compile_options_ += common_options
1808      args = [
1809        "--script-file",
1810        rebase_path(_root_out_dir_) +
1811            "/arkcompiler/ets_runtime/ark_aot_compiler",
1812        "--script-options",
1813        _aot_compile_options_,
1814        "--script-args",
1815        _script_args_,
1816        "--expect-sub-output",
1817        "ts aot compile success",
1818        "--env-path",
1819        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1820            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1821            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1822            rebase_path(_root_out_dir_) +
1823            "/resourceschedule/frame_aware_sched:" +
1824            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1825            rebase_path(_root_out_dir_) +
1826            "/thirdparty/bounds_checking_function:" +
1827            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1828      ]
1829
1830      inputs = [ _test_abc_path_ ]
1831
1832      outputs = [
1833        _test_aot_path_litecg_,
1834        _test_aot_snapshot_path_litecg_,
1835      ]
1836    }
1837
1838    action("${_target_name_}AotActionWithLiteCGQemu") {
1839      testonly = true
1840
1841      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
1842      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1843
1844      deps = [
1845        ":${_target_name_}AotCompileActionWithLiteCGQemu",
1846        ":gen_${_target_name_}_abc",
1847        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
1848        _host_jsvm_target_,
1849      ]
1850      deps += _deps_
1851
1852      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1853
1854      _aot_run_options_ =
1855          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1856          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1857
1858      if (defined(invoker.is_enable_enableArkTools) &&
1859          invoker.is_enable_enableArkTools) {
1860        _aot_run_options_ += " --enable-ark-tools=true"
1861        _aot_run_options_ += " --enable-force-gc=false"
1862      }
1863      _aot_run_options_ += common_options
1864      if (defined(invoker.log_option)) {
1865        _aot_run_options_ += invoker.log_option
1866      }
1867
1868      if (defined(invoker.is_enable_typed_op_profiler) &&
1869          invoker.is_enable_typed_op_profiler) {
1870        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1871      }
1872
1873      if (defined(invoker.is_enable_lowering_builtin) &&
1874          invoker.is_enable_lowering_builtin) {
1875        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1876      }
1877
1878      _icu_data_path_options_ =
1879          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1880      _aot_run_options_ += _icu_data_path_options_
1881
1882      args = [
1883        "--script-file",
1884        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1885        "--script-options",
1886        _aot_run_options_,
1887        "--script-args",
1888        _script_args_,
1889        "--expect-file",
1890        rebase_path(_test_expect_path_),
1891        "--qemu-binary-path",
1892        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
1893        "--qemu-ld-prefix",
1894        rebase_path(musl_linker_so_out_dir, root_build_dir),
1895        "--clang-lib-path",
1896        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
1897                    root_build_dir) + rebase_path(_root_out_dir_) +
1898            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
1899            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
1900            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
1901            "/resourceschedule/frame_aware_sched:" +
1902            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1903            rebase_path(_root_out_dir_) +
1904            "/thirdparty/bounds_checking_function:" +
1905            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1906      ]
1907
1908      inputs = [ _test_abc_path_ ]
1909
1910      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
1911    }
1912
1913    action("${_target_name_}AotContextActionWithLiteCGQemu") {
1914      testonly = true
1915
1916      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
1917      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1918
1919      deps = [
1920        ":${_target_name_}AotCompileActionWithLiteCGQemu",
1921        ":gen_${_target_name_}_abc",
1922        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
1923        _host_jsvm_target_,
1924      ]
1925      deps += _deps_
1926
1927      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1928
1929      _aot_run_options_ =
1930          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1931          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1932
1933      if (defined(invoker.is_enable_enableArkTools) &&
1934          invoker.is_enable_enableArkTools) {
1935        _aot_run_options_ += " --enable-ark-tools=true"
1936        _aot_run_options_ += " --enable-force-gc=false"
1937      }
1938
1939      if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1940        _aot_run_options_ += " --enable-force-gc=false"
1941      }
1942
1943      _aot_run_options_ += common_options
1944
1945      if (defined(invoker.log_option)) {
1946        _aot_run_options_ += invoker.log_option
1947      }
1948
1949      if (defined(invoker.is_enable_typed_op_profiler) &&
1950          invoker.is_enable_typed_op_profiler) {
1951        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1952      }
1953
1954      if (defined(invoker.is_enable_lowering_builtin) &&
1955          invoker.is_enable_lowering_builtin) {
1956        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1957      }
1958
1959      _icu_data_path_options_ =
1960          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1961      _aot_run_options_ += _icu_data_path_options_
1962      _aot_run_options_ += " --enable-context=true"
1963
1964      args = [
1965        "--script-file",
1966        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1967        "--script-options",
1968        _aot_run_options_,
1969        "--script-args",
1970        _script_args_,
1971        "--expect-file",
1972        rebase_path(_test_expect_path_),
1973        "--qemu-binary-path",
1974        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
1975        "--qemu-ld-prefix",
1976        rebase_path(musl_linker_so_out_dir, root_build_dir),
1977        "--clang-lib-path",
1978        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
1979                    root_build_dir) + rebase_path(_root_out_dir_) +
1980            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
1981            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
1982            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
1983            "/resourceschedule/frame_aware_sched:" +
1984            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1985            rebase_path(_root_out_dir_) +
1986            "/thirdparty/bounds_checking_function:" +
1987            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1988      ]
1989
1990      inputs = [ _test_abc_path_ ]
1991
1992      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
1993    }
1994  }
1995}
1996
1997template("host_aot_js_assert_test_action") {
1998  _target_name_ = "${target_name}"
1999  _deps_ = invoker.deps
2000
2001  _test_ts_path_ = "./${_target_name_}.js"
2002  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
2003  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
2004  _test_aot_log_level = "info"
2005
2006  if (defined(invoker.is_common_js) && invoker.is_common_js) {
2007    extra_args = [ "--commonjs" ]
2008  } else {
2009    extra_args = [ "--module" ]
2010  }
2011  extra_args += [ "--merge-abc" ]
2012
2013  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
2014    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
2015    extra_dependencies = _deps_
2016    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
2017      src_js = rebase_path("./")
2018    } else {
2019      src_js = rebase_path(_test_ts_path_)
2020    }
2021    dst_file = rebase_path(_test_abc_path_)
2022
2023    in_puts = [ _test_ts_path_ ]
2024    out_puts = [ _test_abc_path_ ]
2025  }
2026
2027  _script_args_ = rebase_path(_test_abc_path_)
2028
2029  action("${_target_name_}PgoExecuteAssert") {
2030    testonly = true
2031    _host_jsvm_target_ =
2032        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2033    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2034
2035    deps = [
2036      ":gen_${_target_name_}_abc",
2037      _host_jsvm_target_,
2038    ]
2039    deps += _deps_
2040
2041    script = "$js_root/script/run_ark_executable.py"
2042
2043    _aot_run_options_ =
2044        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
2045        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
2046        rebase_path(_test_aot_arg_) + "/modules.ap"
2047
2048    if (defined(invoker.is_enable_enableArkTools) &&
2049        invoker.is_enable_enableArkTools) {
2050      _aot_run_options_ += " --enable-ark-tools=true"
2051      _aot_run_options_ += " --enable-force-gc=false"
2052    }
2053
2054    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
2055      _aot_run_options_ += " --enable-force-gc=false"
2056    }
2057
2058    _aot_run_options_ += common_options
2059
2060    if (defined(invoker.log_option)) {
2061      _aot_run_options_ += invoker.log_option
2062    }
2063
2064    _aot_run_options_ += " --test-assert=true"
2065
2066    args = [
2067      "--script-file",
2068      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2069      "--script-options",
2070      _aot_run_options_,
2071      "--script-args",
2072      _script_args_,
2073      "--expect-output",
2074      "0",
2075      "--env-path",
2076      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2077          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2078          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2079          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2080          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2081          rebase_path(_root_out_dir_) +
2082          "/thirdparty/bounds_checking_function:" +
2083          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2084    ]
2085
2086    inputs = [ _test_abc_path_ ]
2087
2088    outputs = [ "$target_out_dir/${_target_name_}/pgoassert" ]
2089  }
2090
2091  action("${_target_name_}AotCompileAssertAction") {
2092    testonly = true
2093
2094    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2095    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2096    deps = [
2097      ":gen_${_target_name_}_abc",
2098      _host_aot_target_,
2099    ]
2100    deps += _deps_
2101
2102    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2103      deps += [ ":${_target_name_}PgoExecuteAssert" ]
2104    }
2105
2106    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2107
2108    _aot_compile_options_ = " --aot-file=" + rebase_path(_test_aot_arg_) +
2109                            " --log-level=" + _test_aot_log_level + " --log-components=compiler --compiler-opt-type-lowering=false --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=false" + " --compiler-empty-catch-function=true"
2110
2111    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2112      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
2113                               rebase_path(_test_aot_arg_) + "/modules.ap"
2114    }
2115
2116    if (defined(invoker.is_enable_trace_deopt) &&
2117        invoker.is_enable_trace_deopt) {
2118      _aot_compile_options_ += " --compiler-trace-deopt=true"
2119    }
2120
2121    if (defined(invoker.is_enable_opt_inlining) &&
2122        invoker.is_enable_opt_inlining) {
2123      _aot_compile_options_ +=
2124          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2125    }
2126
2127    if (defined(invoker.is_enable_typed_op_profiler) &&
2128        invoker.is_enable_typed_op_profiler) {
2129      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
2130    }
2131
2132    if (defined(invoker.is_enable_lowering_builtin) &&
2133        invoker.is_enable_lowering_builtin) {
2134      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
2135    }
2136
2137    if (defined(invoker.is_enable_native_inline) &&
2138        invoker.is_enable_native_inline) {
2139      _aot_compile_options_ += " --compiler-enable-native-inline"
2140    }
2141
2142    if (defined(invoker.is_enable_opt_loop_peeling) &&
2143        invoker.is_enable_opt_loop_peeling) {
2144      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2145    }
2146
2147    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2148        invoker.is_enable_opt_array_bounds_check_elimination) {
2149      _aot_compile_options_ +=
2150          " --compiler-opt-array-bounds-check-elimination=true"
2151    }
2152
2153    if (defined(invoker.is_enable_inline_trace) &&
2154        invoker.is_enable_inline_trace) {
2155      _aot_compile_options_ += " --compiler-trace-inline=true"
2156    }
2157
2158    if (defined(invoker.userDefinedMethodsInModule) &&
2159        invoker.userDefinedMethodsInModule) {
2160      _aot_compile_options_ += " --compiler-module-methods=2"
2161    }
2162    _aot_compile_options_ += common_options
2163    _aot_compile_options_ += " --test-assert=true"
2164
2165    args = [
2166      "--script-file",
2167      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2168      "--script-options",
2169      _aot_compile_options_,
2170      "--script-args",
2171      _script_args_,
2172      "--expect-sub-output",
2173      "ts aot compile success",
2174      "--env-path",
2175      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2176          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2177          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2178          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2179          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2180          rebase_path(_root_out_dir_) +
2181          "/thirdparty/bounds_checking_function:" +
2182          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2183    ]
2184
2185    inputs = [ _test_abc_path_ ]
2186
2187    outputs = [
2188      "$target_out_dir/${_target_name_}AotCompileAssert.an",
2189      "$target_out_dir/${_target_name_}AotCompileAssert.ai",
2190    ]
2191  }
2192
2193  action("${_target_name_}AotAssertAction") {
2194    testonly = true
2195
2196    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2197    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2198
2199    deps = [
2200      ":${_target_name_}AotCompileAssertAction",
2201      ":gen_${_target_name_}_abc",
2202      _host_jsvm_target_,
2203    ]
2204    deps += _deps_
2205
2206    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2207
2208    _aot_run_options_ =
2209        " --aot-file=" + rebase_path(_test_aot_arg_) +
2210        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2211
2212    if (defined(invoker.is_enable_enableArkTools) &&
2213        invoker.is_enable_enableArkTools) {
2214      _aot_run_options_ += " --enable-ark-tools=true"
2215      _aot_run_options_ += " --enable-force-gc=false"
2216    }
2217    _aot_run_options_ += common_options
2218    if (defined(invoker.log_option)) {
2219      _aot_run_options_ += invoker.log_option
2220    }
2221
2222    if (defined(invoker.is_enable_typed_op_profiler) &&
2223        invoker.is_enable_typed_op_profiler) {
2224      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2225    }
2226
2227    if (defined(invoker.is_enable_lowering_builtin) &&
2228        invoker.is_enable_lowering_builtin) {
2229      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2230    }
2231
2232    _icu_data_path_options_ =
2233        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2234    _aot_run_options_ += _icu_data_path_options_
2235
2236    if (defined(invoker.log_option)) {
2237      _aot_run_options_ += invoker.log_option
2238    }
2239
2240    _aot_run_options_ += " --test-assert=true"
2241
2242    args = [
2243      "--script-file",
2244      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2245      "--script-options",
2246      _aot_run_options_,
2247      "--script-args",
2248      _script_args_,
2249      "--expect-output",
2250      "0",
2251      "--env-path",
2252      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2253          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2254          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2255          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2256          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2257          rebase_path(_root_out_dir_) +
2258          "/thirdparty/bounds_checking_function:" +
2259          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2260    ]
2261
2262    inputs = [ _test_abc_path_ ]
2263
2264    outputs = [ "$target_out_dir/${_target_name_}AotAssert/" ]
2265  }
2266
2267  action("${_target_name_}AotContextAssertAction") {
2268    testonly = true
2269
2270    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2271    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2272
2273    deps = [
2274      ":${_target_name_}AotCompileAssertAction",
2275      ":gen_${_target_name_}_abc",
2276      _host_jsvm_target_,
2277    ]
2278    deps += _deps_
2279
2280    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2281
2282    _aot_run_options_ =
2283        " --aot-file=" + rebase_path(_test_aot_arg_) +
2284        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2285
2286    if (defined(invoker.is_enable_enableArkTools) &&
2287        invoker.is_enable_enableArkTools) {
2288      _aot_run_options_ += " --enable-ark-tools=true"
2289      _aot_run_options_ += " --enable-force-gc=false"
2290    }
2291
2292    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
2293      _aot_run_options_ += " --enable-force-gc=false"
2294    }
2295    _aot_run_options_ += common_options
2296
2297    if (defined(invoker.log_option)) {
2298      _aot_run_options_ += invoker.log_option
2299    }
2300
2301    if (defined(invoker.is_enable_typed_op_profiler) &&
2302        invoker.is_enable_typed_op_profiler) {
2303      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2304    }
2305
2306    if (defined(invoker.is_enable_lowering_builtin) &&
2307        invoker.is_enable_lowering_builtin) {
2308      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2309    }
2310
2311    _icu_data_path_options_ =
2312        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2313    _aot_run_options_ += _icu_data_path_options_
2314    _aot_run_options_ += " --enable-context=true"
2315    _aot_run_options_ += " --test-assert=true"
2316
2317    args = [
2318      "--script-file",
2319      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2320      "--script-options",
2321      _aot_run_options_,
2322      "--script-args",
2323      _script_args_,
2324      "--expect-output",
2325      "0",
2326      "--env-path",
2327      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2328          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2329          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2330          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2331          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2332          rebase_path(_root_out_dir_) +
2333          "/thirdparty/bounds_checking_function:" +
2334          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2335    ]
2336
2337    inputs = [ _test_abc_path_ ]
2338
2339    outputs = [ "$target_out_dir/${_target_name_}ContextAssert/" ]
2340  }
2341}
2342
2343template("host_aot_test_action") {
2344  _target_name_ = "${target_name}"
2345  _deps_ = invoker.deps
2346
2347  _src_dir_ = "."
2348  if (defined(invoker.src_dir) && invoker.src_dir != "") {
2349    _src_dir_ = invoker.src_dir
2350  }
2351
2352  if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2353    _test_ts_template_path_ = "${_src_dir_}/${_target_name_}.ts"
2354    _test_ts_path_ = "$target_out_dir/${_target_name_}.ts"
2355  } else {
2356    _test_ts_path_ = "${_src_dir_}/${_target_name_}.ts"
2357  }
2358  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
2359  _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
2360  _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
2361  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
2362  _test_profiler_path_ = "${_test_aot_arg_}/modules.ap"
2363  _test_aot_path_slowpath_ = "$target_out_dir/slowpath/${_target_name_}.an"
2364  _test_aot_snapshot_path_slowpath_ =
2365      "$target_out_dir/slowpath/${_target_name_}.ai"
2366  _test_aot_arg_slowpath_ = "$target_out_dir/slowpath/${_target_name_}"
2367  _test_aot_log_level = "info"
2368  _test_expect_path_ = "${_src_dir_}/expect_output.txt"
2369  _test_pgo_expect_path_ = "${_src_dir_}/pgo_expect_output.txt"
2370  _is_test_llvm_only_ = TEST_LLVM_ONLY
2371  if (!TEST_LLVM_ONLY && defined(invoker.is_test_llvm_only) &&
2372      invoker.is_test_llvm_only) {
2373    _is_test_llvm_only_ = true
2374  }
2375  if (defined(invoker.use_one_expect_path) && invoker.use_one_expect_path) {
2376    _test_pgo_expect_path_ = _test_expect_path_
2377  }
2378  if (target_cpu == "x64" ||
2379      (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2380       target_os == "ohos" && target_cpu == "arm64")) {
2381    _test_aot_path_litecg_ = "$target_out_dir/litecg/${_target_name_}.an"
2382    _test_aot_snapshot_path_litecg_ =
2383        "$target_out_dir/litecg/${_target_name_}.ai"
2384    _test_aot_arg_litecg_ = "$target_out_dir/litecg/${_target_name_}"
2385    _test_aot_path_slowpath_litecg_ =
2386        "$target_out_dir/slowpath/litecg/${_target_name_}.an"
2387    _test_aot_snapshot_path_slowpath_litecg_ =
2388        "$target_out_dir/slowpath/litecg/${_target_name_}.ai"
2389    _test_aot_arg_slowpath_litecg_ =
2390        "$target_out_dir/slowpath/litecg/${_target_name_}"
2391  }
2392
2393  if (defined(invoker.gen_expect_output) && invoker.gen_expect_output) {
2394    _test_expect_path_ = "$target_out_dir/expect_output.txt"
2395    _test_pgo_expect_path_ = "$target_out_dir/pgo_expect_output.txt"
2396
2397    action("${_target_name_}GenExpectOutput") {
2398      script = "$js_root/script/gen_expect_output.sh"
2399      sources = [ _test_ts_path_ ]
2400      outputs = [ _test_expect_path_ ]
2401      args = [ "aot" ] + rebase_path(sources + outputs)
2402    }
2403
2404    action("${_target_name_}PgoGenExpectOutput") {
2405      script = "$js_root/script/gen_expect_output.sh"
2406      sources = [ _test_ts_path_ ]
2407      outputs = [ _test_pgo_expect_path_ ]
2408      args = [ "pgo" ] + rebase_path(sources + outputs)
2409    }
2410    _deps_ += [
2411      ":${_target_name_}GenExpectOutput",
2412      ":${_target_name_}PgoGenExpectOutput",
2413    ]
2414  }
2415
2416  if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2417    action("gen_${_target_name_}_ts") {
2418      script = "//arkcompiler/ets_runtime/test/quickfix/generate_js_and_merge_file.py"
2419      src_file = rebase_path(_test_ts_template_path_)
2420      dst_file = rebase_path(_test_ts_path_)
2421      args = [
2422        "--input=$src_file",
2423        "--output=$dst_file",
2424      ]
2425      inputs = [ _test_ts_template_path_ ]
2426      outputs = [ _test_ts_path_ ]
2427    }
2428  }
2429
2430  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
2431    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
2432    extra_dependencies = _deps_
2433    if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2434      extra_dependencies += [ ":gen_${_target_name_}_ts" ]
2435    }
2436    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
2437      src_js = rebase_path("./")
2438    } else {
2439      src_js = rebase_path(_test_ts_path_)
2440    }
2441    dst_file = rebase_path(_test_abc_path_)
2442    extension = "ts"
2443    extra_args = [ "--merge-abc" ]
2444
2445    if (!(defined(invoker.without_module) && invoker.without_module)) {
2446      extra_args += [ "--module" ]
2447    }
2448
2449    if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
2450      extra_args += [ "--debug" ]
2451    }
2452
2453    in_puts = [
2454      _test_ts_path_,
2455      _test_expect_path_,
2456    ]
2457    out_puts = [ _test_abc_path_ ]
2458  }
2459
2460  _script_args_ = rebase_path(_test_abc_path_)
2461
2462  action("${_target_name_}PgoExecute") {
2463    testonly = true
2464    _host_jsvm_target_ =
2465        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2466    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2467
2468    deps = [
2469      ":gen_${_target_name_}_abc",
2470      _host_jsvm_target_,
2471    ]
2472    deps += _deps_
2473
2474    script = "$js_root/script/run_ark_executable.py"
2475
2476    _aot_run_options_ =
2477        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
2478        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
2479        rebase_path(_test_profiler_path_)
2480
2481    if (defined(invoker.is_enable_enableArkTools) &&
2482        invoker.is_enable_enableArkTools) {
2483      _aot_run_options_ += " --enable-ark-tools=true"
2484      _aot_run_options_ += " --enable-force-gc=false"
2485    }
2486    if (defined(invoker.log_option)) {
2487      _aot_run_options_ += invoker.log_option
2488    }
2489    _aot_run_options_ += common_options
2490    args = [
2491      "--script-file",
2492      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2493      "--script-options",
2494      _aot_run_options_,
2495      "--script-args",
2496      _script_args_,
2497      "--expect-file",
2498      rebase_path(_test_pgo_expect_path_),
2499      "--env-path",
2500      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2501          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2502          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2503          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2504          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2505          rebase_path(_root_out_dir_) +
2506          "/thirdparty/bounds_checking_function:" +
2507          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2508    ]
2509
2510    inputs = [ _test_abc_path_ ]
2511
2512    outputs = [ _test_profiler_path_ ]
2513  }
2514
2515  action("${_target_name_}AotCompileAction") {
2516    testonly = true
2517
2518    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2519    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2520    deps = [
2521      ":gen_${_target_name_}_abc",
2522      _host_aot_target_,
2523    ]
2524    deps += _deps_
2525
2526    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2527      deps += [ ":${_target_name_}PgoExecute" ]
2528    }
2529
2530    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2531
2532    _aot_compile_options_ =
2533        " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
2534        _test_aot_log_level + " --log-components=compiler" +
2535        " --compiler-opt-inlining=false" +
2536        " --compiler-opt-loop-peeling=false" +
2537        " --compiler-empty-catch-function=true"
2538
2539    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2540      _aot_compile_options_ +=
2541          " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
2542    }
2543    if (defined(invoker.is_enable_trace_deopt) &&
2544        invoker.is_enable_trace_deopt) {
2545      _aot_compile_options_ += " --compiler-trace-deopt=true"
2546    }
2547    if (defined(invoker.is_enable_opt_inlining) &&
2548        invoker.is_enable_opt_inlining) {
2549      _aot_compile_options_ +=
2550          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2551    }
2552
2553    if (defined(invoker.is_enable_typed_op_profiler) &&
2554        invoker.is_enable_typed_op_profiler) {
2555      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
2556    }
2557
2558    if (defined(invoker.is_enable_lowering_builtin) &&
2559        invoker.is_enable_lowering_builtin) {
2560      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
2561    }
2562
2563    if (defined(invoker.is_enable_native_inline) &&
2564        invoker.is_enable_native_inline) {
2565      _aot_compile_options_ += " --compiler-enable-native-inline"
2566    }
2567
2568    if (defined(invoker.is_enable_opt_loop_peeling) &&
2569        invoker.is_enable_opt_loop_peeling) {
2570      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2571    }
2572
2573    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2574        invoker.is_enable_opt_array_bounds_check_elimination) {
2575      _aot_compile_options_ +=
2576          " --compiler-opt-array-bounds-check-elimination=true"
2577    }
2578
2579    if (defined(invoker.is_enable_inline_trace) &&
2580        invoker.is_enable_inline_trace) {
2581      _aot_compile_options_ += " --compiler-trace-inline=true"
2582    }
2583
2584    if (defined(invoker.userDefinedMethodsInModule) &&
2585        invoker.userDefinedMethodsInModule) {
2586      _aot_compile_options_ += " --compiler-module-methods=2"
2587    }
2588    _aot_compile_options_ += common_options
2589    args = [
2590      "--script-file",
2591      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2592      "--script-options",
2593      _aot_compile_options_,
2594      "--script-args",
2595      _script_args_,
2596      "--expect-sub-output",
2597      "ts aot compile success",
2598      "--env-path",
2599      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2600          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2601          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2602          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2603          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2604          rebase_path(_root_out_dir_) +
2605          "/thirdparty/bounds_checking_function:" +
2606          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2607    ]
2608
2609    inputs = [ _test_abc_path_ ]
2610
2611    outputs = [
2612      _test_aot_path_,
2613      _test_aot_snapshot_path_,
2614    ]
2615  }
2616
2617  action("${_target_name_}AotCompileActionSlowPath") {
2618    testonly = true
2619    _host_aot_target_ =
2620        "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2621    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2622    deps = [
2623      ":gen_${_target_name_}_abc",
2624      _host_aot_target_,
2625    ]
2626    deps += _deps_
2627
2628    script = "$js_root/script/run_ark_executable.py"
2629
2630    _aot_compile_options_ =
2631        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
2632        " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
2633        " --compiler-opt-type-lowering=false" +
2634        " --compiler-opt-inlining=false" +
2635        " --compiler-opt-loop-peeling=false" +
2636        " --compiler-empty-catch-function=true"
2637
2638    if (defined(invoker.is_enable_trace_deopt) &&
2639        invoker.is_enable_trace_deopt) {
2640      _aot_compile_options_ += " --compiler-trace-deopt=true"
2641    }
2642
2643    if (defined(invoker.is_enable_opt_inlining) &&
2644        invoker.is_enable_opt_inlining) {
2645      _aot_compile_options_ +=
2646          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2647    }
2648
2649    if (defined(invoker.is_enable_native_inline) &&
2650        invoker.is_enable_native_inline) {
2651      _aot_compile_options_ += " --compiler-enable-native-inline"
2652    }
2653
2654    if (defined(invoker.is_enable_opt_loop_peeling) &&
2655        invoker.is_enable_opt_loop_peeling) {
2656      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2657    }
2658
2659    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2660        invoker.is_enable_opt_array_bounds_check_elimination) {
2661      _aot_compile_options_ +=
2662          " --compiler-opt-array-bounds-check-elimination=true"
2663    }
2664
2665    if (defined(invoker.is_enable_inline_trace) &&
2666        invoker.is_enable_inline_trace) {
2667      _aot_compile_options_ += " --compiler-trace-inline=true"
2668    }
2669
2670    if (defined(invoker.userDefinedMethodsInModule) &&
2671        invoker.userDefinedMethodsInModule) {
2672      _aot_compile_options_ += " --compiler-module-methods=2"
2673    }
2674    _aot_compile_options_ += common_options
2675    args = [
2676      "--script-file",
2677      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2678      "--script-options",
2679      _aot_compile_options_,
2680      "--script-args",
2681      _script_args_,
2682      "--expect-sub-output",
2683      "ts aot compile success",
2684      "--env-path",
2685      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2686          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2687          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2688          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2689          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2690          rebase_path(_root_out_dir_) +
2691          "/thirdparty/bounds_checking_function:" +
2692          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2693    ]
2694
2695    inputs = [ _test_abc_path_ ]
2696
2697    outputs = [
2698      _test_aot_path_slowpath_,
2699      _test_aot_snapshot_path_slowpath_,
2700    ]
2701  }
2702
2703  action("${_target_name_}AotAction") {
2704    testonly = true
2705    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2706    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2707
2708    deps = [
2709      ":${_target_name_}AotCompileAction",
2710      ":gen_${_target_name_}_abc",
2711      _host_jsvm_target_,
2712    ]
2713    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
2714      deps += [ ":${_target_name_}AotActionSlowPath" ]
2715    }
2716    deps += _deps_
2717
2718    _is_test_llvm_only_ =
2719        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
2720    if (!_is_test_llvm_only_) {
2721      if (target_cpu == "x64") {
2722        deps += [ ":${_target_name_}AotActionWithLiteCG" ]
2723      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2724                 target_os == "ohos" && target_cpu == "arm64") {
2725        deps += [ ":${_target_name_}AotActionWithLiteCGQemu" ]
2726      }
2727    }
2728
2729    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2730
2731    _aot_run_options_ =
2732        " --aot-file=" + rebase_path(_test_aot_arg_) +
2733        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2734
2735    _icu_data_path_options_ =
2736        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2737    _aot_run_options_ += _icu_data_path_options_
2738
2739    if (defined(invoker.is_enable_enableArkTools) &&
2740        invoker.is_enable_enableArkTools) {
2741      _aot_run_options_ += " --enable-ark-tools=true"
2742      _aot_run_options_ += " --enable-force-gc=false"
2743    }
2744    _aot_run_options_ += common_options
2745    if (defined(invoker.log_option)) {
2746      _aot_run_options_ += invoker.log_option
2747    }
2748
2749    if (defined(invoker.is_enable_typed_op_profiler) &&
2750        invoker.is_enable_typed_op_profiler) {
2751      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2752    }
2753
2754    if (defined(invoker.is_enable_lowering_builtin) &&
2755        invoker.is_enable_lowering_builtin) {
2756      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2757    }
2758
2759    if (defined(invoker.is_enable_trace_deopt) &&
2760        invoker.is_enable_trace_deopt) {
2761      _aot_run_options_ += " --compiler-trace-deopt=true"
2762    }
2763    args = [
2764      "--script-file",
2765      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2766      "--script-options",
2767      _aot_run_options_,
2768      "--script-args",
2769      _script_args_,
2770      "--expect-file",
2771      rebase_path(_test_expect_path_),
2772      "--env-path",
2773      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2774          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2775          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2776          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2777          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2778          rebase_path(_root_out_dir_) +
2779          "/thirdparty/bounds_checking_function:" +
2780          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2781    ]
2782
2783    inputs = [ _test_abc_path_ ]
2784
2785    outputs = [ "$target_out_dir/${_target_name_}/" ]
2786  }
2787
2788  action("${_target_name_}AotContextAction") {
2789    testonly = true
2790    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2791    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2792
2793    deps = [
2794      ":${_target_name_}AotCompileAction",
2795      ":gen_${_target_name_}_abc",
2796      _host_jsvm_target_,
2797    ]
2798    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
2799      deps += [ ":${_target_name_}AotActionSlowPath" ]
2800    }
2801    deps += _deps_
2802
2803    _is_test_llvm_only_ =
2804        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
2805    if (!_is_test_llvm_only_) {
2806      if (target_cpu == "x64") {
2807        deps += [ ":${_target_name_}AotContextActionWithLiteCG" ]
2808      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2809                 target_os == "ohos" && target_cpu == "arm64") {
2810        deps += [ ":${_target_name_}AotContextActionWithLiteCGQemu" ]
2811      }
2812    }
2813
2814    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2815
2816    _aot_run_options_ =
2817        " --aot-file=" + rebase_path(_test_aot_arg_) +
2818        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2819
2820    _icu_data_path_options_ =
2821        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2822    _aot_run_options_ += _icu_data_path_options_
2823
2824    if (defined(invoker.is_enable_enableArkTools) &&
2825        invoker.is_enable_enableArkTools) {
2826      _aot_run_options_ += " --enable-ark-tools=true"
2827      _aot_run_options_ += " --enable-force-gc=false"
2828    }
2829    if (defined(invoker.log_option)) {
2830      _aot_run_options_ += invoker.log_option
2831    }
2832    _aot_run_options_ += " --enable-context=true"
2833
2834    if (defined(invoker.is_enable_typed_op_profiler) &&
2835        invoker.is_enable_typed_op_profiler) {
2836      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2837    }
2838    _aot_run_options_ += common_options
2839    if (defined(invoker.is_enable_lowering_builtin) &&
2840        invoker.is_enable_lowering_builtin) {
2841      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2842    }
2843
2844    if (defined(invoker.is_enable_trace_deopt) &&
2845        invoker.is_enable_trace_deopt) {
2846      _aot_run_options_ += " --compiler-trace-deopt=true"
2847    }
2848
2849    args = [
2850      "--script-file",
2851      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2852      "--script-options",
2853      _aot_run_options_,
2854      "--script-args",
2855      _script_args_,
2856      "--expect-file",
2857      rebase_path(_test_expect_path_),
2858      "--env-path",
2859      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2860          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2861          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2862          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2863          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2864          rebase_path(_root_out_dir_) +
2865          "/thirdparty/bounds_checking_function:" +
2866          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2867    ]
2868
2869    inputs = [ _test_abc_path_ ]
2870
2871    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
2872  }
2873
2874  action("${_target_name_}AotActionSlowPath") {
2875    testonly = true
2876    _host_jsvm_target_ =
2877        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2878    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2879
2880    deps = [
2881      ":${_target_name_}AotCompileActionSlowPath",
2882      ":gen_${_target_name_}_abc",
2883      _host_jsvm_target_,
2884    ]
2885    deps += _deps_
2886
2887    script = "$js_root/script/run_ark_executable.py"
2888
2889    _aot_run_options_ =
2890        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
2891        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2892
2893    _icu_data_path_options_ =
2894        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2895    _aot_run_options_ += _icu_data_path_options_
2896
2897    if (defined(invoker.is_enable_enableArkTools) &&
2898        invoker.is_enable_enableArkTools) {
2899      _aot_run_options_ += " --enable-ark-tools=true"
2900      _aot_run_options_ += " --enable-force-gc=false"
2901    }
2902    if (defined(invoker.log_option)) {
2903      _aot_run_options_ += invoker.log_option
2904    }
2905    _aot_run_options_ += common_options
2906    args = [
2907      "--script-file",
2908      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2909      "--script-options",
2910      _aot_run_options_,
2911      "--script-args",
2912      _script_args_,
2913      "--expect-file",
2914      rebase_path(_test_expect_path_),
2915      "--env-path",
2916      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2917          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2918          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2919          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2920          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2921          rebase_path(_root_out_dir_) +
2922          "/thirdparty/bounds_checking_function:" +
2923          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2924    ]
2925
2926    inputs = [ _test_abc_path_ ]
2927
2928    outputs = [ "$target_out_dir/${_target_name_}/SlowPath" ]
2929  }
2930
2931  if (target_cpu == "x64") {
2932    action("${_target_name_}AotCompileActionWithLiteCG") {
2933      testonly = true
2934
2935      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2936      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2937      deps = [
2938        ":gen_${_target_name_}_abc",
2939        _host_aot_target_,
2940      ]
2941      deps += _deps_
2942
2943      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2944        deps += [ ":${_target_name_}PgoExecute" ]
2945      }
2946
2947      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2948
2949      _aot_compile_options_ =
2950          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
2951          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
2952          " --compiler-opt-inlining=false" +
2953          " --compiler-opt-loop-peeling=false" +
2954          " --compiler-enable-litecg=true" +
2955          " --compiler-empty-catch-function=true"
2956
2957      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2958        _aot_compile_options_ +=
2959            " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
2960      }
2961      if (defined(invoker.is_enable_trace_deopt) &&
2962          invoker.is_enable_trace_deopt) {
2963        _aot_compile_options_ += " --compiler-trace-deopt=true"
2964      }
2965      if (defined(invoker.is_enable_opt_inlining) &&
2966          invoker.is_enable_opt_inlining) {
2967        _aot_compile_options_ +=
2968            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2969      }
2970
2971      if (defined(invoker.is_enable_typed_op_profiler) &&
2972          invoker.is_enable_typed_op_profiler) {
2973        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
2974      }
2975
2976      if (defined(invoker.is_enable_lowering_builtin) &&
2977          invoker.is_enable_lowering_builtin) {
2978        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
2979      }
2980
2981      if (defined(invoker.is_enable_native_inline) &&
2982          invoker.is_enable_native_inline) {
2983        _aot_compile_options_ += " --compiler-enable-native-inline"
2984      }
2985
2986      if (defined(invoker.is_enable_opt_loop_peeling) &&
2987          invoker.is_enable_opt_loop_peeling) {
2988        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2989      }
2990
2991      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2992          invoker.is_enable_opt_array_bounds_check_elimination) {
2993        _aot_compile_options_ +=
2994            " --compiler-opt-array-bounds-check-elimination=true"
2995      }
2996
2997      if (defined(invoker.is_enable_inline_trace) &&
2998          invoker.is_enable_inline_trace) {
2999        _aot_compile_options_ += " --compiler-trace-inline=true"
3000      }
3001
3002      if (defined(invoker.userDefinedMethodsInModule) &&
3003          invoker.userDefinedMethodsInModule) {
3004        _aot_compile_options_ += " --compiler-module-methods=2"
3005      }
3006      _aot_compile_options_ += common_options
3007      args = [
3008        "--script-file",
3009        rebase_path(_root_out_dir_) +
3010            "/arkcompiler/ets_runtime/ark_aot_compiler",
3011        "--script-options",
3012        _aot_compile_options_,
3013        "--script-args",
3014        _script_args_,
3015        "--expect-sub-output",
3016        "ts aot compile success",
3017        "--env-path",
3018        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3019            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3020            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3021            rebase_path(_root_out_dir_) +
3022            "/resourceschedule/frame_aware_sched:" +
3023            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3024            rebase_path(_root_out_dir_) +
3025            "/thirdparty/bounds_checking_function:" +
3026            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3027      ]
3028
3029      inputs = [ _test_abc_path_ ]
3030
3031      outputs = [
3032        _test_aot_path_litecg_,
3033        _test_aot_snapshot_path_litecg_,
3034      ]
3035    }
3036
3037    action("${_target_name_}AotCompileActionSlowPathWithLiteCG") {
3038      testonly = true
3039      _host_aot_target_ =
3040          "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3041      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3042      deps = [
3043        ":gen_${_target_name_}_abc",
3044        _host_aot_target_,
3045      ]
3046      deps += _deps_
3047
3048      script = "$js_root/script/run_ark_executable.py"
3049
3050      _aot_compile_options_ =
3051          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3052          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3053          " --compiler-opt-type-lowering=false" +
3054          " --compiler-opt-inlining=false" +
3055          " --compiler-opt-loop-peeling=false" +
3056          " --compiler-enable-litecg=true" +
3057          " --compiler-empty-catch-function=true"
3058      if (defined(invoker.is_enable_trace_deopt) &&
3059          invoker.is_enable_trace_deopt) {
3060        _aot_compile_options_ += " --compiler-trace-deopt=true"
3061      }
3062
3063      if (defined(invoker.is_enable_opt_inlining) &&
3064          invoker.is_enable_opt_inlining) {
3065        _aot_compile_options_ +=
3066            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3067      }
3068
3069      if (defined(invoker.is_enable_native_inline) &&
3070          invoker.is_enable_native_inline) {
3071        _aot_compile_options_ += " --compiler-enable-native-inline"
3072      }
3073
3074      if (defined(invoker.is_enable_opt_loop_peeling) &&
3075          invoker.is_enable_opt_loop_peeling) {
3076        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3077      }
3078
3079      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3080          invoker.is_enable_opt_array_bounds_check_elimination) {
3081        _aot_compile_options_ +=
3082            " --compiler-opt-array-bounds-check-elimination=true"
3083      }
3084
3085      if (defined(invoker.is_enable_inline_trace) &&
3086          invoker.is_enable_inline_trace) {
3087        _aot_compile_options_ += " --compiler-trace-inline=true"
3088      }
3089
3090      if (defined(invoker.userDefinedMethodsInModule) &&
3091          invoker.userDefinedMethodsInModule) {
3092        _aot_compile_options_ += " --compiler-module-methods=2"
3093      }
3094      _aot_compile_options_ += common_options
3095      args = [
3096        "--script-file",
3097        rebase_path(_root_out_dir_) +
3098            "/arkcompiler/ets_runtime/ark_aot_compiler",
3099        "--script-options",
3100        _aot_compile_options_,
3101        "--script-args",
3102        _script_args_,
3103        "--expect-sub-output",
3104        "ts aot compile success",
3105        "--env-path",
3106        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3107            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3108            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3109            rebase_path(_root_out_dir_) +
3110            "/resourceschedule/frame_aware_sched:" +
3111            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3112            rebase_path(_root_out_dir_) +
3113            "/thirdparty/bounds_checking_function:" +
3114            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3115      ]
3116
3117      inputs = [ _test_abc_path_ ]
3118
3119      outputs = [
3120        _test_aot_path_slowpath_litecg_,
3121        _test_aot_snapshot_path_slowpath_litecg_,
3122      ]
3123    }
3124
3125    action("${_target_name_}AotActionWithLiteCG") {
3126      testonly = true
3127      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3128      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3129
3130      deps = [
3131        ":${_target_name_}AotCompileActionWithLiteCG",
3132        ":gen_${_target_name_}_abc",
3133        _host_jsvm_target_,
3134      ]
3135      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3136        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCG" ]
3137      }
3138      deps += _deps_
3139
3140      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3141
3142      _aot_run_options_ =
3143          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3144          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3145
3146      _icu_data_path_options_ =
3147          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3148      _aot_run_options_ += _icu_data_path_options_
3149
3150      if (defined(invoker.is_enable_enableArkTools) &&
3151          invoker.is_enable_enableArkTools) {
3152        _aot_run_options_ += " --enable-ark-tools=true"
3153        _aot_run_options_ += " --enable-force-gc=false"
3154      }
3155      _aot_run_options_ += common_options
3156      if (defined(invoker.log_option)) {
3157        _aot_run_options_ += invoker.log_option
3158      }
3159
3160      if (defined(invoker.is_enable_typed_op_profiler) &&
3161          invoker.is_enable_typed_op_profiler) {
3162        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3163      }
3164
3165      if (defined(invoker.is_enable_lowering_builtin) &&
3166          invoker.is_enable_lowering_builtin) {
3167        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3168      }
3169
3170      if (defined(invoker.is_enable_trace_deopt) &&
3171          invoker.is_enable_trace_deopt) {
3172        _aot_run_options_ += " --compiler-trace-deopt=true"
3173      }
3174
3175      args = [
3176        "--script-file",
3177        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3178        "--script-options",
3179        _aot_run_options_,
3180        "--script-args",
3181        _script_args_,
3182        "--expect-file",
3183        rebase_path(_test_expect_path_),
3184        "--env-path",
3185        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3186            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3187            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3188            rebase_path(_root_out_dir_) +
3189            "/resourceschedule/frame_aware_sched:" +
3190            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3191            rebase_path(_root_out_dir_) +
3192            "/thirdparty/bounds_checking_function:" +
3193            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3194      ]
3195
3196      inputs = [ _test_abc_path_ ]
3197
3198      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
3199    }
3200
3201    action("${_target_name_}AotContextActionWithLiteCG") {
3202      testonly = true
3203      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3204      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3205
3206      deps = [
3207        ":${_target_name_}AotCompileAction",
3208        ":gen_${_target_name_}_abc",
3209        _host_jsvm_target_,
3210      ]
3211      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3212        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCG" ]
3213      }
3214      deps += _deps_
3215
3216      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3217
3218      _aot_run_options_ =
3219          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3220          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3221
3222      _icu_data_path_options_ =
3223          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3224      _aot_run_options_ += _icu_data_path_options_
3225
3226      if (defined(invoker.is_enable_enableArkTools) &&
3227          invoker.is_enable_enableArkTools) {
3228        _aot_run_options_ += " --enable-ark-tools=true"
3229        _aot_run_options_ += " --enable-force-gc=false"
3230      }
3231      _aot_run_options_ += common_options
3232      if (defined(invoker.log_option)) {
3233        _aot_run_options_ += invoker.log_option
3234      }
3235      _aot_run_options_ += " --enable-context=true"
3236
3237      if (defined(invoker.is_enable_typed_op_profiler) &&
3238          invoker.is_enable_typed_op_profiler) {
3239        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3240      }
3241
3242      if (defined(invoker.is_enable_lowering_builtin) &&
3243          invoker.is_enable_lowering_builtin) {
3244        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3245      }
3246
3247      if (defined(invoker.is_enable_trace_deopt) &&
3248          invoker.is_enable_trace_deopt) {
3249        _aot_run_options_ += " --compiler-trace-deopt=true"
3250      }
3251
3252      args = [
3253        "--script-file",
3254        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3255        "--script-options",
3256        _aot_run_options_,
3257        "--script-args",
3258        _script_args_,
3259        "--expect-file",
3260        rebase_path(_test_expect_path_),
3261        "--env-path",
3262        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3263            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3264            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3265            rebase_path(_root_out_dir_) +
3266            "/resourceschedule/frame_aware_sched:" +
3267            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3268            rebase_path(_root_out_dir_) +
3269            "/thirdparty/bounds_checking_function:" +
3270            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3271      ]
3272
3273      inputs = [ _test_abc_path_ ]
3274
3275      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
3276    }
3277
3278    action("${_target_name_}AotActionSlowPathWithLiteCG") {
3279      testonly = true
3280      _host_jsvm_target_ =
3281          "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3282      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3283
3284      deps = [
3285        ":${_target_name_}AotCompileActionSlowPathWithLiteCG",
3286        ":gen_${_target_name_}_abc",
3287        _host_jsvm_target_,
3288      ]
3289      deps += _deps_
3290
3291      script = "$js_root/script/run_ark_executable.py"
3292
3293      _aot_run_options_ =
3294          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3295          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3296
3297      _icu_data_path_options_ =
3298          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3299      _aot_run_options_ += _icu_data_path_options_
3300
3301      if (defined(invoker.is_enable_enableArkTools) &&
3302          invoker.is_enable_enableArkTools) {
3303        _aot_run_options_ += " --enable-ark-tools=true"
3304        _aot_run_options_ += " --enable-force-gc=false"
3305      }
3306
3307      if (defined(invoker.log_option)) {
3308        _aot_run_options_ += invoker.log_option
3309      }
3310      _aot_run_options_ += common_options
3311      args = [
3312        "--script-file",
3313        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3314        "--script-options",
3315        _aot_run_options_,
3316        "--script-args",
3317        _script_args_,
3318        "--expect-file",
3319        rebase_path(_test_expect_path_),
3320        "--env-path",
3321        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3322            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3323            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3324            rebase_path(_root_out_dir_) +
3325            "/resourceschedule/frame_aware_sched:" +
3326            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3327            rebase_path(_root_out_dir_) +
3328            "/thirdparty/bounds_checking_function:" +
3329            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3330      ]
3331
3332      inputs = [ _test_abc_path_ ]
3333
3334      outputs = [ "$target_out_dir/${_target_name_}/SlowPath/LiteCG" ]
3335    }
3336  } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
3337             target_os == "ohos" && target_cpu == "arm64") {
3338    import("$ark_third_party_root/musl/musl_template.gni")
3339    import("$build_root/config/qemu/config.gni")
3340
3341    action("${_target_name_}AotCompileActionWithLiteCGQemu") {
3342      testonly = true
3343
3344      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3345      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3346      deps = [
3347        ":gen_${_target_name_}_abc",
3348        _host_aot_target_,
3349      ]
3350      deps += _deps_
3351
3352      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3353        deps += [ ":${_target_name_}PgoExecute" ]
3354      }
3355
3356      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3357
3358      _aot_compile_options_ =
3359          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3360          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3361          " --compiler-opt-inlining=false" +
3362          " --compiler-opt-loop-peeling=false" +
3363          " --compiler-enable-litecg=true" +
3364          " --compiler-target-triple=aarch64-unknown-linux-gnu" +
3365          " --compiler-empty-catch-function=true"
3366
3367      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3368        _aot_compile_options_ +=
3369            " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
3370      }
3371      if (defined(invoker.is_enable_trace_deopt) &&
3372          invoker.is_enable_trace_deopt) {
3373        _aot_compile_options_ += " --compiler-trace-deopt=true"
3374      }
3375      if (defined(invoker.is_enable_opt_inlining) &&
3376          invoker.is_enable_opt_inlining) {
3377        _aot_compile_options_ +=
3378            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3379      }
3380
3381      if (defined(invoker.is_enable_typed_op_profiler) &&
3382          invoker.is_enable_typed_op_profiler) {
3383        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
3384      }
3385
3386      if (defined(invoker.is_enable_lowering_builtin) &&
3387          invoker.is_enable_lowering_builtin) {
3388        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
3389      }
3390
3391      if (defined(invoker.is_enable_native_inline) &&
3392          invoker.is_enable_native_inline) {
3393        _aot_compile_options_ += " --compiler-enable-native-inline"
3394      }
3395
3396      if (defined(invoker.is_enable_opt_loop_peeling) &&
3397          invoker.is_enable_opt_loop_peeling) {
3398        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3399      }
3400
3401      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3402          invoker.is_enable_opt_array_bounds_check_elimination) {
3403        _aot_compile_options_ +=
3404            " --compiler-opt-array-bounds-check-elimination=true"
3405      }
3406
3407      if (defined(invoker.is_enable_inline_trace) &&
3408          invoker.is_enable_inline_trace) {
3409        _aot_compile_options_ += " --compiler-trace-inline=true"
3410      }
3411
3412      if (defined(invoker.userDefinedMethodsInModule) &&
3413          invoker.userDefinedMethodsInModule) {
3414        _aot_compile_options_ += " --compiler-module-methods=2"
3415      }
3416      _aot_compile_options_ += common_options
3417      args = [
3418        "--script-file",
3419        rebase_path(_root_out_dir_) +
3420            "/arkcompiler/ets_runtime/ark_aot_compiler",
3421        "--script-options",
3422        _aot_compile_options_,
3423        "--script-args",
3424        _script_args_,
3425        "--expect-sub-output",
3426        "ts aot compile success",
3427        "--env-path",
3428        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3429            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3430            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3431            rebase_path(_root_out_dir_) +
3432            "/resourceschedule/frame_aware_sched:" +
3433            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3434            rebase_path(_root_out_dir_) +
3435            "/thirdparty/bounds_checking_function:" +
3436            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3437      ]
3438
3439      inputs = [ _test_abc_path_ ]
3440
3441      outputs = [
3442        _test_aot_path_litecg_,
3443        _test_aot_snapshot_path_litecg_,
3444      ]
3445    }
3446
3447    action("${_target_name_}AotCompileActionSlowPathWithLiteCGQemu") {
3448      testonly = true
3449      _host_aot_target_ =
3450          "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3451      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3452      deps = [
3453        ":gen_${_target_name_}_abc",
3454        _host_aot_target_,
3455      ]
3456      deps += _deps_
3457
3458      script = "$js_root/script/run_ark_executable.py"
3459
3460      _aot_compile_options_ =
3461          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3462          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3463          " --compiler-opt-type-lowering=false" +
3464          " --compiler-opt-inlining=false" +
3465          " --compiler-opt-loop-peeling=false" +
3466          " --compiler-enable-litecg=true" +
3467          " --compiler-target-triple=aarch64-unknown-linux-gnu" +
3468          " --compiler-empty-catch-function=true"
3469      if (defined(invoker.is_enable_trace_deopt) &&
3470          invoker.is_enable_trace_deopt) {
3471        _aot_compile_options_ += " --compiler-trace-deopt=true"
3472      }
3473
3474      if (defined(invoker.is_enable_opt_inlining) &&
3475          invoker.is_enable_opt_inlining) {
3476        _aot_compile_options_ +=
3477            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3478      }
3479
3480      if (defined(invoker.is_enable_native_inline) &&
3481          invoker.is_enable_native_inline) {
3482        _aot_compile_options_ += " --compiler-enable-native-inline"
3483      }
3484
3485      if (defined(invoker.is_enable_opt_loop_peeling) &&
3486          invoker.is_enable_opt_loop_peeling) {
3487        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3488      }
3489
3490      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3491          invoker.is_enable_opt_array_bounds_check_elimination) {
3492        _aot_compile_options_ +=
3493            " --compiler-opt-array-bounds-check-elimination=true"
3494      }
3495
3496      if (defined(invoker.is_enable_inline_trace) &&
3497          invoker.is_enable_inline_trace) {
3498        _aot_compile_options_ += " --compiler-trace-inline=true"
3499      }
3500
3501      if (defined(invoker.userDefinedMethodsInModule) &&
3502          invoker.userDefinedMethodsInModule) {
3503        _aot_compile_options_ += " --compiler-module-methods=2"
3504      }
3505      _aot_compile_options_ += common_options
3506      args = [
3507        "--script-file",
3508        rebase_path(_root_out_dir_) +
3509            "/arkcompiler/ets_runtime/ark_aot_compiler",
3510        "--script-options",
3511        _aot_compile_options_,
3512        "--script-args",
3513        _script_args_,
3514        "--expect-sub-output",
3515        "ts aot compile success",
3516        "--env-path",
3517        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3518            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3519            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3520            rebase_path(_root_out_dir_) +
3521            "/resourceschedule/frame_aware_sched:" +
3522            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3523            rebase_path(_root_out_dir_) +
3524            "/thirdparty/bounds_checking_function:" +
3525            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3526      ]
3527
3528      inputs = [ _test_abc_path_ ]
3529
3530      outputs = [
3531        _test_aot_path_slowpath_litecg_,
3532        _test_aot_snapshot_path_slowpath_litecg_,
3533      ]
3534    }
3535
3536    action("${_target_name_}AotActionWithLiteCGQemu") {
3537      testonly = true
3538      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3539      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3540
3541      deps = [
3542        ":${_target_name_}AotCompileActionWithLiteCGQemu",
3543        ":gen_${_target_name_}_abc",
3544        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3545        _host_jsvm_target_,
3546      ]
3547      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3548        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCGQemu" ]
3549      }
3550      deps += _deps_
3551
3552      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3553
3554      _aot_run_options_ =
3555          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3556          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3557
3558      _icu_data_path_options_ =
3559          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3560      _aot_run_options_ += _icu_data_path_options_
3561
3562      if (defined(invoker.is_enable_enableArkTools) &&
3563          invoker.is_enable_enableArkTools) {
3564        _aot_run_options_ += " --enable-ark-tools=true"
3565        _aot_run_options_ += " --enable-force-gc=false"
3566      }
3567      _aot_run_options_ += common_options
3568      if (defined(invoker.log_option)) {
3569        _aot_run_options_ += invoker.log_option
3570      }
3571
3572      if (defined(invoker.is_enable_typed_op_profiler) &&
3573          invoker.is_enable_typed_op_profiler) {
3574        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3575      }
3576
3577      if (defined(invoker.is_enable_lowering_builtin) &&
3578          invoker.is_enable_lowering_builtin) {
3579        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3580      }
3581
3582      if (defined(invoker.is_enable_trace_deopt) &&
3583          invoker.is_enable_trace_deopt) {
3584        _aot_run_options_ += " --compiler-trace-deopt=true"
3585      }
3586
3587      args = [
3588        "--script-file",
3589        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3590        "--script-options",
3591        _aot_run_options_,
3592        "--script-args",
3593        _script_args_,
3594        "--expect-file",
3595        rebase_path(_test_expect_path_),
3596        "--qemu-binary-path",
3597        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3598        "--qemu-ld-prefix",
3599        rebase_path(musl_linker_so_out_dir, root_build_dir),
3600        "--clang-lib-path",
3601        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3602                    root_build_dir) + rebase_path(_root_out_dir_) +
3603            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3604            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3605            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3606            "/resourceschedule/frame_aware_sched:" +
3607            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3608            rebase_path(_root_out_dir_) +
3609            "/thirdparty/bounds_checking_function:" +
3610            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3611      ]
3612
3613      inputs = [ _test_abc_path_ ]
3614
3615      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
3616    }
3617
3618    action("${_target_name_}AotContextActionWithLiteCGQemu") {
3619      testonly = true
3620      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3621      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3622
3623      deps = [
3624        ":${_target_name_}AotCompileActionWithLiteCGQemu",
3625        ":gen_${_target_name_}_abc",
3626        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3627        _host_jsvm_target_,
3628      ]
3629      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3630        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCGQemu" ]
3631      }
3632      deps += _deps_
3633
3634      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3635
3636      _aot_run_options_ =
3637          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3638          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3639
3640      _icu_data_path_options_ =
3641          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3642      _aot_run_options_ += _icu_data_path_options_
3643
3644      if (defined(invoker.is_enable_enableArkTools) &&
3645          invoker.is_enable_enableArkTools) {
3646        _aot_run_options_ += " --enable-ark-tools=true"
3647        _aot_run_options_ += " --enable-force-gc=false"
3648      }
3649      _aot_run_options_ += common_options
3650      if (defined(invoker.log_option)) {
3651        _aot_run_options_ += invoker.log_option
3652      }
3653      _aot_run_options_ += " --enable-context=true"
3654
3655      if (defined(invoker.is_enable_typed_op_profiler) &&
3656          invoker.is_enable_typed_op_profiler) {
3657        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3658      }
3659
3660      if (defined(invoker.is_enable_lowering_builtin) &&
3661          invoker.is_enable_lowering_builtin) {
3662        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3663      }
3664
3665      if (defined(invoker.is_enable_trace_deopt) &&
3666          invoker.is_enable_trace_deopt) {
3667        _aot_run_options_ += " --compiler-trace-deopt=true"
3668      }
3669
3670      args = [
3671        "--script-file",
3672        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3673        "--script-options",
3674        _aot_run_options_,
3675        "--script-args",
3676        _script_args_,
3677        "--expect-file",
3678        rebase_path(_test_expect_path_),
3679        "--qemu-binary-path",
3680        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3681        "--qemu-ld-prefix",
3682        rebase_path(musl_linker_so_out_dir, root_build_dir),
3683        "--clang-lib-path",
3684        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3685                    root_build_dir) + rebase_path(_root_out_dir_) +
3686            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3687            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3688            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3689            "/resourceschedule/frame_aware_sched:" +
3690            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3691            rebase_path(_root_out_dir_) +
3692            "/thirdparty/bounds_checking_function:" +
3693            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3694      ]
3695
3696      inputs = [ _test_abc_path_ ]
3697
3698      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
3699    }
3700
3701    action("${_target_name_}AotActionSlowPathWithLiteCGQemu") {
3702      testonly = true
3703      _host_jsvm_target_ =
3704          "$js_root/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3705      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3706
3707      deps = [
3708        ":${_target_name_}AotCompileActionSlowPathWithLiteCGQemu",
3709        ":gen_${_target_name_}_abc",
3710        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3711        _host_jsvm_target_,
3712      ]
3713      deps += _deps_
3714
3715      script = "$js_root/script/run_ark_executable.py"
3716
3717      _aot_run_options_ =
3718          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3719          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3720
3721      _icu_data_path_options_ =
3722          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3723      _aot_run_options_ += _icu_data_path_options_
3724
3725      if (defined(invoker.is_enable_enableArkTools) &&
3726          invoker.is_enable_enableArkTools) {
3727        _aot_run_options_ += " --enable-ark-tools=true"
3728        _aot_run_options_ += " --enable-force-gc=false"
3729      }
3730      _aot_run_options_ += common_options
3731      if (defined(invoker.log_option)) {
3732        _aot_run_options_ += invoker.log_option
3733      }
3734
3735      args = [
3736        "--script-file",
3737        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3738        "--script-options",
3739        _aot_run_options_,
3740        "--script-args",
3741        _script_args_,
3742        "--expect-file",
3743        rebase_path(_test_expect_path_),
3744        "--qemu-binary-path",
3745        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3746        "--qemu-ld-prefix",
3747        rebase_path(musl_linker_so_out_dir, root_build_dir),
3748        "--clang-lib-path",
3749        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3750                    root_build_dir) + rebase_path(_root_out_dir_) +
3751            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3752            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3753            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3754            "/resourceschedule/frame_aware_sched:" +
3755            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3756            rebase_path(_root_out_dir_) +
3757            "/thirdparty/bounds_checking_function:" +
3758            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3759      ]
3760
3761      inputs = [ _test_abc_path_ ]
3762
3763      outputs = [ "$target_out_dir/${_target_name_}/SlowPath/LiteCG" ]
3764    }
3765  }
3766}
3767
3768template("host_aot_assert_test_action") {
3769  _target_name_ = "${target_name}"
3770  _deps_ = invoker.deps
3771
3772  _src_dir_ = "."
3773  if (defined(invoker.src_dir) && invoker.src_dir != "") {
3774    _src_dir_ = invoker.src_dir
3775  }
3776
3777  _test_ts_path_ = "${_src_dir_}/${_target_name_}.ts"
3778  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
3779  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
3780  _test_aot_arg_slowpath_ = "$target_out_dir/slowpath/${_target_name_}"
3781  _test_aot_log_level = "info"
3782
3783  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
3784    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
3785    extra_dependencies = _deps_
3786    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
3787      src_js = rebase_path("./")
3788    } else {
3789      src_js = rebase_path(_test_ts_path_)
3790    }
3791    dst_file = rebase_path(_test_abc_path_)
3792    extension = "ts"
3793    extra_args = [ "--merge-abc" ]
3794
3795    if (!(defined(invoker.without_module) && invoker.without_module)) {
3796      extra_args += [ "--module" ]
3797    }
3798
3799    if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
3800      extra_args += [ "--debug" ]
3801    }
3802    in_puts = [ _test_ts_path_ ]
3803    out_puts = [ _test_abc_path_ ]
3804  }
3805
3806  _script_args_ = rebase_path(_test_abc_path_)
3807
3808  action("${_target_name_}PgoExecuteAssert") {
3809    testonly = true
3810    _host_jsvm_target_ =
3811        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3812    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3813
3814    deps = [
3815      ":gen_${_target_name_}_abc",
3816      _host_jsvm_target_,
3817    ]
3818    deps += _deps_
3819
3820    script = "$js_root/script/run_ark_executable.py"
3821
3822    _aot_run_options_ =
3823        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
3824        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
3825        rebase_path(_test_aot_arg_) + "/modules.ap"
3826
3827    if (defined(invoker.is_enable_enableArkTools) &&
3828        invoker.is_enable_enableArkTools) {
3829      _aot_run_options_ += " --enable-ark-tools=true"
3830      _aot_run_options_ += " --enable-force-gc=false"
3831    }
3832    if (defined(invoker.log_option)) {
3833      _aot_run_options_ += invoker.log_option
3834    }
3835    _aot_run_options_ += " --test-assert=true"
3836    _aot_run_options_ += common_options
3837    args = [
3838      "--script-file",
3839      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3840      "--script-options",
3841      _aot_run_options_,
3842      "--script-args",
3843      _script_args_,
3844      "--expect-output",
3845      "0",
3846      "--env-path",
3847      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3848          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3849          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3850          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
3851          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3852          rebase_path(_root_out_dir_) +
3853          "/thirdparty/bounds_checking_function:" +
3854          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3855    ]
3856
3857    inputs = [ _test_abc_path_ ]
3858
3859    outputs = [ "$target_out_dir/${_target_name_}/pgoassert" ]
3860  }
3861
3862  action("${_target_name_}AotCompileAssertAction") {
3863    testonly = true
3864
3865    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3866    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3867    deps = [
3868      ":gen_${_target_name_}_abc",
3869      _host_aot_target_,
3870    ]
3871    deps += _deps_
3872
3873    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3874      deps += [ ":${_target_name_}PgoExecuteAssert" ]
3875    }
3876
3877    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3878
3879    _aot_compile_options_ =
3880        " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
3881        _test_aot_log_level + " --log-components=compiler" +
3882        " --compiler-opt-inlining=false" +
3883        " --compiler-opt-loop-peeling=false" +
3884        " --compiler-empty-catch-function=true"
3885
3886    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3887      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
3888                               rebase_path(_test_aot_arg_) + "/modules.ap"
3889    }
3890    if (defined(invoker.is_enable_trace_deopt) &&
3891        invoker.is_enable_trace_deopt) {
3892      _aot_compile_options_ += " --compiler-trace-deopt=true"
3893    }
3894    if (defined(invoker.is_enable_opt_inlining) &&
3895        invoker.is_enable_opt_inlining) {
3896      _aot_compile_options_ +=
3897          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3898    }
3899
3900    if (defined(invoker.is_enable_typed_op_profiler) &&
3901        invoker.is_enable_typed_op_profiler) {
3902      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
3903    }
3904
3905    if (defined(invoker.is_enable_lowering_builtin) &&
3906        invoker.is_enable_lowering_builtin) {
3907      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
3908    }
3909
3910    if (defined(invoker.is_enable_native_inline) &&
3911        invoker.is_enable_native_inline) {
3912      _aot_compile_options_ += " --compiler-enable-native-inline"
3913    }
3914
3915    if (defined(invoker.is_enable_opt_loop_peeling) &&
3916        invoker.is_enable_opt_loop_peeling) {
3917      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3918    }
3919
3920    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3921        invoker.is_enable_opt_array_bounds_check_elimination) {
3922      _aot_compile_options_ +=
3923          " --compiler-opt-array-bounds-check-elimination=true"
3924    }
3925
3926    if (defined(invoker.is_enable_inline_trace) &&
3927        invoker.is_enable_inline_trace) {
3928      _aot_compile_options_ += " --compiler-trace-inline=true"
3929    }
3930
3931    if (defined(invoker.userDefinedMethodsInModule) &&
3932        invoker.userDefinedMethodsInModule) {
3933      _aot_compile_options_ += " --compiler-module-methods=2"
3934    }
3935    _aot_compile_options_ += common_options
3936    _aot_compile_options_ += " --test-assert=true"
3937
3938    args = [
3939      "--script-file",
3940      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
3941      "--script-options",
3942      _aot_compile_options_,
3943      "--script-args",
3944      _script_args_,
3945      "--expect-output",
3946      "0",
3947      "--env-path",
3948      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3949          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3950          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3951          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
3952          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3953          rebase_path(_root_out_dir_) +
3954          "/thirdparty/bounds_checking_function:" +
3955          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3956    ]
3957
3958    inputs = [ _test_abc_path_ ]
3959
3960    outputs = [
3961      "$target_out_dir/${_target_name_}AotCompileAssert.an",
3962      "$target_out_dir/${_target_name_}AotCompileAssert.ai",
3963    ]
3964  }
3965
3966  action("${_target_name_}AotCompileAssertActionSlowPath") {
3967    testonly = true
3968    _host_aot_target_ =
3969        "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3970    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3971    deps = [
3972      ":gen_${_target_name_}_abc",
3973      _host_aot_target_,
3974    ]
3975    deps += _deps_
3976
3977    script = "$js_root/script/run_ark_executable.py"
3978
3979    _aot_compile_options_ =
3980        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
3981        " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3982        " --compiler-opt-type-lowering=false" +
3983        " --compiler-opt-inlining=false" +
3984        " --compiler-opt-loop-peeling=false" +
3985        " --compiler-empty-catch-function=true"
3986
3987    if (defined(invoker.aot_log_option)) {
3988      _aot_compile_options_ += invoker.aot_log_option
3989    }
3990
3991    if (defined(invoker.is_enable_trace_deopt) &&
3992        invoker.is_enable_trace_deopt) {
3993      _aot_compile_options_ += " --compiler-trace-deopt=true"
3994    }
3995
3996    if (defined(invoker.is_enable_opt_inlining) &&
3997        invoker.is_enable_opt_inlining) {
3998      _aot_compile_options_ +=
3999          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
4000    }
4001
4002    if (defined(invoker.is_enable_native_inline) &&
4003        invoker.is_enable_native_inline) {
4004      _aot_compile_options_ += " --compiler-enable-native-inline"
4005    }
4006
4007    if (defined(invoker.is_enable_opt_loop_peeling) &&
4008        invoker.is_enable_opt_loop_peeling) {
4009      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
4010    }
4011
4012    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
4013        invoker.is_enable_opt_array_bounds_check_elimination) {
4014      _aot_compile_options_ +=
4015          " --compiler-opt-array-bounds-check-elimination=true"
4016    }
4017
4018    if (defined(invoker.is_enable_inline_trace) &&
4019        invoker.is_enable_inline_trace) {
4020      _aot_compile_options_ += " --compiler-trace-inline=true"
4021    }
4022
4023    if (defined(invoker.userDefinedMethodsInModule) &&
4024        invoker.userDefinedMethodsInModule) {
4025      _aot_compile_options_ += " --compiler-module-methods=2"
4026    }
4027    _aot_compile_options_ += common_options
4028    _aot_compile_options_ += " --test-assert=true"
4029
4030    args = [
4031      "--script-file",
4032      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4033      "--script-options",
4034      _aot_compile_options_,
4035      "--script-args",
4036      _script_args_,
4037      "--expect-output",
4038      "0",
4039      "--env-path",
4040      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4041          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4042          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4043          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4044          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4045          rebase_path(_root_out_dir_) +
4046          "/thirdparty/bounds_checking_function:" +
4047          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4048    ]
4049
4050    inputs = [ _test_abc_path_ ]
4051
4052    outputs = [
4053      "$target_out_dir/slowpath/${_target_name_}AotCompileAssert.an",
4054      "$target_out_dir/slowpath/${_target_name_}AotCompileAssert.ai",
4055    ]
4056  }
4057
4058  action("${_target_name_}AotAssertAction") {
4059    testonly = true
4060    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4061    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4062
4063    deps = [
4064      ":${_target_name_}AotCompileAssertAction",
4065      ":gen_${_target_name_}_abc",
4066      _host_jsvm_target_,
4067    ]
4068    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
4069      deps += [ ":${_target_name_}AotAssertActionSlowPath" ]
4070    }
4071    deps += _deps_
4072
4073    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4074
4075    _aot_run_options_ =
4076        " --aot-file=" + rebase_path(_test_aot_arg_) +
4077        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4078
4079    _icu_data_path_options_ =
4080        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4081    _aot_run_options_ += _icu_data_path_options_
4082
4083    if (defined(invoker.is_enable_enableArkTools) &&
4084        invoker.is_enable_enableArkTools) {
4085      _aot_run_options_ += " --enable-ark-tools=true"
4086      _aot_run_options_ += " --enable-force-gc=false"
4087    }
4088
4089    if (defined(invoker.log_option)) {
4090      _aot_run_options_ += invoker.log_option
4091    }
4092
4093    if (defined(invoker.is_enable_typed_op_profiler) &&
4094        invoker.is_enable_typed_op_profiler) {
4095      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
4096    }
4097
4098    if (defined(invoker.is_enable_lowering_builtin) &&
4099        invoker.is_enable_lowering_builtin) {
4100      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
4101    }
4102
4103    if (defined(invoker.is_enable_trace_deopt) &&
4104        invoker.is_enable_trace_deopt) {
4105      _aot_run_options_ += " --compiler-trace-deopt=true"
4106    }
4107
4108    _aot_run_options_ += " --test-assert=true"
4109    _aot_run_options_ += common_options
4110    args = [
4111      "--script-file",
4112      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4113      "--script-options",
4114      _aot_run_options_,
4115      "--script-args",
4116      _script_args_,
4117      "--expect-output",
4118      "0",
4119      "--env-path",
4120      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4121          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4122          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4123          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4124          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4125          rebase_path(_root_out_dir_) +
4126          "/thirdparty/bounds_checking_function:" +
4127          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4128    ]
4129
4130    inputs = [ _test_abc_path_ ]
4131
4132    outputs = [ "$target_out_dir/${_target_name_}AotAssert/" ]
4133  }
4134
4135  action("${_target_name_}AotContextAssertAction") {
4136    testonly = true
4137    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4138    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4139
4140    deps = [
4141      ":${_target_name_}AotCompileAssertAction",
4142      ":gen_${_target_name_}_abc",
4143      _host_jsvm_target_,
4144    ]
4145    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
4146      deps += [ ":${_target_name_}AotAssertActionSlowPath" ]
4147    }
4148    deps += _deps_
4149
4150    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4151
4152    _aot_run_options_ =
4153        " --aot-file=" + rebase_path(_test_aot_arg_) +
4154        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4155
4156    _icu_data_path_options_ =
4157        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4158    _aot_run_options_ += _icu_data_path_options_
4159
4160    if (defined(invoker.is_enable_enableArkTools) &&
4161        invoker.is_enable_enableArkTools) {
4162      _aot_run_options_ += " --enable-ark-tools=true"
4163      _aot_run_options_ += " --enable-force-gc=false"
4164    }
4165    if (defined(invoker.log_option)) {
4166      _aot_run_options_ += invoker.log_option
4167    }
4168    _aot_run_options_ += " --enable-context=true"
4169
4170    if (defined(invoker.is_enable_typed_op_profiler) &&
4171        invoker.is_enable_typed_op_profiler) {
4172      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
4173    }
4174
4175    if (defined(invoker.is_enable_lowering_builtin) &&
4176        invoker.is_enable_lowering_builtin) {
4177      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
4178    }
4179
4180    if (defined(invoker.is_enable_trace_deopt) &&
4181        invoker.is_enable_trace_deopt) {
4182      _aot_run_options_ += " --compiler-trace-deopt=true"
4183    }
4184
4185    _aot_run_options_ += " --test-assert=true"
4186    _aot_run_options_ += common_options
4187    args = [
4188      "--script-file",
4189      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4190      "--script-options",
4191      _aot_run_options_,
4192      "--script-args",
4193      _script_args_,
4194      "--expect-output",
4195      "0",
4196      "--env-path",
4197      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4198          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4199          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4200          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4201          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4202          rebase_path(_root_out_dir_) +
4203          "/thirdparty/bounds_checking_function:" +
4204          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4205    ]
4206
4207    inputs = [ _test_abc_path_ ]
4208
4209    outputs = [ "$target_out_dir/${_target_name_}ContextAssert/" ]
4210  }
4211
4212  action("${_target_name_}AotAssertActionSlowPath") {
4213    testonly = true
4214    _host_jsvm_target_ =
4215        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4216    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4217
4218    deps = [
4219      ":${_target_name_}AotCompileAssertActionSlowPath",
4220      ":gen_${_target_name_}_abc",
4221      _host_jsvm_target_,
4222    ]
4223    deps += _deps_
4224
4225    script = "$js_root/script/run_ark_executable.py"
4226
4227    _aot_run_options_ =
4228        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
4229        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4230
4231    _icu_data_path_options_ =
4232        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4233    _aot_run_options_ += _icu_data_path_options_
4234
4235    if (defined(invoker.is_enable_enableArkTools) &&
4236        invoker.is_enable_enableArkTools) {
4237      _aot_run_options_ += " --enable-ark-tools=true"
4238      _aot_run_options_ += " --enable-force-gc=false"
4239    }
4240    if (defined(invoker.log_option)) {
4241      _aot_run_options_ += invoker.log_option
4242    }
4243
4244    _aot_run_options_ += " --test-assert=true"
4245    _aot_run_options_ += common_options
4246    args = [
4247      "--script-file",
4248      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4249      "--script-options",
4250      _aot_run_options_,
4251      "--script-args",
4252      _script_args_,
4253      "--expect-output",
4254      "0",
4255      "--env-path",
4256      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4257          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4258          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4259          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4260          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4261          rebase_path(_root_out_dir_) +
4262          "/thirdparty/bounds_checking_function:" +
4263          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4264    ]
4265
4266    inputs = [ _test_abc_path_ ]
4267
4268    outputs = [ "$target_out_dir/${_target_name_}/AssertSlowPath" ]
4269  }
4270}
4271
4272template("host_pgotypeinfer_test_action") {
4273  _target_name_ = "${target_name}"
4274  _deps_ = invoker.deps
4275
4276  _test_ts_path_ = "./${_target_name_}.js"
4277  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
4278
4279  _host_aot_target_ =
4280      "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
4281
4282  _test_es2abc_abc_path_ = "$target_out_dir/es2abc/${_target_name_}.abc"
4283
4284  if (defined(invoker.is_common_js) && invoker.is_common_js) {
4285    extra_args = [ "--commonjs" ]
4286  } else {
4287    extra_args = [ "--module" ]
4288  }
4289  extra_args += [ "--merge-abc" ]
4290
4291  es2abc_gen_newest_abc("es2abc_gen_${_target_name_}_abc") {
4292    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
4293    extra_dependencies = _deps_
4294    if (defined(invoker.is_multi_file_tests) && invoker.is_multi_file_tests) {
4295      _test_es2abc_ts_path_ = "."
4296    } else {
4297      _test_es2abc_ts_path_ = _test_ts_path_
4298    }
4299    src_js = rebase_path(_test_es2abc_ts_path_)
4300    dst_file = rebase_path(_test_es2abc_abc_path_)
4301
4302    in_puts = [ _test_ts_path_ ]
4303    out_puts = [ _test_es2abc_abc_path_ ]
4304  }
4305
4306  _script_args_ = rebase_path(_test_es2abc_abc_path_)
4307
4308  action("${_target_name_}PgoExecute") {
4309    testonly = true
4310    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4311    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4312
4313    deps = [
4314      ":es2abc_gen_${_target_name_}_abc",
4315      _host_jsvm_target_,
4316    ]
4317    deps += _deps_
4318
4319    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4320
4321    _aot_run_options_ =
4322        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
4323        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
4324        rebase_path(_test_aot_arg_) + "/modules.ap"
4325
4326    if (defined(invoker.is_enable_enableArkTools) &&
4327        invoker.is_enable_enableArkTools) {
4328      _aot_run_options_ += " --enable-ark-tools=true"
4329      _aot_run_options_ += " --enable-force-gc=false"
4330    }
4331
4332    if (defined(invoker.log_option)) {
4333      _aot_run_options_ += invoker.log_option
4334    }
4335    _aot_run_options_ += common_options
4336    args = [
4337      "--script-file",
4338      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4339      "--script-options",
4340      _aot_run_options_,
4341      "--script-args",
4342      _script_args_,
4343      "--expect-output",
4344      "0",
4345      "--env-path",
4346      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4347          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4348          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4349          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4350          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4351          rebase_path(_root_out_dir_) +
4352          "/thirdparty/bounds_checking_function:" +
4353          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4354    ]
4355
4356    inputs = [ _test_es2abc_abc_path_ ]
4357
4358    outputs = [ "$target_out_dir/${_target_name_}/pgo" ]
4359  }
4360
4361  action("${_target_name_}Es2abcAotTypeInferAction") {
4362    testonly = true
4363
4364    _script_args_ = rebase_path(_test_es2abc_abc_path_)
4365    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
4366    deps = [
4367      ":es2abc_gen_${_target_name_}_abc",
4368      _host_aot_target_,
4369    ]
4370    deps += _deps_
4371    if (target_cpu == "x64") {
4372      deps += [ ":${_target_name_}Es2abcAotTypeInferActionWithLiteCG" ]
4373    }
4374
4375    # Pgo Execute
4376    deps += [ ":${_target_name_}PgoExecute" ]
4377
4378    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4379
4380    _aot_compile_options_ = " --compiler-opt-type-lowering=false" +
4381                            " --compiler-opt-loop-peeling=false" +
4382                            " --compiler-empty-catch-function=true"
4383
4384    # Pgo Option
4385    _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
4386                             rebase_path(_test_aot_arg_) + "/modules.ap"
4387    _aot_compile_options_ += common_options
4388    args = [
4389      "--script-file",
4390      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4391      "--script-options",
4392      _aot_compile_options_,
4393      "--script-args",
4394      _script_args_,
4395      "--expect-output",
4396      "0",
4397      "--env-path",
4398      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4399          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4400          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4401          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4402          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4403          rebase_path(_root_out_dir_) +
4404          "/thirdparty/bounds_checking_function:" +
4405          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4406    ]
4407
4408    inputs = [ _test_es2abc_abc_path_ ]
4409
4410    outputs = [ "$target_out_dir/${_target_name_}/es2abc/" ]
4411  }
4412
4413  action("${_target_name_}Es2abcAotTypeInferActionWithLiteCG") {
4414    testonly = true
4415
4416    _script_args_ = rebase_path(_test_es2abc_abc_path_)
4417    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
4418    deps = [
4419      ":es2abc_gen_${_target_name_}_abc",
4420      _host_aot_target_,
4421    ]
4422    deps += _deps_
4423
4424    # Pgo Execute
4425    deps += [ ":${_target_name_}PgoExecute" ]
4426
4427    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4428
4429    _aot_compile_options_ = " --compiler-opt-type-lowering=false" +
4430                            " --compiler-opt-loop-peeling=false" +
4431                            " --compiler-enable-litecg=true" +
4432                            " --compiler-empty-catch-function=true"
4433
4434    # Pgo Option
4435    _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
4436                             rebase_path(_test_aot_arg_) + "/modules.ap"
4437    _aot_compile_options_ += common_options
4438    args = [
4439      "--script-file",
4440      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4441      "--script-options",
4442      _aot_compile_options_,
4443      "--script-args",
4444      _script_args_,
4445      "--expect-output",
4446      "0",
4447      "--env-path",
4448      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4449          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4450          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4451          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4452          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4453          rebase_path(_root_out_dir_) +
4454          "/thirdparty/bounds_checking_function:" +
4455          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4456    ]
4457
4458    inputs = [ _test_es2abc_abc_path_ ]
4459
4460    outputs = [ "$target_out_dir/${_target_name_}/es2abc/LiteCG/" ]
4461  }
4462}
4463
4464template("host_quickfix_test_action") {
4465  _target_name_ = "${target_name}"
4466
4467  _test_expect_path_ = "./${_target_name_}/expect_output.txt"
4468  _test_file_name_ = [
4469    "base",
4470    "test",
4471    "retest",
4472    "patch",
4473  ]
4474
4475  if (defined(invoker.extra_patches)) {
4476    _test_file_name_ += invoker.extra_patches
4477  }
4478
4479  if (defined(invoker.entry_point)) {
4480    _script_args_ = invoker.entry_point + " "
4481  }
4482
4483  if (defined(invoker.is_hotpatch) && invoker.is_hotpatch) {
4484    _test_map_path_ = "$target_out_dir/${_target_name_}/base.map"
4485  }
4486
4487  foreach(filename, _test_file_name_) {
4488    merge_file_raw = "//arkcompiler/ets_runtime/test/quickfix/"
4489    if (filename == "test" || filename == "retest") {
4490      merge_file_raw += "${filename}.txt"
4491    } else {
4492      merge_file_raw += "${_target_name_}/${filename}.txt"
4493    }
4494    merge_file = "$target_out_dir/${_target_name_}/${filename}.txt"
4495    merge_file_prefix =
4496        "//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"
4497
4498    if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
4499      action("gen_${_target_name_}_${filename}_js_file_and_merge") {
4500        script = "//arkcompiler/ets_runtime/test/quickfix/generate_js_and_merge_file.py"
4501        args = [
4502          "--input",
4503          rebase_path(merge_file_raw),
4504          "--output",
4505          rebase_path(merge_file),
4506          "--prefix",
4507          rebase_path(merge_file_prefix),
4508        ]
4509        inputs = [ merge_file_raw ]
4510        outputs = [ merge_file ]
4511      }
4512    } else {
4513      action("gen_${_target_name_}_${filename}_merge_file") {
4514        script =
4515            "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
4516        args = [
4517          "--input",
4518          rebase_path(merge_file_raw),
4519          "--output",
4520          rebase_path(merge_file),
4521          "--prefix",
4522          rebase_path(merge_file_prefix),
4523        ]
4524        inputs = [ merge_file_raw ]
4525        outputs = [ merge_file ]
4526      }
4527    }
4528
4529    abc_path = "$target_out_dir/${_target_name_}/${filename}.abc"
4530
4531    es2abc_gen_newest_abc("gen_${_target_name_}_${filename}_abc") {
4532      extra_visibility =
4533          [ ":*" ]  # Only targets in this file can depend on this.
4534      if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
4535        extra_dependencies =
4536            [ ":gen_${_target_name_}_${filename}_js_file_and_merge" ]
4537      } else {
4538        extra_dependencies = [ ":gen_${_target_name_}_${filename}_merge_file" ]
4539      }
4540
4541      if (defined(invoker.is_hotpatch) && filename == "patch") {
4542        extra_dependencies += [ ":gen_${_target_name_}_base_abc" ]
4543      }
4544
4545      src_js = "@" + rebase_path(merge_file)
4546      dst_file = rebase_path(abc_path)
4547      extra_args = [
4548        "--module",
4549        "--merge-abc",
4550      ]
4551
4552      if (defined(invoker.is_hotpatch) && filename == "patch") {
4553        extra_args += [ "--generate-patch" ]
4554      }
4555
4556      if (defined(invoker.is_hotpatch) && filename == "base") {
4557        dump_symbol_table = rebase_path(_test_map_path_)
4558      }
4559
4560      if (defined(invoker.is_hotpatch) && filename == "patch") {
4561        input_symbol_table = rebase_path(_test_map_path_)
4562      }
4563
4564      in_puts = [
4565        _test_expect_path_,
4566        merge_file,
4567      ]
4568
4569      if (defined(invoker.is_hotpatch) && filename == "patch") {
4570        in_puts += [ _test_map_path_ ]
4571      }
4572
4573      out_puts = [ abc_path ]
4574
4575      if (defined(invoker.is_hotpatch) && filename == "base") {
4576        out_puts += [ _test_map_path_ ]
4577      }
4578    }
4579
4580    if (filename != _test_file_name_[0]) {
4581      _script_args_ += ":"
4582    }
4583    _script_args_ += rebase_path(abc_path)
4584  }
4585
4586  action("${_target_name_}QuickfixAction") {
4587    testonly = true
4588
4589    _host_quickfix_target_ = "//arkcompiler/ets_runtime/ecmascript/quick_fix:quick_fix(${host_toolchain})"
4590    _root_out_dir_ = get_label_info(_host_quickfix_target_, "root_out_dir")
4591
4592    deps = [ _host_quickfix_target_ ]
4593    foreach(filename, _test_file_name_) {
4594      deps += [ ":gen_${_target_name_}_${filename}_abc" ]
4595    }
4596
4597    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4598
4599    quickfix_options = " --merge-abc true "
4600    if (is_mac) {
4601      quickfix_options = " --merge-abc true  --asm-interpreter=false"
4602    }
4603
4604    args = [
4605      "--script-file",
4606      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/quick_fix",
4607      "--script-options",
4608      quickfix_options,
4609      "--script-args",
4610      _script_args_,
4611      "--timeout-limit",
4612      "${_timeout_}",
4613      "--expect-file",
4614      rebase_path(_test_expect_path_),
4615      "--env-path",
4616      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4617          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4618          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4619          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4620          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4621          rebase_path(_root_out_dir_) +
4622          "/thirdparty/bounds_checking_function:" +
4623          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4624    ]
4625
4626    inputs = []
4627
4628    outputs = [ "$target_out_dir/${_target_name_}/" ]
4629  }
4630}
4631
4632template("host_aot_builtin_inlining_test_action") {
4633  host_aot_test_action("${target_name}") {
4634    forward_variables_from(invoker, "*")
4635
4636    is_enable_pgo = true
4637    is_only_typed_path = true
4638    is_enable_opt_inlining = true
4639    is_enable_trace_deopt = true
4640    log_option = " --log-info=trace"
4641    is_enable_inline_trace = true
4642    is_enable_enableArkTools = true
4643    gen_expect_output = true
4644    is_test_llvm_only = true
4645    deps = []
4646  }
4647}
4648
4649template("host_jit_test_action") {
4650  _target_name_ = "${target_name}"
4651  _deps_ = invoker.deps
4652
4653  _test_ts_path_ = "./${_target_name_}.ts"
4654  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
4655  _script_args_ = rebase_path(_test_abc_path_)
4656  _test_expect_path_ = "./expect_output.txt"
4657
4658  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
4659    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
4660
4661    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
4662      src_js = rebase_path("./")
4663    } else {
4664      src_js = rebase_path(_test_ts_path_)
4665    }
4666    dst_file = rebase_path(_test_abc_path_)
4667    extension = "ts"
4668    extra_args = [
4669      "--module",
4670      "--merge-abc",
4671    ]
4672    in_puts = [ _test_ts_path_ ]
4673    out_puts = [ _test_abc_path_ ]
4674  }
4675
4676  action("${_target_name_}JitAction") {
4677    testonly = true
4678    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4679
4680    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4681    _host_jsoptimizer_lib_ = "//arkcompiler/ets_runtime/ecmascript/compiler:libark_jsoptimizer(${host_toolchain})"
4682    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4683    _jit_run_options_ =
4684        " --asm-interpreter=true" + " --compiler-enable-jit=true" +
4685        " --compiler-enable-jit-pgo=true" +
4686        " --compiler-jit-hotness-threshold=5" + " --enable-pgo-profiler=true" +
4687        " --compiler-enable-litecg=true" + " --entry-point=${_target_name_} "
4688
4689    if (defined(invoker.enable_osr) && invoker.enable_osr) {
4690      _jit_run_options_ += " --compiler-enable-osr=true "
4691      _jit_run_options_ += " --compiler-osr-hotness-threshold=1 "
4692    }
4693    if (defined(invoker.extra_option)) {
4694      _jit_run_options_ += invoker.extra_option
4695    }
4696
4697    _jit_run_options_ += common_options
4698    deps = [
4699      ":gen_${_target_name_}_abc",
4700      _host_jsoptimizer_lib_,
4701      _host_jsvm_target_,
4702    ]
4703    deps += _deps_
4704
4705    args = [
4706      "--script-file",
4707      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4708      "--script-options",
4709      _jit_run_options_,
4710      "--script-args",
4711      _script_args_,
4712      "--expect-file",
4713      rebase_path(_test_expect_path_),
4714      "--env-path",
4715      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4716          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4717          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4718          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4719          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4720          rebase_path(_root_out_dir_) +
4721          "/thirdparty/bounds_checking_function:" +
4722          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4723    ]
4724
4725    inputs = [ _test_abc_path_ ]
4726
4727    outputs = [ "$target_out_dir/${_target_name_}/" ]
4728  }
4729}
4730