Change dex caches to be weak roots
Changed dex caches to be weak roots. This is necessary for class
unloading since the resolved types arrays would keep classes live
when they should be unloaded. Currently the dex caches still don't
get freed due to the class loader roots.
Also deleted some unused functionality in image writer.
Bug: 22720414
Change-Id: If22cb3cad7e3baabc8158a77d7f20799faf4c341
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 1912314..49451ad 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -791,6 +791,12 @@
return failure_count;
}
+void Runtime::SetSentinel(mirror::Object* sentinel) {
+ CHECK(sentinel_.Read() == nullptr);
+ CHECK(sentinel != nullptr);
+ sentinel_ = GcRoot<mirror::Object>(sentinel);
+}
+
bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) {
ATRACE_BEGIN("Runtime::Init");
CHECK_EQ(sysconf(_SC_PAGE_SIZE), kPageSize);
@@ -1054,10 +1060,6 @@
CHECK(class_linker_ != nullptr);
- // Initialize the special sentinel_ value early.
- sentinel_ = GcRoot<mirror::Object>(class_linker_->AllocObject(self));
- CHECK(sentinel_.Read() != nullptr);
-
verifier::MethodVerifier::Init();
if (runtime_options.Exists(Opt::MethodTrace)) {