OSDN Git Service

Merge branch 'aosp/honeycomb-LTE-release' into honeycomb-mr2-x86
[android-x86/dalvik.git] / dexopt / OptMain.c
index ca55565..194a62b 100644 (file)
@@ -125,12 +125,12 @@ static int extractAndProcessZip(int zipFd, int cacheFd,
         goto bail;
     }
 
-    /*
-     * Prep the VM and perform the optimization.
-     */
+    /* Parse the options. */
+
     DexClassVerifyMode verifyMode = VERIFY_MODE_ALL;
     DexOptimizerMode dexOptMode = OPTIMIZE_MODE_VERIFIED;
     int dexoptFlags = 0;        /* bit flags, from enum DexoptFlags */
+
     if (dexoptFlagStr[0] != '\0') {
         const char* opc;
         const char* val;
@@ -159,7 +159,21 @@ static int extractAndProcessZip(int zipFd, int cacheFd,
         if (opc != NULL) {
             dexoptFlags |= DEXOPT_GEN_REGISTER_MAPS;
         }
+
+        opc = strstr(dexoptFlagStr, "u=");      /* uniprocessor target */
+        if (opc != NULL) {
+            switch (*(opc+2)) {
+            case 'y':   dexoptFlags |= DEXOPT_UNIPROCESSOR;     break;
+            case 'n':   dexoptFlags |= DEXOPT_SMP;              break;
+            default:                                            break;
+            }
+        }
     }
+
+    /*
+     * Prep the VM and perform the optimization.
+     */
+
     if (dvmPrepForDexOpt(bootClassPath, dexOptMode, verifyMode,
             dexoptFlags) != 0)
     {
@@ -224,7 +238,7 @@ static int processZipFile(int zipFd, int cacheFd, const char* zipName,
         if (matchOffset > 0 && bcp[matchOffset-1] == ':')
             matchOffset--;
         LOGV("DexOptZ: found '%s' in bootclasspath, cutting off at %d\n",
-            inputFileName, matchOffset);
+            zipName, matchOffset);
         bcpCopy = strdup(bcp);
         bcpCopy[matchOffset] = '\0';
 
@@ -340,6 +354,13 @@ static int preopt(int argc, char* const argv[])
     const char* outName = argv[3];
     const char* dexoptFlags = argv[4];
 
+    if (strstr(dexoptFlags, "u=y") == NULL &&
+        strstr(dexoptFlags, "u=n") == NULL)
+    {
+        fprintf(stderr, "Either 'u=y' or 'u=n' must be specified\n");
+        goto bail;
+    }
+
     zipFd = open(zipName, O_RDONLY);
     if (zipFd < 0) {
         perror(argv[0]);
@@ -473,7 +494,6 @@ static int fromDex(int argc, char* const argv[])
     bool onlyOptVerifiedDex = false;
     DexClassVerifyMode verifyMode;
     DexOptimizerMode dexOptMode;
-    int dexoptFlags = 0;
 
     /* ugh -- upgrade these to a bit field if they get any more complex */
     if ((flags & DEXOPT_VERIFY_ENABLED) != 0) {
@@ -492,13 +512,8 @@ static int fromDex(int argc, char* const argv[])
     } else {
         dexOptMode = OPTIMIZE_MODE_NONE;
     }
-    if ((flags & DEXOPT_GEN_REGISTER_MAP) != 0) {
-        dexoptFlags |= DEXOPT_GEN_REGISTER_MAPS;
-    }
 
-    if (dvmPrepForDexOpt(bootClassPath, dexOptMode, verifyMode,
-            dexoptFlags) != 0)
-    {
+    if (dvmPrepForDexOpt(bootClassPath, dexOptMode, verifyMode, flags) != 0) {
         LOGE("VM init failed\n");
         goto bail;
     }