diff options
| -rw-r--r-- | runtime/gc/space/image_space_fs.h | 6 | ||||
| -rw-r--r-- | runtime/native/dalvik_system_VMRuntime.cc | 6 | ||||
| -rw-r--r-- | runtime/runtime.cc | 3 | ||||
| -rw-r--r-- | runtime/runtime.h | 11 |
4 files changed, 25 insertions, 1 deletions
diff --git a/runtime/gc/space/image_space_fs.h b/runtime/gc/space/image_space_fs.h index ec4bf92a2a..5237466c00 100644 --- a/runtime/gc/space/image_space_fs.h +++ b/runtime/gc/space/image_space_fs.h @@ -26,6 +26,7 @@ #include "base/unix_file/fd_file.h" #include "globals.h" #include "os.h" +#include "runtime.h" #include "utils.h" namespace art { @@ -200,6 +201,11 @@ static void PruneDalvikCache(InstructionSet isa) { impl::DeleteDirectoryContents(GetDalvikCacheOrDie(".", false), false); // Prune /data/dalvik-cache/<isa>. impl::DeleteDirectoryContents(GetDalvikCacheOrDie(GetInstructionSetString(isa), false), false); + + // Be defensive. There should be a runtime created here, but this may be called in a test. + if (Runtime::Current() != nullptr) { + Runtime::Current()->SetPrunedDalvikCache(true); + } } // We write out an empty file to the zygote's ISA specific cache dir at the start of diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index f6b2f21515..4ac28ae593 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -622,6 +622,11 @@ static jstring VMRuntime_getCurrentInstructionSet(JNIEnv* env, jclass) { return env->NewStringUTF(GetInstructionSetString(kRuntimeISA)); } +static jboolean VMRuntime_didPruneDalvikCache(JNIEnv* env ATTRIBUTE_UNUSED, + jclass klass ATTRIBUTE_UNUSED) { + return Runtime::Current()->GetPrunedDalvikCache() ? JNI_TRUE : JNI_FALSE; +} + static JNINativeMethod gMethods[] = { NATIVE_METHOD(VMRuntime, addressOf, "!(Ljava/lang/Object;)J"), NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"), @@ -657,6 +662,7 @@ static JNINativeMethod gMethods[] = { "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V"), NATIVE_METHOD(VMRuntime, isBootClassPathOnDisk, "(Ljava/lang/String;)Z"), NATIVE_METHOD(VMRuntime, getCurrentInstructionSet, "()Ljava/lang/String;"), + NATIVE_METHOD(VMRuntime, didPruneDalvikCache, "()Z"), }; void register_dalvik_system_VMRuntime(JNIEnv* env) { diff --git a/runtime/runtime.cc b/runtime/runtime.cc index c8085fbfc7..364ae5d21a 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -207,7 +207,8 @@ Runtime::Runtime() experimental_flags_(ExperimentalFlags::kNone), oat_file_manager_(nullptr), is_low_memory_mode_(false), - safe_mode_(false) { + safe_mode_(false), + pruned_dalvik_cache_(false) { CheckAsmSupportOffsetsAndSizes(); std::fill(callee_save_methods_, callee_save_methods_ + arraysize(callee_save_methods_), 0u); interpreter::CheckInterpreterAsmConstants(); diff --git a/runtime/runtime.h b/runtime/runtime.h index 8e99f800e0..aebfad7989 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -610,6 +610,14 @@ class Runtime { return dump_native_stack_on_sig_quit_; } + bool GetPrunedDalvikCache() const { + return pruned_dalvik_cache_; + } + + void SetPrunedDalvikCache(bool pruned) { + pruned_dalvik_cache_ = pruned; + } + private: static void InitPlatformSignalHandlers(); @@ -822,6 +830,9 @@ class Runtime { // Whether threads should dump their native stack on SIGQUIT. bool dump_native_stack_on_sig_quit_; + // Whether the dalvik cache was pruned when initializing the runtime. + bool pruned_dalvik_cache_; + DISALLOW_COPY_AND_ASSIGN(Runtime); }; std::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs); |