diff options
author | Andy McFadden <fadden@android.com> | 2010-04-23 16:34:52 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2010-05-06 14:26:02 -0700 |
commit | 80a4e2497c3b5ef24fe1408c678053fbc6cd4b25 (patch) | |
tree | 98c348c0c35ef7ce4442b50dd65b48e610c1ea72 /dexopt | |
parent | f6cd559ad0d1df42da5b8f2acf926a0ed51da1a3 (diff) | |
download | android_dalvik-80a4e2497c3b5ef24fe1408c678053fbc6cd4b25.tar.gz android_dalvik-80a4e2497c3b5ef24fe1408c678053fbc6cd4b25.tar.bz2 android_dalvik-80a4e2497c3b5ef24fe1408c678053fbc6cd4b25.zip |
Dalvik Zip rewrite.
Change the way zip archives are handled. This is necessary to deal with
very large (~1GB) APK files, for which our current approach of mapping
the entire file falls over.
We now do the classic scavenger hunt for the End Of Central Directory magic
on a buffer of data read from the file, instead of a memory-mapped section.
We use what we find to create a map that covers the Central Directory only.
For most uses in the VM this is all we really need, since we just want
to check file attributes vs. the optimized DEX to see if we're out of date.
If the caller is interested in unpacking the file contents, we have to
do an additional file read to discover the size of the Local File Header
section so we can skip past it. We also now do a file-to-file extraction
using read() calls instead of a buffer-to-file extraction on mmap()ed data.
No difference in performance (as measured by first-boot dexopt).
Since this is more of a rewrite than an update, I also took the opportunity
to change buffer size variables from "long" to "size_t", and normalized
return values to int (some were using bool, which is common in the VM but
was mixed in the zip code). Failure messages are now all LOGW with the
word "Zip" up front (didn't want to change log tag away from "dalvikvm").
Also, removed a not-quite-right check in the "map part of a file" code,
and clarified that the file offset is absolute.
For bug 2620103.
Change-Id: I745fb15abb541376f467969ffe422222676f1e5f
Diffstat (limited to 'dexopt')
-rw-r--r-- | dexopt/OptMain.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/dexopt/OptMain.c b/dexopt/OptMain.c index 953db0b00..d897789b9 100644 --- a/dexopt/OptMain.c +++ b/dexopt/OptMain.c @@ -56,7 +56,8 @@ static int extractAndProcessZip(int zipFd, int cacheFd, { ZipArchive zippy; ZipEntry zipEntry; - long uncompLen, modWhen, crc32; + size_t uncompLen; + long modWhen, crc32; off_t dexOffset; int err; int result = -1; @@ -100,8 +101,8 @@ static int extractAndProcessZip(int zipFd, int cacheFd, /* * Extract some info about the zip entry. */ - if (!dexZipGetEntryInfo(&zippy, zipEntry, NULL, &uncompLen, NULL, NULL, - &modWhen, &crc32)) + if (dexZipGetEntryInfo(&zippy, zipEntry, NULL, &uncompLen, NULL, NULL, + &modWhen, &crc32) != 0) { LOGW("DexOptZ: zip archive GetEntryInfo failed on %s\n", debugFileName); goto bail; @@ -114,7 +115,7 @@ static int extractAndProcessZip(int zipFd, int cacheFd, /* * Extract the DEX data into the cache file at the current offset. */ - if (!dexZipExtractEntryToFile(&zippy, zipEntry, cacheFd)) { + if (dexZipExtractEntryToFile(&zippy, zipEntry, cacheFd) != 0) { LOGW("DexOptZ: extraction of %s from %s failed\n", kClassesDex, debugFileName); goto bail; |