summaryrefslogtreecommitdiff
path: root/src/class_linker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/class_linker.cc')
-rw-r--r--src/class_linker.cc39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 83661cbafc..a76c9c85d3 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -222,6 +222,7 @@ ClassLinker::ClassLinker(InternTable* intern_table)
class_roots_(NULL),
array_iftable_(NULL),
init_done_(false),
+ is_dirty_(false),
intern_table_(intern_table) {
CHECK_EQ(arraysize(class_roots_descriptors_), size_t(kClassRootsMax));
}
@@ -706,7 +707,7 @@ OatFile* ClassLinker::OpenOat(const ImageSpace* space) {
uint32_t image_oat_checksum = image_header.GetOatChecksum();
if (oat_checksum != image_oat_checksum) {
LOG(ERROR) << "Failed to match oat file checksum " << std::hex << oat_checksum
- << " to expected oat checksum " << std::hex << oat_checksum
+ << " to expected oat checksum " << std::hex << image_oat_checksum
<< " in image";
return NULL;
}
@@ -742,7 +743,11 @@ static const DexFile* FindDexFileInOatLocation(const std::string& dex_location,
}
Runtime* runtime = Runtime::Current();
const ImageHeader& image_header = runtime->GetHeap()->GetImageSpace()->GetImageHeader();
- if (oat_file->GetOatHeader().GetImageFileLocationChecksum() != image_header.GetOatChecksum()) {
+ if (oat_file->GetOatHeader().GetImageFileLocationOatChecksum() != image_header.GetOatChecksum()) {
+ return NULL;
+ }
+ if (oat_file->GetOatHeader().GetImageFileLocationOatBegin()
+ != reinterpret_cast<uint32_t>(image_header.GetOatBegin())) {
return NULL;
}
const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location);
@@ -813,8 +818,10 @@ bool ClassLinker::VerifyOatFileChecksums(const OatFile* oat_file,
uint32_t dex_location_checksum) {
Runtime* runtime = Runtime::Current();
const ImageHeader& image_header = runtime->GetHeap()->GetImageSpace()->GetImageHeader();
- uint32_t image_checksum = image_header.GetOatChecksum();
- bool image_check = (oat_file->GetOatHeader().GetImageFileLocationChecksum() == image_checksum);
+ uint32_t image_oat_checksum = image_header.GetOatChecksum();
+ uint32_t image_oat_begin = reinterpret_cast<uint32_t>(image_header.GetOatBegin());
+ bool image_check = ((oat_file->GetOatHeader().GetImageFileLocationOatChecksum() == image_oat_checksum)
+ && (oat_file->GetOatHeader().GetImageFileLocationOatBegin() == image_oat_begin));
const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location);
if (oat_dex_file == NULL) {
@@ -828,7 +835,7 @@ bool ClassLinker::VerifyOatFileChecksums(const OatFile* oat_file,
}
return false;
}
- bool dex_check = (dex_location_checksum == oat_dex_file->GetDexFileLocationChecksum());
+ bool dex_check = dex_location_checksum == oat_dex_file->GetDexFileLocationChecksum();
if (image_check && dex_check) {
return true;
@@ -838,14 +845,15 @@ bool ClassLinker::VerifyOatFileChecksums(const OatFile* oat_file,
std::string image_file(image_header.GetImageRoot(
ImageHeader::kOatLocation)->AsString()->ToModifiedUtf8());
LOG(WARNING) << ".oat file " << oat_file->GetLocation()
- << " checksum ( " << std::hex << oat_dex_file->GetDexFileLocationChecksum()
- << ") mismatch with " << image_file
- << " (" << std::hex << image_checksum << ")";
+ << " mismatch ( " << std::hex << oat_file->GetOatHeader().GetImageFileLocationOatChecksum()
+ << ", " << oat_file->GetOatHeader().GetImageFileLocationOatBegin()
+ << ") with " << image_file
+ << " (" << image_oat_checksum << ", " << std::hex << image_oat_begin << ")";
}
if (!dex_check) {
LOG(WARNING) << ".oat file " << oat_file->GetLocation()
- << " checksum ( " << std::hex << oat_dex_file->GetDexFileLocationChecksum()
- << ") mismatch with " << dex_location
+ << " mismatch ( " << std::hex << oat_dex_file->GetDexFileLocationChecksum()
+ << ") with " << dex_location
<< " (" << std::hex << dex_location_checksum << ")";
}
return false;
@@ -957,7 +965,8 @@ void ClassLinker::InitFromImage() {
ImageSpace* space = heap->GetImageSpace();
OatFile* oat_file = OpenOat(space);
CHECK(oat_file != NULL) << "Failed to open oat file for image";
- CHECK_EQ(oat_file->GetOatHeader().GetImageFileLocationChecksum(), 0U);
+ CHECK_EQ(oat_file->GetOatHeader().GetImageFileLocationOatChecksum(), 0U);
+ CHECK_EQ(oat_file->GetOatHeader().GetImageFileLocationOatBegin(), 0U);
CHECK(oat_file->GetOatHeader().GetImageFileLocation().empty());
Object* dex_caches_object = space->GetImageHeader().GetImageRoot(ImageHeader::kDexCaches);
ObjectArray<DexCache>* dex_caches = dex_caches_object->AsObjectArray<DexCache>();
@@ -1043,7 +1052,7 @@ void ClassLinker::InitFromImageCallback(Object* obj, void* arg) {
// Keep in sync with InitCallback. Anything we visit, we need to
// reinit references to when reinitializing a ClassLinker from a
// mapped image.
-void ClassLinker::VisitRoots(Heap::RootVisitor* visitor, void* arg) const {
+void ClassLinker::VisitRoots(Heap::RootVisitor* visitor, void* arg) {
visitor(class_roots_, arg);
Thread* self = Thread::Current();
{
@@ -1065,6 +1074,7 @@ void ClassLinker::VisitRoots(Heap::RootVisitor* visitor, void* arg) const {
}
visitor(array_iftable_, arg);
+ is_dirty_ = false;
}
void ClassLinker::VisitClasses(ClassVisitor* visitor, void* arg) const {
@@ -1746,6 +1756,7 @@ void ClassLinker::RegisterDexFileLocked(const DexFile& dex_file, SirtRef<DexCach
CHECK(dex_cache->GetLocation()->Equals(dex_file.GetLocation()));
dex_caches_.push_back(dex_cache.get());
dex_cache->SetDexFile(&dex_file);
+ Dirty();
}
void ClassLinker::RegisterDexFile(const DexFile& dex_file) {
@@ -1990,6 +2001,7 @@ Class* ClassLinker::InsertClass(const StringPiece& descriptor, Class* klass, boo
return existing;
}
classes.insert(std::make_pair(hash, klass));
+ Dirty();
return NULL;
}
@@ -2803,7 +2815,8 @@ bool ClassLinker::InitializeStaticFields(Class* klass) {
const DexFile::ClassDef* dex_class_def = kh.GetClassDef();
CHECK(dex_class_def != NULL);
const DexFile& dex_file = kh.GetDexFile();
- EncodedStaticFieldValueIterator it(dex_file, dex_cache, this, *dex_class_def);
+ EncodedStaticFieldValueIterator it(dex_file, dex_cache, klass->GetClassLoader(),
+ this, *dex_class_def);
if (it.HasNext()) {
// We reordered the fields, so we need to be able to map the field indexes to the right fields.