summaryrefslogtreecommitdiffstats
path: root/dexopt
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2010-04-23 16:34:52 -0700
committerAndy McFadden <fadden@android.com>2010-04-29 10:34:30 -0700
commit8911f7a2222124ba724a4a9281555b74d0e098e2 (patch)
treed14964da4f4ba33384208ca9aaaeefc42eeffca0 /dexopt
parent12a744d079c4ff434db2f4a9db461386a0ec9e2c (diff)
downloadandroid_dalvik-8911f7a2222124ba724a4a9281555b74d0e098e2.tar.gz
android_dalvik-8911f7a2222124ba724a4a9281555b74d0e098e2.tar.bz2
android_dalvik-8911f7a2222124ba724a4a9281555b74d0e098e2.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.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/dexopt/OptMain.c b/dexopt/OptMain.c
index 1e47009b6..edd5425dc 100644
--- a/dexopt/OptMain.c
+++ b/dexopt/OptMain.c
@@ -55,7 +55,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;
@@ -99,8 +100,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;
@@ -113,7 +114,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;