summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2018-06-05 12:51:04 +0100
committer Vladimir Marko <vmarko@google.com> 2018-06-07 14:24:02 +0100
commitf75613cb7c5cda6a4603ab7041d6f98ec62a80cd (patch)
tree5d253108db708da20e0bbf55a5f3d8e2f8bce4d7 /runtime/class_linker.cc
parent2b40dd35c65ad644d448611750f5b577e97594a1 (diff)
Keep objects for Integer.valueOf() intrinsic alive.
Keep boot image objects referenced by the intrinsic alive through boot image roots, so that they can never be dead as the intrinsic would still be able to resurrect them later. Note that currently the GC considers all boot image objects live forever. That risks leaking memory and should be fixed. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 71526895 Change-Id: Iec25cc27e9c5c4bd3c5711991e3111bfb19ef182
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index be636d80a8..45332c8a1a 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -990,8 +990,7 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) {
class_roots_ = GcRoot<mirror::ObjectArray<mirror::Class>>(
ObjPtr<mirror::ObjectArray<mirror::Class>>::DownCast(MakeObjPtr(
spaces[0]->GetImageHeader().GetImageRoot(ImageHeader::kClassRoots))));
- DCHECK_EQ(GetClassRoot(ClassRoot::kJavaLangClass, this)->GetClassFlags(),
- mirror::kClassFlagClass);
+ DCHECK_EQ(GetClassRoot<mirror::Class>(this)->GetClassFlags(), mirror::kClassFlagClass);
ObjPtr<mirror::Class> java_lang_Object = GetClassRoot<mirror::Object>(this);
java_lang_Object->SetObjectSize(sizeof(mirror::Object));
@@ -1610,10 +1609,9 @@ bool ClassLinker::AddImageSpace(
hs.NewHandle(dex_caches_object->AsObjectArray<mirror::DexCache>()));
Handle<mirror::ObjectArray<mirror::Class>> class_roots(hs.NewHandle(
header.GetImageRoot(ImageHeader::kClassRoots)->AsObjectArray<mirror::Class>()));
- static_assert(ImageHeader::kClassLoader + 1u == ImageHeader::kImageRootsMax,
- "Class loader should be the last image root.");
MutableHandle<mirror::ClassLoader> image_class_loader(hs.NewHandle(
- app_image ? header.GetImageRoot(ImageHeader::kClassLoader)->AsClassLoader() : nullptr));
+ app_image ? header.GetImageRoot(ImageHeader::kAppImageClassLoader)->AsClassLoader()
+ : nullptr));
DCHECK(class_roots != nullptr);
if (class_roots->GetLength() != static_cast<int32_t>(ClassRoot::kMax)) {
*error_msg = StringPrintf("Expected %d class roots but got %d",