summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker.h
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-01-15 09:37:19 -0800
committerRichard Uhler <ruhler@google.com>2015-03-09 14:46:23 -0700
commit66d874d96d5699bb090c59f47a5a528956ca053e (patch)
treed59bf83a08fead7d9823230831bea63c9e43a62c /runtime/class_linker.h
parent2cfdabd2bb4833d7092819d27ef08a9e1cdffead (diff)
downloadart-66d874d96d5699bb090c59f47a5a528956ca053e.tar.gz
art-66d874d96d5699bb090c59f47a5a528956ca053e.tar.bz2
art-66d874d96d5699bb090c59f47a5a528956ca053e.zip
Create OatFileAssistant class for assisting with oat files.
The oat file assistant is used for determining whether dex2oat or patchoat is needed, for running dex2oat or patchoat as needed to make an oat file up to date, and to load dex files associated with a given dex location. The introduction of the OatFileAssistant class is meant to clean up and consolidate code related to the management of oat files that was duplicated and spread across dalvik_system_DexFile.cc and class_linker.cc. Bug: 11301553 Change-Id: I0c16027b9bae4570c2c50faa9c14f581c0cbafb8
Diffstat (limited to 'runtime/class_linker.h')
-rw-r--r--runtime/class_linker.h107
1 files changed, 17 insertions, 90 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 6570c5f02a..75fbdf3f59 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -313,33 +313,25 @@ class ClassLinker {
LOCKS_EXCLUDED(dex_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- // Generate an oat file from a dex file
- bool GenerateOatFile(const char* dex_filename,
- int oat_fd,
- const char* oat_cache_filename,
- std::string* error_msg)
- LOCKS_EXCLUDED(Locks::mutator_lock_);
-
- // Find or create the oat file holding dex_location. Then load all corresponding dex files
- // (if multidex) into the given vector.
- bool OpenDexFilesFromOat(const char* dex_location, const char* oat_location,
- std::vector<std::string>* error_msgs,
- std::vector<std::unique_ptr<const DexFile>>* dex_files)
+ // Finds or creates the oat file holding dex_location. Then loads and returns
+ // all corresponding dex files (there may be more than one dex file loaded
+ // in the case of multidex).
+ // This may return the original, unquickened dex files if the oat file could
+ // not be generated.
+ //
+ // Returns an empty vector if the dex files could not be loaded. In this
+ // case, there will be at least one error message returned describing why no
+ // dex files could not be loaded. The 'error_msgs' argument must not be
+ // null, regardless of whether there is an error or not.
+ //
+ // This method should not be called with the mutator_lock_ held, because it
+ // could end up starving GC if we need to generate or relocate any oat
+ // files.
+ std::vector<std::unique_ptr<const DexFile>> OpenDexFilesFromOat(
+ const char* dex_location, const char* oat_location,
+ std::vector<std::string>* error_msgs)
LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
- // Returns true if the given oat file has the same image checksum as the image it is paired with.
- static bool VerifyOatImageChecksum(const OatFile* oat_file, const InstructionSet instruction_set);
- // Returns true if the oat file checksums match with the image and the offsets are such that it
- // could be loaded with it.
- static bool VerifyOatChecksums(const OatFile* oat_file, const InstructionSet instruction_set,
- std::string* error_msg);
- // Returns true if oat file contains the dex file with the given location and checksum.
- static bool VerifyOatAndDexFileChecksums(const OatFile* oat_file,
- const char* dex_location,
- uint32_t dex_location_checksum,
- InstructionSet instruction_set,
- std::string* error_msg);
-
// Allocate an instance of a java.lang.Object.
mirror::Object* AllocObject(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -612,73 +604,9 @@ class ClassLinker {
const uint32_t* dex_location_checksum)
LOCKS_EXCLUDED(dex_lock_);
- // Will open the oat file directly without relocating, even if we could/should do relocation.
- const OatFile* FindOatFileFromOatLocation(const std::string& oat_location,
- std::string* error_msg)
- LOCKS_EXCLUDED(dex_lock_);
-
const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location)
LOCKS_EXCLUDED(dex_lock_);
- const OatFile* OpenOatFileFromDexLocation(const std::string& dex_location,
- InstructionSet isa,
- bool* already_opened,
- bool* obsolete_file_cleanup_failed,
- std::vector<std::string>* error_msg)
- LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
-
- const OatFile* GetInterpretedOnlyOat(const std::string& oat_path,
- InstructionSet isa,
- std::string* error_msg);
-
- const OatFile* PatchAndRetrieveOat(const std::string& input, const std::string& output,
- const std::string& image_location, InstructionSet isa,
- std::string* error_msg)
- LOCKS_EXCLUDED(Locks::mutator_lock_);
-
- bool CheckOatFile(const Runtime* runtime, const OatFile* oat_file, InstructionSet isa,
- bool* checksum_verified, std::string* error_msg);
-
- // Note: will not register the oat file.
- const OatFile* FindOatFileInOatLocationForDexFile(const char* dex_location,
- uint32_t dex_location_checksum,
- const char* oat_location,
- std::string* error_msg)
- LOCKS_EXCLUDED(dex_lock_);
-
- // Creates the oat file from the dex_location to the oat_location. Needs a file descriptor for
- // the file to be written, which is assumed to be under a lock.
- const OatFile* CreateOatFileForDexLocation(const char* dex_location,
- int fd, const char* oat_location,
- std::vector<std::string>* error_msgs)
- LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
-
- // Finds an OatFile that contains a DexFile for the given a DexFile location.
- //
- // Note 1: this will not check open oat files, which are assumed to be stale when this is run.
- // Note 2: Does not register the oat file. It is the caller's job to register if the file is to
- // be kept.
- const OatFile* FindOatFileContainingDexFileFromDexLocation(const char* dex_location,
- const uint32_t* dex_location_checksum,
- InstructionSet isa,
- std::vector<std::string>* error_msgs,
- bool* obsolete_file_cleanup_failed)
- LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
-
- // Verifies:
- // - that the oat file contains the dex file (with a matching checksum, which may be null if the
- // file was pre-opted)
- // - the checksums of the oat file (against the image space)
- // - the checksum of the dex file against dex_location_checksum
- // - that the dex file can be opened
- // Returns true iff all verification succeed.
- //
- // The dex_location is the dex location as stored in the oat file header.
- // (see DexFile::GetDexCanonicalLocation for a description of location conventions)
- bool VerifyOatWithDexFile(const OatFile* oat_file, const char* dex_location,
- const uint32_t* dex_location_checksum,
- std::string* error_msg);
-
mirror::ArtMethod* CreateProxyConstructor(Thread* self, Handle<mirror::Class> klass,
mirror::Class* proxy_class)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -803,7 +731,6 @@ class ClassLinker {
friend class ImageWriter; // for GetClassRoots
friend class ImageDumper; // for FindOpenedOatFileFromOatLocation
- friend class ElfPatcher; // for FindOpenedOatFileForDexFile & FindOpenedOatFileFromOatLocation
friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub
friend class NoDex2OatTest; // for FindOpenedOatFileForDexFile
friend class NoPatchoatTest; // for FindOpenedOatFileForDexFile