mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Fix performance degradation issues
1. Fix inline Poly call method causing deopt 2. Fix bug in mono builtin judgment Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAF7NO Signed-off-by: ginxu <xujie101@huawei.com> Change-Id: I97df150548c71cf71997090f668e48e509d3446d
This commit is contained in:
parent
9317976966
commit
47c183b538
@ -281,7 +281,7 @@ void ProfilerStubBuilder::ProfileCall(
|
||||
Bind(&resetSlot);
|
||||
{
|
||||
// NOTICE-PGO: lx about poly
|
||||
GateRef nonType = IntToTaggedInt(Int64(0));
|
||||
GateRef nonType = IntToTaggedInt(Int32(0));
|
||||
SetValueToTaggedArray(VariableType::JS_ANY(), glue, profileTypeInfo, slotId, nonType);
|
||||
TryPreDumpInner(glue, func, profileTypeInfo);
|
||||
Jump(&exit);
|
||||
|
@ -568,10 +568,6 @@ uint32_t InlineTypeInfoAccessor::GetCallMethodId() const
|
||||
uint32_t methodOffset = 0;
|
||||
if (IsNormalCall() && IsValidCallMethodId()) {
|
||||
methodOffset = GetFuncMethodOffsetFromPGO();
|
||||
if (methodOffset == base::PGO_POLY_INLINE_REP) {
|
||||
methodOffset = 0;
|
||||
return methodOffset;
|
||||
}
|
||||
}
|
||||
if (IsCallAccessor()) {
|
||||
const PGORWOpType *pgoTypes = acc_.TryGetPGOType(gate_).GetPGORWOpType();
|
||||
@ -1200,13 +1196,31 @@ LoadBulitinObjTypeInfoAccessor::LoadBulitinObjTypeInfoAccessor(const Compilation
|
||||
FetchBuiltinsTypes();
|
||||
}
|
||||
|
||||
bool AccBuiltinObjTypeInfoAccessor::IsStringMonoBuiltins() const
|
||||
{
|
||||
for (auto type : types_) {
|
||||
if (!type.IsBuiltinsString()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccBuiltinObjTypeInfoAccessor::IsMonoBuiltins() const
|
||||
{
|
||||
if (types_.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsStringMonoBuiltins()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < types_.size(); i++) {
|
||||
if (!types_[0].IsBuiltinsType()) {
|
||||
if (!types_[i].IsBuiltinsType()) {
|
||||
return false;
|
||||
}
|
||||
if (types_[i].GetBuiltinsType() != types_[0].GetBuiltinsType()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1741,6 +1741,7 @@ public:
|
||||
|
||||
protected:
|
||||
bool IsMonoBuiltins() const;
|
||||
bool IsStringMonoBuiltins() const;
|
||||
void FetchBuiltinsTypes();
|
||||
bool CheckDuplicatedBuiltinType(ProfileType newType) const;
|
||||
|
||||
|
@ -1378,9 +1378,10 @@ void PGOProfiler::DumpCall(ApEntityId abcId, const CString &recordName, EntityId
|
||||
calleeAbcId = abcId;
|
||||
ASSERT(calleeMethodId <= 0);
|
||||
if (calleeMethodId == 0) {
|
||||
return;
|
||||
kind = ProfileType::Kind::MethodId;
|
||||
} else {
|
||||
kind = ProfileType::Kind::BuiltinFunctionId;
|
||||
}
|
||||
kind = ProfileType::Kind::BuiltinFunctionId;
|
||||
} else if (slotValue.IsJSFunction()) {
|
||||
JSFunction *callee = JSFunction::Cast(slotValue);
|
||||
Method *calleeMethod = Method::Cast(callee->GetMethod());
|
||||
|
@ -186,6 +186,7 @@ group("ark_aot_ts_test") {
|
||||
"map",
|
||||
"mod",
|
||||
"modules",
|
||||
"mono_builtin",
|
||||
"mul",
|
||||
"multi_module_compilation",
|
||||
"neg",
|
||||
|
22
test/aottest/mono_builtin/BUILD.gn
Normal file
22
test/aottest/mono_builtin/BUILD.gn
Normal file
@ -0,0 +1,22 @@
|
||||
# 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_test_action("mono_builtin") {
|
||||
deps = []
|
||||
is_only_typed_path = true
|
||||
is_enable_pgo = true
|
||||
is_enable_enableArkTools = true
|
||||
is_enable_trace_deopt = true
|
||||
}
|
15
test/aottest/mono_builtin/expect_output.txt
Normal file
15
test/aottest/mono_builtin/expect_output.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# 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.
|
||||
|
||||
true
|
||||
false
|
42
test/aottest/mono_builtin/mono_builtin.ts
Normal file
42
test/aottest/mono_builtin/mono_builtin.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare function print(arg:any):string;
|
||||
|
||||
declare interface ArkTools {
|
||||
isAOTCompiled(args: any): boolean;
|
||||
}
|
||||
|
||||
function foo(arr) {
|
||||
let length = arr.length;
|
||||
let sum = 0;
|
||||
for (let i = 0; i < length; i++) {
|
||||
sum += arr[i]
|
||||
}
|
||||
for (let i = 0; i < length; i++) {
|
||||
sum = sum * arr[i]
|
||||
}
|
||||
for (let i = 0; i < length; i++) {
|
||||
sum = sum * arr[i]
|
||||
}
|
||||
}
|
||||
|
||||
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
const typedArray = new Int8Array(8);
|
||||
typedArray[0] = 32;
|
||||
foo(arr)
|
||||
foo(typedArray)
|
||||
print(ArkTools.isAOTCompiled(foo))
|
||||
print(ArkTools.isAOTDeoptimized(foo))
|
15
test/aottest/mono_builtin/pgo_expect_output.txt
Normal file
15
test/aottest/mono_builtin/pgo_expect_output.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# 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.
|
||||
|
||||
false
|
||||
false
|
Loading…
Reference in New Issue
Block a user