summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-06-03 01:24:10 +0100
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-06-03 01:24:10 +0100
commitdf4822ef8ac1ed2b64b8376a29307b835b97530e (patch)
tree25969cc6091e768ad33606ed3c63826f9aca7783
parente3422459524e20107b82be5cfdd6e55765ceac5a (diff)
parent36e356c96640775f0a3f167bd2426ea0f0093b8b (diff)
downloadandroid_dalvik-df4822ef8ac1ed2b64b8376a29307b835b97530e.tar.gz
android_dalvik-df4822ef8ac1ed2b64b8376a29307b835b97530e.tar.bz2
android_dalvik-df4822ef8ac1ed2b64b8376a29307b835b97530e.zip
Merge tag 'android-4.4.3_r1' into HEAD
Android 4.4.3 release 1
-rw-r--r--dx/src/com/android/dx/command/dexer/Main.java3
-rw-r--r--dx/src/com/android/dx/merge/DexMerger.java8
-rw-r--r--vm/JarFile.cpp106
3 files changed, 64 insertions, 53 deletions
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 947bd4178..9f4a177d7 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -1474,8 +1474,9 @@ public class Main {
}
if (multiDex && numThreads != 1) {
- System.out.println(NUM_THREADS_OPTION + "is ignored when used with "
+ System.out.println(NUM_THREADS_OPTION + " is ignored when used with "
+ MULTI_DEX_OPTION);
+ numThreads = 1;
}
if (multiDex && incremental) {
diff --git a/dx/src/com/android/dx/merge/DexMerger.java b/dx/src/com/android/dx/merge/DexMerger.java
index 8080947cb..507c0766a 100644
--- a/dx/src/com/android/dx/merge/DexMerger.java
+++ b/dx/src/com/android/dx/merge/DexMerger.java
@@ -28,6 +28,7 @@ import com.android.dex.ProtoId;
import com.android.dex.SizeOf;
import com.android.dex.TableOfContents;
import com.android.dex.TypeList;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -1049,7 +1050,12 @@ public final class DexMerger {
+ contents.methodIds.size * SizeOf.MEMBER_ID_ITEM
+ contents.classDefs.size * SizeOf.CLASS_DEF_ITEM;
mapList = SizeOf.UINT + (contents.sections.length * SizeOf.MAP_ITEM);
- typeList += contents.typeLists.byteCount;
+ typeList += fourByteAlign(contents.typeLists.byteCount); // We count each dex's
+ // typelists section as realigned on 4 bytes, because each typelist of each dex's
+ // typelists section is aligned on 4 bytes. If we didn't, there is a case where each
+ // size of both dex's typelists section is a multiple of 2 but not a multiple of 4,
+ // and the sum of both sizes is a multiple of 4 but would not be sufficient to write
+ // each typelist aligned on 4 bytes.
stringData += contents.stringDatas.byteCount;
annotationsDirectory += contents.annotationsDirectories.byteCount;
annotationsSet += contents.annotationSets.byteCount;
diff --git a/vm/JarFile.cpp b/vm/JarFile.cpp
index 3a037a057..e643a5fe5 100644
--- a/vm/JarFile.cpp
+++ b/vm/JarFile.cpp
@@ -82,6 +82,8 @@ bail:
/*
* Checks the dependencies of the dex cache file corresponding
* to the jar file at the absolute path "fileName".
+ *
+ * Note: This should parallel the logic of dvmJarFileOpen.
*/
DexCacheStatus dvmDexCacheStatus(const char *fileName)
{
@@ -99,72 +101,72 @@ DexCacheStatus dvmDexCacheStatus(const char *fileName)
return DEX_CACHE_OK;
}
- //TODO: match dvmJarFileOpen()'s logic. Not super-important
- // (the odex-first logic is only necessary for dexpreopt)
- // but it would be nice to be consistent.
-
/* Try to find the dex file inside of the archive.
*/
if (dexZipOpenArchive(fileName, &archive) != 0) {
return DEX_CACHE_BAD_ARCHIVE;
}
- entry = dexZipFindEntry(&archive, kDexInJarName);
- if (entry != NULL) {
- bool newFile = false;
-
- /*
- * See if there's an up-to-date copy of the optimized dex
- * in the cache, but don't create one if there isn't.
- */
- ALOGV("dvmDexCacheStatus: Checking cache for %s", fileName);
- cachedName = dexOptGenerateCacheFileName(fileName, kDexInJarName);
- if (cachedName == NULL)
- return DEX_CACHE_BAD_ARCHIVE;
-
- fd = dvmOpenCachedDexFile(fileName, cachedName,
- dexGetZipEntryModTime(&archive, entry),
- dexGetZipEntryCrc32(&archive, entry),
- /*isBootstrap=*/false, &newFile, /*createIfMissing=*/false);
- ALOGV("dvmOpenCachedDexFile returned fd %d", fd);
- if (fd < 0) {
- result = DEX_CACHE_STALE;
- goto bail;
- }
- /* dvmOpenCachedDexFile locks the file as a side-effect.
- * Unlock and close it.
- */
- if (!dvmUnlockCachedDexFile(fd)) {
- /* uh oh -- this process needs to exit or we'll wedge the system */
- ALOGE("Unable to unlock DEX file");
- goto bail;
+ /* First, look for a ".odex" alongside the jar file. It will
+ * have the same name/path except for the extension.
+ */
+ fd = openAlternateSuffix(fileName, "odex", O_RDONLY, &cachedName);
+ if (fd >= 0) {
+ ALOGV("Using alternate file (odex) for %s ...", fileName);
+ if (!dvmCheckOptHeaderAndDependencies(fd, false, 0, 0, true, true)) {
+ ALOGE("%s odex has stale dependencies", fileName);
+ free(cachedName);
+ cachedName = NULL;
+ close(fd);
+ fd = -1;
+ goto tryArchive;
+ } else {
+ ALOGV("%s odex has good dependencies", fileName);
}
-
- /* When createIfMissing is false, dvmOpenCachedDexFile() only
- * returns a valid fd if the cache file is up-to-date.
- */
} else {
+
+tryArchive:
/*
- * There's no dex file in the jar file. See if there's an
- * optimized dex file living alongside the jar.
+ * Pre-created .odex absent or stale. Look inside the jar for a
+ * "classes.dex".
*/
- fd = openAlternateSuffix(fileName, "odex", O_RDONLY, &cachedName);
- if (fd < 0) {
+ entry = dexZipFindEntry(&archive, kDexInJarName);
+ if (entry != NULL) {
+ bool newFile = false;
+
+ /*
+ * See if there's an up-to-date copy of the optimized dex
+ * in the cache, but don't create one if there isn't.
+ */
+ ALOGV("dvmDexCacheStatus: Checking cache for %s", fileName);
+ cachedName = dexOptGenerateCacheFileName(fileName, kDexInJarName);
+ if (cachedName == NULL)
+ return DEX_CACHE_BAD_ARCHIVE;
+
+ fd = dvmOpenCachedDexFile(fileName, cachedName,
+ dexGetZipEntryModTime(&archive, entry),
+ dexGetZipEntryCrc32(&archive, entry),
+ /*isBootstrap=*/false, &newFile, /*createIfMissing=*/false);
+ ALOGV("dvmOpenCachedDexFile returned fd %d", fd);
+ if (fd < 0) {
+ result = DEX_CACHE_STALE;
+ goto bail;
+ }
+
+ /* dvmOpenCachedDexFile locks the file as a side-effect.
+ * Unlock and close it.
+ */
+ if (!dvmUnlockCachedDexFile(fd)) {
+ /* uh oh -- this process needs to exit or we'll wedge the system */
+ ALOGE("Unable to unlock DEX file");
+ goto bail;
+ }
+ } else {
ALOGI("Zip is good, but no %s inside, and no .odex "
"file in the same directory", kDexInJarName);
result = DEX_CACHE_BAD_ARCHIVE;
goto bail;
}
-
- ALOGV("Using alternate file (odex) for %s ...", fileName);
- if (!dvmCheckOptHeaderAndDependencies(fd, false, 0, 0, true, true)) {
- ALOGE("%s odex has stale dependencies", fileName);
- ALOGE("odex source not available -- failing");
- result = DEX_CACHE_STALE_ODEX;
- goto bail;
- } else {
- ALOGV("%s odex has good dependencies", fileName);
- }
}
result = DEX_CACHE_OK;
@@ -184,6 +186,8 @@ bail:
*
* If "isBootstrap" is not set, the optimizer/verifier regards this DEX as
* being part of a different class loader.
+ *
+ * Note: This should parallel the logic of dvmDexCacheStatus.
*/
int dvmJarFileOpen(const char* fileName, const char* odexOutputName,
JarFile** ppJarFile, bool isBootstrap)