summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 1343b16193..b2e7d99497 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -951,12 +951,12 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) {
gc::Heap* const heap = runtime->GetHeap();
std::vector<gc::space::ImageSpace*> spaces = heap->GetBootImageSpaces();
CHECK(!spaces.empty());
- uint32_t pointer_size_unchecked = spaces[0]->GetImageHeader().GetPointerSizeUnchecked();
+ const ImageHeader& image_header = spaces[0]->GetImageHeader();
+ uint32_t pointer_size_unchecked = image_header.GetPointerSizeUnchecked();
if (!ValidPointerSize(pointer_size_unchecked)) {
*error_msg = StringPrintf("Invalid image pointer size: %u", pointer_size_unchecked);
return false;
}
- const ImageHeader& image_header = spaces[0]->GetImageHeader();
image_pointer_size_ = image_header.GetPointerSize();
if (!runtime->IsAotCompiler()) {
// Only the Aot compiler supports having an image with a different pointer size than the
@@ -1057,15 +1057,15 @@ bool ClassLinker::InitFromBootImage(std::string* error_msg) {
class_roots_ = GcRoot<mirror::ObjectArray<mirror::Class>>(
ObjPtr<mirror::ObjectArray<mirror::Class>>::DownCast(
- spaces[0]->GetImageHeader().GetImageRoot(ImageHeader::kClassRoots)));
+ image_header.GetImageRoot(ImageHeader::kClassRoots)));
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));
- // Allocate in non-movable so that it's possible to check if a JNI weak global ref has been
- // cleared without triggering the read barrier and unintentionally mark the sentinel alive.
- runtime->SetSentinel(heap->AllocNonMovableObject(
- self, java_lang_Object, java_lang_Object->GetObjectSize(), VoidFunctor()));
+ DCHECK_EQ(GetClassRoot<mirror::Object>(this)->GetObjectSize(), sizeof(mirror::Object));
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects =
+ ObjPtr<mirror::ObjectArray<mirror::Object>>::DownCast(
+ image_header.GetImageRoot(ImageHeader::kBootImageLiveObjects));
+ runtime->SetSentinel(boot_image_live_objects->Get(ImageHeader::kClearedJniWeakSentinel));
+ DCHECK(runtime->GetSentinel().Read()->GetClass() == GetClassRoot<mirror::Object>(this));
const std::vector<std::string>& boot_class_path_locations = runtime->GetBootClassPathLocations();
CHECK_LE(spaces.size(), boot_class_path_locations.size());