From dc2a12f836e53dd37d4ef655577703675b5dd6fe Mon Sep 17 00:00:00 2001 From: linxiang8 Date: Mon, 17 Jul 2023 14:53:24 +0800 Subject: [PATCH] Bugfix: stp/ltp need 16 align Issue: ehttps://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7LO01 Signed-off-by: linxiang8 Change-Id: Ie3900d13ff674b53a95435cd06cd2b30b0c9198a --- .../trampoline/aarch64/optimized_call.cpp | 11 ++++---- test/aottest/BUILD.gn | 1 + test/aottest/optimized_call/BUILD.gn | 19 +++++++++++++ test/aottest/optimized_call/expect_output.txt | 14 ++++++++++ test/aottest/optimized_call/optimized_call.ts | 28 +++++++++++++++++++ 5 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 test/aottest/optimized_call/BUILD.gn create mode 100644 test/aottest/optimized_call/expect_output.txt create mode 100644 test/aottest/optimized_call/optimized_call.ts diff --git a/ecmascript/compiler/trampoline/aarch64/optimized_call.cpp b/ecmascript/compiler/trampoline/aarch64/optimized_call.cpp index 0391ffcd8e..32615a8d4f 100644 --- a/ecmascript/compiler/trampoline/aarch64/optimized_call.cpp +++ b/ecmascript/compiler/trampoline/aarch64/optimized_call.cpp @@ -747,13 +747,12 @@ void OptimizedCall::CallRuntimeWithArgv(ExtendedAssembler *assembler) Register sp(SP); // 2 : 2 means pair __ Stp(argc, argv, MemoryOperand(sp, -FRAME_SLOT_SIZE * 2, AddrMode::PREINDEX)); - __ Str(runtimeId, MemoryOperand(sp, -FRAME_SLOT_SIZE, AddrMode::PREINDEX)); - __ PushFpAndLr(); + __ Stp(Register(X30), runtimeId, MemoryOperand(sp, -FRAME_SLOT_SIZE * 2, AddrMode::PREINDEX)); Register fp(X29); // construct leave frame Register frameType(X9); __ Mov(frameType, Immediate(static_cast(FrameType::LEAVE_FRAME_WITH_ARGV))); - __ Str(frameType, MemoryOperand(sp, -FRAME_SLOT_SIZE, AddrMode::PREINDEX)); + __ Stp(frameType, Register(X29), MemoryOperand(sp, -FRAME_SLOT_SIZE * 2, AddrMode::PREINDEX)); __ Add(Register(FP), sp, Immediate(FRAME_SLOT_SIZE)); __ Str(fp, MemoryOperand(glue, JSThread::GlueData::GetLeaveFrameOffset(false))); @@ -766,9 +765,9 @@ void OptimizedCall::CallRuntimeWithArgv(ExtendedAssembler *assembler) __ Mov(X1, argc); __ Mov(X2, argv); __ Blr(rtfunc); - __ Add(sp, sp, Immediate(FRAME_SLOT_SIZE)); - __ RestoreFpAndLr(); - __ Add(sp, sp, Immediate(3 * FRAME_SLOT_SIZE)); // 3 : 3 means pair + __ Ldp(Register(Zero), Register(X29), MemoryOperand(sp, ExtendedAssembler::PAIR_SLOT_SIZE, POSTINDEX)); + __ Ldp(Register(X30), Register(Zero), MemoryOperand(sp, ExtendedAssembler::PAIR_SLOT_SIZE, POSTINDEX)); + __ Add(sp, sp, Immediate(2 * FRAME_SLOT_SIZE)); // 2 : 2 means pair __ Ret(); } diff --git a/test/aottest/BUILD.gn b/test/aottest/BUILD.gn index 87a80d1d6a..1174dd112c 100644 --- a/test/aottest/BUILD.gn +++ b/test/aottest/BUILD.gn @@ -148,6 +148,7 @@ group("ark_aot_ts_test") { "not", "numberspeculativeretype", "optimization", + "optimized_call", "or", "poplexenv", "proxy", diff --git a/test/aottest/optimized_call/BUILD.gn b/test/aottest/optimized_call/BUILD.gn new file mode 100644 index 0000000000..dab09e4c11 --- /dev/null +++ b/test/aottest/optimized_call/BUILD.gn @@ -0,0 +1,19 @@ +# 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("optimized_call") { + deps = [] + userDefinedMethodsInModule = true +} diff --git a/test/aottest/optimized_call/expect_output.txt b/test/aottest/optimized_call/expect_output.txt new file mode 100644 index 0000000000..11e347853e --- /dev/null +++ b/test/aottest/optimized_call/expect_output.txt @@ -0,0 +1,14 @@ +# 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 diff --git a/test/aottest/optimized_call/optimized_call.ts b/test/aottest/optimized_call/optimized_call.ts new file mode 100644 index 0000000000..ac75a1d266 --- /dev/null +++ b/test/aottest/optimized_call/optimized_call.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ +declare function print(arg:any):void; + +function sum(a:number, b:number, c:number) { + return a + b + c; +} + +const object = { + apply: function(a:number, b:number, c:number) { + return 2; + } +}; + +const proxy = new Proxy(sum, object); +print(proxy(1, 2, 3)); \ No newline at end of file