Permalink
Browse files

revert to asm-2.2.3

  • Loading branch information...
1 parent 165981c commit 200a06a7a7325fe66f010a86c1f51c982a011cc4 @krestenkrab committed Dec 3, 2009
View
@@ -3,7 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="examples"/>
<classpathentry kind="src" path="bench"/>
- <classpathentry kind="src" path="test"/>
+ <classpathentry kind="src" output="testclasses" path="test"/>
<classpathentry kind="lib" path="libs/asm-all-2.2.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="libs/junit.jar"/>
View
Binary file not shown.
View
Binary file not shown.
@@ -23,7 +23,7 @@ public static int getPausableStatus(String className, String methodName,
if (classCache == null) {
ClassReader cr = new ClassReader(className);
ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
+ cr.accept(cn, false);
classCache = cache(className, cn);
}
int status = classCache.getPausableStatus(methodName, desc);
@@ -41,7 +41,6 @@
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.IincInsnNode;
-import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
@@ -297,8 +296,8 @@ int initialize(int pos) {
case IF_ACMPNE:
case JSR:
case GOTO:
- LabelNode l = ((JumpInsnNode) ain).label;
- bb = flow.getOrCreateBasicBlock(l.getLabel());
+ Label l = ((JumpInsnNode) ain).label;
+ bb = flow.getOrCreateBasicBlock(l);
if (opcode == JSR) {
bb.setFlag(IS_SUBROUTINE);
hasFollower = false;
@@ -324,20 +323,20 @@ int initialize(int pos) {
case TABLESWITCH:
case LOOKUPSWITCH:
- LabelNode defaultLabel;
- List<LabelNode> otherLabels;
+ Label defaultLabel;
+ List<Label> otherLabels;
if (opcode == TABLESWITCH) {
defaultLabel = ((TableSwitchInsnNode) ain).dflt;
otherLabels = ((TableSwitchInsnNode) ain).labels;
} else {
defaultLabel = ((LookupSwitchInsnNode) ain).dflt;
otherLabels = ((LookupSwitchInsnNode) ain).labels;
}
- for (Iterator<LabelNode> it = otherLabels.iterator(); it.hasNext();) {
- l = (LabelNode) it.next();
- addSuccessor(flow.getOrCreateBasicBlock(l.getLabel()));
+ for (Iterator<Label> it = otherLabels.iterator(); it.hasNext();) {
+ l = (Label) it.next();
+ addSuccessor(flow.getOrCreateBasicBlock(l));
}
- addSuccessor(flow.getOrCreateBasicBlock(defaultLabel.getLabel()));
+ addSuccessor(flow.getOrCreateBasicBlock(defaultLabel));
endOfBB = true;
hasFollower = false;
break;
@@ -350,8 +349,8 @@ int initialize(int pos) {
if (pos == startPos) {
setFlag(PAUSABLE);
} else {
- Label ll = flow.getOrCreateLabelAtPos(pos);
- bb = flow.getOrCreateBasicBlock(ll);
+ l = flow.getOrCreateLabelAtPos(pos);
+ bb = flow.getOrCreateBasicBlock(l);
bb.setFlag(PAUSABLE);
addSuccessor(bb);
pos--; // don't consume this instruction
@@ -1065,8 +1064,6 @@ void interpret() {
v = Value.make(i, TypeDesc.getInterned(sb.toString()));
frame.push(v);
break;
- case -1:
- break;
default:
assert false : "Unexpected opcode: " + ain.getOpcode();
}
@@ -1192,7 +1189,7 @@ public boolean flowVarUsage() {
*/
ArrayList<BasicBlock> inline() throws KilimException {
HashMap<BasicBlock, BasicBlock> bbCopyMap = null;
- HashMap<Label, LabelNode> labelCopyMap = null;
+ HashMap<Label, Label> labelCopyMap = null;
BasicBlock targetBB = successors.get(0);
Label returnToLabel = flow.getOrCreateLabelAtPos(endPos+1);
BasicBlock returnToBB = flow.getOrCreateBasicBlock(returnToLabel);
@@ -1213,7 +1210,7 @@ public boolean flowVarUsage() {
return null;
}
bbCopyMap = new HashMap<BasicBlock, BasicBlock>(10);
- labelCopyMap = new HashMap<Label, LabelNode>(10);
+ labelCopyMap = new HashMap<Label, Label>(10);
successors.clear();
// first pass
targetBB.dupBBAndLabels(isPausableSub, bbCopyMap, labelCopyMap, returnToBB);
@@ -1224,7 +1221,7 @@ public boolean flowVarUsage() {
void dupBBAndLabels(boolean deepCopy,
HashMap<BasicBlock, BasicBlock> bbCopyMap,
- HashMap<Label, LabelNode> labelCopyMap, BasicBlock returnToBB)
+ HashMap<Label, Label> labelCopyMap, BasicBlock returnToBB)
throws KilimException {
for (BasicBlock orig : getSubBlocks()) {
@@ -1236,7 +1233,7 @@ void dupBBAndLabels(boolean deepCopy,
for (int i = orig.startPos; i <= orig.endPos; i++) {
Label origLabel = flow.getLabelAt(i);
if (origLabel != null) {
- LabelNode l = labelCopyMap.put(origLabel, new LabelNode());
+ Label l = labelCopyMap.put(origLabel, new Label());
assert l == null;
}
}
@@ -1249,7 +1246,7 @@ void dupBBAndLabels(boolean deepCopy,
static ArrayList<BasicBlock> dupCopyContents(boolean deepCopy,
BasicBlock targetBB, BasicBlock returnToBB,
HashMap<BasicBlock, BasicBlock> bbCopyMap,
- HashMap<Label, LabelNode> labelCopyMap) throws KilimException {
+ HashMap<Label, Label> labelCopyMap) throws KilimException {
ArrayList<BasicBlock> newBBs = new ArrayList<BasicBlock>(targetBB.getSubBlocks().size());
for (BasicBlock orig : targetBB.getSubBlocks()) {
@@ -1281,9 +1278,9 @@ void dupBBAndLabels(boolean deepCopy,
if (deepCopy) {
MethodFlow flow = targetBB.flow;
- InsnList instructions = flow.instructions;
+ List instructions = flow.instructions;
// copy instructions
- dup.startLabel = labelCopyMap.get(orig.startLabel).getLabel();
+ dup.startLabel = labelCopyMap.get(orig.startLabel);
dup.startPos = instructions.size();
dup.endPos = dup.startPos + (orig.endPos - orig.startPos);
// Note: last instruction (@endPos) isn't copied in the loop.
@@ -1297,7 +1294,7 @@ void dupBBAndLabels(boolean deepCopy,
for (i = orig.startPos; i <= end; i++, newPos++) {
Label l = flow.getLabelAt(i);
if (l != null) {
- l = labelCopyMap.get(l).getLabel();
+ l = labelCopyMap.get(l);
assert l != null;
flow.setLabel(newPos, l);
}
@@ -1308,7 +1305,7 @@ void dupBBAndLabels(boolean deepCopy,
}
AbstractInsnNode lastInsn = (AbstractInsnNode) instructions.get(orig.endPos);
- LabelNode dupLabel;
+ Label dupLabel;
int opcode = lastInsn.getOpcode();
if (lastInsn instanceof JumpInsnNode) {
JumpInsnNode jin = (JumpInsnNode) lastInsn;
@@ -1320,7 +1317,7 @@ void dupBBAndLabels(boolean deepCopy,
} else if (opcode == TABLESWITCH) {
TableSwitchInsnNode tsin = (TableSwitchInsnNode) lastInsn;
- LabelNode[] labels = new LabelNode[tsin.labels.size()];
+ Label[] labels = new Label[tsin.labels.size()];
for (i = 0; i < labels.length; i++) {
dupLabel = labelCopyMap.get(tsin.labels.get(i));
assert dupLabel != null;
@@ -1331,7 +1328,7 @@ void dupBBAndLabels(boolean deepCopy,
lastInsn = new TableSwitchInsnNode(tsin.min, tsin.max, dupLabel, labels);
} else if (opcode == LOOKUPSWITCH) {
LookupSwitchInsnNode lsin = (LookupSwitchInsnNode) lastInsn;
- LabelNode[] labels = new LabelNode[lsin.labels.size()];
+ Label[] labels = new Label[lsin.labels.size()];
for (i = 0; i < labels.length; i++) {
dupLabel = labelCopyMap.get(lsin.labels.get(i));
assert dupLabel != null;
@@ -1495,12 +1492,11 @@ void changeJSR_RET_toGOTOs() throws KilimException {
@SuppressWarnings("unchecked")
void setInstruction(int pos, AbstractInsnNode insn) {
- AbstractInsnNode location = flow.instructions.get(pos);
- flow.instructions.set(location, insn);
+ flow.instructions.set(pos, insn);
}
void changeLastInsnToGOTO(Label label) {
- setInstruction(endPos, new JumpInsnNode(GOTO, flow.getLabelNode(label)));
+ setInstruction(endPos, new JumpInsnNode(GOTO, label));
}
public boolean isGetCurrentTask() {
@@ -300,7 +300,7 @@ int getNumBottom() {
*/
void genRewind(MethodVisitor mv) {
Frame f = bb.startFrame;
- // Usage u = bb.usage;
+ Usage u = bb.usage;
// The last parameter to the method is fiber, but the original
// code doesn't know that and will use up that slot as it
@@ -74,7 +74,7 @@ public MethodVisitor visitMethod(
public ArrayList<MethodFlow> analyze(boolean forceAnalysis) throws KilimException {
// cr.accept(this, ClassReader.SKIP_DEBUG);
- cr.accept(this, 0);
+ cr.accept(this, true);
for (Object o: this.fields) {
FieldNode fn = (FieldNode)o;
if (fn.name.equals(Constants.WOVEN_FIELD)) {
@@ -49,7 +49,7 @@ public ClassWeaver(String className, Detector detector) throws IOException {
private void weave() throws KilimException {
classFlow.analyze(false);
if (classFlow.isPausable() && needsWeaving()) {
- ClassWriter cw = new ClassWriter(0);
+ ClassWriter cw = new ClassWriter(false);
accept(cw);
addClassInfo(new ClassInfo(classFlow.getClassName(), cw.toByteArray()));
}
@@ -187,7 +187,7 @@ String createStateClass(ValInfoList valInfoList) {
return className;
}
stateClasses.add(className);
- ClassWriter cw = new ClassWriter(0);
+ ClassWriter cw = new ClassWriter(false);
cw.visit(V1_1, ACC_PUBLIC | ACC_FINAL, className, null, "kilim/State", null);
// Create default constructor
@@ -175,15 +175,6 @@ private String toString(String className, String methName, String desc) {
return className.replace('/', '.') + '.' + methName + desc;
}
- /* (non-Javadoc)
- * @see org.objectweb.asm.tree.MethodNode#visitLineNumber(int, org.objectweb.asm.Label)
- */
- @Override
- public void visitLineNumber(int line, Label start) {
- // TODO Auto-generated method stub
- super.visitLineNumber(line, start);
- }
-
@Override
public void visitLabel(Label label) {
// if (hasPausableAnnotation)
@@ -286,7 +277,7 @@ private void assignCatchHandlers() {
getLabelPosition(tcb.start),
getLabelPosition(tcb.end) - 1, // end is inclusive
tcb.type,
- getOrCreateBasicBlock(tcb.handler.getLabel())));
+ getOrCreateBasicBlock(tcb.handler)));
}
for (BasicBlock bb : basicBlocks) {
bb.chooseCatchHandlers(handlers);
@@ -406,10 +397,6 @@ Label getOrCreateLabelAtPos(int pos) {
return ret;
}
- int getLabelPosition(LabelNode l) {
- return labelToPosMap.get(l.getLabel());
- }
-
int getLabelPosition(Label l) {
return labelToPosMap.get(l);
}
@@ -532,12 +519,10 @@ public void accept(final MethodVisitor mv) {
((LocalVariableNode) localVariables.get(i)).accept(mv);
}
// visits line numbers
- /*
n = lineNumbers == null ? 0 : lineNumbers.size();
for (i = 0; i < n; ++i) {
((LineNumberNode) lineNumbers.get(i)).accept(mv);
}
- */
// visits maxs
mv.visitMaxs(maxStack, maxLocals);
}
@@ -156,7 +156,7 @@ private void visitCode(MethodVisitor mv) {
mv.visitCode();
visitTryCatchBlocks(mv);
visitInstructions(mv);
- //visitLineNumbers(mv);
+ visitLineNumbers(mv);
visitLocals(mv);
mv.visitMaxs(maxStack, maxVars);
}
@@ -168,13 +168,11 @@ private void visitLocals(MethodVisitor mv) {
}
}
- /*
private void visitLineNumbers(MethodVisitor mv) {
- for (Object l: methodFlow.lineNumbers()) {
+ for (Object l: methodFlow.lineNumbers) {
((LineNumberNode)l).accept(mv);
}
}
-*/
private void visitInstructions(MethodVisitor mv) {
//TODO gen code for pausable JSRs
@@ -27,13 +27,4 @@ public int getType() {
public void accept(MethodVisitor mv) {
// Do nothing
}
-
- /* (non-Javadoc)
- * @see org.objectweb.asm.tree.AbstractInsnNode#clone(java.util.Map)
- */
- @Override
- public AbstractInsnNode clone(Map labels) {
- // TODO Auto-generated method stub
- return this;
- }
}
View
@@ -89,7 +89,7 @@ public static void main(String[] args) throws IOException {
public Asm(String afileName) throws IOException {
fileName = afileName;
reader = new LineNumberReader(new FileReader(fileName));
- cv = new ClassWriter(0);
+ cv = new ClassWriter(false);
try {
parseClass();
} catch (EOF eof) {
@@ -44,7 +44,7 @@
public static void main(String[] args) throws IOException {
String name = args.length == 2 ? args[1] : args[0];
//int flags = args.length == 2 ? 0: ClassReader.SKIP_DEBUG;
- int flags = ClassReader.SKIP_DEBUG; // skipdebug
+ boolean flags = false; // skipdebug
if (name.endsWith(".jar")) {
try {
@@ -66,7 +66,7 @@ public static void main(String[] args) throws IOException {
- DumpClass(String className, int flags) throws IOException {
+ DumpClass(String className, boolean flags) throws IOException {
ClassReader cr;
if (className.endsWith(".class")) {
FileInputStream fis = new FileInputStream(className);
View
@@ -9,15 +9,14 @@
import java.util.ArrayList;
import java.util.List;
-import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.InsnList;
-import org.objectweb.asm.tree.MethodInsnNode;
-
+import junit.framework.TestCase;
import kilim.analysis.BasicBlock;
import kilim.analysis.ClassFlow;
import kilim.analysis.Detector;
import kilim.analysis.MethodFlow;
-import junit.framework.TestCase;
+
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
public class Base extends TestCase {
private static ArrayList<MethodFlow> stflows;
@@ -69,7 +68,7 @@ protected void checkCov(String methodName) {
ArrayList<BasicBlock> bbs = flow.getBasicBlocks();
// Verify that all instructions are covered and that the only ones that
// aren't are labelnodes. Also verify that there are no overlaps.
- InsnList instructions = flow.instructions;
+ List instructions = flow.instructions;
int size = instructions.size();
boolean coverage[] = new boolean[size];
for (int i = 0; i < size; i++) {

0 comments on commit 200a06a

Please sign in to comment.