resolved conflicts for merge of 613eae4a to dalvik-dev
Change-Id: I61734cbf585decf9a50ba23f008b341d025339ff
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 179fb1a..c19f872 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -192,7 +192,8 @@
class_roots_(NULL),
array_iftable_(NULL),
init_done_(false),
- is_dirty_(false),
+ dex_caches_dirty_(false),
+ class_table_dirty_(false),
intern_table_(intern_table),
portable_resolution_trampoline_(NULL),
quick_resolution_trampoline_(NULL) {
@@ -1088,24 +1089,32 @@
// Keep in sync with InitCallback. Anything we visit, we need to
// reinit references to when reinitializing a ClassLinker from a
// mapped image.
-void ClassLinker::VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) {
- class_roots_ = reinterpret_cast<mirror::ObjectArray<mirror::Class>*>(visitor(class_roots_, arg));
- DCHECK(class_roots_ != nullptr);
-
+void ClassLinker::VisitRoots(RootVisitor* visitor, void* arg, bool only_dirty, bool clean_dirty) {
+ class_roots_ = down_cast<mirror::ObjectArray<mirror::Class>*>(visitor(class_roots_, arg));
Thread* self = Thread::Current();
{
ReaderMutexLock mu(self, dex_lock_);
- for (mirror::DexCache*& dex_cache : dex_caches_) {
- dex_cache = reinterpret_cast<mirror::DexCache*>(visitor(dex_cache, arg));
- DCHECK(dex_cache != nullptr);
+ if (!only_dirty || dex_caches_dirty_) {
+ for (mirror::DexCache*& dex_cache : dex_caches_) {
+ dex_cache = down_cast<mirror::DexCache*>(visitor(dex_cache, arg));
+ DCHECK(dex_cache != nullptr);
+ }
+ if (clean_dirty) {
+ dex_caches_dirty_ = false;
+ }
}
}
{
ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_);
- for (std::pair<size_t const, mirror::Class*>& it : class_table_) {
- it.second = reinterpret_cast<mirror::Class*>(visitor(it.second, arg));
- DCHECK(it.second != nullptr);
+ if (!only_dirty || class_table_dirty_) {
+ for (std::pair<const size_t, mirror::Class*>& it : class_table_) {
+ it.second = down_cast<mirror::Class*>(visitor(it.second, arg));
+ DCHECK(it.second != nullptr);
+ }
+ if (clean_dirty) {
+ class_table_dirty_ = false;
+ }
}
// We deliberately ignore the class roots in the image since we
@@ -1114,9 +1123,6 @@
array_iftable_ = reinterpret_cast<mirror::IfTable*>(visitor(array_iftable_, arg));
DCHECK(array_iftable_ != nullptr);
- if (clean_dirty) {
- is_dirty_ = false;
- }
}
void ClassLinker::VisitClasses(ClassVisitor* visitor, void* arg) {
@@ -1933,7 +1939,7 @@
CHECK(dex_cache->GetLocation()->Equals(dex_file.GetLocation()));
dex_caches_.push_back(dex_cache.get());
dex_cache->SetDexFile(&dex_file);
- Dirty();
+ dex_caches_dirty_ = true;
}
void ClassLinker::RegisterDexFile(const DexFile& dex_file) {
@@ -2208,7 +2214,7 @@
}
Runtime::Current()->GetHeap()->VerifyObject(klass);
class_table_.insert(std::make_pair(hash, klass));
- Dirty();
+ class_table_dirty_ = true;
return NULL;
}
@@ -2321,7 +2327,7 @@
}
}
}
- Dirty();
+ class_table_dirty_ = true;
dex_cache_image_class_lookup_required_ = false;
self->EndAssertNoThreadSuspension(old_no_suspend_cause);
}