Change root visitor to use Object**.
Simplifies code and improves the performance of root visiting since
we usually don't need to check to see if the object moved.
Change-Id: Iba998f5a15ae1fa1b53ca5226dd2168a411196cf
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3863ee5..f8a20d0 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1120,14 +1120,13 @@
// reinit references to when reinitializing a ClassLinker from a
// mapped image.
void ClassLinker::VisitRoots(RootCallback* callback, void* arg, bool only_dirty, bool clean_dirty) {
- class_roots_ = down_cast<mirror::ObjectArray<mirror::Class>*>(
- callback(class_roots_, arg, 0, kRootVMInternal));
+ callback(reinterpret_cast<mirror::Object**>(&class_roots_), arg, 0, kRootVMInternal);
Thread* self = Thread::Current();
{
ReaderMutexLock mu(self, dex_lock_);
if (!only_dirty || dex_caches_dirty_) {
for (mirror::DexCache*& dex_cache : dex_caches_) {
- dex_cache = down_cast<mirror::DexCache*>(callback(dex_cache, arg, 0, kRootVMInternal));
+ callback(reinterpret_cast<mirror::Object**>(&dex_cache), arg, 0, kRootVMInternal);
DCHECK(dex_cache != nullptr);
}
if (clean_dirty) {
@@ -1135,25 +1134,21 @@
}
}
}
-
{
WriterMutexLock mu(self, *Locks::classlinker_classes_lock_);
if (!only_dirty || class_table_dirty_) {
for (std::pair<const size_t, mirror::Class*>& it : class_table_) {
- it.second = down_cast<mirror::Class*>(callback(it.second, arg, 0, kRootStickyClass));
+ callback(reinterpret_cast<mirror::Object**>(&it.second), arg, 0, kRootStickyClass);
DCHECK(it.second != nullptr);
}
if (clean_dirty) {
class_table_dirty_ = false;
}
}
-
// We deliberately ignore the class roots in the image since we
// handle image roots by using the MS/CMS rescanning of dirty cards.
}
-
- array_iftable_ = reinterpret_cast<mirror::IfTable*>(callback(array_iftable_, arg, 0,
- kRootVMInternal));
+ callback(reinterpret_cast<mirror::Object**>(&array_iftable_), arg, 0, kRootVMInternal);
DCHECK(array_iftable_ != nullptr);
}