diff options
author | jeffhao <jeffhao@google.com> | 2012-10-17 10:50:43 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-17 10:50:43 -0700 |
commit | d5cc36801bb86ba4e8b3db6efc67282f41b5b784 (patch) | |
tree | ba955c731aa8992b1ae1e046befb9f8950c9690e | |
parent | 9bd5a9db106863069dd6c12de881acca6103f8d7 (diff) | |
parent | 9db54b1e21b8e994658890328e57caa822e444a7 (diff) | |
download | android_dalvik-d5cc36801bb86ba4e8b3db6efc67282f41b5b784.tar.gz android_dalvik-d5cc36801bb86ba4e8b3db6efc67282f41b5b784.tar.bz2 android_dalvik-d5cc36801bb86ba4e8b3db6efc67282f41b5b784.zip |
am 9db54b1e: Add dx option to always generate const-string/jumbo. do not merge.
* commit '9db54b1e21b8e994658890328e57caa822e444a7':
Add dx option to always generate const-string/jumbo. do not merge.
-rw-r--r-- | dx/src/com/android/dx/command/Main.java | 2 | ||||
-rw-r--r-- | dx/src/com/android/dx/command/dexer/Main.java | 7 | ||||
-rw-r--r-- | dx/src/com/android/dx/dex/DexOptions.java | 3 | ||||
-rw-r--r-- | dx/src/com/android/dx/dex/code/OutputFinisher.java | 9 | ||||
-rw-r--r-- | dx/src/com/android/dx/merge/InstructionTransformer.java | 20 |
5 files changed, 32 insertions, 9 deletions
diff --git a/dx/src/com/android/dx/command/Main.java b/dx/src/com/android/dx/command/Main.java index 10a117929..6540e353b 100644 --- a/dx/src/com/android/dx/command/Main.java +++ b/dx/src/com/android/dx/command/Main.java @@ -33,7 +33,7 @@ public class Main { "[--dump-width=<n>]\n" + " [--dump-method=<name>[*]] [--verbose-dump] [--no-files] " + "[--core-library]\n" + - " [--num-threads=<n>]\n" + + " [--num-threads=<n>] [--incremental] [--force-jumbo]\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 80ddbd0a2..87f152afb 100644 --- a/dx/src/com/android/dx/command/dexer/Main.java +++ b/dx/src/com/android/dx/command/dexer/Main.java @@ -934,6 +934,10 @@ public class Main { /** 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; @@ -1140,6 +1144,8 @@ public class Main { 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(); @@ -1180,6 +1186,7 @@ public class Main { 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 03573844e..0a0745192 100644 --- a/dx/src/com/android/dx/dex/DexOptions.java +++ b/dx/src/com/android/dx/dex/DexOptions.java @@ -23,6 +23,9 @@ public class DexOptions { /** 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 3602de8f9..c9387fab6 100644 --- a/dx/src/com/android/dx/dex/code/OutputFinisher.java +++ b/dx/src/com/android/dx/dex/code/OutputFinisher.java @@ -504,7 +504,14 @@ public final class OutputFinisher { while (guess != null) { if (guess.getFormat().isCompatible(insn)) { - break; + /* + * Don't break out for const_string to generate jumbo version + * when option is enabled. + */ + if (!dexOptions.forceJumbo || + guess.getOpcode() != Opcodes.CONST_STRING) { + 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 62c3a49f3..6051e17d8 100644 --- a/dx/src/com/android/dx/merge/InstructionTransformer.java +++ b/dx/src/com/android/dx/merge/InstructionTransformer.java @@ -17,6 +17,7 @@ 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; @@ -66,7 +67,8 @@ final class InstructionTransformer { public void visit(DecodedInstruction[] all, DecodedInstruction one) { int stringId = one.getIndex(); int mappedId = indexMap.adjustString(stringId); - jumboCheck(stringId, mappedId); + boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); + jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); } } @@ -75,7 +77,8 @@ final class InstructionTransformer { public void visit(DecodedInstruction[] all, DecodedInstruction one) { int fieldId = one.getIndex(); int mappedId = indexMap.adjustField(fieldId); - jumboCheck(fieldId, mappedId); + boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); + jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); } } @@ -84,7 +87,8 @@ final class InstructionTransformer { public void visit(DecodedInstruction[] all, DecodedInstruction one) { int typeId = one.getIndex(); int mappedId = indexMap.adjustType(typeId); - jumboCheck(typeId, mappedId); + boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); + jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); } } @@ -93,14 +97,16 @@ final class InstructionTransformer { public void visit(DecodedInstruction[] all, DecodedInstruction one) { int methodId = one.getIndex(); int mappedId = indexMap.adjustMethod(methodId); - jumboCheck(methodId, mappedId); + boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); + jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); } } - private static void jumboCheck(int oldIndex, int newIndex) { - if ((oldIndex <= 0xffff) && (newIndex > 0xffff)) { - throw new DexException("Cannot handle conversion to jumbo index!"); + 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!"); } } } |