diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/driver/compiler_driver_test.cc | 8 | ||||
-rw-r--r-- | compiler/image_writer.cc | 43 | ||||
-rw-r--r-- | compiler/image_writer.h | 4 | ||||
-rw-r--r-- | compiler/jni/jni_compiler_test.cc | 5 |
4 files changed, 30 insertions, 30 deletions
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 96f17accad..e323b1684a 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -207,8 +207,8 @@ TEST_F(CompilerDriverMethodsTest, Selection) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ScopedObjectAccess soa(self); StackHandleScope<1> hs(self); - Handle<mirror::ClassLoader> h_loader(hs.NewHandle( - reinterpret_cast<mirror::ClassLoader*>(self->DecodeJObject(class_loader)))); + Handle<mirror::ClassLoader> h_loader( + hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader))); mirror::Class* klass = class_linker->FindClass(self, "LStaticLeafMethods;", h_loader); ASSERT_NE(klass, nullptr); @@ -265,8 +265,8 @@ class CompilerDriverProfileTest : public CompilerDriverTest { Thread* self = Thread::Current(); ScopedObjectAccess soa(self); StackHandleScope<1> hs(self); - Handle<mirror::ClassLoader> h_loader(hs.NewHandle( - reinterpret_cast<mirror::ClassLoader*>(self->DecodeJObject(class_loader)))); + Handle<mirror::ClassLoader> h_loader( + hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader))); mirror::Class* klass = class_linker->FindClass(self, clazz.c_str(), h_loader); ASSERT_NE(klass, nullptr); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 66938b2e07..8ae04a1e49 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -433,9 +433,9 @@ void ImageWriter::PrepareDexCacheArraySlots() { Thread* const self = Thread::Current(); ReaderMutexLock mu(self, *class_linker->DexLock()); for (const ClassLinker::DexCacheData& data : class_linker->GetDexCachesData()) { - mirror::DexCache* dex_cache = - down_cast<mirror::DexCache*>(self->DecodeJObject(data.weak_root)); - if (dex_cache == nullptr || IsInBootImage(dex_cache)) { + ObjPtr<mirror::DexCache> dex_cache = + ObjPtr<mirror::DexCache>::DownCast(self->DecodeJObject(data.weak_root)); + if (dex_cache == nullptr || IsInBootImage(dex_cache.Ptr())) { continue; } const DexFile* dex_file = dex_cache->GetDexFile(); @@ -464,7 +464,9 @@ void ImageWriter::PrepareDexCacheArraySlots() { } } -void ImageWriter::AddDexCacheArrayRelocation(void* array, size_t offset, DexCache* dex_cache) { +void ImageWriter::AddDexCacheArrayRelocation(void* array, + size_t offset, + ObjPtr<mirror::DexCache> dex_cache) { if (array != nullptr) { DCHECK(!IsInBootImage(array)); size_t oat_index = GetOatIndexForDexCache(dex_cache); @@ -878,7 +880,7 @@ void ImageWriter::PruneNonImageClasses() { if (self->IsJWeakCleared(data.weak_root)) { continue; } - mirror::DexCache* dex_cache = self->DecodeJObject(data.weak_root)->AsDexCache(); + ObjPtr<mirror::DexCache> dex_cache = self->DecodeJObject(data.weak_root)->AsDexCache(); for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { Class* klass = dex_cache->GetResolvedType(i); if (klass != nullptr && !KeepClass(klass)) { @@ -1005,13 +1007,13 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots(size_t oat_index) const { ReaderMutexLock mu(self, *class_linker->DexLock()); // Count number of dex caches not in the boot image. for (const ClassLinker::DexCacheData& data : class_linker->GetDexCachesData()) { - mirror::DexCache* dex_cache = - down_cast<mirror::DexCache*>(self->DecodeJObject(data.weak_root)); + ObjPtr<mirror::DexCache> dex_cache = + ObjPtr<mirror::DexCache>::DownCast(self->DecodeJObject(data.weak_root)); if (dex_cache == nullptr) { continue; } const DexFile* dex_file = dex_cache->GetDexFile(); - if (!IsInBootImage(dex_cache)) { + if (!IsInBootImage(dex_cache.Ptr())) { dex_cache_count += image_dex_files.find(dex_file) != image_dex_files.end() ? 1u : 0u; } } @@ -1024,13 +1026,13 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots(size_t oat_index) const { size_t non_image_dex_caches = 0; // Re-count number of non image dex caches. for (const ClassLinker::DexCacheData& data : class_linker->GetDexCachesData()) { - mirror::DexCache* dex_cache = - down_cast<mirror::DexCache*>(self->DecodeJObject(data.weak_root)); + ObjPtr<mirror::DexCache> dex_cache = + ObjPtr<mirror::DexCache>::DownCast(self->DecodeJObject(data.weak_root)); if (dex_cache == nullptr) { continue; } const DexFile* dex_file = dex_cache->GetDexFile(); - if (!IsInBootImage(dex_cache)) { + if (!IsInBootImage(dex_cache.Ptr())) { non_image_dex_caches += image_dex_files.find(dex_file) != image_dex_files.end() ? 1u : 0u; } } @@ -1038,14 +1040,15 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots(size_t oat_index) const { << "The number of non-image dex caches changed."; size_t i = 0; for (const ClassLinker::DexCacheData& data : class_linker->GetDexCachesData()) { - mirror::DexCache* dex_cache = - down_cast<mirror::DexCache*>(self->DecodeJObject(data.weak_root)); + ObjPtr<mirror::DexCache> dex_cache = + ObjPtr<mirror::DexCache>::DownCast(self->DecodeJObject(data.weak_root)); if (dex_cache == nullptr) { continue; } const DexFile* dex_file = dex_cache->GetDexFile(); - if (!IsInBootImage(dex_cache) && image_dex_files.find(dex_file) != image_dex_files.end()) { - dex_caches->Set<false>(i, dex_cache); + if (!IsInBootImage(dex_cache.Ptr()) && + image_dex_files.find(dex_file) != image_dex_files.end()) { + dex_caches->Set<false>(i, dex_cache.Ptr()); ++i; } } @@ -2384,12 +2387,10 @@ size_t ImageWriter::GetOatIndexForDexFile(const DexFile* dex_file) const { return it->second; } -size_t ImageWriter::GetOatIndexForDexCache(mirror::DexCache* dex_cache) const { - if (dex_cache == nullptr) { - return GetDefaultOatIndex(); - } else { - return GetOatIndexForDexFile(dex_cache->GetDexFile()); - } +size_t ImageWriter::GetOatIndexForDexCache(ObjPtr<mirror::DexCache> dex_cache) const { + return (dex_cache == nullptr) + ? GetDefaultOatIndex() + : GetOatIndexForDexFile(dex_cache->GetDexFile()); } void ImageWriter::UpdateOatFileLayout(size_t oat_index, diff --git a/compiler/image_writer.h b/compiler/image_writer.h index acd16813cb..c9cf4cbc1b 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -132,7 +132,7 @@ class ImageWriter FINAL { size_t GetOatIndexForDexFile(const DexFile* dex_file) const; // Get the index of the oat file containing the dex file served by the dex cache. - size_t GetOatIndexForDexCache(mirror::DexCache* dex_cache) const + size_t GetOatIndexForDexCache(ObjPtr<mirror::DexCache> dex_cache) const REQUIRES_SHARED(Locks::mutator_lock_); // Update the oat layout for the given oat file. @@ -334,7 +334,7 @@ class ImageWriter FINAL { REQUIRES_SHARED(Locks::mutator_lock_); BinSlot GetImageBinSlot(mirror::Object* object) const REQUIRES_SHARED(Locks::mutator_lock_); - void AddDexCacheArrayRelocation(void* array, size_t offset, mirror::DexCache* dex_cache) + void AddDexCacheArrayRelocation(void* array, size_t offset, ObjPtr<mirror::DexCache> dex_cache) REQUIRES_SHARED(Locks::mutator_lock_); void AddMethodPointerArray(mirror::PointerArray* arr) REQUIRES_SHARED(Locks::mutator_lock_); diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc index 6b56fe0b7f..36e252742c 100644 --- a/compiler/jni/jni_compiler_test.cc +++ b/compiler/jni/jni_compiler_test.cc @@ -523,8 +523,7 @@ bool ScopedDisableCheckNumStackReferences::sCheckNumStackReferences = true; // Check that the handle scope at the start of this block is the same as the handle scope at the end of the block. struct ScopedCheckHandleScope { - ScopedCheckHandleScope() { - handle_scope_ = Thread::Current()->GetTopHandleScope(); + ScopedCheckHandleScope() : handle_scope_(Thread::Current()->GetTopHandleScope()) { } ~ScopedCheckHandleScope() { @@ -533,7 +532,7 @@ struct ScopedCheckHandleScope { << "invocations have finished (as before they were invoked)."; } - HandleScope* handle_scope_; + HandleScope* const handle_scope_; }; static void expectNumStackReferences(size_t val1, size_t val2) { |