Fix up dex cache strings stored in classes

Previously we left the image pointer instead of fixing up the pointer
to the one in the BSS. This only showed up because JIT does the same
as boot image, bypassing null check.

Fixed a bug where oat files without embedded dex cache arrays would
get their dex cache arrays corrupted.

Added a non virtual class visitor for performance.

Bug: 26846419
Bug: 22858531

Change-Id: I8cd0d61e440f753b4628ddb8c932eb23a0a81027
diff --git a/runtime/utils/dex_cache_arrays_layout-inl.h b/runtime/utils/dex_cache_arrays_layout-inl.h
index f6ee6a2..d63083c 100644
--- a/runtime/utils/dex_cache_arrays_layout-inl.h
+++ b/runtime/utils/dex_cache_arrays_layout-inl.h
@@ -87,11 +87,13 @@
 }
 
 inline size_t DexCacheArraysLayout::StringsSize(size_t num_elements) const {
-  return ArraySize(sizeof(GcRoot<mirror::String>), num_elements);
+  // 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_);
 }
 
 inline size_t DexCacheArraysLayout::StringsAlignment() const {
-  return alignof(GcRoot<mirror::String>);
+  // App image patching relies on having enough room for a forwarding pointer in the strings array.
+  return pointer_size_;
 }
 
 inline size_t DexCacheArraysLayout::FieldOffset(uint32_t field_idx) const {