From a4138567d867d09dac9da0abcb58919fced66023 Mon Sep 17 00:00:00 2001 From: yy Date: Wed, 17 Jul 2024 18:17:13 +0800 Subject: [PATCH 1/7] add arm test262 Signed-off-by: yy --- test262/config.py | 1 + test262/run_sunspider.py | 12 ++++++++++++ test262/run_test262.py | 12 ++++++++++++ test262/utils.py | 12 ++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/test262/config.py b/test262/config.py index b621a242e4..6e1a291390 100755 --- a/test262/config.py +++ b/test262/config.py @@ -69,6 +69,7 @@ DEFAULT_ZLIB_DIR = f"{CODE_ROOT}/out/hispark_taurus/clang_x64/thirdparty/zlib" DEFAULT_ARK_TOOL = os.path.join(DEFAULT_ARK_JS_RUNTIME_DIR, "ark_js_vm") DEFAULT_LIBS_DIR = f"{DEFAULT_ICUI_DIR}:{LLVM_DIR}:{DEFAULT_ARK_JS_RUNTIME_DIR}:{DEFAULT_ZLIB_DIR}" +DEFAULT_STUB_FILE = f"" DEFAULT_ARK_AOT_TOOL = os.path.join(DEFAULT_ARK_JS_RUNTIME_DIR, "ark_aot_compiler") DEFAULT_HOST_TYPE = "panda" diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index 75f8a7d7c5..bbd44ffa87 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -52,6 +52,9 @@ def parse_args(): parser.add_argument("--js-file", required=True, help="js file") + parser.add_argument("--stub-file", + required=False, + help="stub file") parser.add_argument('--ark-frontend', default=DEFAULT_ARK_FRONTEND, required=False, @@ -142,6 +145,7 @@ class ArkProgram(): self.module_list = [] self.dynamicImport_list = [] self.js_file = "" + self.stub_file = "" self.module = False self.abc_file = "" self.arch = ARK_ARCH @@ -212,6 +216,8 @@ class ArkProgram(): self.js_file = self.args.js_file + self.stub_file = self.args.stub_file + self.arch = self.args.ark_arch self.arch_root = self.args.ark_arch_root @@ -562,6 +568,8 @@ class ArkProgram(): cmd_args.append("--compiler-opt-inlining=true") cmd_args.append("--compiler-max-inline-bytecodes=45") cmd_args.append("--compiler-opt-level=2") + if self.stub_file != "": + cmd_args.append(f"--stub-file={self.stub_file}") if self.disable_force_gc: cmd_args.append(f"--enable-force-gc=false") cmd_args.append(f'--compiler-pgo-profiler-path={file_name_pre}.ap') @@ -622,6 +630,8 @@ class ArkProgram(): record_name = os.path.splitext(os.path.split(self.js_file)[1])[0] cmd_args.insert(-1, f'--entry-point={record_name}') + if self.stub_file != "": + cmd_args.insert(-1, f'--stub-file={self.stub_file}') retcode = exec_command(cmd_args) if retcode: print_command(cmd_args) @@ -721,6 +731,8 @@ class ArkProgram(): f'--compiler-pgo-profiler-path={file_name_pre}.ap', "--asm-interpreter=true", f'--entry-point={record_name}'] + if self.stub_file != "": + cmd_args.append(f"--stub-file={self.stub_file}") if self.disable_force_gc: cmd_args.append(f"--enable-force-gc=false") cmd_args.append(f'{file_name_pre}.abc') diff --git a/test262/run_test262.py b/test262/run_test262.py index 23fd3df39e..074fd46355 100755 --- a/test262/run_test262.py +++ b/test262/run_test262.py @@ -138,6 +138,9 @@ def parse_args(): help="Run test262 with baseline JIT") parser.add_argument('--abc2program', action='store_true', help="Use abc2prog to generate abc, aot or pgo is not supported yet under this option") + parser.add_argument('--stub-file', + default=DEFAULT_STUB_FILE, + help="stub file") parser.add_argument('--disable-force-gc', action='store_true', help="Run test262 with close force-gc") parser.add_argument('--enable-arkguard', action='store_true', @@ -692,6 +695,11 @@ def get_disable_force_gc(host_args, args): return host_args +def get_host_args_of_stub_file(args, host_args): + host_args += f"--disable-force-gc " + + return host_args + def get_host_args(args, host_type): host_args = "" ark_tool = DEFAULT_ARK_TOOL @@ -700,6 +708,7 @@ def get_host_args(args, host_type): ark_frontend = DEFAULT_ARK_FRONTEND ark_frontend_binary = DEFAULT_ARK_FRONTEND_BINARY ark_arch = DEFAULT_ARK_ARCH + stub_file = DEFAULT_STUB_FILE opt_level = DEFAULT_OPT_LEVEL es2abc_thread_count = DEFAULT_ES2ABC_THREAD_COUNT merge_abc_binary = DEFAULT_MERGE_ABC_BINARY @@ -747,6 +756,9 @@ def get_host_args(args, host_type): if args.ark_arch != ark_arch: host_args = get_host_args_of_ark_arch(args, host_args) + if args.stub_file != stub_file: + host_args = get_host_args_of_stub_file(args, host_args) + if args.disable_force_gc: host_args = get_disable_force_gc(host_args, args) diff --git a/test262/utils.py b/test262/utils.py index 186a2f237d..54d18efbba 100755 --- a/test262/utils.py +++ b/test262/utils.py @@ -73,10 +73,18 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT, custom_cwd=None): (output_res, errs) = proc.communicate(timeout=timeout) ret_code = proc.poll() - if errs.decode(code_format, 'ignore') != '': - output(1, errs.decode(code_format, 'ignore')) + errs_str = errs.decode(code_format, 'ignore') + list_errs = [] + for err in errs_str.split("\n"): + if "memset will be used instead" not in err and "This is the expected behaviour if you are running under QEMU" not in err and "Can't connect to server" not in err: + list_errs.append(err) + + if len(list_errs) != 1: + output(1, "".join(list_errs)) return 1 + errs = None + if ret_code and ret_code != 1: code = ret_code msg = f"Command {cmd_string}: \n" -- Gitee From 555b14a00556ea5668f0596b52c2bd36cb7870f9 Mon Sep 17 00:00:00 2001 From: yy Date: Wed, 17 Jul 2024 12:18:06 +0000 Subject: [PATCH 2/7] update test262/run_test262.py. Signed-off-by: yy --- test262/run_test262.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test262/run_test262.py b/test262/run_test262.py index 074fd46355..58335ff8dd 100755 --- a/test262/run_test262.py +++ b/test262/run_test262.py @@ -696,7 +696,7 @@ def get_disable_force_gc(host_args, args): return host_args def get_host_args_of_stub_file(args, host_args): - host_args += f"--disable-force-gc " + host_args += f"--stub-file={args.stub_file} " return host_args -- Gitee From e981020e0082b3a7a18b5be50f8a5d0b0a5bb7f5 Mon Sep 17 00:00:00 2001 From: yy Date: Wed, 17 Jul 2024 12:18:52 +0000 Subject: [PATCH 3/7] update test262/run_sunspider.py. Signed-off-by: yy --- test262/run_sunspider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index bbd44ffa87..1a0c85e686 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -732,7 +732,7 @@ class ArkProgram(): "--asm-interpreter=true", f'--entry-point={record_name}'] if self.stub_file != "": - cmd_args.append(f"--stub-file={self.stub_file}") + cmd_args.append(f"--stub-file={self.stub_file}") if self.disable_force_gc: cmd_args.append(f"--enable-force-gc=false") cmd_args.append(f'{file_name_pre}.abc') -- Gitee From 761fed2f85b0fa42e0f6908fa2b9c99adb8b4b4f Mon Sep 17 00:00:00 2001 From: yy Date: Wed, 17 Jul 2024 12:19:19 +0000 Subject: [PATCH 4/7] update test262/utils.py. Signed-off-by: yy --- test262/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test262/utils.py b/test262/utils.py index 54d18efbba..5c21ea4871 100755 --- a/test262/utils.py +++ b/test262/utils.py @@ -78,7 +78,7 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT, custom_cwd=None): for err in errs_str.split("\n"): if "memset will be used instead" not in err and "This is the expected behaviour if you are running under QEMU" not in err and "Can't connect to server" not in err: list_errs.append(err) - + if len(list_errs) != 1: output(1, "".join(list_errs)) return 1 -- Gitee From 6aea2c021bf62f84169e25ffe1c032568ff20ee8 Mon Sep 17 00:00:00 2001 From: yy Date: Wed, 17 Jul 2024 12:44:11 +0000 Subject: [PATCH 5/7] update test262/run_sunspider.py. Signed-off-by: yy --- test262/run_sunspider.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index 1a0c85e686..ab91d86e94 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -53,6 +53,7 @@ def parse_args(): required=True, help="js file") parser.add_argument("--stub-file", + default=DEFAULT_STUB_FILE, required=False, help="stub file") parser.add_argument('--ark-frontend', -- Gitee From c59e3d912810f3e8a351b6968d75eaf5c154d02d Mon Sep 17 00:00:00 2001 From: yy Date: Thu, 18 Jul 2024 07:15:00 +0000 Subject: [PATCH 6/7] update test262/run_sunspider.py. Signed-off-by: yy --- test262/run_sunspider.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index ab91d86e94..0791ac4b93 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -673,7 +673,6 @@ class ArkProgram(): if self.run_jit or self.run_baseline_jit: cmd_args.insert(-1, f'--compiler-target-triple=aarch64-unknown-linux-gnu') if self.run_baseline_jit: - cmd_args.insert(-1, f'--stub-file=../../out/arm64.release/gen/arkcompiler/ets_runtime/stub.an') cmd_args.insert(-1, f'--test-assert=true') elif self.arch == ARK_ARCH_LIST[2]: qemu_tool = "qemu-arm" @@ -699,6 +698,8 @@ class ArkProgram(): if self.run_baseline_jit: cmd_args.insert(-1, f'--compiler-enable-baselinejit=true') cmd_args.insert(-1, f'--compiler-force-baselinejit-compile-main=true') + if self.stub_file != "": + cmd_args.insert(-1, f"--stub-file={self.stub_file}") retcode = 0 if self.abc2program: retcode = self.execute_abc2program_outputs(cmd_args) -- Gitee From c1a100a9ecd52b7eb000f3ff69696c149f87e0da Mon Sep 17 00:00:00 2001 From: yy Date: Thu, 18 Jul 2024 07:16:32 +0000 Subject: [PATCH 7/7] supplement arm test262 operation mode Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IADPCL Signed-off-by: yy --- test262/run_test262.py | 3 +++ test262/utils.py | 28 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/test262/run_test262.py b/test262/run_test262.py index 58335ff8dd..30101afccd 100755 --- a/test262/run_test262.py +++ b/test262/run_test262.py @@ -690,16 +690,19 @@ def get_host_args_of_ark_arch(args, host_args): return host_args + def get_disable_force_gc(host_args, args): host_args += f"--disable-force-gc " return host_args + def get_host_args_of_stub_file(args, host_args): host_args += f"--stub-file={args.stub_file} " return host_args + def get_host_args(args, host_type): host_args = "" ark_tool = DEFAULT_ARK_TOOL diff --git a/test262/utils.py b/test262/utils.py index 5c21ea4871..16c5c502b8 100755 --- a/test262/utils.py +++ b/test262/utils.py @@ -57,6 +57,22 @@ def output(retcode, msg): sys.stderr.write("Unknown Error: " + str(retcode)) +def filter_arm_specific_errors(errs_str): + list_errs = [] + for err in errs_str.split("\n"): + if err: + if ("memset will be used instead" not in err and + "This is the expected behaviour if you are running under QEMU" not in err and + "Can't connect to server" not in err): + list_errs.append(err) + + if len(list_errs) != 0: + output(1, "".join(list_errs)) + return False + + return True + + def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT, custom_cwd=None): proc = subprocess.Popen(cmd_args, stderr=subprocess.PIPE, @@ -74,17 +90,11 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT, custom_cwd=None): ret_code = proc.poll() errs_str = errs.decode(code_format, 'ignore') - list_errs = [] - for err in errs_str.split("\n"): - if "memset will be used instead" not in err and "This is the expected behaviour if you are running under QEMU" not in err and "Can't connect to server" not in err: - list_errs.append(err) - - if len(list_errs) != 1: - output(1, "".join(list_errs)) + if filter_arm_specific_errors(errs_str): + errs = None + else: return 1 - errs = None - if ret_code and ret_code != 1: code = ret_code msg = f"Command {cmd_string}: \n" -- Gitee