!5228 Do not use baseline ap

Merge pull request !5228 from hzzhouzebin/DoNotUseBaselineAp
This commit is contained in:
openharmony_ci 2023-11-13 14:09:33 +00:00 committed by Gitee
commit 76f9720b13
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 17 additions and 11 deletions

View File

@ -356,10 +356,10 @@ public:
return;
}
// 2. use baseline ap if there's no runtime ap
// 2. do not baseline ap until new format supported
auto baselineAp = pgoDir_ + '/' + pgo::ApNameUtils::GetOhosPkgApName(moduleName_);
if (FileExist(baselineAp.c_str())) {
pgoPaths = baselineAp;
LOG_COMPILER(ERROR) << "Do not support base line ap now, please waiting. baseline ap: " << baselineAp;
}
}
@ -395,10 +395,10 @@ private:
}
if (pkgArgs->GetPgoDir().empty() && !cOptions.profilerIn_.empty()) {
// try get pgo dir from --compiler-pgo-profiler-path
arg_list_t pandaFileNames = base::StringHelper::SplitString(cOptions.profilerIn_, GetFileDelimiter());
ASSERT(!pandaFileNames.empty());
arg_list_t apFileNames = base::StringHelper::SplitString(cOptions.profilerIn_, GetFileDelimiter());
ASSERT(!apFileNames.empty());
// just parse the first ap's dir
pkgArgs->SetPgoDir(ResolveDirPath(pandaFileNames.at(0)));
pkgArgs->SetPgoDir(ResolveDirPath(apFileNames.at(0)));
}
// reset profilerIn from pgo dir
pkgArgs->GetPgoPaths(cOptions.profilerIn_, cOptions.needMerge_);

View File

@ -121,16 +121,17 @@ HWTEST_F_L0(OhosTest, AotWhiteListTest)
HWTEST_F_L0(OhosTest, OhosPkgArgsParse)
{
const char *pgoDir = "ohos-OhosPkgArgsParse";
std::string baselineAp = std::string(pgoDir) + "/entry.ap";
std::string runtimeAp = std::string(pgoDir) + "/rt_entry.ap";
mkdir(pgoDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::ofstream file(baselineAp);
std::ofstream file(runtimeAp);
file.close();
AddWhiteList();
arg_list_t pandaFileNames {};
std::map<std::string, std::shared_ptr<OhosPkgArgs>> pkgArgsMap;
PGOProfilerDecoder decoder;
runtimeOptions_.SetPGOProfilerPath(baselineAp);
runtimeOptions_.SetPGOProfilerPath(runtimeAp);
runtimeOptions_.SetCompilerPkgJsonInfo(BuildOhosPkgJson(""));
CompilationOptions cOptions(vm_, runtimeOptions_);
@ -146,7 +147,7 @@ HWTEST_F_L0(OhosTest, OhosPkgArgsParse)
ASSERT_EQ(preProcessor.GetPkgsArgs().size(), 3);
unlink(baselineAp.c_str());
unlink(runtimeAp.c_str());
rmdir(pgoDir);
}
@ -166,18 +167,23 @@ HWTEST_F_L0(OhosTest, UseBaselineApFromPgoDir)
{
const char *pgoDir = "ohos-UseBaselineApFromPgoDir";
std::string baselineAp = std::string(pgoDir) + "/entry.ap";
std::string runtimeAp = std::string(pgoDir) + "/rt_entry.ap";
mkdir(pgoDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::ofstream file(baselineAp);
file.close();
file.open(runtimeAp);
file.close();
// do not add to white list
arg_list_t pandaFileNames {};
std::map<std::string, std::shared_ptr<OhosPkgArgs>> pkgArgsMap;
PGOProfilerDecoder decoder;
CompilationOptions cOptions(vm_, runtimeOptions_);
AotCompilerPreprocessor preProcessor(vm_, runtimeOptions_, pkgArgsMap, decoder, pandaFileNames);
runtimeOptions_.SetCompilerPkgJsonInfo(BuildOhosPkgJson(pgoDir));
ASSERT_TRUE(preProcessor.HandleTargetCompilerMode(cOptions));
ASSERT_FALSE(preProcessor.HandleTargetCompilerMode(cOptions));
ASSERT_EQ(cOptions.profilerIn_, baselineAp);
ASSERT_TRUE(cOptions.profilerIn_.empty());
unlink(baselineAp.c_str());
rmdir(pgoDir);
}