summaryrefslogtreecommitdiff
path: root/runtime/oat_file_assistant.cc
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2017-08-03 17:07:13 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-08-03 17:07:13 +0000
commitcda934e3f8c24d76cc3b1b64e24dd9b865cb500f (patch)
treeab8b7b8539a7f3fafc56a42242bf88ac3653441a /runtime/oat_file_assistant.cc
parent9a19be9c170e094c3e5ef991d018b476008112c5 (diff)
parent84f82b9972ec29bd05b1575ae6d638255be2f285 (diff)
Merge changes Iba4cb348,I51c43230,Iae90c4a1,Ica43ee8a
* changes: Stop using the runtime classpath in dex2oat Do not pass --runtime-arg -classpath in dex2oat_test Do not pass --runtime-arg -classpath to dex2oat in dex fuzz Pass the class loader context to dex2oat when optimizing at runtime
Diffstat (limited to 'runtime/oat_file_assistant.cc')
-rw-r--r--runtime/oat_file_assistant.cc31
1 files changed, 20 insertions, 11 deletions
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index dae41c1b67..3794f51cb7 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -37,6 +37,7 @@
#include "scoped_thread_state_change-inl.h"
#include "utils.h"
#include "vdex_file.h"
+#include "class_loader_context.h"
namespace art {
@@ -225,13 +226,25 @@ bool OatFileAssistant::IsUpToDate() {
}
OatFileAssistant::ResultOfAttemptToUpdate
-OatFileAssistant::MakeUpToDate(bool profile_changed, std::string* error_msg) {
+OatFileAssistant::MakeUpToDate(bool profile_changed,
+ const std::string& class_loader_context,
+ std::string* error_msg) {
CompilerFilter::Filter target;
if (!GetRuntimeCompilerFilterOption(&target, error_msg)) {
return kUpdateNotAttempted;
}
OatFileInfo& info = GetBestInfo();
+ // TODO(calin, jeffhao): the context should really be passed to GetDexOptNeeded: b/62269291.
+ // This is actually not trivial in the current logic as it will interact with the collision
+ // check:
+ // - currently, if the context does not match but we have no collisions we still accept the
+ // oat file.
+ // - if GetDexOptNeeded would return kDex2OatFromScratch for a context mismatch and we make
+ // the oat code up to date the collision check becomes useless.
+ // - however, MakeUpToDate will not always succeed (e.g. for primary apks, or for dex files
+ // loaded in other processes). So it boils down to how far do we want to complicate
+ // the logic in order to enable the use of oat files. Maybe its time to try simplify it.
switch (info.GetDexOptNeeded(target, profile_changed, /*downgrade*/ false)) {
case kNoDexOptNeeded:
return kUpdateSucceeded;
@@ -243,7 +256,7 @@ OatFileAssistant::MakeUpToDate(bool profile_changed, std::string* error_msg) {
case kDex2OatForBootImage:
case kDex2OatForRelocation:
case kDex2OatForFilter:
- return GenerateOatFileNoChecks(info, target, error_msg);
+ return GenerateOatFileNoChecks(info, target, class_loader_context, error_msg);
}
UNREACHABLE();
}
@@ -628,7 +641,10 @@ static bool PrepareOdexDirectories(const std::string& dex_location,
}
OatFileAssistant::ResultOfAttemptToUpdate OatFileAssistant::GenerateOatFileNoChecks(
- OatFileAssistant::OatFileInfo& info, CompilerFilter::Filter filter, std::string* error_msg) {
+ OatFileAssistant::OatFileInfo& info,
+ CompilerFilter::Filter filter,
+ const std::string& class_loader_context,
+ std::string* error_msg) {
CHECK(error_msg != nullptr);
Runtime* runtime = Runtime::Current();
@@ -704,6 +720,7 @@ OatFileAssistant::ResultOfAttemptToUpdate OatFileAssistant::GenerateOatFileNoChe
args.push_back("--oat-fd=" + std::to_string(oat_file->Fd()));
args.push_back("--oat-location=" + oat_file_name);
args.push_back("--compiler-filter=" + CompilerFilter::NameOfFilter(filter));
+ args.push_back("--class-loader-context=" + class_loader_context);
if (!Dex2Oat(args, error_msg)) {
// Manually delete the oat and vdex files. This ensures there is no garbage
@@ -743,14 +760,6 @@ bool OatFileAssistant::Dex2Oat(const std::vector<std::string>& args,
std::vector<std::string> argv;
argv.push_back(runtime->GetCompilerExecutable());
- argv.push_back("--runtime-arg");
- argv.push_back("-classpath");
- argv.push_back("--runtime-arg");
- std::string class_path = runtime->GetClassPathString();
- if (class_path == "") {
- class_path = OatFile::kSpecialSharedLibrary;
- }
- argv.push_back(class_path);
if (runtime->IsJavaDebuggable()) {
argv.push_back("--debuggable");
}