summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker.h
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-05-21 18:46:59 -0700
committerAndreas Gampe <agampe@google.com>2014-06-25 19:34:58 -0700
commit833a48501d560c9fa7fc78ef619888138c2d374f (patch)
treeadd308298a5486d44caddea120cc9200dd70c38a /runtime/class_linker.h
parentb849f6dd638fd1246724160cd5c01ab1a5ff33bd (diff)
downloadart-833a48501d560c9fa7fc78ef619888138c2d374f.zip
art-833a48501d560c9fa7fc78ef619888138c2d374f.tar.gz
art-833a48501d560c9fa7fc78ef619888138c2d374f.tar.bz2
ART: Native support for multidex
Native support for zip files with multiple classesX.dex. Works by explicitly looking for those files in ascending order. As these files have no file system representation for themselves, introduce synthetic dex locations: the name of the originating file plus a colon plus the name of the dex file, e.g., test.jar:classes2.dex. Opening a zip dex file will return all dex files in this way. This keeps the changes to dex2oat minimal. To hide multidex/synthetic names from the Java layer, let the handle of dalvik.system.DexFile refer to a vector of DexFile objects. When opening a location, test possible synthetic names and add them to the vector. Thus, the original multidex jar in the classpath will be associated with all embedded dex files. Change-Id: I0de107e1369cbc94416c544aca3b17525c9eac8b
Diffstat (limited to 'runtime/class_linker.h')
-rw-r--r--runtime/class_linker.h67
1 files changed, 41 insertions, 26 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 7d7bf15..60dad7b 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -273,23 +273,12 @@ class ClassLinker {
std::string* error_msg)
LOCKS_EXCLUDED(dex_lock_);
- // Finds the oat file for a dex location, generating the oat file if
- // it is missing or out of date. Returns the DexFile from within the
- // created oat file.
- const DexFile* FindOrCreateOatFileForDexLocation(const char* dex_location,
- uint32_t dex_location_checksum,
- const char* oat_location,
- std::vector<std::string>* error_msgs)
+ // 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<const DexFile*>* dex_files)
LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
- // Find a DexFile within an OatFile given a DexFile location. Note
- // that this returns null if the location checksum of the DexFile
- // does not match the OatFile.
- const DexFile* FindDexFileInOatFileFromDexLocation(const char* location,
- const uint32_t* const location_checksum,
- InstructionSet isa,
- std::vector<std::string>* error_msgs)
- LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
-
// Returns true if oat file contains the dex file with the given location and checksum.
static bool VerifyOatFileChecksums(const OatFile* oat_file,
@@ -545,21 +534,47 @@ class ClassLinker {
const OatFile* FindOpenedOatFileForDexFile(const DexFile& dex_file)
LOCKS_EXCLUDED(dex_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- const OatFile* FindOpenedOatFileFromDexLocation(const char* dex_location,
- const uint32_t* const dex_location_checksum)
+
+ // Find an opened oat file that contains dex_location. If oat_location is not nullptr, the file
+ // must have that location, else any oat location is accepted.
+ const OatFile* FindOpenedOatFile(const char* oat_location, const char* dex_location,
+ const uint32_t* const dex_location_checksum)
LOCKS_EXCLUDED(dex_lock_);
const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location)
LOCKS_EXCLUDED(dex_lock_);
- const DexFile* FindDexFileInOatLocation(const char* dex_location,
- uint32_t dex_location_checksum,
- const char* oat_location,
- 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_);
- const DexFile* VerifyAndOpenDexFileFromOatFile(const std::string& oat_file_location,
- const char* dex_location,
- std::string* error_msg,
- bool* open_failed)
+ // 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* location,
+ const uint32_t* const location_checksum,
+ InstructionSet isa,
+ std::vector<std::string>* error_msgs)
+ LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
+
+ // Find a verify an oat file with the given dex file. Will return nullptr when the oat file
+ // was not found or the dex file could not be verified.
+ // Note: Does not register the oat file.
+ const OatFile* LoadOatFileAndVerifyDexFile(const std::string& oat_file_location,
+ const char* dex_location,
+ std::string* error_msg,
+ bool* open_failed)
LOCKS_EXCLUDED(dex_lock_);
mirror::ArtMethod* CreateProxyConstructor(Thread* self, Handle<mirror::Class> klass,