From 69a0405e79fc9b61e90d6cf0364f85f10fa29a36 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 2 Feb 2016 14:43:28 +0000 Subject: [PATCH] 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 --- runtime/class_linker.cc | 9 +++++---- runtime/utils/dex_cache_arrays_layout-inl.h | 6 ++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c73949088..777786cad 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1230,7 +1230,6 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( DCHECK(strings[j].IsNull()); } std::copy_n(image_resolved_strings, num_strings, strings); - *reinterpret_cast**>(image_resolved_strings) = strings; dex_cache->SetStrings(strings); } if (num_types != 0u) { @@ -1406,10 +1405,12 @@ class UpdateClassLoaderAndResolvedStringsVisitor { if (forward_strings_) { GcRoot* strings = klass->GetDexCacheStrings(); if (strings != nullptr) { - DCHECK(space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains( - reinterpret_cast(strings) - space_->Begin())) + DCHECK( + space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains( + reinterpret_cast(strings) - space_->Begin())) << "String dex cache array for " << PrettyClass(klass) << " is not in app image"; - GcRoot* new_strings = *reinterpret_cast**>(strings); + // Dex caches have already been updated, so take the strings pointer from there. + GcRoot* 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 d63083c5c..f6ee6a2b1 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::StringOffset(uint32_t string_idx) const { } 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), num_elements), pointer_size_); + return ArraySize(sizeof(GcRoot), 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); } inline size_t DexCacheArraysLayout::FieldOffset(uint32_t field_idx) const { -- 2.11.0