OSDN Git Service

ART: Added DCHECKS to find alignment breakage.
authorChristina Wadsworth <cwadsworth@google.com>
Fri, 19 Aug 2016 22:58:05 +0000 (15:58 -0700)
committerChristina Wadsworth <cwadsworth@google.com>
Fri, 19 Aug 2016 23:06:18 +0000 (16:06 -0700)
Change-Id: I47aed866ec3c3858dc3ee27cb84cfaddf44009d1

runtime/class_linker.cc
runtime/utils/dex_cache_arrays_layout-inl.h

index 9b0fb7d..1a3bba5 100644 (file)
@@ -2096,8 +2096,12 @@ mirror::DexCache* ClassLinker::AllocDexCache(Thread* self,
   if (dex_file.NumStringIds() < num_strings) {
     num_strings = dex_file.NumStringIds();
   }
+  DCHECK_ALIGNED(raw_arrays, alignof(mirror::StringDexCacheType)) <<
+                 "Expected raw_arrays to align to StringDexCacheType.";
+  DCHECK_ALIGNED(layout.StringsOffset(), alignof(mirror::StringDexCacheType)) <<
+                 "Expected StringsOffset() to align to StringDexCacheType.";
   DCHECK_ALIGNED(strings, alignof(mirror::StringDexCacheType)) <<
-                "Expected strings to align to StringDexCacheType.";
+                 "Expected strings to align to StringDexCacheType.";
   static_assert(alignof(mirror::StringDexCacheType) == 8u,
                 "Expected StringDexCacheType to have align of 8.");
   if (kIsDebugBuild) {
index c2b2f65..4c63156 100644 (file)
@@ -100,6 +100,8 @@ inline size_t DexCacheArraysLayout::StringsSize(size_t num_elements) const {
 }
 
 inline size_t DexCacheArraysLayout::StringsAlignment() const {
+  static_assert(alignof(mirror::StringDexCacheType) == 8,
+                "Expecting alignof(StringDexCacheType) == 8");
   return alignof(mirror::StringDexCacheType);
 }