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    _icu_data_path_options_ =
297        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
298    js_vm_options += _icu_data_path_options_
299    js_vm_options += common_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=true"
1224    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1225      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1226                               rebase_path(_test_aot_arg_) + "/modules.ap"
1227    }
1228    _aot_compile_options_ += common_options
1229    if (defined(invoker.is_enable_trace_deopt) &&
1230        invoker.is_enable_trace_deopt) {
1231      _aot_compile_options_ += " --compiler-trace-deopt=true"
1232    }
1233
1234    if (defined(invoker.is_enable_opt_inlining) &&
1235        invoker.is_enable_opt_inlining) {
1236      _aot_compile_options_ +=
1237          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1238    }
1239
1240    if (defined(invoker.is_enable_typed_op_profiler) &&
1241        invoker.is_enable_typed_op_profiler) {
1242      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
1243    }
1244
1245    if (defined(invoker.is_enable_lowering_builtin) &&
1246        invoker.is_enable_lowering_builtin) {
1247      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1248    }
1249
1250    if (defined(invoker.is_enable_native_inline) &&
1251        invoker.is_enable_native_inline) {
1252      _aot_compile_options_ += " --compiler-enable-native-inline"
1253    }
1254
1255    if (defined(invoker.is_enable_opt_loop_peeling) &&
1256        invoker.is_enable_opt_loop_peeling) {
1257      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1258    }
1259
1260    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1261        invoker.is_enable_opt_array_bounds_check_elimination) {
1262      _aot_compile_options_ +=
1263          " --compiler-opt-array-bounds-check-elimination=true"
1264    }
1265
1266    if (defined(invoker.is_enable_inline_trace) &&
1267        invoker.is_enable_inline_trace) {
1268      _aot_compile_options_ += " --compiler-trace-inline=true"
1269    }
1270
1271    if (defined(invoker.userDefinedMethodsInModule) &&
1272        invoker.userDefinedMethodsInModule) {
1273      _aot_compile_options_ += " --compiler-module-methods=2"
1274    }
1275
1276    if (defined(invoker.disable_opt_loop_peeling) &&
1277        invoker.disable_opt_loop_peeling) {
1278      _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
1279    }
1280
1281    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
1282      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
1283    }
1284
1285    args = [
1286      "--script-file",
1287      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
1288      "--script-options",
1289      _aot_compile_options_,
1290      "--script-args",
1291      _script_args_,
1292      "--expect-sub-output",
1293      "ts aot compile success",
1294      "--env-path",
1295      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1296          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1297          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1298          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1299          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1300          rebase_path(_root_out_dir_) +
1301          "/thirdparty/bounds_checking_function:" +
1302          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1303    ]
1304
1305    inputs = [ _test_abc_path_ ]
1306
1307    outputs = [
1308      _test_aot_path_,
1309      _test_aot_snapshot_path_,
1310    ]
1311  }
1312
1313  action("${_target_name_}AotAction") {
1314    testonly = true
1315
1316    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1317    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1318
1319    deps = [
1320      ":${_target_name_}AotCompileAction",
1321      ":gen_${_target_name_}_abc",
1322      _host_jsvm_target_,
1323    ]
1324    deps += _deps_
1325    _is_test_llvm_only_ =
1326        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
1327    if (!_is_test_llvm_only_) {
1328      if (target_cpu == "x64") {
1329        deps += [ ":${_target_name_}AotActionWithLiteCG" ]
1330      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1331                 target_os == "ohos" && target_cpu == "arm64") {
1332        deps += [ ":${_target_name_}AotActionWithLiteCGQemu" ]
1333      }
1334    }
1335
1336    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1337
1338    _aot_run_options_ =
1339        " --aot-file=" + rebase_path(_test_aot_arg_) +
1340        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1341
1342    if (defined(invoker.is_enable_enableArkTools) &&
1343        invoker.is_enable_enableArkTools) {
1344      _aot_run_options_ += " --enable-ark-tools=true"
1345      _aot_run_options_ += " --enable-force-gc=false"
1346    }
1347    _aot_run_options_ += common_options
1348    if (defined(invoker.log_option)) {
1349      _aot_run_options_ += invoker.log_option
1350    }
1351
1352    if (defined(invoker.is_enable_typed_op_profiler) &&
1353        invoker.is_enable_typed_op_profiler) {
1354      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1355    }
1356
1357    if (defined(invoker.is_enable_lowering_builtin) &&
1358        invoker.is_enable_lowering_builtin) {
1359      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1360    }
1361
1362    _icu_data_path_options_ =
1363        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1364    _aot_run_options_ += _icu_data_path_options_
1365
1366    if (defined(invoker.log_option)) {
1367      _aot_run_options_ += invoker.log_option
1368    }
1369
1370    args = [
1371      "--script-file",
1372      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1373      "--script-options",
1374      _aot_run_options_,
1375      "--script-args",
1376      _script_args_,
1377      "--expect-file",
1378      rebase_path(_test_expect_path_),
1379      "--env-path",
1380      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1381          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1382          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1383          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1384          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1385          rebase_path(_root_out_dir_) +
1386          "/thirdparty/bounds_checking_function:" +
1387          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1388    ]
1389
1390    inputs = [ _test_abc_path_ ]
1391
1392    outputs = [ "$target_out_dir/${_target_name_}/" ]
1393  }
1394
1395  action("${_target_name_}AotContextAction") {
1396    testonly = true
1397
1398    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1399    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1400
1401    deps = [
1402      ":${_target_name_}AotCompileAction",
1403      ":gen_${_target_name_}_abc",
1404      _host_jsvm_target_,
1405    ]
1406    deps += _deps_
1407
1408    _is_test_llvm_only_ =
1409        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
1410    if (!_is_test_llvm_only_) {
1411      if (target_cpu == "x64") {
1412        deps += [ ":${_target_name_}AotContextActionWithLiteCG" ]
1413      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1414                 target_os == "ohos" && target_cpu == "arm64") {
1415        deps += [ ":${_target_name_}AotContextActionWithLiteCGQemu" ]
1416      }
1417    }
1418
1419    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1420
1421    _aot_run_options_ =
1422        " --aot-file=" + rebase_path(_test_aot_arg_) +
1423        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1424
1425    _aot_run_options_ += common_options
1426    if (defined(invoker.is_enable_enableArkTools) &&
1427        invoker.is_enable_enableArkTools) {
1428      _aot_run_options_ += " --enable-ark-tools=true"
1429      _aot_run_options_ += " --enable-force-gc=false"
1430    }
1431
1432    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1433      _aot_run_options_ += " --enable-force-gc=false"
1434    }
1435
1436    if (defined(invoker.log_option)) {
1437      _aot_run_options_ += invoker.log_option
1438    }
1439
1440    if (defined(invoker.is_enable_typed_op_profiler) &&
1441        invoker.is_enable_typed_op_profiler) {
1442      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1443    }
1444
1445    if (defined(invoker.is_enable_lowering_builtin) &&
1446        invoker.is_enable_lowering_builtin) {
1447      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1448    }
1449
1450    _icu_data_path_options_ =
1451        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1452    _aot_run_options_ += _icu_data_path_options_
1453    _aot_run_options_ += " --enable-context=true"
1454
1455    args = [
1456      "--script-file",
1457      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1458      "--script-options",
1459      _aot_run_options_,
1460      "--script-args",
1461      _script_args_,
1462      "--expect-file",
1463      rebase_path(_test_expect_path_),
1464      "--env-path",
1465      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1466          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1467          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1468          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
1469          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1470          rebase_path(_root_out_dir_) +
1471          "/thirdparty/bounds_checking_function:" +
1472          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1473    ]
1474
1475    inputs = [ _test_abc_path_ ]
1476
1477    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
1478  }
1479
1480  if (target_cpu == "x64") {
1481    action("${_target_name_}AotCompileActionWithLiteCG") {
1482      testonly = true
1483
1484      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1485      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1486      deps = [
1487        ":gen_${_target_name_}_abc",
1488        _host_aot_target_,
1489      ]
1490      deps += _deps_
1491
1492      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1493        deps += [ ":${_target_name_}PgoExecute" ]
1494      }
1495
1496      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1497
1498      _aot_compile_options_ =
1499          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1500          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
1501          " --compiler-opt-type-lowering=false" +
1502          " --compiler-opt-inlining=false" +
1503          " --compiler-opt-loop-peeling=true" + " --compiler-enable-litecg=true"
1504
1505      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1506        _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1507                                 rebase_path(_test_aot_arg_) + "/modules.ap"
1508      }
1509
1510      if (defined(invoker.is_enable_trace_deopt) &&
1511          invoker.is_enable_trace_deopt) {
1512        _aot_compile_options_ += " --compiler-trace-deopt=true"
1513      }
1514
1515      if (defined(invoker.is_enable_opt_inlining) &&
1516          invoker.is_enable_opt_inlining) {
1517        _aot_compile_options_ +=
1518            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1519      }
1520
1521      if (defined(invoker.is_enable_typed_op_profiler) &&
1522          invoker.is_enable_typed_op_profiler) {
1523        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
1524      }
1525
1526      if (defined(invoker.is_enable_lowering_builtin) &&
1527          invoker.is_enable_lowering_builtin) {
1528        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1529      }
1530
1531      if (defined(invoker.is_enable_native_inline) &&
1532          invoker.is_enable_native_inline) {
1533        _aot_compile_options_ += " --compiler-enable-native-inline"
1534      }
1535
1536      if (defined(invoker.is_enable_opt_loop_peeling) &&
1537          invoker.is_enable_opt_loop_peeling) {
1538        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1539      }
1540
1541      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1542          invoker.is_enable_opt_array_bounds_check_elimination) {
1543        _aot_compile_options_ +=
1544            " --compiler-opt-array-bounds-check-elimination=true"
1545      }
1546
1547      if (defined(invoker.is_enable_inline_trace) &&
1548          invoker.is_enable_inline_trace) {
1549        _aot_compile_options_ += " --compiler-trace-inline=true"
1550      }
1551
1552      if (defined(invoker.userDefinedMethodsInModule) &&
1553          invoker.userDefinedMethodsInModule) {
1554        _aot_compile_options_ += " --compiler-module-methods=2"
1555      }
1556
1557      if (defined(invoker.disable_opt_loop_peeling) &&
1558          invoker.disable_opt_loop_peeling) {
1559        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
1560      }
1561
1562      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
1563        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
1564      }
1565
1566      _aot_compile_options_ += common_options
1567      args = [
1568        "--script-file",
1569        rebase_path(_root_out_dir_) +
1570            "/arkcompiler/ets_runtime/ark_aot_compiler",
1571        "--script-options",
1572        _aot_compile_options_,
1573        "--script-args",
1574        _script_args_,
1575        "--expect-sub-output",
1576        "ts aot compile success",
1577        "--env-path",
1578        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1579            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1580            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1581            rebase_path(_root_out_dir_) +
1582            "/resourceschedule/frame_aware_sched:" +
1583            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1584            rebase_path(_root_out_dir_) +
1585            "/thirdparty/bounds_checking_function:" +
1586            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1587      ]
1588
1589      inputs = [ _test_abc_path_ ]
1590
1591      outputs = [
1592        _test_aot_path_litecg_,
1593        _test_aot_snapshot_path_litecg_,
1594      ]
1595    }
1596
1597    action("${_target_name_}AotActionWithLiteCG") {
1598      testonly = true
1599
1600      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1601      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1602
1603      deps = [
1604        ":${_target_name_}AotCompileActionWithLiteCG",
1605        ":gen_${_target_name_}_abc",
1606        _host_jsvm_target_,
1607      ]
1608      deps += _deps_
1609
1610      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1611
1612      _aot_run_options_ =
1613          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1614          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1615
1616      if (defined(invoker.is_enable_enableArkTools) &&
1617          invoker.is_enable_enableArkTools) {
1618        _aot_run_options_ += " --enable-ark-tools=true"
1619        _aot_run_options_ += " --enable-force-gc=false"
1620      }
1621      _aot_run_options_ += common_options
1622      if (defined(invoker.log_option)) {
1623        _aot_run_options_ += invoker.log_option
1624      }
1625
1626      if (defined(invoker.is_enable_typed_op_profiler) &&
1627          invoker.is_enable_typed_op_profiler) {
1628        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1629      }
1630
1631      if (defined(invoker.is_enable_lowering_builtin) &&
1632          invoker.is_enable_lowering_builtin) {
1633        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1634      }
1635
1636      _icu_data_path_options_ =
1637          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1638      _aot_run_options_ += _icu_data_path_options_
1639
1640      args = [
1641        "--script-file",
1642        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1643        "--script-options",
1644        _aot_run_options_,
1645        "--script-args",
1646        _script_args_,
1647        "--expect-file",
1648        rebase_path(_test_expect_path_),
1649        "--env-path",
1650        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1651            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1652            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1653            rebase_path(_root_out_dir_) +
1654            "/resourceschedule/frame_aware_sched:" +
1655            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1656            rebase_path(_root_out_dir_) +
1657            "/thirdparty/bounds_checking_function:" +
1658            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1659      ]
1660
1661      inputs = [ _test_abc_path_ ]
1662
1663      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
1664    }
1665
1666    action("${_target_name_}AotContextActionWithLiteCG") {
1667      testonly = true
1668
1669      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
1670      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1671
1672      deps = [
1673        ":${_target_name_}AotCompileActionWithLiteCG",
1674        ":gen_${_target_name_}_abc",
1675        _host_jsvm_target_,
1676      ]
1677      deps += _deps_
1678
1679      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1680
1681      _aot_run_options_ =
1682          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1683          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1684
1685      if (defined(invoker.is_enable_enableArkTools) &&
1686          invoker.is_enable_enableArkTools) {
1687        _aot_run_options_ += " --enable-ark-tools=true"
1688        _aot_run_options_ += " --enable-force-gc=false"
1689      }
1690
1691      if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1692        _aot_run_options_ += " --enable-force-gc=false"
1693      }
1694      _aot_run_options_ += common_options
1695
1696      if (defined(invoker.log_option)) {
1697        _aot_run_options_ += invoker.log_option
1698      }
1699
1700      if (defined(invoker.is_enable_typed_op_profiler) &&
1701          invoker.is_enable_typed_op_profiler) {
1702        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1703      }
1704
1705      if (defined(invoker.is_enable_lowering_builtin) &&
1706          invoker.is_enable_lowering_builtin) {
1707        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1708      }
1709
1710      _icu_data_path_options_ =
1711          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1712      _aot_run_options_ += _icu_data_path_options_
1713      _aot_run_options_ += " --enable-context=true"
1714
1715      args = [
1716        "--script-file",
1717        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1718        "--script-options",
1719        _aot_run_options_,
1720        "--script-args",
1721        _script_args_,
1722        "--expect-file",
1723        rebase_path(_test_expect_path_),
1724        "--env-path",
1725        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1726            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1727            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1728            rebase_path(_root_out_dir_) +
1729            "/resourceschedule/frame_aware_sched:" +
1730            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1731            rebase_path(_root_out_dir_) +
1732            "/thirdparty/bounds_checking_function:" +
1733            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1734      ]
1735
1736      inputs = [ _test_abc_path_ ]
1737
1738      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
1739    }
1740  } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
1741             target_os == "ohos" && target_cpu == "arm64") {
1742    import("$ark_third_party_root/musl/musl_template.gni")
1743    import("$build_root/config/qemu/config.gni")
1744
1745    action("${_target_name_}AotCompileActionWithLiteCGQemu") {
1746      testonly = true
1747
1748      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
1749      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
1750      deps = [
1751        ":gen_${_target_name_}_abc",
1752        _host_aot_target_,
1753      ]
1754      deps += _deps_
1755
1756      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1757        deps += [ ":${_target_name_}PgoExecute" ]
1758      }
1759
1760      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1761
1762      _aot_compile_options_ =
1763          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1764          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
1765          " --compiler-opt-type-lowering=false" +
1766          " --compiler-opt-inlining=false" +
1767          " --compiler-opt-loop-peeling=true" +
1768          " --compiler-enable-litecg=true" +
1769          " --compiler-target-triple=aarch64-unknown-linux-gnu"
1770
1771      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
1772        _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
1773                                 rebase_path(_test_aot_arg_) + "/modules.ap"
1774      }
1775
1776      if (defined(invoker.is_enable_trace_deopt) &&
1777          invoker.is_enable_trace_deopt) {
1778        _aot_compile_options_ += " --compiler-trace-deopt=true"
1779      }
1780
1781      if (defined(invoker.is_enable_opt_inlining) &&
1782          invoker.is_enable_opt_inlining) {
1783        _aot_compile_options_ +=
1784            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
1785      }
1786
1787      if (defined(invoker.is_enable_typed_op_profiler) &&
1788          invoker.is_enable_typed_op_profiler) {
1789        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
1790      }
1791
1792      if (defined(invoker.is_enable_lowering_builtin) &&
1793          invoker.is_enable_lowering_builtin) {
1794        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
1795      }
1796
1797      if (defined(invoker.is_enable_native_inline) &&
1798          invoker.is_enable_native_inline) {
1799        _aot_compile_options_ += " --compiler-enable-native-inline"
1800      }
1801
1802      if (defined(invoker.is_enable_opt_loop_peeling) &&
1803          invoker.is_enable_opt_loop_peeling) {
1804        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
1805      }
1806
1807      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
1808          invoker.is_enable_opt_array_bounds_check_elimination) {
1809        _aot_compile_options_ +=
1810            " --compiler-opt-array-bounds-check-elimination=true"
1811      }
1812
1813      if (defined(invoker.is_enable_inline_trace) &&
1814          invoker.is_enable_inline_trace) {
1815        _aot_compile_options_ += " --compiler-trace-inline=true"
1816      }
1817
1818      if (defined(invoker.userDefinedMethodsInModule) &&
1819          invoker.userDefinedMethodsInModule) {
1820        _aot_compile_options_ += " --compiler-module-methods=2"
1821      }
1822
1823      if (defined(invoker.disable_opt_loop_peeling) &&
1824          invoker.disable_opt_loop_peeling) {
1825        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
1826      }
1827
1828      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
1829        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
1830      }
1831
1832      _aot_compile_options_ += common_options
1833      args = [
1834        "--script-file",
1835        rebase_path(_root_out_dir_) +
1836            "/arkcompiler/ets_runtime/ark_aot_compiler",
1837        "--script-options",
1838        _aot_compile_options_,
1839        "--script-args",
1840        _script_args_,
1841        "--expect-sub-output",
1842        "ts aot compile success",
1843        "--env-path",
1844        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
1845            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
1846            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
1847            rebase_path(_root_out_dir_) +
1848            "/resourceschedule/frame_aware_sched:" +
1849            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1850            rebase_path(_root_out_dir_) +
1851            "/thirdparty/bounds_checking_function:" +
1852            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1853      ]
1854
1855      inputs = [ _test_abc_path_ ]
1856
1857      outputs = [
1858        _test_aot_path_litecg_,
1859        _test_aot_snapshot_path_litecg_,
1860      ]
1861    }
1862
1863    action("${_target_name_}AotActionWithLiteCGQemu") {
1864      testonly = true
1865
1866      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
1867      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1868
1869      deps = [
1870        ":${_target_name_}AotCompileActionWithLiteCGQemu",
1871        ":gen_${_target_name_}_abc",
1872        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
1873        _host_jsvm_target_,
1874      ]
1875      deps += _deps_
1876
1877      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1878
1879      _aot_run_options_ =
1880          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1881          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1882
1883      if (defined(invoker.is_enable_enableArkTools) &&
1884          invoker.is_enable_enableArkTools) {
1885        _aot_run_options_ += " --enable-ark-tools=true"
1886        _aot_run_options_ += " --enable-force-gc=false"
1887      }
1888      _aot_run_options_ += common_options
1889      if (defined(invoker.log_option)) {
1890        _aot_run_options_ += invoker.log_option
1891      }
1892
1893      if (defined(invoker.is_enable_typed_op_profiler) &&
1894          invoker.is_enable_typed_op_profiler) {
1895        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1896      }
1897
1898      if (defined(invoker.is_enable_lowering_builtin) &&
1899          invoker.is_enable_lowering_builtin) {
1900        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1901      }
1902
1903      _icu_data_path_options_ =
1904          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1905      _aot_run_options_ += _icu_data_path_options_
1906
1907      args = [
1908        "--script-file",
1909        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1910        "--script-options",
1911        _aot_run_options_,
1912        "--script-args",
1913        _script_args_,
1914        "--expect-file",
1915        rebase_path(_test_expect_path_),
1916        "--qemu-binary-path",
1917        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
1918        "--qemu-ld-prefix",
1919        rebase_path(musl_linker_so_out_dir, root_build_dir),
1920        "--clang-lib-path",
1921        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
1922                    root_build_dir) + rebase_path(_root_out_dir_) +
1923            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
1924            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
1925            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
1926            "/resourceschedule/frame_aware_sched:" +
1927            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
1928            rebase_path(_root_out_dir_) +
1929            "/thirdparty/bounds_checking_function:" +
1930            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
1931      ]
1932
1933      inputs = [ _test_abc_path_ ]
1934
1935      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
1936    }
1937
1938    action("${_target_name_}AotContextActionWithLiteCGQemu") {
1939      testonly = true
1940
1941      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
1942      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
1943
1944      deps = [
1945        ":${_target_name_}AotCompileActionWithLiteCGQemu",
1946        ":gen_${_target_name_}_abc",
1947        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
1948        _host_jsvm_target_,
1949      ]
1950      deps += _deps_
1951
1952      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
1953
1954      _aot_run_options_ =
1955          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
1956          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
1957
1958      if (defined(invoker.is_enable_enableArkTools) &&
1959          invoker.is_enable_enableArkTools) {
1960        _aot_run_options_ += " --enable-ark-tools=true"
1961        _aot_run_options_ += " --enable-force-gc=false"
1962      }
1963
1964      if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
1965        _aot_run_options_ += " --enable-force-gc=false"
1966      }
1967
1968      _aot_run_options_ += common_options
1969
1970      if (defined(invoker.log_option)) {
1971        _aot_run_options_ += invoker.log_option
1972      }
1973
1974      if (defined(invoker.is_enable_typed_op_profiler) &&
1975          invoker.is_enable_typed_op_profiler) {
1976        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
1977      }
1978
1979      if (defined(invoker.is_enable_lowering_builtin) &&
1980          invoker.is_enable_lowering_builtin) {
1981        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
1982      }
1983
1984      _icu_data_path_options_ =
1985          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
1986      _aot_run_options_ += _icu_data_path_options_
1987      _aot_run_options_ += " --enable-context=true"
1988
1989      args = [
1990        "--script-file",
1991        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
1992        "--script-options",
1993        _aot_run_options_,
1994        "--script-args",
1995        _script_args_,
1996        "--expect-file",
1997        rebase_path(_test_expect_path_),
1998        "--qemu-binary-path",
1999        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
2000        "--qemu-ld-prefix",
2001        rebase_path(musl_linker_so_out_dir, root_build_dir),
2002        "--clang-lib-path",
2003        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
2004                    root_build_dir) + rebase_path(_root_out_dir_) +
2005            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
2006            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
2007            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
2008            "/resourceschedule/frame_aware_sched:" +
2009            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2010            rebase_path(_root_out_dir_) +
2011            "/thirdparty/bounds_checking_function:" +
2012            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2013      ]
2014
2015      inputs = [ _test_abc_path_ ]
2016
2017      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
2018    }
2019  }
2020}
2021
2022template("host_aot_js_assert_test_action") {
2023  _target_name_ = "${target_name}"
2024  _deps_ = invoker.deps
2025
2026  _test_ts_path_ = "./${_target_name_}.js"
2027  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
2028  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
2029  _test_aot_log_level = "info"
2030
2031  if (defined(invoker.is_common_js) && invoker.is_common_js) {
2032    extra_args = [ "--commonjs" ]
2033  } else {
2034    extra_args = [ "--module" ]
2035  }
2036  extra_args += [ "--merge-abc" ]
2037
2038  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
2039    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
2040    extra_dependencies = _deps_
2041    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
2042      src_js = rebase_path("./")
2043    } else {
2044      src_js = rebase_path(_test_ts_path_)
2045    }
2046    dst_file = rebase_path(_test_abc_path_)
2047
2048    in_puts = [ _test_ts_path_ ]
2049    out_puts = [ _test_abc_path_ ]
2050  }
2051
2052  _script_args_ = rebase_path(_test_abc_path_)
2053
2054  action("${_target_name_}PgoExecuteAssert") {
2055    testonly = true
2056    _host_jsvm_target_ =
2057        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2058    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2059
2060    deps = [
2061      ":gen_${_target_name_}_abc",
2062      _host_jsvm_target_,
2063    ]
2064    deps += _deps_
2065
2066    script = "$js_root/script/run_ark_executable.py"
2067
2068    _aot_run_options_ =
2069        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
2070        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
2071        rebase_path(_test_aot_arg_) + "/modules.ap"
2072
2073    if (defined(invoker.is_enable_enableArkTools) &&
2074        invoker.is_enable_enableArkTools) {
2075      _aot_run_options_ += " --enable-ark-tools=true"
2076      _aot_run_options_ += " --enable-force-gc=false"
2077    }
2078
2079    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
2080      _aot_run_options_ += " --enable-force-gc=false"
2081    }
2082
2083    _aot_run_options_ += common_options
2084
2085    if (defined(invoker.log_option)) {
2086      _aot_run_options_ += invoker.log_option
2087    }
2088
2089    _aot_run_options_ += " --test-assert=true"
2090
2091    args = [
2092      "--script-file",
2093      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2094      "--script-options",
2095      _aot_run_options_,
2096      "--script-args",
2097      _script_args_,
2098      "--expect-output",
2099      "0",
2100      "--env-path",
2101      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2102          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2103          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2104          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2105          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2106          rebase_path(_root_out_dir_) +
2107          "/thirdparty/bounds_checking_function:" +
2108          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2109    ]
2110
2111    inputs = [ _test_abc_path_ ]
2112
2113    outputs = [ "$target_out_dir/${_target_name_}/pgoassert" ]
2114  }
2115
2116  action("${_target_name_}AotCompileAssertAction") {
2117    testonly = true
2118
2119    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2120    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2121    deps = [
2122      ":gen_${_target_name_}_abc",
2123      _host_aot_target_,
2124    ]
2125    deps += _deps_
2126
2127    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2128      deps += [ ":${_target_name_}PgoExecuteAssert" ]
2129    }
2130
2131    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2132
2133    _aot_compile_options_ = " --aot-file=" + rebase_path(_test_aot_arg_) +
2134                            " --log-level=" + _test_aot_log_level + " --log-components=compiler --compiler-opt-type-lowering=false --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=true"
2135
2136    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2137      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
2138                               rebase_path(_test_aot_arg_) + "/modules.ap"
2139    }
2140
2141    if (defined(invoker.is_enable_trace_deopt) &&
2142        invoker.is_enable_trace_deopt) {
2143      _aot_compile_options_ += " --compiler-trace-deopt=true"
2144    }
2145
2146    if (defined(invoker.is_enable_opt_inlining) &&
2147        invoker.is_enable_opt_inlining) {
2148      _aot_compile_options_ +=
2149          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2150    }
2151
2152    if (defined(invoker.is_enable_typed_op_profiler) &&
2153        invoker.is_enable_typed_op_profiler) {
2154      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
2155    }
2156
2157    if (defined(invoker.is_enable_lowering_builtin) &&
2158        invoker.is_enable_lowering_builtin) {
2159      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
2160    }
2161
2162    if (defined(invoker.is_enable_native_inline) &&
2163        invoker.is_enable_native_inline) {
2164      _aot_compile_options_ += " --compiler-enable-native-inline"
2165    }
2166
2167    if (defined(invoker.is_enable_opt_loop_peeling) &&
2168        invoker.is_enable_opt_loop_peeling) {
2169      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2170    }
2171
2172    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
2173      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
2174    }
2175
2176    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2177        invoker.is_enable_opt_array_bounds_check_elimination) {
2178      _aot_compile_options_ +=
2179          " --compiler-opt-array-bounds-check-elimination=true"
2180    }
2181
2182    if (defined(invoker.is_enable_inline_trace) &&
2183        invoker.is_enable_inline_trace) {
2184      _aot_compile_options_ += " --compiler-trace-inline=true"
2185    }
2186
2187    if (defined(invoker.userDefinedMethodsInModule) &&
2188        invoker.userDefinedMethodsInModule) {
2189      _aot_compile_options_ += " --compiler-module-methods=2"
2190    }
2191    _aot_compile_options_ += common_options
2192    _aot_compile_options_ += " --test-assert=true"
2193
2194    args = [
2195      "--script-file",
2196      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2197      "--script-options",
2198      _aot_compile_options_,
2199      "--script-args",
2200      _script_args_,
2201      "--expect-sub-output",
2202      "ts aot compile success",
2203      "--env-path",
2204      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2205          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2206          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2207          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2208          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2209          rebase_path(_root_out_dir_) +
2210          "/thirdparty/bounds_checking_function:" +
2211          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2212    ]
2213
2214    inputs = [ _test_abc_path_ ]
2215
2216    outputs = [
2217      "$target_out_dir/${_target_name_}AotCompileAssert.an",
2218      "$target_out_dir/${_target_name_}AotCompileAssert.ai",
2219    ]
2220  }
2221
2222  action("${_target_name_}AotAssertAction") {
2223    testonly = true
2224
2225    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2226    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2227
2228    deps = [
2229      ":${_target_name_}AotCompileAssertAction",
2230      ":gen_${_target_name_}_abc",
2231      _host_jsvm_target_,
2232    ]
2233    deps += _deps_
2234
2235    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2236
2237    _aot_run_options_ =
2238        " --aot-file=" + rebase_path(_test_aot_arg_) +
2239        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2240
2241    if (defined(invoker.is_enable_enableArkTools) &&
2242        invoker.is_enable_enableArkTools) {
2243      _aot_run_options_ += " --enable-ark-tools=true"
2244      _aot_run_options_ += " --enable-force-gc=false"
2245    }
2246    _aot_run_options_ += common_options
2247    if (defined(invoker.log_option)) {
2248      _aot_run_options_ += invoker.log_option
2249    }
2250
2251    if (defined(invoker.is_enable_typed_op_profiler) &&
2252        invoker.is_enable_typed_op_profiler) {
2253      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2254    }
2255
2256    if (defined(invoker.is_enable_lowering_builtin) &&
2257        invoker.is_enable_lowering_builtin) {
2258      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2259    }
2260
2261    _icu_data_path_options_ =
2262        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2263    _aot_run_options_ += _icu_data_path_options_
2264
2265    if (defined(invoker.log_option)) {
2266      _aot_run_options_ += invoker.log_option
2267    }
2268
2269    _aot_run_options_ += " --test-assert=true"
2270
2271    args = [
2272      "--script-file",
2273      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2274      "--script-options",
2275      _aot_run_options_,
2276      "--script-args",
2277      _script_args_,
2278      "--expect-output",
2279      "0",
2280      "--env-path",
2281      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2282          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2283          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2284          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2285          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2286          rebase_path(_root_out_dir_) +
2287          "/thirdparty/bounds_checking_function:" +
2288          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2289    ]
2290
2291    inputs = [ _test_abc_path_ ]
2292
2293    outputs = [ "$target_out_dir/${_target_name_}AotAssert/" ]
2294  }
2295
2296  action("${_target_name_}AotContextAssertAction") {
2297    testonly = true
2298
2299    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2300    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2301
2302    deps = [
2303      ":${_target_name_}AotCompileAssertAction",
2304      ":gen_${_target_name_}_abc",
2305      _host_jsvm_target_,
2306    ]
2307    deps += _deps_
2308
2309    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2310
2311    _aot_run_options_ =
2312        " --aot-file=" + rebase_path(_test_aot_arg_) +
2313        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2314
2315    if (defined(invoker.is_enable_enableArkTools) &&
2316        invoker.is_enable_enableArkTools) {
2317      _aot_run_options_ += " --enable-ark-tools=true"
2318      _aot_run_options_ += " --enable-force-gc=false"
2319    }
2320
2321    if (defined(invoker.disable_force_gc) && invoker.disable_force_gc) {
2322      _aot_run_options_ += " --enable-force-gc=false"
2323    }
2324    _aot_run_options_ += common_options
2325
2326    if (defined(invoker.log_option)) {
2327      _aot_run_options_ += invoker.log_option
2328    }
2329
2330    if (defined(invoker.is_enable_typed_op_profiler) &&
2331        invoker.is_enable_typed_op_profiler) {
2332      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2333    }
2334
2335    if (defined(invoker.is_enable_lowering_builtin) &&
2336        invoker.is_enable_lowering_builtin) {
2337      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2338    }
2339
2340    _icu_data_path_options_ =
2341        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2342    _aot_run_options_ += _icu_data_path_options_
2343    _aot_run_options_ += " --enable-context=true"
2344    _aot_run_options_ += " --test-assert=true"
2345
2346    args = [
2347      "--script-file",
2348      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2349      "--script-options",
2350      _aot_run_options_,
2351      "--script-args",
2352      _script_args_,
2353      "--expect-output",
2354      "0",
2355      "--env-path",
2356      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2357          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2358          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2359          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2360          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2361          rebase_path(_root_out_dir_) +
2362          "/thirdparty/bounds_checking_function:" +
2363          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2364    ]
2365
2366    inputs = [ _test_abc_path_ ]
2367
2368    outputs = [ "$target_out_dir/${_target_name_}ContextAssert/" ]
2369  }
2370}
2371
2372template("host_aot_test_action") {
2373  _target_name_ = "${target_name}"
2374  _deps_ = invoker.deps
2375
2376  _src_dir_ = "."
2377  if (defined(invoker.src_dir) && invoker.src_dir != "") {
2378    _src_dir_ = invoker.src_dir
2379  }
2380
2381  if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2382    _test_ts_template_path_ = "${_src_dir_}/${_target_name_}.ts"
2383    _test_ts_path_ = "$target_out_dir/${_target_name_}.ts"
2384  } else {
2385    _test_ts_path_ = "${_src_dir_}/${_target_name_}.ts"
2386  }
2387  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
2388  _test_aot_path_ = "$target_out_dir/${_target_name_}.an"
2389  _test_aot_snapshot_path_ = "$target_out_dir/${_target_name_}.ai"
2390  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
2391  _test_profiler_path_ = "${_test_aot_arg_}/modules.ap"
2392  _test_aot_path_slowpath_ = "$target_out_dir/slowpath/${_target_name_}.an"
2393  _test_aot_snapshot_path_slowpath_ =
2394      "$target_out_dir/slowpath/${_target_name_}.ai"
2395  _test_aot_arg_slowpath_ = "$target_out_dir/slowpath/${_target_name_}"
2396  _test_aot_log_level = "info"
2397  _test_expect_path_ = "${_src_dir_}/expect_output.txt"
2398  _test_slowpath_expect_path_ = _test_expect_path_
2399  _test_pgo_expect_path_ = "${_src_dir_}/pgo_expect_output.txt"
2400  _is_test_llvm_only_ = TEST_LLVM_ONLY
2401  if (!TEST_LLVM_ONLY && defined(invoker.is_test_llvm_only) &&
2402      invoker.is_test_llvm_only) {
2403    _is_test_llvm_only_ = true
2404  }
2405  if (defined(invoker.use_one_expect_path) && invoker.use_one_expect_path) {
2406    _test_pgo_expect_path_ = _test_expect_path_
2407  }
2408  if (defined(invoker.use_distinct_slowpath_expect_path) &&
2409      invoker.use_distinct_slowpath_expect_path) {
2410    _test_slowpath_expect_path_ = "${_src_dir_}/slowpath_expect_output.txt"
2411  }
2412  if (target_cpu == "x64" ||
2413      (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2414       target_os == "ohos" && target_cpu == "arm64")) {
2415    _test_aot_path_litecg_ = "$target_out_dir/litecg/${_target_name_}.an"
2416    _test_aot_snapshot_path_litecg_ =
2417        "$target_out_dir/litecg/${_target_name_}.ai"
2418    _test_aot_arg_litecg_ = "$target_out_dir/litecg/${_target_name_}"
2419    _test_aot_path_slowpath_litecg_ =
2420        "$target_out_dir/slowpath/litecg/${_target_name_}.an"
2421    _test_aot_snapshot_path_slowpath_litecg_ =
2422        "$target_out_dir/slowpath/litecg/${_target_name_}.ai"
2423    _test_aot_arg_slowpath_litecg_ =
2424        "$target_out_dir/slowpath/litecg/${_target_name_}"
2425  }
2426
2427  if (defined(invoker.gen_expect_output) && invoker.gen_expect_output) {
2428    _test_expect_path_ = "$target_out_dir/expect_output.txt"
2429    _test_pgo_expect_path_ = "$target_out_dir/pgo_expect_output.txt"
2430    _test_slowpath_expect_path_ = _test_expect_path_
2431
2432    action("${_target_name_}GenExpectOutput") {
2433      script = "$js_root/script/gen_expect_output.sh"
2434      sources = [ _test_ts_path_ ]
2435      outputs = [ _test_expect_path_ ]
2436      args = [ "aot" ] + rebase_path(sources + outputs)
2437    }
2438
2439    action("${_target_name_}PgoGenExpectOutput") {
2440      script = "$js_root/script/gen_expect_output.sh"
2441      sources = [ _test_ts_path_ ]
2442      outputs = [ _test_pgo_expect_path_ ]
2443      args = [ "pgo" ] + rebase_path(sources + outputs)
2444    }
2445    _deps_ += [
2446      ":${_target_name_}GenExpectOutput",
2447      ":${_target_name_}PgoGenExpectOutput",
2448    ]
2449  }
2450
2451  if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2452    action("gen_${_target_name_}_ts") {
2453      script = "//arkcompiler/ets_runtime/test/quickfix/generate_js_and_merge_file.py"
2454      src_file = rebase_path(_test_ts_template_path_)
2455      dst_file = rebase_path(_test_ts_path_)
2456      args = [
2457        "--input=$src_file",
2458        "--output=$dst_file",
2459      ]
2460      inputs = [ _test_ts_template_path_ ]
2461      outputs = [ _test_ts_path_ ]
2462    }
2463  }
2464
2465  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
2466    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
2467    extra_dependencies = _deps_
2468    if (defined(invoker.gen_ts_by_script) && invoker.gen_ts_by_script) {
2469      extra_dependencies += [ ":gen_${_target_name_}_ts" ]
2470    }
2471    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
2472      src_js = rebase_path("./")
2473    } else {
2474      src_js = rebase_path(_test_ts_path_)
2475    }
2476    dst_file = rebase_path(_test_abc_path_)
2477    extension = "ts"
2478    extra_args = [ "--merge-abc" ]
2479
2480    if (!(defined(invoker.without_module) && invoker.without_module)) {
2481      extra_args += [ "--module" ]
2482    }
2483
2484    if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
2485      extra_args += [ "--debug" ]
2486    }
2487
2488    in_puts = [
2489      _test_ts_path_,
2490      _test_expect_path_,
2491    ]
2492    out_puts = [ _test_abc_path_ ]
2493  }
2494
2495  _script_args_ = rebase_path(_test_abc_path_)
2496
2497  action("${_target_name_}PgoExecute") {
2498    testonly = true
2499    _host_jsvm_target_ =
2500        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2501    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2502
2503    deps = [
2504      ":gen_${_target_name_}_abc",
2505      _host_jsvm_target_,
2506    ]
2507    deps += _deps_
2508
2509    script = "$js_root/script/run_ark_executable.py"
2510
2511    _aot_run_options_ =
2512        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
2513        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
2514        rebase_path(_test_profiler_path_)
2515
2516    if (defined(invoker.is_enable_enableArkTools) &&
2517        invoker.is_enable_enableArkTools) {
2518      _aot_run_options_ += " --enable-ark-tools=true"
2519      _aot_run_options_ += " --enable-force-gc=false"
2520    }
2521    if (defined(invoker.log_option)) {
2522      _aot_run_options_ += invoker.log_option
2523    }
2524    if (defined(invoker.is_enable_force_ic) && !invoker.is_enable_force_ic) {
2525      _aot_run_options_ += " --enable-force-ic=false"
2526    }
2527    _aot_run_options_ += common_options
2528    args = [
2529      "--script-file",
2530      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2531      "--script-options",
2532      _aot_run_options_,
2533      "--script-args",
2534      _script_args_,
2535      "--expect-file",
2536      rebase_path(_test_pgo_expect_path_),
2537      "--env-path",
2538      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2539          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2540          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2541          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2542          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2543          rebase_path(_root_out_dir_) +
2544          "/thirdparty/bounds_checking_function:" +
2545          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2546    ]
2547
2548    inputs = [ _test_abc_path_ ]
2549
2550    outputs = [ _test_profiler_path_ ]
2551  }
2552
2553  action("${_target_name_}AotCompileAction") {
2554    testonly = true
2555
2556    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2557    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2558    deps = [
2559      ":gen_${_target_name_}_abc",
2560      _host_aot_target_,
2561    ]
2562    deps += _deps_
2563
2564    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2565      deps += [ ":${_target_name_}PgoExecute" ]
2566    }
2567
2568    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2569
2570    _aot_compile_options_ =
2571        " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
2572        _test_aot_log_level + " --log-components=compiler" +
2573        " --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=true"
2574
2575    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
2576      _aot_compile_options_ +=
2577          " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
2578    }
2579    if (defined(invoker.is_enable_trace_deopt) &&
2580        invoker.is_enable_trace_deopt) {
2581      _aot_compile_options_ += " --compiler-trace-deopt=true"
2582    }
2583    if (defined(invoker.is_enable_opt_inlining) &&
2584        invoker.is_enable_opt_inlining) {
2585      _aot_compile_options_ +=
2586          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2587    }
2588
2589    if (defined(invoker.is_enable_typed_op_profiler) &&
2590        invoker.is_enable_typed_op_profiler) {
2591      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
2592    }
2593
2594    if (defined(invoker.is_enable_lowering_builtin) &&
2595        invoker.is_enable_lowering_builtin) {
2596      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
2597    }
2598
2599    if (defined(invoker.is_enable_native_inline) &&
2600        invoker.is_enable_native_inline) {
2601      _aot_compile_options_ += " --compiler-enable-native-inline"
2602    }
2603
2604    if (defined(invoker.is_enable_opt_loop_peeling) &&
2605        invoker.is_enable_opt_loop_peeling) {
2606      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2607    }
2608
2609    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2610        invoker.is_enable_opt_array_bounds_check_elimination) {
2611      _aot_compile_options_ +=
2612          " --compiler-opt-array-bounds-check-elimination=true"
2613    }
2614
2615    if (defined(invoker.is_enable_inline_trace) &&
2616        invoker.is_enable_inline_trace) {
2617      _aot_compile_options_ += " --compiler-trace-inline=true"
2618    }
2619
2620    if (defined(invoker.userDefinedMethodsInModule) &&
2621        invoker.userDefinedMethodsInModule) {
2622      _aot_compile_options_ += " --compiler-module-methods=2"
2623    }
2624
2625    if (defined(invoker.disable_opt_loop_peeling) &&
2626        invoker.disable_opt_loop_peeling) {
2627      _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
2628    }
2629
2630    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
2631      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
2632    }
2633
2634    _aot_compile_options_ += common_options
2635    args = [
2636      "--script-file",
2637      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2638      "--script-options",
2639      _aot_compile_options_,
2640      "--script-args",
2641      _script_args_,
2642      "--expect-sub-output",
2643      "ts aot compile success",
2644      "--env-path",
2645      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2646          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2647          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2648          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2649          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2650          rebase_path(_root_out_dir_) +
2651          "/thirdparty/bounds_checking_function:" +
2652          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2653    ]
2654
2655    inputs = [ _test_abc_path_ ]
2656
2657    outputs = [
2658      _test_aot_path_,
2659      _test_aot_snapshot_path_,
2660    ]
2661  }
2662
2663  action("${_target_name_}AotCompileActionSlowPath") {
2664    testonly = true
2665    _host_aot_target_ =
2666        "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2667    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2668    deps = [
2669      ":gen_${_target_name_}_abc",
2670      _host_aot_target_,
2671    ]
2672    deps += _deps_
2673
2674    script = "$js_root/script/run_ark_executable.py"
2675
2676    _aot_compile_options_ =
2677        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
2678        " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
2679        " --compiler-opt-type-lowering=false" +
2680        " --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=true"
2681
2682    if (defined(invoker.is_enable_trace_deopt) &&
2683        invoker.is_enable_trace_deopt) {
2684      _aot_compile_options_ += " --compiler-trace-deopt=true"
2685    }
2686
2687    if (defined(invoker.is_enable_opt_inlining) &&
2688        invoker.is_enable_opt_inlining) {
2689      _aot_compile_options_ +=
2690          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
2691    }
2692
2693    if (defined(invoker.is_enable_native_inline) &&
2694        invoker.is_enable_native_inline) {
2695      _aot_compile_options_ += " --compiler-enable-native-inline"
2696    }
2697
2698    if (defined(invoker.is_enable_opt_loop_peeling) &&
2699        invoker.is_enable_opt_loop_peeling) {
2700      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
2701    }
2702
2703    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
2704        invoker.is_enable_opt_array_bounds_check_elimination) {
2705      _aot_compile_options_ +=
2706          " --compiler-opt-array-bounds-check-elimination=true"
2707    }
2708
2709    if (defined(invoker.is_enable_inline_trace) &&
2710        invoker.is_enable_inline_trace) {
2711      _aot_compile_options_ += " --compiler-trace-inline=true"
2712    }
2713
2714    if (defined(invoker.userDefinedMethodsInModule) &&
2715        invoker.userDefinedMethodsInModule) {
2716      _aot_compile_options_ += " --compiler-module-methods=2"
2717    }
2718
2719    if (defined(invoker.disable_opt_loop_peeling) &&
2720        invoker.disable_opt_loop_peeling) {
2721      _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
2722    }
2723
2724    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
2725      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
2726    }
2727
2728    _aot_compile_options_ += common_options
2729    args = [
2730      "--script-file",
2731      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
2732      "--script-options",
2733      _aot_compile_options_,
2734      "--script-args",
2735      _script_args_,
2736      "--expect-sub-output",
2737      "ts aot compile success",
2738      "--env-path",
2739      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2740          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2741          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2742          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2743          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2744          rebase_path(_root_out_dir_) +
2745          "/thirdparty/bounds_checking_function:" +
2746          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2747    ]
2748
2749    inputs = [ _test_abc_path_ ]
2750
2751    outputs = [
2752      _test_aot_path_slowpath_,
2753      _test_aot_snapshot_path_slowpath_,
2754    ]
2755  }
2756
2757  action("${_target_name_}AotAction") {
2758    testonly = true
2759    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2760    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2761
2762    deps = [
2763      ":${_target_name_}AotCompileAction",
2764      ":gen_${_target_name_}_abc",
2765      _host_jsvm_target_,
2766    ]
2767    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
2768      deps += [ ":${_target_name_}AotActionSlowPath" ]
2769    }
2770    deps += _deps_
2771
2772    _is_test_llvm_only_ =
2773        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
2774    if (!_is_test_llvm_only_) {
2775      if (target_cpu == "x64") {
2776        deps += [ ":${_target_name_}AotActionWithLiteCG" ]
2777      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2778                 target_os == "ohos" && target_cpu == "arm64") {
2779        deps += [ ":${_target_name_}AotActionWithLiteCGQemu" ]
2780      }
2781    }
2782
2783    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2784
2785    _aot_run_options_ =
2786        " --aot-file=" + rebase_path(_test_aot_arg_) +
2787        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2788
2789    _icu_data_path_options_ =
2790        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2791    _aot_run_options_ += _icu_data_path_options_
2792
2793    if (defined(invoker.is_enable_enableArkTools) &&
2794        invoker.is_enable_enableArkTools) {
2795      _aot_run_options_ += " --enable-ark-tools=true"
2796      _aot_run_options_ += " --enable-force-gc=false"
2797    }
2798    _aot_run_options_ += common_options
2799    if (defined(invoker.log_option)) {
2800      _aot_run_options_ += invoker.log_option
2801    }
2802
2803    if (defined(invoker.is_enable_typed_op_profiler) &&
2804        invoker.is_enable_typed_op_profiler) {
2805      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2806    }
2807
2808    if (defined(invoker.is_enable_lowering_builtin) &&
2809        invoker.is_enable_lowering_builtin) {
2810      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2811    }
2812
2813    if (defined(invoker.is_enable_trace_deopt) &&
2814        invoker.is_enable_trace_deopt) {
2815      _aot_run_options_ += " --compiler-trace-deopt=true"
2816    }
2817
2818    args = [
2819      "--script-file",
2820      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2821      "--script-options",
2822      _aot_run_options_,
2823      "--script-args",
2824      _script_args_,
2825      "--expect-file",
2826      rebase_path(_test_expect_path_),
2827      "--env-path",
2828      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2829          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2830          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2831          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2832          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2833          rebase_path(_root_out_dir_) +
2834          "/thirdparty/bounds_checking_function:" +
2835          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2836    ]
2837
2838    inputs = [ _test_abc_path_ ]
2839
2840    outputs = [ "$target_out_dir/${_target_name_}/" ]
2841  }
2842
2843  action("${_target_name_}AotContextAction") {
2844    testonly = true
2845    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2846    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2847
2848    deps = [
2849      ":${_target_name_}AotCompileAction",
2850      ":gen_${_target_name_}_abc",
2851      _host_jsvm_target_,
2852    ]
2853    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
2854      deps += [ ":${_target_name_}AotActionSlowPath" ]
2855    }
2856    deps += _deps_
2857
2858    _is_test_llvm_only_ =
2859        defined(invoker.is_test_llvm_only) && invoker.is_test_llvm_only
2860    if (!_is_test_llvm_only_) {
2861      if (target_cpu == "x64") {
2862        deps += [ ":${_target_name_}AotContextActionWithLiteCG" ]
2863      } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
2864                 target_os == "ohos" && target_cpu == "arm64") {
2865        deps += [ ":${_target_name_}AotContextActionWithLiteCGQemu" ]
2866      }
2867    }
2868
2869    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
2870
2871    _aot_run_options_ =
2872        " --aot-file=" + rebase_path(_test_aot_arg_) +
2873        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2874
2875    _icu_data_path_options_ =
2876        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2877    _aot_run_options_ += _icu_data_path_options_
2878
2879    if (defined(invoker.is_enable_enableArkTools) &&
2880        invoker.is_enable_enableArkTools) {
2881      _aot_run_options_ += " --enable-ark-tools=true"
2882      _aot_run_options_ += " --enable-force-gc=false"
2883    }
2884    if (defined(invoker.log_option)) {
2885      _aot_run_options_ += invoker.log_option
2886    }
2887    _aot_run_options_ += " --enable-context=true"
2888
2889    if (defined(invoker.is_enable_typed_op_profiler) &&
2890        invoker.is_enable_typed_op_profiler) {
2891      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
2892    }
2893    _aot_run_options_ += common_options
2894    if (defined(invoker.is_enable_lowering_builtin) &&
2895        invoker.is_enable_lowering_builtin) {
2896      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
2897    }
2898
2899    if (defined(invoker.is_enable_trace_deopt) &&
2900        invoker.is_enable_trace_deopt) {
2901      _aot_run_options_ += " --compiler-trace-deopt=true"
2902    }
2903
2904    args = [
2905      "--script-file",
2906      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2907      "--script-options",
2908      _aot_run_options_,
2909      "--script-args",
2910      _script_args_,
2911      "--expect-file",
2912      rebase_path(_test_expect_path_),
2913      "--env-path",
2914      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2915          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2916          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2917          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2918          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2919          rebase_path(_root_out_dir_) +
2920          "/thirdparty/bounds_checking_function:" +
2921          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2922    ]
2923
2924    inputs = [ _test_abc_path_ ]
2925
2926    outputs = [ "$target_out_dir/${_target_name_}Context/" ]
2927  }
2928
2929  action("${_target_name_}AotActionSlowPath") {
2930    testonly = true
2931    _host_jsvm_target_ =
2932        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
2933    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
2934
2935    deps = [
2936      ":${_target_name_}AotCompileActionSlowPath",
2937      ":gen_${_target_name_}_abc",
2938      _host_jsvm_target_,
2939    ]
2940    deps += _deps_
2941
2942    script = "$js_root/script/run_ark_executable.py"
2943
2944    _aot_run_options_ =
2945        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
2946        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
2947
2948    _icu_data_path_options_ =
2949        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
2950    _aot_run_options_ += _icu_data_path_options_
2951
2952    if (defined(invoker.is_enable_enableArkTools) &&
2953        invoker.is_enable_enableArkTools) {
2954      _aot_run_options_ += " --enable-ark-tools=true"
2955      _aot_run_options_ += " --enable-force-gc=false"
2956    }
2957    if (defined(invoker.log_option)) {
2958      _aot_run_options_ += invoker.log_option
2959    }
2960    _aot_run_options_ += common_options
2961    args = [
2962      "--script-file",
2963      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
2964      "--script-options",
2965      _aot_run_options_,
2966      "--script-args",
2967      _script_args_,
2968      "--timeout-limit",
2969      "${_timeout_}",
2970      "--expect-file",
2971      rebase_path(_test_slowpath_expect_path_),
2972      "--env-path",
2973      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
2974          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
2975          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
2976          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
2977          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
2978          rebase_path(_root_out_dir_) +
2979          "/thirdparty/bounds_checking_function:" +
2980          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
2981    ]
2982
2983    inputs = [ _test_abc_path_ ]
2984
2985    outputs = [ "$target_out_dir/${_target_name_}/SlowPath" ]
2986  }
2987
2988  if (target_cpu == "x64") {
2989    action("${_target_name_}AotCompileActionWithLiteCG") {
2990      testonly = true
2991
2992      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
2993      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
2994      deps = [
2995        ":gen_${_target_name_}_abc",
2996        _host_aot_target_,
2997      ]
2998      deps += _deps_
2999
3000      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3001        deps += [ ":${_target_name_}PgoExecute" ]
3002      }
3003
3004      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3005
3006      _aot_compile_options_ =
3007          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3008          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3009          " --compiler-opt-inlining=false" +
3010          " --compiler-opt-loop-peeling=true" + " --compiler-enable-litecg=true"
3011
3012      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3013        _aot_compile_options_ +=
3014            " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
3015      }
3016      if (defined(invoker.is_enable_trace_deopt) &&
3017          invoker.is_enable_trace_deopt) {
3018        _aot_compile_options_ += " --compiler-trace-deopt=true"
3019      }
3020      if (defined(invoker.is_enable_opt_inlining) &&
3021          invoker.is_enable_opt_inlining) {
3022        _aot_compile_options_ +=
3023            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3024      }
3025
3026      if (defined(invoker.is_enable_typed_op_profiler) &&
3027          invoker.is_enable_typed_op_profiler) {
3028        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
3029      }
3030
3031      if (defined(invoker.is_enable_lowering_builtin) &&
3032          invoker.is_enable_lowering_builtin) {
3033        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
3034      }
3035
3036      if (defined(invoker.is_enable_native_inline) &&
3037          invoker.is_enable_native_inline) {
3038        _aot_compile_options_ += " --compiler-enable-native-inline"
3039      }
3040
3041      if (defined(invoker.is_enable_opt_loop_peeling) &&
3042          invoker.is_enable_opt_loop_peeling) {
3043        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3044      }
3045
3046      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3047          invoker.is_enable_opt_array_bounds_check_elimination) {
3048        _aot_compile_options_ +=
3049            " --compiler-opt-array-bounds-check-elimination=true"
3050      }
3051
3052      if (defined(invoker.is_enable_inline_trace) &&
3053          invoker.is_enable_inline_trace) {
3054        _aot_compile_options_ += " --compiler-trace-inline=true"
3055      }
3056
3057      if (defined(invoker.userDefinedMethodsInModule) &&
3058          invoker.userDefinedMethodsInModule) {
3059        _aot_compile_options_ += " --compiler-module-methods=2"
3060      }
3061
3062      if (defined(invoker.disable_opt_loop_peeling) &&
3063          invoker.disable_opt_loop_peeling) {
3064        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
3065      }
3066
3067      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
3068        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
3069      }
3070
3071      _aot_compile_options_ += common_options
3072      args = [
3073        "--script-file",
3074        rebase_path(_root_out_dir_) +
3075            "/arkcompiler/ets_runtime/ark_aot_compiler",
3076        "--script-options",
3077        _aot_compile_options_,
3078        "--script-args",
3079        _script_args_,
3080        "--expect-sub-output",
3081        "ts aot compile success",
3082        "--env-path",
3083        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3084            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3085            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3086            rebase_path(_root_out_dir_) +
3087            "/resourceschedule/frame_aware_sched:" +
3088            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3089            rebase_path(_root_out_dir_) +
3090            "/thirdparty/bounds_checking_function:" +
3091            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3092      ]
3093
3094      inputs = [ _test_abc_path_ ]
3095
3096      outputs = [
3097        _test_aot_path_litecg_,
3098        _test_aot_snapshot_path_litecg_,
3099      ]
3100    }
3101
3102    action("${_target_name_}AotCompileActionSlowPathWithLiteCG") {
3103      testonly = true
3104      _host_aot_target_ =
3105          "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3106      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3107      deps = [
3108        ":gen_${_target_name_}_abc",
3109        _host_aot_target_,
3110      ]
3111      deps += _deps_
3112
3113      script = "$js_root/script/run_ark_executable.py"
3114
3115      _aot_compile_options_ =
3116          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3117          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3118          " --compiler-opt-type-lowering=false" +
3119          " --compiler-opt-inlining=false" +
3120          " --compiler-opt-loop-peeling=true" + " --compiler-enable-litecg=true"
3121      if (defined(invoker.is_enable_trace_deopt) &&
3122          invoker.is_enable_trace_deopt) {
3123        _aot_compile_options_ += " --compiler-trace-deopt=true"
3124      }
3125
3126      if (defined(invoker.is_enable_opt_inlining) &&
3127          invoker.is_enable_opt_inlining) {
3128        _aot_compile_options_ +=
3129            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3130      }
3131
3132      if (defined(invoker.is_enable_native_inline) &&
3133          invoker.is_enable_native_inline) {
3134        _aot_compile_options_ += " --compiler-enable-native-inline"
3135      }
3136
3137      if (defined(invoker.is_enable_opt_loop_peeling) &&
3138          invoker.is_enable_opt_loop_peeling) {
3139        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3140      }
3141
3142      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3143          invoker.is_enable_opt_array_bounds_check_elimination) {
3144        _aot_compile_options_ +=
3145            " --compiler-opt-array-bounds-check-elimination=true"
3146      }
3147
3148      if (defined(invoker.is_enable_inline_trace) &&
3149          invoker.is_enable_inline_trace) {
3150        _aot_compile_options_ += " --compiler-trace-inline=true"
3151      }
3152
3153      if (defined(invoker.userDefinedMethodsInModule) &&
3154          invoker.userDefinedMethodsInModule) {
3155        _aot_compile_options_ += " --compiler-module-methods=2"
3156      }
3157
3158      if (defined(invoker.disable_opt_loop_peeling) &&
3159          invoker.disable_opt_loop_peeling) {
3160        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
3161      }
3162
3163      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
3164        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
3165      }
3166
3167      _aot_compile_options_ += common_options
3168      args = [
3169        "--script-file",
3170        rebase_path(_root_out_dir_) +
3171            "/arkcompiler/ets_runtime/ark_aot_compiler",
3172        "--script-options",
3173        _aot_compile_options_,
3174        "--script-args",
3175        _script_args_,
3176        "--expect-sub-output",
3177        "ts aot compile success",
3178        "--env-path",
3179        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3180            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3181            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3182            rebase_path(_root_out_dir_) +
3183            "/resourceschedule/frame_aware_sched:" +
3184            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3185            rebase_path(_root_out_dir_) +
3186            "/thirdparty/bounds_checking_function:" +
3187            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3188      ]
3189
3190      inputs = [ _test_abc_path_ ]
3191
3192      outputs = [
3193        _test_aot_path_slowpath_litecg_,
3194        _test_aot_snapshot_path_slowpath_litecg_,
3195      ]
3196    }
3197
3198    action("${_target_name_}AotActionWithLiteCG") {
3199      testonly = true
3200      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3201      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3202
3203      deps = [
3204        ":${_target_name_}AotCompileActionWithLiteCG",
3205        ":gen_${_target_name_}_abc",
3206        _host_jsvm_target_,
3207      ]
3208      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3209        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCG" ]
3210      }
3211      deps += _deps_
3212
3213      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3214
3215      _aot_run_options_ =
3216          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3217          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3218
3219      _icu_data_path_options_ =
3220          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3221      _aot_run_options_ += _icu_data_path_options_
3222
3223      if (defined(invoker.is_enable_enableArkTools) &&
3224          invoker.is_enable_enableArkTools) {
3225        _aot_run_options_ += " --enable-ark-tools=true"
3226        _aot_run_options_ += " --enable-force-gc=false"
3227      }
3228      _aot_run_options_ += common_options
3229      if (defined(invoker.log_option)) {
3230        _aot_run_options_ += invoker.log_option
3231      }
3232
3233      if (defined(invoker.is_enable_typed_op_profiler) &&
3234          invoker.is_enable_typed_op_profiler) {
3235        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3236      }
3237
3238      if (defined(invoker.is_enable_lowering_builtin) &&
3239          invoker.is_enable_lowering_builtin) {
3240        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3241      }
3242
3243      if (defined(invoker.is_enable_trace_deopt) &&
3244          invoker.is_enable_trace_deopt) {
3245        _aot_run_options_ += " --compiler-trace-deopt=true"
3246      }
3247
3248      args = [
3249        "--script-file",
3250        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3251        "--script-options",
3252        _aot_run_options_,
3253        "--script-args",
3254        _script_args_,
3255        "--expect-file",
3256        rebase_path(_test_expect_path_),
3257        "--env-path",
3258        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3259            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3260            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3261            rebase_path(_root_out_dir_) +
3262            "/resourceschedule/frame_aware_sched:" +
3263            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3264            rebase_path(_root_out_dir_) +
3265            "/thirdparty/bounds_checking_function:" +
3266            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3267      ]
3268
3269      inputs = [ _test_abc_path_ ]
3270
3271      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
3272    }
3273
3274    action("${_target_name_}AotContextActionWithLiteCG") {
3275      testonly = true
3276      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3277      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3278
3279      deps = [
3280        ":${_target_name_}AotCompileActionWithLiteCG",
3281        ":gen_${_target_name_}_abc",
3282        _host_jsvm_target_,
3283      ]
3284      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3285        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCG" ]
3286      }
3287      deps += _deps_
3288
3289      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3290
3291      _aot_run_options_ =
3292          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3293          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3294
3295      _icu_data_path_options_ =
3296          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3297      _aot_run_options_ += _icu_data_path_options_
3298
3299      if (defined(invoker.is_enable_enableArkTools) &&
3300          invoker.is_enable_enableArkTools) {
3301        _aot_run_options_ += " --enable-ark-tools=true"
3302        _aot_run_options_ += " --enable-force-gc=false"
3303      }
3304      _aot_run_options_ += common_options
3305      if (defined(invoker.log_option)) {
3306        _aot_run_options_ += invoker.log_option
3307      }
3308      _aot_run_options_ += " --enable-context=true"
3309
3310      if (defined(invoker.is_enable_typed_op_profiler) &&
3311          invoker.is_enable_typed_op_profiler) {
3312        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3313      }
3314
3315      if (defined(invoker.is_enable_lowering_builtin) &&
3316          invoker.is_enable_lowering_builtin) {
3317        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3318      }
3319
3320      if (defined(invoker.is_enable_trace_deopt) &&
3321          invoker.is_enable_trace_deopt) {
3322        _aot_run_options_ += " --compiler-trace-deopt=true"
3323      }
3324
3325      args = [
3326        "--script-file",
3327        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3328        "--script-options",
3329        _aot_run_options_,
3330        "--script-args",
3331        _script_args_,
3332        "--expect-file",
3333        rebase_path(_test_expect_path_),
3334        "--env-path",
3335        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3336            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3337            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3338            rebase_path(_root_out_dir_) +
3339            "/resourceschedule/frame_aware_sched:" +
3340            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3341            rebase_path(_root_out_dir_) +
3342            "/thirdparty/bounds_checking_function:" +
3343            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3344      ]
3345
3346      inputs = [ _test_abc_path_ ]
3347
3348      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
3349    }
3350
3351    action("${_target_name_}AotActionSlowPathWithLiteCG") {
3352      testonly = true
3353      _host_jsvm_target_ =
3354          "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3355      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3356
3357      deps = [
3358        ":${_target_name_}AotCompileActionSlowPathWithLiteCG",
3359        ":gen_${_target_name_}_abc",
3360        _host_jsvm_target_,
3361      ]
3362      deps += _deps_
3363
3364      script = "$js_root/script/run_ark_executable.py"
3365
3366      _aot_run_options_ =
3367          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3368          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3369
3370      _icu_data_path_options_ =
3371          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3372      _aot_run_options_ += _icu_data_path_options_
3373
3374      if (defined(invoker.is_enable_enableArkTools) &&
3375          invoker.is_enable_enableArkTools) {
3376        _aot_run_options_ += " --enable-ark-tools=true"
3377        _aot_run_options_ += " --enable-force-gc=false"
3378      }
3379
3380      if (defined(invoker.log_option)) {
3381        _aot_run_options_ += invoker.log_option
3382      }
3383      _aot_run_options_ += common_options
3384      args = [
3385        "--script-file",
3386        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3387        "--script-options",
3388        _aot_run_options_,
3389        "--script-args",
3390        _script_args_,
3391        "--timeout-limit",
3392        "${_timeout_}",
3393        "--expect-file",
3394        rebase_path(_test_slowpath_expect_path_),
3395        "--env-path",
3396        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3397            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3398            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3399            rebase_path(_root_out_dir_) +
3400            "/resourceschedule/frame_aware_sched:" +
3401            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3402            rebase_path(_root_out_dir_) +
3403            "/thirdparty/bounds_checking_function:" +
3404            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3405      ]
3406
3407      inputs = [ _test_abc_path_ ]
3408
3409      outputs = [ "$target_out_dir/${_target_name_}/SlowPath/LiteCG" ]
3410    }
3411  } else if (ark_standalone_build && run_with_qemu && host_os == "linux" &&
3412             target_os == "ohos" && target_cpu == "arm64") {
3413    import("$ark_third_party_root/musl/musl_template.gni")
3414    import("$build_root/config/qemu/config.gni")
3415
3416    action("${_target_name_}AotCompileActionWithLiteCGQemu") {
3417      testonly = true
3418
3419      _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3420      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3421      deps = [
3422        ":gen_${_target_name_}_abc",
3423        _host_aot_target_,
3424      ]
3425      deps += _deps_
3426
3427      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3428        deps += [ ":${_target_name_}PgoExecute" ]
3429      }
3430
3431      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3432
3433      _aot_compile_options_ =
3434          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3435          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3436          " --compiler-opt-inlining=false" +
3437          " --compiler-opt-loop-peeling=true" +
3438          " --compiler-enable-litecg=true" +
3439          " --compiler-target-triple=aarch64-unknown-linux-gnu"
3440
3441      if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3442        _aot_compile_options_ +=
3443            " --compiler-pgo-profiler-path=" + rebase_path(_test_profiler_path_)
3444      }
3445      if (defined(invoker.is_enable_trace_deopt) &&
3446          invoker.is_enable_trace_deopt) {
3447        _aot_compile_options_ += " --compiler-trace-deopt=true"
3448      }
3449      if (defined(invoker.is_enable_opt_inlining) &&
3450          invoker.is_enable_opt_inlining) {
3451        _aot_compile_options_ +=
3452            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3453      }
3454
3455      if (defined(invoker.is_enable_typed_op_profiler) &&
3456          invoker.is_enable_typed_op_profiler) {
3457        _aot_compile_options_ += " --compiler-typed-op-profiler=ture"
3458      }
3459
3460      if (defined(invoker.is_enable_lowering_builtin) &&
3461          invoker.is_enable_lowering_builtin) {
3462        _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
3463      }
3464
3465      if (defined(invoker.is_enable_native_inline) &&
3466          invoker.is_enable_native_inline) {
3467        _aot_compile_options_ += " --compiler-enable-native-inline"
3468      }
3469
3470      if (defined(invoker.is_enable_opt_loop_peeling) &&
3471          invoker.is_enable_opt_loop_peeling) {
3472        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3473      }
3474
3475      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3476          invoker.is_enable_opt_array_bounds_check_elimination) {
3477        _aot_compile_options_ +=
3478            " --compiler-opt-array-bounds-check-elimination=true"
3479      }
3480
3481      if (defined(invoker.is_enable_inline_trace) &&
3482          invoker.is_enable_inline_trace) {
3483        _aot_compile_options_ += " --compiler-trace-inline=true"
3484      }
3485
3486      if (defined(invoker.userDefinedMethodsInModule) &&
3487          invoker.userDefinedMethodsInModule) {
3488        _aot_compile_options_ += " --compiler-module-methods=2"
3489      }
3490
3491      if (defined(invoker.disable_opt_loop_peeling) &&
3492          invoker.disable_opt_loop_peeling) {
3493        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
3494      }
3495
3496      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
3497        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
3498      }
3499
3500      _aot_compile_options_ += common_options
3501      args = [
3502        "--script-file",
3503        rebase_path(_root_out_dir_) +
3504            "/arkcompiler/ets_runtime/ark_aot_compiler",
3505        "--script-options",
3506        _aot_compile_options_,
3507        "--script-args",
3508        _script_args_,
3509        "--expect-sub-output",
3510        "ts aot compile success",
3511        "--env-path",
3512        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3513            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3514            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3515            rebase_path(_root_out_dir_) +
3516            "/resourceschedule/frame_aware_sched:" +
3517            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3518            rebase_path(_root_out_dir_) +
3519            "/thirdparty/bounds_checking_function:" +
3520            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3521      ]
3522
3523      inputs = [ _test_abc_path_ ]
3524
3525      outputs = [
3526        _test_aot_path_litecg_,
3527        _test_aot_snapshot_path_litecg_,
3528      ]
3529    }
3530
3531    action("${_target_name_}AotCompileActionSlowPathWithLiteCGQemu") {
3532      testonly = true
3533      _host_aot_target_ =
3534          "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3535      _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3536      deps = [
3537        ":gen_${_target_name_}_abc",
3538        _host_aot_target_,
3539      ]
3540      deps += _deps_
3541
3542      script = "$js_root/script/run_ark_executable.py"
3543
3544      _aot_compile_options_ =
3545          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3546          " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
3547          " --compiler-opt-type-lowering=false" +
3548          " --compiler-opt-inlining=false" +
3549          " --compiler-opt-loop-peeling=true" +
3550          " --compiler-enable-litecg=true" +
3551          " --compiler-target-triple=aarch64-unknown-linux-gnu"
3552      if (defined(invoker.is_enable_trace_deopt) &&
3553          invoker.is_enable_trace_deopt) {
3554        _aot_compile_options_ += " --compiler-trace-deopt=true"
3555      }
3556
3557      if (defined(invoker.is_enable_opt_inlining) &&
3558          invoker.is_enable_opt_inlining) {
3559        _aot_compile_options_ +=
3560            " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3561      }
3562
3563      if (defined(invoker.is_enable_native_inline) &&
3564          invoker.is_enable_native_inline) {
3565        _aot_compile_options_ += " --compiler-enable-native-inline"
3566      }
3567
3568      if (defined(invoker.is_enable_opt_loop_peeling) &&
3569          invoker.is_enable_opt_loop_peeling) {
3570        _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
3571      }
3572
3573      if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
3574          invoker.is_enable_opt_array_bounds_check_elimination) {
3575        _aot_compile_options_ +=
3576            " --compiler-opt-array-bounds-check-elimination=true"
3577      }
3578
3579      if (defined(invoker.is_enable_inline_trace) &&
3580          invoker.is_enable_inline_trace) {
3581        _aot_compile_options_ += " --compiler-trace-inline=true"
3582      }
3583
3584      if (defined(invoker.userDefinedMethodsInModule) &&
3585          invoker.userDefinedMethodsInModule) {
3586        _aot_compile_options_ += " --compiler-module-methods=2"
3587      }
3588
3589      if (defined(invoker.disable_opt_loop_peeling) &&
3590          invoker.disable_opt_loop_peeling) {
3591        _aot_compile_options_ += " --compiler-opt-loop-peeling=false"
3592      }
3593
3594      if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
3595        _aot_compile_options_ += " --compiler-enable-pgo-space=true"
3596      }
3597
3598      _aot_compile_options_ += common_options
3599      args = [
3600        "--script-file",
3601        rebase_path(_root_out_dir_) +
3602            "/arkcompiler/ets_runtime/ark_aot_compiler",
3603        "--script-options",
3604        _aot_compile_options_,
3605        "--script-args",
3606        _script_args_,
3607        "--expect-sub-output",
3608        "ts aot compile success",
3609        "--env-path",
3610        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3611            rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3612            rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3613            rebase_path(_root_out_dir_) +
3614            "/resourceschedule/frame_aware_sched:" +
3615            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3616            rebase_path(_root_out_dir_) +
3617            "/thirdparty/bounds_checking_function:" +
3618            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3619      ]
3620
3621      inputs = [ _test_abc_path_ ]
3622
3623      outputs = [
3624        _test_aot_path_slowpath_litecg_,
3625        _test_aot_snapshot_path_slowpath_litecg_,
3626      ]
3627    }
3628
3629    action("${_target_name_}AotActionWithLiteCGQemu") {
3630      testonly = true
3631      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3632      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3633
3634      deps = [
3635        ":${_target_name_}AotCompileActionWithLiteCGQemu",
3636        ":gen_${_target_name_}_abc",
3637        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3638        _host_jsvm_target_,
3639      ]
3640      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3641        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCGQemu" ]
3642      }
3643      deps += _deps_
3644
3645      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3646
3647      _aot_run_options_ =
3648          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3649          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3650
3651      _icu_data_path_options_ =
3652          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3653      _aot_run_options_ += _icu_data_path_options_
3654
3655      if (defined(invoker.is_enable_enableArkTools) &&
3656          invoker.is_enable_enableArkTools) {
3657        _aot_run_options_ += " --enable-ark-tools=true"
3658        _aot_run_options_ += " --enable-force-gc=false"
3659      }
3660      _aot_run_options_ += common_options
3661      if (defined(invoker.log_option)) {
3662        _aot_run_options_ += invoker.log_option
3663      }
3664
3665      if (defined(invoker.is_enable_typed_op_profiler) &&
3666          invoker.is_enable_typed_op_profiler) {
3667        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3668      }
3669
3670      if (defined(invoker.is_enable_lowering_builtin) &&
3671          invoker.is_enable_lowering_builtin) {
3672        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3673      }
3674
3675      if (defined(invoker.is_enable_trace_deopt) &&
3676          invoker.is_enable_trace_deopt) {
3677        _aot_run_options_ += " --compiler-trace-deopt=true"
3678      }
3679
3680      args = [
3681        "--script-file",
3682        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3683        "--script-options",
3684        _aot_run_options_,
3685        "--script-args",
3686        _script_args_,
3687        "--expect-file",
3688        rebase_path(_test_expect_path_),
3689        "--qemu-binary-path",
3690        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3691        "--qemu-ld-prefix",
3692        rebase_path(musl_linker_so_out_dir, root_build_dir),
3693        "--clang-lib-path",
3694        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3695                    root_build_dir) + rebase_path(_root_out_dir_) +
3696            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3697            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3698            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3699            "/resourceschedule/frame_aware_sched:" +
3700            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3701            rebase_path(_root_out_dir_) +
3702            "/thirdparty/bounds_checking_function:" +
3703            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3704      ]
3705
3706      inputs = [ _test_abc_path_ ]
3707
3708      outputs = [ "$target_out_dir/${_target_name_}/LiteCG/" ]
3709    }
3710
3711    action("${_target_name_}AotContextActionWithLiteCGQemu") {
3712      testonly = true
3713      _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3714      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3715
3716      deps = [
3717        ":${_target_name_}AotCompileActionWithLiteCGQemu",
3718        ":gen_${_target_name_}_abc",
3719        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3720        _host_jsvm_target_,
3721      ]
3722      if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
3723        deps += [ ":${_target_name_}AotActionSlowPathWithLiteCGQemu" ]
3724      }
3725      deps += _deps_
3726
3727      script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3728
3729      _aot_run_options_ =
3730          " --aot-file=" + rebase_path(_test_aot_arg_litecg_) +
3731          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3732
3733      _icu_data_path_options_ =
3734          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3735      _aot_run_options_ += _icu_data_path_options_
3736
3737      if (defined(invoker.is_enable_enableArkTools) &&
3738          invoker.is_enable_enableArkTools) {
3739        _aot_run_options_ += " --enable-ark-tools=true"
3740        _aot_run_options_ += " --enable-force-gc=false"
3741      }
3742      _aot_run_options_ += common_options
3743      if (defined(invoker.log_option)) {
3744        _aot_run_options_ += invoker.log_option
3745      }
3746      _aot_run_options_ += " --enable-context=true"
3747
3748      if (defined(invoker.is_enable_typed_op_profiler) &&
3749          invoker.is_enable_typed_op_profiler) {
3750        _aot_run_options_ += " --compiler-typed-op-profiler=ture"
3751      }
3752
3753      if (defined(invoker.is_enable_lowering_builtin) &&
3754          invoker.is_enable_lowering_builtin) {
3755        _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
3756      }
3757
3758      if (defined(invoker.is_enable_trace_deopt) &&
3759          invoker.is_enable_trace_deopt) {
3760        _aot_run_options_ += " --compiler-trace-deopt=true"
3761      }
3762
3763      args = [
3764        "--script-file",
3765        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3766        "--script-options",
3767        _aot_run_options_,
3768        "--script-args",
3769        _script_args_,
3770        "--expect-file",
3771        rebase_path(_test_expect_path_),
3772        "--qemu-binary-path",
3773        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3774        "--qemu-ld-prefix",
3775        rebase_path(musl_linker_so_out_dir, root_build_dir),
3776        "--clang-lib-path",
3777        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3778                    root_build_dir) + rebase_path(_root_out_dir_) +
3779            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3780            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3781            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3782            "/resourceschedule/frame_aware_sched:" +
3783            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3784            rebase_path(_root_out_dir_) +
3785            "/thirdparty/bounds_checking_function:" +
3786            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3787      ]
3788
3789      inputs = [ _test_abc_path_ ]
3790
3791      outputs = [ "$target_out_dir/${_target_name_}Context/LiteCG/" ]
3792    }
3793
3794    action("${_target_name_}AotActionSlowPathWithLiteCGQemu") {
3795      testonly = true
3796      _host_jsvm_target_ =
3797          "$js_root/ecmascript/js_vm:ark_js_vm(${default_toolchain})"
3798      _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3799
3800      deps = [
3801        ":${_target_name_}AotCompileActionSlowPathWithLiteCGQemu",
3802        ":gen_${_target_name_}_abc",
3803        "$ark_third_party_root/musl:soft_create_linker_for_qemu",
3804        _host_jsvm_target_,
3805      ]
3806      deps += _deps_
3807
3808      script = "$js_root/script/run_ark_executable.py"
3809
3810      _aot_run_options_ =
3811          " --aot-file=" + rebase_path(_test_aot_arg_slowpath_litecg_) +
3812          " --asm-interpreter=true" + " --entry-point=${_target_name_}"
3813
3814      _icu_data_path_options_ =
3815          " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
3816      _aot_run_options_ += _icu_data_path_options_
3817
3818      if (defined(invoker.is_enable_enableArkTools) &&
3819          invoker.is_enable_enableArkTools) {
3820        _aot_run_options_ += " --enable-ark-tools=true"
3821        _aot_run_options_ += " --enable-force-gc=false"
3822      }
3823      _aot_run_options_ += common_options
3824      if (defined(invoker.log_option)) {
3825        _aot_run_options_ += invoker.log_option
3826      }
3827
3828      args = [
3829        "--script-file",
3830        rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3831        "--script-options",
3832        _aot_run_options_,
3833        "--script-args",
3834        _script_args_,
3835        "--expect-file",
3836        rebase_path(_test_expect_path_),
3837        "--qemu-binary-path",
3838        "${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
3839        "--qemu-ld-prefix",
3840        rebase_path(musl_linker_so_out_dir, root_build_dir),
3841        "--clang-lib-path",
3842        rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos:",
3843                    root_build_dir) + rebase_path(_root_out_dir_) +
3844            "/arkcompiler/ets_runtime:" + rebase_path(_root_out_dir_) +
3845            "/${_icu_path_}:" + rebase_path(_root_out_dir_) +
3846            "/thirdparty/zlib:" + rebase_path(_root_out_dir_) +
3847            "/resourceschedule/frame_aware_sched:" +
3848            rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3849            rebase_path(_root_out_dir_) +
3850            "/thirdparty/bounds_checking_function:" +
3851            rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3852      ]
3853
3854      inputs = [ _test_abc_path_ ]
3855
3856      outputs = [ "$target_out_dir/${_target_name_}/SlowPath/LiteCG" ]
3857    }
3858  }
3859}
3860
3861template("host_aot_assert_test_action") {
3862  _target_name_ = "${target_name}"
3863  _deps_ = invoker.deps
3864
3865  _src_dir_ = "."
3866  if (defined(invoker.src_dir) && invoker.src_dir != "") {
3867    _src_dir_ = invoker.src_dir
3868  }
3869
3870  _test_ts_path_ = "${_src_dir_}/${_target_name_}.ts"
3871  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
3872  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
3873  _test_aot_arg_slowpath_ = "$target_out_dir/slowpath/${_target_name_}"
3874  _test_aot_log_level = "info"
3875
3876  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
3877    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
3878    extra_dependencies = _deps_
3879    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
3880      src_js = rebase_path("./")
3881    } else {
3882      src_js = rebase_path(_test_ts_path_)
3883    }
3884    dst_file = rebase_path(_test_abc_path_)
3885    extension = "ts"
3886    extra_args = [ "--merge-abc" ]
3887
3888    if (!(defined(invoker.without_module) && invoker.without_module)) {
3889      extra_args += [ "--module" ]
3890    }
3891
3892    if (defined(invoker.is_debug_abc) && invoker.is_debug_abc) {
3893      extra_args += [ "--debug" ]
3894    }
3895    in_puts = [ _test_ts_path_ ]
3896    out_puts = [ _test_abc_path_ ]
3897  }
3898
3899  _script_args_ = rebase_path(_test_abc_path_)
3900
3901  action("${_target_name_}PgoExecuteAssert") {
3902    testonly = true
3903    _host_jsvm_target_ =
3904        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
3905    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
3906
3907    deps = [
3908      ":gen_${_target_name_}_abc",
3909      _host_jsvm_target_,
3910    ]
3911    deps += _deps_
3912
3913    script = "$js_root/script/run_ark_executable.py"
3914
3915    _aot_run_options_ =
3916        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
3917        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
3918        rebase_path(_test_aot_arg_) + "/modules.ap"
3919
3920    if (defined(invoker.is_enable_enableArkTools) &&
3921        invoker.is_enable_enableArkTools) {
3922      _aot_run_options_ += " --enable-ark-tools=true"
3923      _aot_run_options_ += " --enable-force-gc=false"
3924    }
3925    if (defined(invoker.log_option)) {
3926      _aot_run_options_ += invoker.log_option
3927    }
3928    _aot_run_options_ += " --test-assert=true"
3929    _aot_run_options_ += common_options
3930    args = [
3931      "--script-file",
3932      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
3933      "--script-options",
3934      _aot_run_options_,
3935      "--script-args",
3936      _script_args_,
3937      "--expect-output",
3938      "0",
3939      "--env-path",
3940      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
3941          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
3942          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
3943          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
3944          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
3945          rebase_path(_root_out_dir_) +
3946          "/thirdparty/bounds_checking_function:" +
3947          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
3948    ]
3949
3950    inputs = [ _test_abc_path_ ]
3951
3952    outputs = [ "$target_out_dir/${_target_name_}/pgoassert" ]
3953  }
3954
3955  action("${_target_name_}AotCompileAssertAction") {
3956    testonly = true
3957
3958    _host_aot_target_ = "//arkcompiler/ets_runtime/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
3959    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
3960    deps = [
3961      ":gen_${_target_name_}_abc",
3962      _host_aot_target_,
3963    ]
3964    deps += _deps_
3965
3966    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3967      deps += [ ":${_target_name_}PgoExecuteAssert" ]
3968    }
3969
3970    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
3971
3972    _aot_compile_options_ =
3973        " --aot-file=" + rebase_path(_test_aot_arg_) + " --log-level=" +
3974        _test_aot_log_level + " --log-components=compiler" +
3975        " --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=true"
3976
3977    if (defined(invoker.is_enable_pgo) && invoker.is_enable_pgo) {
3978      _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
3979                               rebase_path(_test_aot_arg_) + "/modules.ap"
3980    }
3981    if (defined(invoker.is_enable_trace_deopt) &&
3982        invoker.is_enable_trace_deopt) {
3983      _aot_compile_options_ += " --compiler-trace-deopt=true"
3984    }
3985    if (defined(invoker.is_enable_opt_inlining) &&
3986        invoker.is_enable_opt_inlining) {
3987      _aot_compile_options_ +=
3988          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
3989    }
3990
3991    if (defined(invoker.is_enable_typed_op_profiler) &&
3992        invoker.is_enable_typed_op_profiler) {
3993      _aot_compile_options_ += " --compiler-typed-op-profiler=true "
3994    }
3995
3996    if (defined(invoker.is_enable_lowering_builtin) &&
3997        invoker.is_enable_lowering_builtin) {
3998      _aot_compile_options_ += " --compiler-enable-lowering-builtin=true"
3999    }
4000
4001    if (defined(invoker.is_enable_native_inline) &&
4002        invoker.is_enable_native_inline) {
4003      _aot_compile_options_ += " --compiler-enable-native-inline"
4004    }
4005
4006    if (defined(invoker.is_enable_opt_loop_peeling) &&
4007        invoker.is_enable_opt_loop_peeling) {
4008      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
4009    }
4010
4011    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
4012      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
4013    }
4014
4015    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
4016        invoker.is_enable_opt_array_bounds_check_elimination) {
4017      _aot_compile_options_ +=
4018          " --compiler-opt-array-bounds-check-elimination=true"
4019    }
4020
4021    if (defined(invoker.is_enable_inline_trace) &&
4022        invoker.is_enable_inline_trace) {
4023      _aot_compile_options_ += " --compiler-trace-inline=true"
4024    }
4025
4026    if (defined(invoker.userDefinedMethodsInModule) &&
4027        invoker.userDefinedMethodsInModule) {
4028      _aot_compile_options_ += " --compiler-module-methods=2"
4029    }
4030    _aot_compile_options_ += common_options
4031    _aot_compile_options_ += " --test-assert=true"
4032
4033    args = [
4034      "--script-file",
4035      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4036      "--script-options",
4037      _aot_compile_options_,
4038      "--script-args",
4039      _script_args_,
4040      "--expect-output",
4041      "0",
4042      "--env-path",
4043      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4044          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4045          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4046          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4047          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4048          rebase_path(_root_out_dir_) +
4049          "/thirdparty/bounds_checking_function:" +
4050          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4051    ]
4052
4053    inputs = [ _test_abc_path_ ]
4054
4055    outputs = [
4056      "$target_out_dir/${_target_name_}AotCompileAssert.an",
4057      "$target_out_dir/${_target_name_}AotCompileAssert.ai",
4058    ]
4059  }
4060
4061  action("${_target_name_}AotCompileAssertActionSlowPath") {
4062    testonly = true
4063    _host_aot_target_ =
4064        "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
4065    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
4066    deps = [
4067      ":gen_${_target_name_}_abc",
4068      _host_aot_target_,
4069    ]
4070    deps += _deps_
4071
4072    script = "$js_root/script/run_ark_executable.py"
4073
4074    _aot_compile_options_ =
4075        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
4076        " --log-level=" + _test_aot_log_level + " --log-components=compiler" +
4077        " --compiler-opt-type-lowering=false" +
4078        " --compiler-opt-inlining=false" + " --compiler-opt-loop-peeling=true"
4079
4080    if (defined(invoker.aot_log_option)) {
4081      _aot_compile_options_ += invoker.aot_log_option
4082    }
4083
4084    if (defined(invoker.is_enable_trace_deopt) &&
4085        invoker.is_enable_trace_deopt) {
4086      _aot_compile_options_ += " --compiler-trace-deopt=true"
4087    }
4088
4089    if (defined(invoker.is_enable_opt_inlining) &&
4090        invoker.is_enable_opt_inlining) {
4091      _aot_compile_options_ +=
4092          " --compiler-opt-inlining=true --compiler-opt-type-lowering=true"
4093    }
4094
4095    if (defined(invoker.is_enable_native_inline) &&
4096        invoker.is_enable_native_inline) {
4097      _aot_compile_options_ += " --compiler-enable-native-inline"
4098    }
4099
4100    if (defined(invoker.is_enable_opt_loop_peeling) &&
4101        invoker.is_enable_opt_loop_peeling) {
4102      _aot_compile_options_ += " --compiler-opt-loop-peeling=true"
4103    }
4104
4105    if (defined(invoker.is_enable_pgo_space) && invoker.is_enable_pgo_space) {
4106      _aot_compile_options_ += " --compiler-enable-pgo-space=true"
4107    }
4108
4109    if (defined(invoker.is_enable_opt_array_bounds_check_elimination) &&
4110        invoker.is_enable_opt_array_bounds_check_elimination) {
4111      _aot_compile_options_ +=
4112          " --compiler-opt-array-bounds-check-elimination=true"
4113    }
4114
4115    if (defined(invoker.is_enable_inline_trace) &&
4116        invoker.is_enable_inline_trace) {
4117      _aot_compile_options_ += " --compiler-trace-inline=true"
4118    }
4119
4120    if (defined(invoker.userDefinedMethodsInModule) &&
4121        invoker.userDefinedMethodsInModule) {
4122      _aot_compile_options_ += " --compiler-module-methods=2"
4123    }
4124    _aot_compile_options_ += common_options
4125    _aot_compile_options_ += " --test-assert=true"
4126
4127    args = [
4128      "--script-file",
4129      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4130      "--script-options",
4131      _aot_compile_options_,
4132      "--script-args",
4133      _script_args_,
4134      "--expect-output",
4135      "0",
4136      "--env-path",
4137      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4138          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4139          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4140          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4141          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4142          rebase_path(_root_out_dir_) +
4143          "/thirdparty/bounds_checking_function:" +
4144          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4145    ]
4146
4147    inputs = [ _test_abc_path_ ]
4148
4149    outputs = [
4150      "$target_out_dir/slowpath/${_target_name_}AotCompileAssert.an",
4151      "$target_out_dir/slowpath/${_target_name_}AotCompileAssert.ai",
4152    ]
4153  }
4154
4155  action("${_target_name_}AotAssertAction") {
4156    testonly = true
4157    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4158    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4159
4160    deps = [
4161      ":${_target_name_}AotCompileAssertAction",
4162      ":gen_${_target_name_}_abc",
4163      _host_jsvm_target_,
4164    ]
4165    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
4166      deps += [ ":${_target_name_}AotAssertActionSlowPath" ]
4167    }
4168    deps += _deps_
4169
4170    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4171
4172    _aot_run_options_ =
4173        " --aot-file=" + rebase_path(_test_aot_arg_) +
4174        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4175
4176    _icu_data_path_options_ =
4177        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4178    _aot_run_options_ += _icu_data_path_options_
4179
4180    if (defined(invoker.is_enable_enableArkTools) &&
4181        invoker.is_enable_enableArkTools) {
4182      _aot_run_options_ += " --enable-ark-tools=true"
4183      _aot_run_options_ += " --enable-force-gc=false"
4184    }
4185
4186    if (defined(invoker.log_option)) {
4187      _aot_run_options_ += invoker.log_option
4188    }
4189
4190    if (defined(invoker.is_enable_typed_op_profiler) &&
4191        invoker.is_enable_typed_op_profiler) {
4192      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
4193    }
4194
4195    if (defined(invoker.is_enable_lowering_builtin) &&
4196        invoker.is_enable_lowering_builtin) {
4197      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
4198    }
4199
4200    if (defined(invoker.is_enable_trace_deopt) &&
4201        invoker.is_enable_trace_deopt) {
4202      _aot_run_options_ += " --compiler-trace-deopt=true"
4203    }
4204
4205    _aot_run_options_ += " --test-assert=true"
4206    _aot_run_options_ += common_options
4207    args = [
4208      "--script-file",
4209      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4210      "--script-options",
4211      _aot_run_options_,
4212      "--script-args",
4213      _script_args_,
4214      "--expect-output",
4215      "0",
4216      "--env-path",
4217      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4218          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4219          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4220          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4221          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4222          rebase_path(_root_out_dir_) +
4223          "/thirdparty/bounds_checking_function:" +
4224          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4225    ]
4226
4227    inputs = [ _test_abc_path_ ]
4228
4229    outputs = [ "$target_out_dir/${_target_name_}AotAssert/" ]
4230  }
4231
4232  action("${_target_name_}AotContextAssertAction") {
4233    testonly = true
4234    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4235    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4236
4237    deps = [
4238      ":${_target_name_}AotCompileAssertAction",
4239      ":gen_${_target_name_}_abc",
4240      _host_jsvm_target_,
4241    ]
4242    if (!defined(invoker.is_only_typed_path) || !invoker.is_only_typed_path) {
4243      deps += [ ":${_target_name_}AotAssertActionSlowPath" ]
4244    }
4245    deps += _deps_
4246
4247    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4248
4249    _aot_run_options_ =
4250        " --aot-file=" + rebase_path(_test_aot_arg_) +
4251        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4252
4253    _icu_data_path_options_ =
4254        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4255    _aot_run_options_ += _icu_data_path_options_
4256
4257    if (defined(invoker.is_enable_enableArkTools) &&
4258        invoker.is_enable_enableArkTools) {
4259      _aot_run_options_ += " --enable-ark-tools=true"
4260      _aot_run_options_ += " --enable-force-gc=false"
4261    }
4262    if (defined(invoker.log_option)) {
4263      _aot_run_options_ += invoker.log_option
4264    }
4265    _aot_run_options_ += " --enable-context=true"
4266
4267    if (defined(invoker.is_enable_typed_op_profiler) &&
4268        invoker.is_enable_typed_op_profiler) {
4269      _aot_run_options_ += " --compiler-typed-op-profiler=ture"
4270    }
4271
4272    if (defined(invoker.is_enable_lowering_builtin) &&
4273        invoker.is_enable_lowering_builtin) {
4274      _aot_run_options_ += " --compiler-enable-lowering-builtin=true"
4275    }
4276
4277    if (defined(invoker.is_enable_trace_deopt) &&
4278        invoker.is_enable_trace_deopt) {
4279      _aot_run_options_ += " --compiler-trace-deopt=true"
4280    }
4281
4282    _aot_run_options_ += " --test-assert=true"
4283    _aot_run_options_ += common_options
4284    args = [
4285      "--script-file",
4286      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4287      "--script-options",
4288      _aot_run_options_,
4289      "--script-args",
4290      _script_args_,
4291      "--expect-output",
4292      "0",
4293      "--env-path",
4294      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4295          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4296          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4297          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4298          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4299          rebase_path(_root_out_dir_) +
4300          "/thirdparty/bounds_checking_function:" +
4301          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4302    ]
4303
4304    inputs = [ _test_abc_path_ ]
4305
4306    outputs = [ "$target_out_dir/${_target_name_}ContextAssert/" ]
4307  }
4308
4309  action("${_target_name_}AotAssertActionSlowPath") {
4310    testonly = true
4311    _host_jsvm_target_ =
4312        "$js_root/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4313    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4314
4315    deps = [
4316      ":${_target_name_}AotCompileAssertActionSlowPath",
4317      ":gen_${_target_name_}_abc",
4318      _host_jsvm_target_,
4319    ]
4320    deps += _deps_
4321
4322    script = "$js_root/script/run_ark_executable.py"
4323
4324    _aot_run_options_ =
4325        " --aot-file=" + rebase_path(_test_aot_arg_slowpath_) +
4326        " --asm-interpreter=true" + " --entry-point=${_target_name_}"
4327
4328    _icu_data_path_options_ =
4329        " --icu-data-path=" + rebase_path("//third_party/icu/ohos_icu4j/data")
4330    _aot_run_options_ += _icu_data_path_options_
4331
4332    if (defined(invoker.is_enable_enableArkTools) &&
4333        invoker.is_enable_enableArkTools) {
4334      _aot_run_options_ += " --enable-ark-tools=true"
4335      _aot_run_options_ += " --enable-force-gc=false"
4336    }
4337    if (defined(invoker.log_option)) {
4338      _aot_run_options_ += invoker.log_option
4339    }
4340
4341    _aot_run_options_ += " --test-assert=true"
4342    _aot_run_options_ += common_options
4343    args = [
4344      "--script-file",
4345      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4346      "--script-options",
4347      _aot_run_options_,
4348      "--script-args",
4349      _script_args_,
4350      "--expect-output",
4351      "0",
4352      "--env-path",
4353      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4354          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4355          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4356          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4357          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4358          rebase_path(_root_out_dir_) +
4359          "/thirdparty/bounds_checking_function:" +
4360          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4361    ]
4362
4363    inputs = [ _test_abc_path_ ]
4364
4365    outputs = [ "$target_out_dir/${_target_name_}/AssertSlowPath" ]
4366  }
4367}
4368
4369template("host_pgotypeinfer_test_action") {
4370  _target_name_ = "${target_name}"
4371  _deps_ = invoker.deps
4372
4373  _test_ts_path_ = "./${_target_name_}.js"
4374  _test_aot_arg_ = "$target_out_dir/${_target_name_}"
4375
4376  _host_aot_target_ =
4377      "$js_root/ecmascript/compiler:ark_aot_compiler(${host_toolchain})"
4378
4379  _test_es2abc_abc_path_ = "$target_out_dir/es2abc/${_target_name_}.abc"
4380
4381  if (defined(invoker.is_common_js) && invoker.is_common_js) {
4382    extra_args = [ "--commonjs" ]
4383  } else {
4384    extra_args = [ "--module" ]
4385  }
4386  extra_args += [ "--merge-abc" ]
4387
4388  es2abc_gen_newest_abc("es2abc_gen_${_target_name_}_abc") {
4389    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
4390    extra_dependencies = _deps_
4391    if (defined(invoker.is_multi_file_tests) && invoker.is_multi_file_tests) {
4392      _test_es2abc_ts_path_ = "."
4393    } else {
4394      _test_es2abc_ts_path_ = _test_ts_path_
4395    }
4396    src_js = rebase_path(_test_es2abc_ts_path_)
4397    dst_file = rebase_path(_test_es2abc_abc_path_)
4398
4399    in_puts = [ _test_ts_path_ ]
4400    out_puts = [ _test_es2abc_abc_path_ ]
4401  }
4402
4403  _script_args_ = rebase_path(_test_es2abc_abc_path_)
4404
4405  action("${_target_name_}PgoExecute") {
4406    testonly = true
4407    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4408    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4409
4410    deps = [
4411      ":es2abc_gen_${_target_name_}_abc",
4412      _host_jsvm_target_,
4413    ]
4414    deps += _deps_
4415
4416    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4417
4418    _aot_run_options_ =
4419        " --asm-interpreter=true" + " --entry-point=${_target_name_}" +
4420        " --enable-pgo-profiler=true" + " --compiler-pgo-profiler-path=" +
4421        rebase_path(_test_aot_arg_) + "/modules.ap"
4422
4423    if (defined(invoker.is_enable_enableArkTools) &&
4424        invoker.is_enable_enableArkTools) {
4425      _aot_run_options_ += " --enable-ark-tools=true"
4426      _aot_run_options_ += " --enable-force-gc=false"
4427    }
4428
4429    if (defined(invoker.log_option)) {
4430      _aot_run_options_ += invoker.log_option
4431    }
4432    _aot_run_options_ += common_options
4433    args = [
4434      "--script-file",
4435      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4436      "--script-options",
4437      _aot_run_options_,
4438      "--script-args",
4439      _script_args_,
4440      "--expect-output",
4441      "0",
4442      "--env-path",
4443      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4444          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4445          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4446          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4447          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4448          rebase_path(_root_out_dir_) +
4449          "/thirdparty/bounds_checking_function:" +
4450          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4451    ]
4452
4453    inputs = [ _test_es2abc_abc_path_ ]
4454
4455    outputs = [ "$target_out_dir/${_target_name_}/pgo" ]
4456  }
4457
4458  action("${_target_name_}Es2abcAotTypeInferAction") {
4459    testonly = true
4460
4461    _script_args_ = rebase_path(_test_es2abc_abc_path_)
4462    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
4463    deps = [
4464      ":es2abc_gen_${_target_name_}_abc",
4465      _host_aot_target_,
4466    ]
4467    deps += _deps_
4468    if (target_cpu == "x64") {
4469      deps += [ ":${_target_name_}Es2abcAotTypeInferActionWithLiteCG" ]
4470    }
4471
4472    # Pgo Execute
4473    deps += [ ":${_target_name_}PgoExecute" ]
4474
4475    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4476
4477    _aot_compile_options_ = " --compiler-opt-type-lowering=false" +
4478                            " --compiler-opt-loop-peeling=true"
4479
4480    # Pgo Option
4481    _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
4482                             rebase_path(_test_aot_arg_) + "/modules.ap"
4483    _aot_compile_options_ += common_options
4484    args = [
4485      "--script-file",
4486      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4487      "--script-options",
4488      _aot_compile_options_,
4489      "--script-args",
4490      _script_args_,
4491      "--expect-output",
4492      "0",
4493      "--env-path",
4494      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4495          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4496          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4497          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4498          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4499          rebase_path(_root_out_dir_) +
4500          "/thirdparty/bounds_checking_function:" +
4501          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4502    ]
4503
4504    inputs = [ _test_es2abc_abc_path_ ]
4505
4506    outputs = [ "$target_out_dir/${_target_name_}/es2abc/" ]
4507  }
4508
4509  action("${_target_name_}Es2abcAotTypeInferActionWithLiteCG") {
4510    testonly = true
4511
4512    _script_args_ = rebase_path(_test_es2abc_abc_path_)
4513    _root_out_dir_ = get_label_info(_host_aot_target_, "root_out_dir")
4514    deps = [
4515      ":es2abc_gen_${_target_name_}_abc",
4516      _host_aot_target_,
4517    ]
4518    deps += _deps_
4519
4520    # Pgo Execute
4521    deps += [ ":${_target_name_}PgoExecute" ]
4522
4523    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4524
4525    _aot_compile_options_ =
4526        " --compiler-opt-type-lowering=false" +
4527        " --compiler-opt-loop-peeling=true" + " --compiler-enable-litecg=true"
4528
4529    # Pgo Option
4530    _aot_compile_options_ += " --compiler-pgo-profiler-path=" +
4531                             rebase_path(_test_aot_arg_) + "/modules.ap"
4532    _aot_compile_options_ += common_options
4533    args = [
4534      "--script-file",
4535      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_aot_compiler",
4536      "--script-options",
4537      _aot_compile_options_,
4538      "--script-args",
4539      _script_args_,
4540      "--expect-output",
4541      "0",
4542      "--env-path",
4543      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4544          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4545          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4546          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4547          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4548          rebase_path(_root_out_dir_) +
4549          "/thirdparty/bounds_checking_function:" +
4550          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4551    ]
4552
4553    inputs = [ _test_es2abc_abc_path_ ]
4554
4555    outputs = [ "$target_out_dir/${_target_name_}/es2abc/LiteCG/" ]
4556  }
4557}
4558
4559template("host_quickfix_test_action") {
4560  _target_name_ = "${target_name}"
4561
4562  _test_expect_path_ = "./${_target_name_}/expect_output.txt"
4563  _test_file_name_ = [
4564    "base",
4565    "test",
4566    "retest",
4567    "patch",
4568  ]
4569
4570  if (defined(invoker.extra_patches)) {
4571    _test_file_name_ += invoker.extra_patches
4572  }
4573
4574  if (defined(invoker.entry_point)) {
4575    _script_args_ = invoker.entry_point + " "
4576  }
4577
4578  if (defined(invoker.is_hotpatch) && invoker.is_hotpatch) {
4579    _test_map_path_ = "$target_out_dir/${_target_name_}/base.map"
4580  }
4581
4582  foreach(filename, _test_file_name_) {
4583    merge_file_raw = "//arkcompiler/ets_runtime/test/quickfix/"
4584    if (filename == "test" || filename == "retest") {
4585      merge_file_raw += "${filename}.txt"
4586    } else {
4587      merge_file_raw += "${_target_name_}/${filename}.txt"
4588    }
4589    merge_file = "$target_out_dir/${_target_name_}/${filename}.txt"
4590    merge_file_prefix =
4591        "//arkcompiler/ets_runtime/test/quickfix/${_target_name_}/"
4592
4593    if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
4594      action("gen_${_target_name_}_${filename}_js_file_and_merge") {
4595        script = "//arkcompiler/ets_runtime/test/quickfix/generate_js_and_merge_file.py"
4596        args = [
4597          "--input",
4598          rebase_path(merge_file_raw),
4599          "--output",
4600          rebase_path(merge_file),
4601          "--prefix",
4602          rebase_path(merge_file_prefix),
4603        ]
4604        inputs = [ merge_file_raw ]
4605        outputs = [ merge_file ]
4606      }
4607    } else {
4608      action("gen_${_target_name_}_${filename}_merge_file") {
4609        script =
4610            "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py"
4611        args = [
4612          "--input",
4613          rebase_path(merge_file_raw),
4614          "--output",
4615          rebase_path(merge_file),
4616          "--prefix",
4617          rebase_path(merge_file_prefix),
4618        ]
4619        inputs = [ merge_file_raw ]
4620        outputs = [ merge_file ]
4621      }
4622    }
4623
4624    abc_path = "$target_out_dir/${_target_name_}/${filename}.abc"
4625
4626    es2abc_gen_newest_abc("gen_${_target_name_}_${filename}_abc") {
4627      extra_visibility =
4628          [ ":*" ]  # Only targets in this file can depend on this.
4629      if (defined(invoker.is_gen_js_by_script) && invoker.is_gen_js_by_script) {
4630        extra_dependencies =
4631            [ ":gen_${_target_name_}_${filename}_js_file_and_merge" ]
4632      } else {
4633        extra_dependencies = [ ":gen_${_target_name_}_${filename}_merge_file" ]
4634      }
4635
4636      if (defined(invoker.is_hotpatch) && filename == "patch") {
4637        extra_dependencies += [ ":gen_${_target_name_}_base_abc" ]
4638      }
4639
4640      src_js = "@" + rebase_path(merge_file)
4641      dst_file = rebase_path(abc_path)
4642      extra_args = [
4643        "--module",
4644        "--merge-abc",
4645      ]
4646
4647      if (defined(invoker.is_hotpatch) && filename == "patch") {
4648        extra_args += [ "--generate-patch" ]
4649      }
4650
4651      if (defined(invoker.is_hotpatch) && filename == "base") {
4652        dump_symbol_table = rebase_path(_test_map_path_)
4653      }
4654
4655      if (defined(invoker.is_hotpatch) && filename == "patch") {
4656        input_symbol_table = rebase_path(_test_map_path_)
4657      }
4658
4659      in_puts = [
4660        _test_expect_path_,
4661        merge_file,
4662      ]
4663
4664      if (defined(invoker.is_hotpatch) && filename == "patch") {
4665        in_puts += [ _test_map_path_ ]
4666      }
4667
4668      out_puts = [ abc_path ]
4669
4670      if (defined(invoker.is_hotpatch) && filename == "base") {
4671        out_puts += [ _test_map_path_ ]
4672      }
4673    }
4674
4675    if (filename != _test_file_name_[0]) {
4676      _script_args_ += ":"
4677    }
4678    _script_args_ += rebase_path(abc_path)
4679  }
4680
4681  action("${_target_name_}QuickfixAction") {
4682    testonly = true
4683
4684    _host_quickfix_target_ = "//arkcompiler/ets_runtime/ecmascript/quick_fix:quick_fix(${host_toolchain})"
4685    _root_out_dir_ = get_label_info(_host_quickfix_target_, "root_out_dir")
4686
4687    deps = [ _host_quickfix_target_ ]
4688    foreach(filename, _test_file_name_) {
4689      deps += [ ":gen_${_target_name_}_${filename}_abc" ]
4690    }
4691
4692    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4693
4694    quickfix_options = " --merge-abc true "
4695    if (is_mac) {
4696      quickfix_options = " --merge-abc true  --asm-interpreter=false"
4697    }
4698
4699    args = [
4700      "--script-file",
4701      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/quick_fix",
4702      "--script-options",
4703      quickfix_options,
4704      "--script-args",
4705      _script_args_,
4706      "--timeout-limit",
4707      "${_timeout_}",
4708      "--expect-file",
4709      rebase_path(_test_expect_path_),
4710      "--env-path",
4711      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4712          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4713          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4714          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4715          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4716          rebase_path(_root_out_dir_) +
4717          "/thirdparty/bounds_checking_function:" +
4718          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4719    ]
4720
4721    inputs = []
4722
4723    outputs = [ "$target_out_dir/${_target_name_}/" ]
4724  }
4725}
4726
4727template("host_aot_builtin_inlining_test_action") {
4728  host_aot_test_action("${target_name}") {
4729    forward_variables_from(invoker, "*")
4730
4731    is_enable_pgo = true
4732    is_only_typed_path = true
4733    is_enable_opt_inlining = true
4734    is_enable_trace_deopt = true
4735    log_option = " --log-info=trace"
4736    is_enable_inline_trace = true
4737    is_enable_enableArkTools = true
4738    gen_expect_output = true
4739    is_test_llvm_only = true
4740    deps = []
4741  }
4742}
4743
4744template("host_jit_test_action") {
4745  _target_name_ = "${target_name}"
4746  _deps_ = invoker.deps
4747
4748  _test_ts_path_ = "./${_target_name_}.ts"
4749  _test_abc_path_ = "$target_out_dir/${_target_name_}.abc"
4750  _script_args_ = rebase_path(_test_abc_path_)
4751  _test_expect_path_ = "./expect_output.txt"
4752
4753  es2abc_gen_newest_abc("gen_${_target_name_}_abc") {
4754    extra_visibility = [ ":*" ]  # Only targets in this file can depend on this.
4755
4756    if (defined(invoker.run_multi_file_tests) && invoker.run_multi_file_tests) {
4757      src_js = rebase_path("./")
4758    } else {
4759      src_js = rebase_path(_test_ts_path_)
4760    }
4761    dst_file = rebase_path(_test_abc_path_)
4762    extension = "ts"
4763    extra_args = [
4764      "--module",
4765      "--merge-abc",
4766    ]
4767    in_puts = [ _test_ts_path_ ]
4768    out_puts = [ _test_abc_path_ ]
4769  }
4770
4771  action("${_target_name_}JitAction") {
4772    testonly = true
4773    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
4774
4775    _host_jsvm_target_ = "//arkcompiler/ets_runtime/ecmascript/js_vm:ark_js_vm(${host_toolchain})"
4776    _host_jsoptimizer_lib_ = "//arkcompiler/ets_runtime/ecmascript/compiler:libark_jsoptimizer(${host_toolchain})"
4777    _root_out_dir_ = get_label_info(_host_jsvm_target_, "root_out_dir")
4778    _jit_run_options_ =
4779        " --asm-interpreter=true" + " --compiler-enable-jit=true" +
4780        " --compiler-enable-jit-pgo=true" +
4781        " --compiler-jit-hotness-threshold=5" + " --enable-pgo-profiler=true" +
4782        " --compiler-enable-litecg=true" + " --entry-point=${_target_name_} "
4783    _jit_run_options_ += common_options
4784
4785    if (defined(invoker.enable_osr) && invoker.enable_osr) {
4786      _jit_run_options_ += " --compiler-enable-osr=true "
4787      _jit_run_options_ += " --compiler-osr-hotness-threshold=1 "
4788    }
4789    if (defined(invoker.extra_option)) {
4790      _jit_run_options_ += invoker.extra_option
4791    }
4792
4793    deps = [
4794      ":gen_${_target_name_}_abc",
4795      _host_jsoptimizer_lib_,
4796      _host_jsvm_target_,
4797    ]
4798    deps += _deps_
4799
4800    args = [
4801      "--script-file",
4802      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime/ark_js_vm",
4803      "--script-options",
4804      _jit_run_options_,
4805      "--script-args",
4806      _script_args_,
4807      "--expect-file",
4808      rebase_path(_test_expect_path_),
4809      "--env-path",
4810      rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
4811          rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
4812          rebase_path(_root_out_dir_) + "/thirdparty/zlib:" +
4813          rebase_path(_root_out_dir_) + "/resourceschedule/frame_aware_sched:" +
4814          rebase_path(_root_out_dir_) + "/hiviewdfx/hilog:" +
4815          rebase_path(_root_out_dir_) +
4816          "/thirdparty/bounds_checking_function:" +
4817          rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"),
4818    ]
4819
4820    inputs = [ _test_abc_path_ ]
4821
4822    outputs = [ "$target_out_dir/${_target_name_}/" ]
4823  }
4824}
4825