RuntimeOptions options;
options.emplace_back(GetClassPathOption("-Xbootclasspath:", GetLibCoreDexFileNames()), nullptr);
options.emplace_back(
GetClassPathOption("-Xbootclasspath-locations:", GetLibCoreDexLocations()), nullptr);
std::string image("-Ximage:");
image.append(helper.image_locations[0].GetFilename());
options.push_back(std::make_pair(image.c_str(), static_cast<void*>(nullptr))); // By default the compiler this creates will not include patch information.
options.push_back(std::make_pair("-Xnorelocate", nullptr));
if (!Runtime::Create(options, false)) {
LOG(FATAL) << "Failed to create runtime"; return;
}
runtime_.reset(Runtime::Current()); // Runtime::Create acquired the mutator_lock_ that is normally given away when we Runtime::Start, // give it away now and then switch to a more managable ScopedObjectAccess.
Thread::Current()->TransitionFromRunnableToSuspended(ThreadState::kNative);
ScopedObjectAccess soa(Thread::Current());
ASSERT_TRUE(runtime_.get() != nullptr);
class_linker_ = runtime_->GetClassLinker();
// We loaded the runtime with an explicit image, so it must exist.
ASSERT_EQ(heap->GetBootImageSpaces().size(), image_file_sizes.size()); for (size_t i = 0; i < helper.dex_file_locations.size(); ++i) {
std::unique_ptr<const DexFile> dex(
LoadExpectSingleDexFile(helper.dex_file_locations[i].c_str()));
ASSERT_TRUE(dex != nullptr);
uint64_t image_file_size = image_file_sizes[i];
gc::space::ImageSpace* image_space = heap->GetBootImageSpaces()[i];
ASSERT_TRUE(image_space != nullptr); if (storage_mode == ImageHeader::kStorageModeUncompressed) { // Uncompressed, image should be smaller than file.
ASSERT_LE(image_space->GetImageHeader().GetImageSize(), image_file_size);
} elseif (image_file_size > 4 * kElfSegmentAlignment) { // Compressed, file should be smaller than image. Not really valid for small images.
ASSERT_LE(image_file_size, image_space->GetImageHeader().GetImageSize()); // TODO: Actually validate the blocks, this is hard since the blocks are not copied over for // compressed images. Add kElfSegmentAlignment since image_size is rounded up to this.
ASSERT_GT(image_space->GetImageHeader().GetBlockCount() * max_image_block_size,
image_space->GetImageHeader().GetImageSize() - kElfSegmentAlignment);
}
image_space->VerifyImageAllocations();
uint8_t* image_begin = image_space->Begin();
uint8_t* image_end = image_space->End(); if (i == 0) { // This check is only valid for image 0.
CHECK_EQ(kRequestedImageBase, reinterpret_cast<uintptr_t>(image_begin));
} for (size_t j = 0; j < dex->NumClassDefs(); ++j) { const dex::ClassDef& class_def = dex->GetClassDef(j); constchar* descriptor = dex->GetClassDescriptor(class_def);
ObjPtr<mirror::Class> klass = class_linker_->FindSystemClass(soa.Self(), descriptor);
EXPECT_TRUE(klass != nullptr) << descriptor;
uint8_t* raw_klass = reinterpret_cast<uint8_t*>(klass.Ptr()); if (image_classes.find(std::string_view(descriptor)) == image_classes.end()) {
EXPECT_TRUE(raw_klass >= image_end || raw_klass < image_begin) << descriptor;
} else { // Image classes should be located inside the image.
EXPECT_LT(image_begin, raw_klass) << descriptor;
EXPECT_LT(raw_klass, image_end) << descriptor;
}
EXPECT_TRUE(Monitor::IsValidLockWord(klass->GetLockWord(false)));
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.