am a0475a59: (-s ours) am d5cc3680: (-s ours) am 9db54b1e: Add dx option to always generate const-string/jumbo. do not merge.

* commit 'a0475a59b58c39c9a3babddc371815c6d51e3f39':
  Add dx option to always generate const-string/jumbo. do not merge.
diff --git a/dx/src/com/android/dx/command/Main.java b/dx/src/com/android/dx/command/Main.java
index 6540e35..10a1179 100644
--- a/dx/src/com/android/dx/command/Main.java
+++ b/dx/src/com/android/dx/command/Main.java
@@ -33,7 +33,7 @@
         "[--dump-width=<n>]\n" +
         "  [--dump-method=<name>[*]] [--verbose-dump] [--no-files] " +
         "[--core-library]\n" +
-        "  [--num-threads=<n>] [--incremental] [--force-jumbo]\n" +
+        "  [--num-threads=<n>]\n" +
         "  [<file>.class | <file>.{zip,jar,apk} | <directory>] ...\n" +
         "    Convert a set of classfiles into a dex file, optionally " +
         "embedded in a\n" +
diff --git a/dx/src/com/android/dx/command/dexer/Main.java b/dx/src/com/android/dx/command/dexer/Main.java
index 87f152a..80ddbd0 100644
--- a/dx/src/com/android/dx/command/dexer/Main.java
+++ b/dx/src/com/android/dx/command/dexer/Main.java
@@ -934,10 +934,6 @@
         /** whether to merge with the output dex file if it exists. */
         public boolean incremental = false;
 
-        /** whether to force generation of const-string/jumbo for all indexes,
-         *  to allow merges between dex files with many strings. */
-        public boolean forceJumbo = false;
-
         /** {@code non-null} after {@link #parse}; file name arguments */
         public String[] fileNames;
 
@@ -1144,8 +1140,6 @@
                     numThreads = Integer.parseInt(parser.getLastValue());
                 } else if (parser.isArg("--incremental")) {
                     incremental = true;
-                } else if (parser.isArg("--force-jumbo")) {
-                    forceJumbo = true;
                 } else {
                     System.err.println("unknown option: " + parser.getCurrent());
                     throw new UsageException();
@@ -1186,7 +1180,6 @@
 
             dexOptions = new DexOptions();
             dexOptions.targetApiLevel = targetApiLevel;
-            dexOptions.forceJumbo = forceJumbo;
         }
     }
 
diff --git a/dx/src/com/android/dx/dex/DexOptions.java b/dx/src/com/android/dx/dex/DexOptions.java
index 0a07451..0357384 100644
--- a/dx/src/com/android/dx/dex/DexOptions.java
+++ b/dx/src/com/android/dx/dex/DexOptions.java
@@ -23,9 +23,6 @@
     /** target API level */
     public int targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
 
-    /** force generation of jumbo opcodes */
-    public boolean forceJumbo = false;
-
     /**
      * Gets the dex file magic number corresponding to this instance.
      */
diff --git a/dx/src/com/android/dx/dex/code/OutputFinisher.java b/dx/src/com/android/dx/dex/code/OutputFinisher.java
index c9387fa..3602de8 100644
--- a/dx/src/com/android/dx/dex/code/OutputFinisher.java
+++ b/dx/src/com/android/dx/dex/code/OutputFinisher.java
@@ -504,14 +504,7 @@
 
         while (guess != null) {
             if (guess.getFormat().isCompatible(insn)) {
-                /*
-                 * Don't break out for const_string to generate jumbo version
-                 * when option is enabled.
-                 */
-                if (!dexOptions.forceJumbo ||
-                    guess.getOpcode() != Opcodes.CONST_STRING) {
-                    break;
-                }
+                break;
             }
 
             guess = Dops.getNextOrNull(guess, dexOptions);
diff --git a/dx/src/com/android/dx/merge/InstructionTransformer.java b/dx/src/com/android/dx/merge/InstructionTransformer.java
index 6051e17..62c3a49 100644
--- a/dx/src/com/android/dx/merge/InstructionTransformer.java
+++ b/dx/src/com/android/dx/merge/InstructionTransformer.java
@@ -17,7 +17,6 @@
 package com.android.dx.merge;
 
 import com.android.dx.io.CodeReader;
-import com.android.dx.io.Opcodes;
 import com.android.dx.io.instructions.DecodedInstruction;
 import com.android.dx.io.instructions.ShortArrayCodeOutput;
 import com.android.dx.util.DexException;
@@ -67,8 +66,7 @@
         public void visit(DecodedInstruction[] all, DecodedInstruction one) {
             int stringId = one.getIndex();
             int mappedId = indexMap.adjustString(stringId);
-            boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO);
-            jumboCheck(isJumbo, mappedId);
+            jumboCheck(stringId, mappedId);
             mappedInstructions[mappedAt++] = one.withIndex(mappedId);
         }
     }
@@ -77,8 +75,7 @@
         public void visit(DecodedInstruction[] all, DecodedInstruction one) {
             int fieldId = one.getIndex();
             int mappedId = indexMap.adjustField(fieldId);
-            boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO);
-            jumboCheck(isJumbo, mappedId);
+            jumboCheck(fieldId, mappedId);
             mappedInstructions[mappedAt++] = one.withIndex(mappedId);
         }
     }
@@ -87,8 +84,7 @@
         public void visit(DecodedInstruction[] all, DecodedInstruction one) {
             int typeId = one.getIndex();
             int mappedId = indexMap.adjustType(typeId);
-            boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO);
-            jumboCheck(isJumbo, mappedId);
+            jumboCheck(typeId, mappedId);
             mappedInstructions[mappedAt++] = one.withIndex(mappedId);
         }
     }
@@ -97,16 +93,14 @@
         public void visit(DecodedInstruction[] all, DecodedInstruction one) {
             int methodId = one.getIndex();
             int mappedId = indexMap.adjustMethod(methodId);
-            boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO);
-            jumboCheck(isJumbo, mappedId);
+            jumboCheck(methodId, mappedId);
             mappedInstructions[mappedAt++] = one.withIndex(mappedId);
         }
     }
 
-    private static void jumboCheck(boolean isJumbo, int newIndex) {
-        if (!isJumbo && (newIndex > 0xffff)) {
-            throw new DexException("Cannot merge new index " + newIndex +
-                                   " into a non-jumbo instruction!");
+    private static void jumboCheck(int oldIndex, int newIndex) {
+        if ((oldIndex <= 0xffff) && (newIndex > 0xffff)) {
+            throw new DexException("Cannot handle conversion to jumbo index!");
         }
     }
 }