diff options
| author | 2016-05-25 18:17:53 +0000 | |
|---|---|---|
| committer | 2016-05-25 18:17:53 +0000 | |
| commit | f736a55d849d18767b827e7efeb9114f80e4e660 (patch) | |
| tree | d2b1d31fcd33d55ef1467e85ba3825bdddcd3ae7 | |
| parent | 29a7c68d297b6494a8c10ec1b67a8726d71f86f0 (diff) | |
| parent | 06e3f4fa00ea9f71c4675f90e250e59b6d9ba36f (diff) | |
Merge changes I5c891dc1,Ie717089d
* changes:
Base isDexOptNeeded result on OatFileAssistant::IsUpToDate.
Only compile dex files if they are not up to date.
| -rw-r--r-- | runtime/native/dalvik_system_DexFile.cc | 25 | ||||
| -rw-r--r-- | runtime/oat_file_assistant.cc | 4 | ||||
| -rw-r--r-- | runtime/oat_file_assistant.h | 4 | ||||
| -rw-r--r-- | runtime/oat_file_manager.cc | 32 |
4 files changed, 41 insertions, 24 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 0126b4d0a4..f30f7a641e 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -475,15 +475,22 @@ static jint DexFile_getDexOptNeeded(JNIEnv* env, // public API static jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename) { - const char* instruction_set = GetInstructionSetString(kRuntimeISA); - ScopedUtfChars filename(env, javaFilename); - jint status = GetDexOptNeeded( - env, - filename.c_str(), - instruction_set, - "speed-profile", - /*profile_changed*/false); - return (status != OatFileAssistant::kNoDexOptNeeded) ? JNI_TRUE : JNI_FALSE; + ScopedUtfChars filename_utf(env, javaFilename); + if (env->ExceptionCheck()) { + return JNI_FALSE; + } + + const char* filename = filename_utf.c_str(); + if ((filename == nullptr) || !OS::FileExists(filename)) { + LOG(ERROR) << "DexFile_isDexOptNeeded file '" << filename << "' does not exist"; + ScopedLocalRef<jclass> fnfe(env, env->FindClass("java/io/FileNotFoundException")); + const char* message = (filename == nullptr) ? "<empty file name>" : filename; + env->ThrowNew(fnfe.get(), message); + return JNI_FALSE; + } + + OatFileAssistant oat_file_assistant(filename, kRuntimeISA, false, false); + return oat_file_assistant.IsUpToDate() ? JNI_FALSE : JNI_TRUE; } static jboolean DexFile_isValidCompilerFilter(JNIEnv* env, diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index 64b40b71b6..218c490b35 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -220,6 +220,10 @@ static bool GetRuntimeCompilerFilterOption(CompilerFilter::Filter* filter, return true; } +bool OatFileAssistant::IsUpToDate() { + return OatFileIsUpToDate() || OdexFileIsUpToDate(); +} + OatFileAssistant::ResultOfAttemptToUpdate OatFileAssistant::MakeUpToDate(std::string* error_msg) { CompilerFilter::Filter target; diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h index f48cdf343c..bb7b40828e 100644 --- a/runtime/oat_file_assistant.h +++ b/runtime/oat_file_assistant.h @@ -149,6 +149,10 @@ class OatFileAssistant { // given compiler filter. DexOptNeeded GetDexOptNeeded(CompilerFilter::Filter target_compiler_filter); + // Returns true if there is up-to-date code for this dex location, + // irrespective of the compiler filter of the up-to-date code. + bool IsUpToDate(); + // Return code used when attempting to generate updated code. enum ResultOfAttemptToUpdate { kUpdateFailed, // We tried making the code up to date, but diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc index 0af6716af7..c6a59c2611 100644 --- a/runtime/oat_file_manager.cc +++ b/runtime/oat_file_manager.cc @@ -586,23 +586,25 @@ std::vector<std::unique_ptr<const DexFile>> OatFileManager::OpenDexFilesFromOat( const OatFile* source_oat_file = nullptr; - // Update the oat file on disk if we can, based on the --compiler-filter - // option derived from the current runtime options. - // This may fail, but that's okay. Best effort is all that matters here. - switch (oat_file_assistant.MakeUpToDate(/*out*/ &error_msg)) { - case OatFileAssistant::kUpdateFailed: - LOG(WARNING) << error_msg; - break; + if (!oat_file_assistant.IsUpToDate()) { + // Update the oat file on disk if we can, based on the --compiler-filter + // option derived from the current runtime options. + // This may fail, but that's okay. Best effort is all that matters here. + switch (oat_file_assistant.MakeUpToDate(/*out*/ &error_msg)) { + case OatFileAssistant::kUpdateFailed: + LOG(WARNING) << error_msg; + break; - case OatFileAssistant::kUpdateNotAttempted: - // Avoid spamming the logs if we decided not to attempt making the oat - // file up to date. - VLOG(oat) << error_msg; - break; + case OatFileAssistant::kUpdateNotAttempted: + // Avoid spamming the logs if we decided not to attempt making the oat + // file up to date. + VLOG(oat) << error_msg; + break; - case OatFileAssistant::kUpdateSucceeded: - // Nothing to do. - break; + case OatFileAssistant::kUpdateSucceeded: + // Nothing to do. + break; + } } // Get the oat file on disk. |