mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
!8321 Unlock unnitest for pgo profile
Merge pull request !8321 from zhuangkudecha/pgoProfileUnnitest
This commit is contained in:
commit
62542cdd42
@ -32,6 +32,9 @@ test_js_files = [
|
||||
"truck",
|
||||
"vehicle",
|
||||
"typedarray_length",
|
||||
"merge_file_1",
|
||||
"merge_file_2",
|
||||
"merge_file_3",
|
||||
]
|
||||
|
||||
foreach(file, test_js_files) {
|
||||
@ -56,7 +59,7 @@ host_unittest_action("PGOProfilerTest") {
|
||||
|
||||
sources = [
|
||||
# test file
|
||||
#"pgo_profiler_test.cpp",
|
||||
"pgo_profiler_test.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "ecmascript/base/file_header.h"
|
||||
#include "ecmascript/elements.h"
|
||||
#include "ecmascript/js_symbol.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
#include "ecmascript/pgo_profiler/ap_file/pgo_file_info.h"
|
||||
@ -775,7 +776,7 @@ HWTEST_F_L0(PGOProfilerTest, UseClassTypeTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName](uint32_t offset, const PGOType *type) {
|
||||
ASSERT_NE(offset, 0);
|
||||
if (type->IsScalarOpType()) {
|
||||
@ -814,7 +815,7 @@ HWTEST_F_L0(PGOProfilerTest, DefineClassTypeTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName, &decoder, jsPandaFile = pf_](uint32_t offset, const PGOType *type) {
|
||||
ASSERT_NE(offset, 0);
|
||||
if (type->IsScalarOpType()) {
|
||||
@ -870,7 +871,7 @@ HWTEST_F_L0(PGOProfilerTest, OpTypeTest)
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
if (std::string(methodName) != "sun" && std::string(methodName) != "sun1") {
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
}
|
||||
auto callback = [methodName, types, &index](uint32_t offset, const PGOType *type) {
|
||||
ASSERT_NE(offset, 0);
|
||||
@ -916,7 +917,7 @@ HWTEST_F_L0(PGOProfilerTest, ArrayProfileTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName, &decoder, jsPandaFile = pf_](uint32_t offset, const PGOType *type) {
|
||||
if (type->IsScalarOpType()) {
|
||||
auto sampleType = *reinterpret_cast<const PGOSampleType *>(type);
|
||||
@ -983,7 +984,7 @@ HWTEST_F_L0(PGOProfilerTest, ObjectLiteralProfileTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName, &decoder, jsPandaFile = pf_](uint32_t offset, const PGOType *type) {
|
||||
if (type->IsScalarOpType()) {
|
||||
auto sampleType = *reinterpret_cast<const PGOSampleType *>(type);
|
||||
@ -1031,7 +1032,7 @@ HWTEST_F_L0(PGOProfilerTest, ArraySizeProfileTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName, jsPandaFile = pf_](uint32_t offset, const PGOType *type) {
|
||||
if (type->IsDefineOpType()) {
|
||||
auto defineOptype = reinterpret_cast<const PGODefineOpType *>(type);
|
||||
@ -1068,7 +1069,7 @@ HWTEST_F_L0(PGOProfilerTest, StringEqualProfileTest)
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
auto callback = [methodName, jsPandaFile = pf_](uint32_t offset, const PGOType *type) {
|
||||
if (type->IsScalarOpType()) {
|
||||
auto sampleType = *reinterpret_cast<const PGOSampleType *>(type);
|
||||
@ -1107,7 +1108,7 @@ HWTEST_F_L0(PGOProfilerTest, BuiltinsTest)
|
||||
auto methodName = methodLiteral->GetMethodName(pf_.get(), methodId);
|
||||
if (std::string(methodName) != "ArrayList") {
|
||||
decoder.MatchAndMarkMethod(pf_.get(), targetRecordName, methodName, methodId);
|
||||
ASSERT_TRUE(decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
ASSERT_TRUE(!decoder.Match(pf_.get(), targetRecordName, methodId));
|
||||
}
|
||||
auto callback = [methodName](uint32_t offset, const PGOType *type) {
|
||||
ASSERT_NE(offset, 0);
|
||||
@ -1206,13 +1207,16 @@ HWTEST_F_L0(PGOProfilerTest, RuntimeMerge)
|
||||
HWTEST_F_L0(PGOProfilerTest, ProfdumpMerge)
|
||||
{
|
||||
mkdir("ark-profiler20/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler20/truck.ap", "truck");
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler20/call_test.ap", "call_test");
|
||||
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler20/merge_file_1.ap", "merge_file_1");
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler20/merge_file_2.ap", "merge_file_2");
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler20/merge_file_3.ap", "merge_file_3");
|
||||
|
||||
// Loader
|
||||
PGOProfilerDecoder loader("ark-profiler20/merged.ap", DECODER_THRESHOLD);
|
||||
ASSERT_TRUE(PGOProfilerManager::MergeApFiles("ark-profiler20/truck.ap:ark-profiler20/call_test.ap",
|
||||
"ark-profiler20/merged.ap", 1, ApGenMode::OVERWRITE));
|
||||
ASSERT_TRUE(PGOProfilerManager::MergeApFiles(
|
||||
"ark-profiler20/merge_file_1.ap:ark-profiler20/merge_file_2.ap:ark-profiler20/merge_file_3.ap",
|
||||
"ark-profiler20/merged.ap", 1, ApGenMode::OVERWRITE));
|
||||
|
||||
CString expectRecordName = "sample_test";
|
||||
#if defined(SUPPORT_ENABLE_ASM_INTERP)
|
||||
@ -1224,8 +1228,9 @@ HWTEST_F_L0(PGOProfilerTest, ProfdumpMerge)
|
||||
uint32_t checksum = pf_->GetChecksum();
|
||||
ASSERT_TRUE(!loader.LoadAndVerify(checksum));
|
||||
#endif
|
||||
unlink("ark-profiler20/truck.ap");
|
||||
unlink("ark-profiler20/call_test.ap");
|
||||
unlink("ark-profiler20/merge_file_1.ap");
|
||||
unlink("ark-profiler20/merge_file_2.ap");
|
||||
unlink("ark-profiler20/merge_file_3.ap");
|
||||
unlink("ark-profiler20/merged.ap");
|
||||
rmdir("ark-profiler20/");
|
||||
}
|
||||
@ -1282,4 +1287,29 @@ HWTEST_F_L0(PGOProfilerTest, TypedArrayOnHeap)
|
||||
unlink("ark-profiler24/modules.ap");
|
||||
rmdir("ark-profiler24/");
|
||||
}
|
||||
|
||||
HWTEST_F_L0(PGOProfilerTest, ProfileTypeConstructor)
|
||||
{
|
||||
mkdir("ark-profiler25/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
const char *targetRecordName = "typedarray_length";
|
||||
ExecuteAndLoadJSPandaFile("ark-profiler25/", targetRecordName);
|
||||
ASSERT_NE(pf_, nullptr);
|
||||
ApEntityId inValidId = 555;
|
||||
ApEntityId validId = 64;
|
||||
// Loader
|
||||
PGOProfilerDecoder decoder("ark-profiler25/modules.ap", 1);
|
||||
ASSERT_TRUE(decoder.LoadFull());
|
||||
|
||||
ProfileType recordType;
|
||||
bool isValid = true;
|
||||
auto invalidType = ProfileTypeRef(inValidId);
|
||||
recordType = ProfileType(decoder.GetRecordDetailInfos(), invalidType, &isValid);
|
||||
ASSERT_TRUE(!isValid);
|
||||
|
||||
auto validType = ProfileTypeRef(validId);
|
||||
recordType = ProfileType(decoder.GetRecordDetailInfos(), validType, &isValid);
|
||||
ASSERT_TRUE(isValid);
|
||||
unlink("ark-profiler25/modules.ap");
|
||||
rmdir("ark-profiler25/");
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_1.js
Normal file
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_1.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
x;
|
||||
constructor(x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
|
||||
function foo(p)
|
||||
{
|
||||
return p.x;
|
||||
}
|
||||
|
||||
let a = new A(1);
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
foo(a);
|
||||
}
|
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_2.js
Normal file
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_2.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
x;
|
||||
constructor(x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
|
||||
function foo(p)
|
||||
{
|
||||
return p.x;
|
||||
}
|
||||
|
||||
let a = new A(2);
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
foo(a);
|
||||
}
|
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_3.js
Normal file
31
ecmascript/pgo_profiler/tests/pgo_test_case/merge_file_3.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
x;
|
||||
constructor(x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
|
||||
function foo(p)
|
||||
{
|
||||
return p.x;
|
||||
}
|
||||
|
||||
let a = new A(3);
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
foo(a);
|
||||
}
|
Loading…
Reference in New Issue
Block a user