#include "base/unix_file/fd_file.h"
#include "globals.h"
#include "os.h"
+#include "runtime.h"
#include "utils.h"
namespace art {
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
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;"),
"(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) {
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();
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();
// 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);