aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/stackmap
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2009-10-19 05:57:11 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2009-10-19 05:57:11 +0000
commit7c8fdddf5fe49444f61c8fd36fc2734293af2bb0 (patch)
tree143afe2176de9ea41bd7d065377398d42c86c0ee /src/main/javassist/bytecode/stackmap
parent0fc7d9b123a5fcf3fc3353e0fdce64a41ec6fbfc (diff)
downloadjavassist-7c8fdddf5fe49444f61c8fd36fc2734293af2bb0.tar.gz
javassist-7c8fdddf5fe49444f61c8fd36fc2734293af2bb0.zip
for JIRA-95
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@497 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/stackmap')
-rw-r--r--src/main/javassist/bytecode/stackmap/MapMaker.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/javassist/bytecode/stackmap/MapMaker.java b/src/main/javassist/bytecode/stackmap/MapMaker.java
index df3300cc..c9fde029 100644
--- a/src/main/javassist/bytecode/stackmap/MapMaker.java
+++ b/src/main/javassist/bytecode/stackmap/MapMaker.java
@@ -462,6 +462,57 @@ public class MapMaker extends Tracer {
return num;
}
+<<<<<<< .mine
+
+ // Phase 3 for J2ME
+
+ public StackMap toStackMap2(ConstPool cp, TypedBlock[] blocks) {
+ StackMap.Writer writer = new StackMap.Writer();
+ int n = blocks.length;
+ boolean[] effective = new boolean[n];
+ TypedBlock prev = blocks[0];
+
+ // Is the first instruction a branch target?
+ effective[0] = prev.incoming > 0;
+
+ int num = effective[0] ? 1 : 0;
+ for (int i = 1; i < n; i++) {
+ TypedBlock bb = blocks[i];
+ if (effective[i] = isTarget(bb, blocks[i - 1])) {
+ bb.resetNumLocals();
+ prev = bb;
+ num++;
+ }
+ }
+
+ writer.write16bit(num);
+ for (int i = 0; i < n; i++)
+ if (effective[i])
+ writeStackFrame(writer, cp, blocks[i].position, blocks[i]);
+
+ return writer.toStackMap(cp);
+ }
+
+ private void writeStackFrame(StackMap.Writer writer, ConstPool cp, int offset, TypedBlock tb) {
+ writer.write16bit(offset);
+ writeVerifyTypeInfo(writer, cp, tb.localsTypes, tb.numLocals);
+ writeVerifyTypeInfo(writer, cp, tb.stackTypes, tb.stackTop);
+ }
+
+ private void writeVerifyTypeInfo(StackMap.Writer writer, ConstPool cp, TypeData[] types, int num) {
+ writer.write16bit(num);
+ for (int i = 0; i < num; i++) {
+ TypeData td = types[i];
+ if (td == TOP)
+ writer.writeVerifyTypeInfo(StackMap.TOP, 0);
+ else {
+ writer.writeVerifyTypeInfo(td.getTypeTag(), td.getTypeData(cp));
+ if (td.is2WordType())
+ i++;
+ }
+ }
+ }
+=======
// Phase 3 for J2ME
@@ -500,4 +551,5 @@ public class MapMaker extends Tracer {
}
}
}
+>>>>>>> .r495
}