ART: Clean up strings fixup for app images.
This is a follow-up to
https://android-review.googlesource.com/199854 .
Bug: 26846419
Bug: 22858531
Change-Id: Ib2b2c299c51686afb7f297697125296705ed77b8
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c739490..777786c 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1230,7 +1230,6 @@
DCHECK(strings[j].IsNull());
}
std::copy_n(image_resolved_strings, num_strings, strings);
- *reinterpret_cast<GcRoot<mirror::String>**>(image_resolved_strings) = strings;
dex_cache->SetStrings(strings);
}
if (num_types != 0u) {
@@ -1406,10 +1405,12 @@
if (forward_strings_) {
GcRoot<mirror::String>* strings = klass->GetDexCacheStrings();
if (strings != nullptr) {
- DCHECK(space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
- reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
+ DCHECK(
+ space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
+ reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
<< "String dex cache array for " << PrettyClass(klass) << " is not in app image";
- GcRoot<mirror::String>* new_strings = *reinterpret_cast<GcRoot<mirror::String>**>(strings);
+ // Dex caches have already been updated, so take the strings pointer from there.
+ GcRoot<mirror::String>* new_strings = klass->GetDexCache()->GetStrings();
DCHECK_NE(strings, new_strings);
klass->SetDexCacheStrings(new_strings);
}
diff --git a/runtime/utils/dex_cache_arrays_layout-inl.h b/runtime/utils/dex_cache_arrays_layout-inl.h
index d63083c..f6ee6a2 100644
--- a/runtime/utils/dex_cache_arrays_layout-inl.h
+++ b/runtime/utils/dex_cache_arrays_layout-inl.h
@@ -87,13 +87,11 @@
}
inline size_t DexCacheArraysLayout::StringsSize(size_t num_elements) const {
- // App image patching relies on having enough room for a forwarding pointer in the types array.
- return std::max(ArraySize(sizeof(GcRoot<mirror::String>), num_elements), pointer_size_);
+ return ArraySize(sizeof(GcRoot<mirror::String>), num_elements);
}
inline size_t DexCacheArraysLayout::StringsAlignment() const {
- // App image patching relies on having enough room for a forwarding pointer in the strings array.
- return pointer_size_;
+ return alignof(GcRoot<mirror::String>);
}
inline size_t DexCacheArraysLayout::FieldOffset(uint32_t field_idx) const {