From e16fcd5a4d1b6df194acff474cbda17247dcb8d9 Mon Sep 17 00:00:00 2001 From: sunzibo Date: Thu, 5 Sep 2024 10:14:51 +0800 Subject: [PATCH] Fix return value of ark_aot_compiler Issue: IAOZIY Signed-off-by: sunzibo --- ecmascript/compiler/aot_compiler.cpp | 2 +- test/aottest/BUILD.gn | 1 + test/aottest/empty/BUILD.gn | 19 +++++++++++++++++++ test/aottest/empty/empty.ts | 14 ++++++++++++++ .../pgo_ldobjbyvalue_string/expect_output.txt | 1 + .../pgo_expect_output.txt | 1 + .../pgo_ldobjbyvalue_string.ts | 10 +++++++--- 7 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 test/aottest/empty/BUILD.gn create mode 100644 test/aottest/empty/empty.ts diff --git a/ecmascript/compiler/aot_compiler.cpp b/ecmascript/compiler/aot_compiler.cpp index 14bba54bd1..9974135c89 100644 --- a/ecmascript/compiler/aot_compiler.cpp +++ b/ecmascript/compiler/aot_compiler.cpp @@ -211,7 +211,7 @@ int Main(const int argc, const char **argv) passManager.CompileValidFiles(generator, ret, compilerStats); if (compilerStats.GetCompilerMethodCount() == 0) { - return ERR_AN_EMPTY; + return runtimeOptions.IsPartialCompilerMode() ? ERR_AN_EMPTY : ERR_OK; } if (!generator.SaveAOTFile(cOptions.outputFileName_ + AOTFileManager::FILE_EXTENSION_AN, appSignature)) { return ERR_AN_FAIL; diff --git a/test/aottest/BUILD.gn b/test/aottest/BUILD.gn index f488d72bb1..3f4bd1c9a6 100644 --- a/test/aottest/BUILD.gn +++ b/test/aottest/BUILD.gn @@ -403,6 +403,7 @@ group("ark_aot_ts_assert_test") { "and", "array_bounds_check_elimination", "check_dump", + "empty", ] foreach(test, assert_test_list) { deps += [ "${test}:${test}AotAssertAction" ] diff --git a/test/aottest/empty/BUILD.gn b/test/aottest/empty/BUILD.gn new file mode 100644 index 0000000000..76ec8cf52a --- /dev/null +++ b/test/aottest/empty/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_aot_assert_test_action("empty") { + deps = [] + is_enable_pgo = true +} diff --git a/test/aottest/empty/empty.ts b/test/aottest/empty/empty.ts new file mode 100644 index 0000000000..81c455d535 --- /dev/null +++ b/test/aottest/empty/empty.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/test/aottest/pgo_ldobjbyvalue_string/expect_output.txt b/test/aottest/pgo_ldobjbyvalue_string/expect_output.txt index 41934b0e58..d39332ac9f 100644 --- a/test/aottest/pgo_ldobjbyvalue_string/expect_output.txt +++ b/test/aottest/pgo_ldobjbyvalue_string/expect_output.txt @@ -14,3 +14,4 @@ [trace] Opcode: LOAD_ELEMENT Count:2 6 7 +true diff --git a/test/aottest/pgo_ldobjbyvalue_string/pgo_expect_output.txt b/test/aottest/pgo_ldobjbyvalue_string/pgo_expect_output.txt index ee47f24465..e281b8d10c 100644 --- a/test/aottest/pgo_ldobjbyvalue_string/pgo_expect_output.txt +++ b/test/aottest/pgo_ldobjbyvalue_string/pgo_expect_output.txt @@ -13,3 +13,4 @@ 6 7 +false diff --git a/test/aottest/pgo_ldobjbyvalue_string/pgo_ldobjbyvalue_string.ts b/test/aottest/pgo_ldobjbyvalue_string/pgo_ldobjbyvalue_string.ts index 85acc21b87..8bcc107e4a 100644 --- a/test/aottest/pgo_ldobjbyvalue_string/pgo_ldobjbyvalue_string.ts +++ b/test/aottest/pgo_ldobjbyvalue_string/pgo_ldobjbyvalue_string.ts @@ -42,6 +42,10 @@ class C3 { } const v9 = new C3(SendableMap, '-39635'); -let x = "filter"["length"] -x++ -print(x) +function testInc() { + let x = "filter"["length"] + x++ + print(x) +} +testInc() +print(ArkTools.isAOTCompiled(testInc))