summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-04-03 17:47:14 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-03 17:49:53 +0000
commitb2d4768e4adc6d880d2e17c5cf4293639c8adab7 (patch)
tree90fbeac8abf73fb9c15be0d89bc01d2572b69626 /runtime/class_linker.cc
parent698385411e5db8c7ac9bd4471f152b8c6ea7f7bf (diff)
parent07b3c2351bb527ea91c084dc19434600af9ae66b (diff)
downloadandroid_art-b2d4768e4adc6d880d2e17c5cf4293639c8adab7.tar.gz
android_art-b2d4768e4adc6d880d2e17c5cf4293639c8adab7.tar.bz2
android_art-b2d4768e4adc6d880d2e17c5cf4293639c8adab7.zip
Merge "Store OatDexFile instead of OatFile in DexFile."
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc50
1 files changed, 15 insertions, 35 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index be4b9e9b68..cdd8e73f83 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -693,35 +693,6 @@ OatFile& ClassLinker::GetImageOatFile(gc::space::ImageSpace* space) {
return *oat_file;
}
-const OatFile::OatDexFile* ClassLinker::FindOpenedOatDexFileForDexFile(const DexFile& dex_file) {
- const char* dex_location = dex_file.GetLocation().c_str();
- uint32_t dex_location_checksum = dex_file.GetLocationChecksum();
- return FindOpenedOatDexFile(nullptr, dex_location, &dex_location_checksum);
-}
-
-const OatFile::OatDexFile* ClassLinker::FindOpenedOatDexFile(const char* oat_location,
- const char* dex_location,
- const uint32_t* dex_location_checksum) {
- ReaderMutexLock mu(Thread::Current(), dex_lock_);
- for (const OatFile* oat_file : oat_files_) {
- DCHECK(oat_file != nullptr);
-
- if (oat_location != nullptr) {
- if (oat_file->GetLocation() != oat_location) {
- continue;
- }
- }
-
- const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location,
- dex_location_checksum,
- false);
- if (oat_dex_file != nullptr) {
- return oat_dex_file;
- }
- }
- return nullptr;
-}
-
std::vector<std::unique_ptr<const DexFile>> ClassLinker::OpenDexFilesFromOat(
const char* dex_location, const char* oat_location,
std::vector<std::string>* error_msgs) {
@@ -1600,7 +1571,7 @@ uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
OatFile::OatClass ClassLinker::FindOatClass(const DexFile& dex_file, uint16_t class_def_idx,
bool* found) {
DCHECK_NE(class_def_idx, DexFile::kDexNoIndex16);
- const OatFile::OatDexFile* oat_dex_file = FindOpenedOatDexFileForDexFile(dex_file);
+ const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
if (oat_dex_file == nullptr) {
*found = false;
return OatFile::OatClass::Invalid();
@@ -2813,7 +2784,7 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class
}
}
- const OatFile::OatDexFile* oat_dex_file = FindOpenedOatDexFileForDexFile(dex_file);
+ const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
// In case we run without an image there won't be a backing oat file.
if (oat_dex_file == nullptr) {
return false;
@@ -3845,9 +3816,19 @@ static bool CheckSuperClassChange(Handle<mirror::Class> klass,
// Now comes the expensive part: things can be broken if (a) the klass' dex file has a
// definition for the super-class, and (b) the files are in separate oat files. The oat files
// are referenced from the dex file, so do (b) first. Only relevant if we have oat files.
- const OatFile* class_oat_file = dex_file.GetOatFile();
+ const OatDexFile* class_oat_dex_file = dex_file.GetOatDexFile();
+ const OatFile* class_oat_file = nullptr;
+ if (class_oat_dex_file != nullptr) {
+ class_oat_file = class_oat_dex_file->GetOatFile();
+ }
+
if (class_oat_file != nullptr) {
- const OatFile* loaded_super_oat_file = super_class->GetDexFile().GetOatFile();
+ const OatDexFile* loaded_super_oat_dex_file = super_class->GetDexFile().GetOatDexFile();
+ const OatFile* loaded_super_oat_file = nullptr;
+ if (loaded_super_oat_dex_file != nullptr) {
+ loaded_super_oat_file = loaded_super_oat_dex_file->GetOatFile();
+ }
+
if (loaded_super_oat_file != nullptr && class_oat_file != loaded_super_oat_file) {
// Now check (a).
const DexFile::ClassDef* super_class_def = dex_file.FindClassDef(class_def.superclass_idx_);
@@ -5293,9 +5274,8 @@ bool ClassLinker::MayBeCalledWithDirectCodePointer(mirror::ArtMethod* m) {
if (m->IsPrivate()) {
// The method can only be called inside its own oat file. Therefore it won't be called using
// its direct code if the oat file has been compiled in PIC mode.
- ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
const DexFile& dex_file = m->GetDeclaringClass()->GetDexFile();
- const OatFile::OatDexFile* oat_dex_file = class_linker->FindOpenedOatDexFileForDexFile(dex_file);
+ const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
if (oat_dex_file == nullptr) {
// No oat file: the method has not been compiled.
return false;