From e6874f106d50959db378fac231ee90808029eb0b Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Sat, 15 Apr 2023 08:56:42 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!3926=20?= =?UTF-8?q?:=20Fix=20async=20function=20reentergenerator=20failed=20when?= =?UTF-8?q?=20deopt=20happened'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecmascript/deoptimizer/deoptimizer.cpp | 4 +- ecmascript/method.h | 7 ---- ecmascript/stubs/runtime_stubs.cpp | 7 +--- test/deopttest/BUILD.gn | 1 - test/deopttest/async_deopt/BUILD.gn | 18 -------- test/deopttest/async_deopt/async_deopt.ts | 44 -------------------- test/deopttest/async_deopt/expect_output.txt | 17 -------- 7 files changed, 4 insertions(+), 94 deletions(-) delete mode 100644 test/deopttest/async_deopt/BUILD.gn delete mode 100644 test/deopttest/async_deopt/async_deopt.ts delete mode 100644 test/deopttest/async_deopt/expect_output.txt diff --git a/ecmascript/deoptimizer/deoptimizer.cpp b/ecmascript/deoptimizer/deoptimizer.cpp index 47fd4373c4..86714bc5ca 100644 --- a/ecmascript/deoptimizer/deoptimizer.cpp +++ b/ecmascript/deoptimizer/deoptimizer.cpp @@ -346,7 +346,9 @@ JSTaggedType Deoptimizier::ConstructAsmInterpretFrame(kungfu::DeoptType type) method->SetDeoptType(type); method->SetDeoptThreshold(--deoptThreshold); } else { - method->ClearAOTFlags(); + method->SetAotCodeBit(false); + method->SetDeoptType(kungfu::DeoptType::NOTCHECK); + method->SetCodeEntryOrLiteral(reinterpret_cast(nullptr)); } FrameWriter frameWriter(this); diff --git a/ecmascript/method.h b/ecmascript/method.h index 7263559b06..a1be38ab24 100644 --- a/ecmascript/method.h +++ b/ecmascript/method.h @@ -369,13 +369,6 @@ public: SetCodeEntryOrLiteral(codeEntry); } - void ClearAOTFlags() - { - SetAotCodeBit(false); - SetDeoptType(kungfu::DeoptType::NOTCHECK); - SetCodeEntryOrLiteral(reinterpret_cast(nullptr)); - } - static constexpr size_t Size() { return sizeof(Method); diff --git a/ecmascript/stubs/runtime_stubs.cpp b/ecmascript/stubs/runtime_stubs.cpp index 57ea21f5a0..bb04ee6940 100644 --- a/ecmascript/stubs/runtime_stubs.cpp +++ b/ecmascript/stubs/runtime_stubs.cpp @@ -2152,12 +2152,7 @@ void RuntimeStubs::SaveFrameToContext(JSThread *thread, JSHandleSet(thread, i, value); } context->SetRegsArray(thread, regsArray.GetTaggedValue()); - JSTaggedValue function = frameHandler.GetFunction(); - Method *method = JSFunction::Cast(function.GetTaggedObject())->GetCallTarget(); - if (method->IsAotWithCallField()) { - method->ClearAOTFlags(); - } - context->SetMethod(thread, function); + context->SetMethod(thread, frameHandler.GetFunction()); context->SetThis(thread, frameHandler.GetThis()); BytecodeInstruction ins(frameHandler.GetPc()); diff --git a/test/deopttest/BUILD.gn b/test/deopttest/BUILD.gn index df0d1d43d9..41fe605244 100644 --- a/test/deopttest/BUILD.gn +++ b/test/deopttest/BUILD.gn @@ -15,7 +15,6 @@ group("ark_deopt_test") { testonly = true test_list = [ "arithmetic", - "async_deopt", "comparison", "dec", "div", diff --git a/test/deopttest/async_deopt/BUILD.gn b/test/deopttest/async_deopt/BUILD.gn deleted file mode 100644 index 386301d29e..0000000000 --- a/test/deopttest/async_deopt/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2023 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_test_action("async_deopt") { - deps = [] -} diff --git a/test/deopttest/async_deopt/async_deopt.ts b/test/deopttest/async_deopt/async_deopt.ts deleted file mode 100644 index 5d9f5e2b50..0000000000 --- a/test/deopttest/async_deopt/async_deopt.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -// @ts-nocheck -declare function print(arg:any):string; -class A { - n: number = 2 -} - -class B { - m:number = 3 -} - -async function foo() { - A.prototype.o = 1 - let a = new A() - let r = await a.n // deopt before suspendgenerator - print(r) -} - -async function bar() { - B.prototype.o = 1 - let b = new B() - let r = await 1 - let c = b.m // deopt after suspendgenerator - print(c) - print(r) -} - -foo() -print('-----------------') -bar() diff --git a/test/deopttest/async_deopt/expect_output.txt b/test/deopttest/async_deopt/expect_output.txt deleted file mode 100644 index 4052352e72..0000000000 --- a/test/deopttest/async_deopt/expect_output.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2023 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. - ------------------ -2 -3 -1 -- Gitee