Record foreign dex files loaded by the app in the profile
A foreign dex file is a file which is not owned by the app
(it's not part of its code paths or its private data directory).
When such a dex file is loaded by the app, the runtime will record
a marker in a dedicated profile folder (foreing_dex_profile_path).
The marker is just a file named after the canonical location of the
dex file where '/' is replaced by '@'.
The markers will be used by the system server system server to
decide if the apk should be fully or profile guide compiled.
Bug: 27334750
Bug: 26080105
(cherry picked from commit 86a9ebe4197e963249ffbbaa1830da97ed642fa5)
Change-Id: I8be1fd4d854fa1e23c3c1054c9c083ad7b27317b
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 47ef214..c2d2dca 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -120,6 +120,7 @@
#include "os.h"
#include "parsed_options.h"
#include "profiler.h"
+#include "jit/profile_saver.h"
#include "quick/quick_method_frame_info.h"
#include "reflection.h"
#include "runtime_options.h"
@@ -1717,7 +1718,9 @@
}
void Runtime::RegisterAppInfo(const std::vector<std::string>& code_paths,
- const std::string& profile_output_filename) {
+ const std::string& profile_output_filename,
+ const std::string& foreign_dex_profile_path,
+ const std::string& app_dir) {
if (jit_.get() == nullptr) {
// We are not JITing. Nothing to do.
return;
@@ -1740,7 +1743,18 @@
}
profile_output_filename_ = profile_output_filename;
- jit_->StartProfileSaver(profile_output_filename, code_paths);
+ jit_->StartProfileSaver(profile_output_filename,
+ code_paths,
+ foreign_dex_profile_path,
+ app_dir);
+}
+
+void Runtime::NotifyDexLoaded(const std::string& dex_location) {
+ VLOG(profiler) << "Notify dex loaded: " << dex_location;
+ // We know that if the ProfileSaver is started then we can record profile information.
+ if (ProfileSaver::IsStarted()) {
+ ProfileSaver::NotifyDexUse(dex_location);
+ }
}
// Transaction support.