diff options
author | Mathieu Chartier <mathieuc@google.com> | 2013-10-23 15:21:37 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2013-10-23 15:38:26 -0700 |
commit | 79b4f38dd35b83206e8166aaafb94bd75c3318b3 (patch) | |
tree | 335bd7217c03932c0875697d431e475b56111cc5 /runtime | |
parent | 1984152ac92aad244ae15184d12f9ceade686b7b (diff) | |
download | art-79b4f38dd35b83206e8166aaafb94bd75c3318b3.zip art-79b4f38dd35b83206e8166aaafb94bd75c3318b3.tar.gz art-79b4f38dd35b83206e8166aaafb94bd75c3318b3.tar.bz2 |
Fix incorrect initial dex cache size.
We were previously setting it to be sizeof(DexCacheClass) instead
of sizeof(DexCache). This was causing some problems with
compaction when I relied on the object sizes being accurate to
visit objects in the bump pointer space.
Bug: 8981901
Change-Id: Iede04763aced041986b1b239368fc867143ad70d
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/class_linker.cc | 7 | ||||
-rw-r--r-- | runtime/mirror/class-inl.h | 4 | ||||
-rw-r--r-- | runtime/mirror/object-inl.h | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index aa5f2bf..663e8b7 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -283,7 +283,7 @@ void ClassLinker::InitFromCompiler(const std::vector<const DexFile*>& boot_class SirtRef<mirror::Class> java_lang_DexCache(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::DexCacheClass))); SetClassRoot(kJavaLangDexCache, java_lang_DexCache.get()); - java_lang_DexCache->SetObjectSize(sizeof(mirror::DexCacheClass)); + java_lang_DexCache->SetObjectSize(sizeof(mirror::DexCache)); java_lang_DexCache->SetStatus(mirror::Class::kStatusResolved, self); // Constructor, Field, Method, and AbstractMethod are necessary so that FindClass can link members. @@ -3911,6 +3911,11 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { klass->SetNumReferenceInstanceFields(num_reference_fields); if (!klass->IsVariableSize()) { DCHECK_GE(size, sizeof(mirror::Object)) << ClassHelper(klass.get(), this).GetDescriptor(); + size_t previous_size = klass->GetObjectSize(); + if (previous_size != 0) { + // Make sure that we didn't originally have an incorrect size. + CHECK_EQ(previous_size, size); + } klass->SetObjectSize(size); } } diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 88cffb7..cd5e865 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -35,9 +35,7 @@ namespace mirror { inline size_t Class::GetObjectSize() const { DCHECK(!IsVariableSize()) << " class=" << PrettyTypeOf(this); DCHECK_EQ(sizeof(size_t), sizeof(int32_t)); - size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), false); - DCHECK_GE(result, sizeof(Object)) << " class=" << PrettyTypeOf(this); - return result; + return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), false); } inline Class* Class::GetSuperClass() const { diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index e659108..e460a8d 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -247,6 +247,7 @@ inline size_t Object::SizeOf() const { } else { result = GetClass()->GetObjectSize(); } + DCHECK_GE(result, sizeof(Object)) << " class=" << PrettyTypeOf(GetClass()); DCHECK(!IsArtField() || result == sizeof(ArtField)); DCHECK(!IsArtMethod() || result == sizeof(ArtMethod)); return result; |