diff options
author | 2023-03-07 16:04:03 +0000 | |
---|---|---|
committer | 2023-03-08 13:54:07 +0000 | |
commit | a18f534adf549ce057297b88f6125639203bd769 (patch) | |
tree | 9d4382bf7d79b02d926922415c695c3d2fd40c27 | |
parent | a74489b60d1a95e39a8ec315ebd663a40576a21e (diff) |
Address review comments in runtime app image.
Address review comments from
https://android-review.git.corp.google.com/c/platform/art/+/2430761
Test: test.py
Bug: 260557058
Change-Id: If6dafa4957e4cb6f9bd53d139b0519c931ec798c
-rw-r--r-- | runtime/gc/space/image_space.cc | 3 | ||||
-rw-r--r-- | runtime/mirror/dex_cache.h | 6 | ||||
-rw-r--r-- | runtime/runtime_image.cc | 14 |
3 files changed, 12 insertions, 11 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index d5ac3e6845..0bfc087881 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -1365,7 +1365,8 @@ class ImageSpace::Loader { image_header->GetImageRoot<kWithoutReadBarrier>(ImageHeader::kDexCaches) ->AsObjectArray<mirror::DexCache, kVerifyNone>(); for (int32_t i = 0, count = dex_caches->GetLength(); i < count; ++i) { - ObjPtr<mirror::DexCache> dex_cache = dex_caches->Get<kVerifyNone, kWithoutReadBarrier>(i); + ObjPtr<mirror::DexCache> dex_cache = + dex_caches->GetWithoutChecks<kVerifyNone, kWithoutReadBarrier>(i); patch_object_visitor.VisitDexCacheArrays(dex_cache); } } diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 099fe00656..20e3e6c253 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -238,11 +238,9 @@ template <typename T> class NativeArray { T** GetPtrEntryPtrSize(uint32_t index, PointerSize ptr_size) { if (ptr_size == PointerSize::k64) { - return reinterpret_cast<T**>( - reinterpret_cast64<uint64_t>(entries_) + index * sizeof(uint64_t)); + return reinterpret_cast<T**>(reinterpret_cast<uint64_t*>(entries_) + index); } else { - return reinterpret_cast<T**>( - reinterpret_cast32<uint32_t>(entries_) + index * sizeof(uint32_t)); + return reinterpret_cast<T**>(reinterpret_cast<uint32_t*>(entries_) + index); } } diff --git a/runtime/runtime_image.cc b/runtime/runtime_image.cc index 3f9db03a7b..fb9c90c0b0 100644 --- a/runtime/runtime_image.cc +++ b/runtime/runtime_image.cc @@ -683,12 +683,14 @@ class RuntimeImageHelper { return; } - auto it = native_relocations_[old_method_array]; - std::vector<uint8_t>& data = (it.first == NativeRelocationKind::kFullNativeDexCacheArray) - ? dex_cache_arrays_ : metadata_; + auto it = native_relocations_.find(old_method_array); + DCHECK(it != native_relocations_.end()); + std::vector<uint8_t>& data = + (it->second.first == NativeRelocationKind::kFullNativeDexCacheArray) + ? dex_cache_arrays_ : metadata_; mirror::NativeArray<T>* content_array = - reinterpret_cast<mirror::NativeArray<T>*>(data.data() + it.second); + reinterpret_cast<mirror::NativeArray<T>*>(data.data() + it->second.second); for (uint32_t i = 0; i < num_ids; ++i) { // We may not have relocations for some entries, in which case we'll // just store null. @@ -719,8 +721,8 @@ class RuntimeImageHelper { ScopedTrace relocate_native_pointers("Relocate native pointers"); ScopedObjectAccess soa(Thread::Current()); NativePointerVisitor visitor(this); - for (auto it : classes_) { - mirror::Class* cls = reinterpret_cast<mirror::Class*>(&objects_[it.second]); + for (auto entry : classes_) { + mirror::Class* cls = reinterpret_cast<mirror::Class*>(&objects_[entry.second]); cls->FixupNativePointers(cls, kRuntimePointerSize, visitor); RelocateMethodPointerArrays(cls, visitor); } |