summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-08-19 16:21:33 -0400
committerJesse Wilson <jessewilson@google.com>2011-08-19 16:27:48 -0400
commita6264bd14e66bd05f98d0b1b98ee9e044b93faf9 (patch)
tree4c0053d9e254fd648791da52f913535ab219dc2a
parentf28000dc9b6f596921b1a4387746bea4c8cd207f (diff)
downloaddalvik-a6264bd14e66bd05f98d0b1b98ee9e044b93faf9.tar.gz
Permit code size to grow when merging dex files.
The throws clauses use variable-length encodings (sleb and uleb) which will have different lengths when the number of types grows. Bug: http://b/5127963 Change-Id: I50598a807596955e458d4ec87a730e62e12168d9
-rw-r--r--dx/src/com/android/dx/merge/DexMerger.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/dx/src/com/android/dx/merge/DexMerger.java b/dx/src/com/android/dx/merge/DexMerger.java
index 50a5dbbe6..b8071176a 100644
--- a/dx/src/com/android/dx/merge/DexMerger.java
+++ b/dx/src/com/android/dx/merge/DexMerger.java
@@ -893,7 +893,6 @@ public final class DexMerger {
+ contents.classDefs.size * SizeOf.CLASS_DEF_ITEM;
mapList = SizeOf.UINT + (contents.sections.length * SizeOf.MAP_ITEM);
typeList += contents.typeLists.byteCount;
- code += contents.codes.byteCount;
stringData += contents.stringDatas.byteCount;
debugInfo += contents.debugInfos.byteCount;
annotationsDirectory += contents.annotationsDirectories.byteCount;
@@ -901,12 +900,18 @@ public final class DexMerger {
annotationsSetRefList += contents.annotationSetRefLists.byteCount;
if (exact) {
+ code += contents.codes.byteCount;
classData += contents.classDatas.byteCount;
encodedArray += contents.encodedArrays.byteCount;
annotation += contents.annotations.byteCount;
} else {
+ // at most 1/4 of the bytes in a code section are uleb/sleb
+ code += (int) Math.ceil(contents.codes.byteCount * 1.25);
+ // at most 1/3 of the bytes in a class data section are uleb/sleb
classData += (int) Math.ceil(contents.classDatas.byteCount * 1.34);
+ // all of the bytes in an encoding arrays section may be uleb/sleb
encodedArray += contents.encodedArrays.byteCount * 2;
+ // at most 1/3 of the bytes in an encoding arrays section are uleb/sleb
annotation += (int) Math.ceil(contents.annotations.byteCount * 1.34);
}
}