use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class ReflectiveFunctorFactory method branch.
@Override
public EvaluationFunctor<Boolean> branch(Type lt, Type rt, ConditionalJumpStmt.ComparisonType type) {
Type opType = TypeUtils.resolveBinOpType(lt, rt);
String name = lt.getClassName() + type.name() + rt.getClassName() + "OPTYPE" + opType.getClassName() + "RETbool";
String desc = "(" + lt.getDescriptor() + rt.getDescriptor() + ")Z";
if (cache.containsKey(name)) {
return _get(name);
}
MethodNode m = makeBase(name, desc);
{
InsnList insns = new InsnList();
insns.add(new VarInsnNode(TypeUtils.getVariableLoadOpcode(lt), 0));
cast(insns, lt, opType);
insns.add(new VarInsnNode(TypeUtils.getVariableLoadOpcode(rt), lt.getSize()));
cast(insns, rt, opType);
LabelNode trueSuccessor = new LabelNode();
if (opType == Type.INT_TYPE) {
insns.add(new JumpInsnNode(Opcodes.IF_ICMPEQ + type.ordinal(), trueSuccessor));
} else if (opType == Type.LONG_TYPE) {
insns.add(new InsnNode(Opcodes.LCMP));
insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
} else if (opType == Type.FLOAT_TYPE) {
insns.add(new InsnNode((type == ConditionalJumpStmt.ComparisonType.LT || type == ConditionalJumpStmt.ComparisonType.LE) ? Opcodes.FCMPL : Opcodes.FCMPG));
insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
} else if (opType == Type.DOUBLE_TYPE) {
insns.add(new InsnNode((type == ConditionalJumpStmt.ComparisonType.LT || type == ConditionalJumpStmt.ComparisonType.LE) ? Opcodes.DCMPL : Opcodes.DCMPG));
insns.add(new JumpInsnNode(Opcodes.IFEQ + type.ordinal(), trueSuccessor));
} else {
throw new IllegalArgumentException(opType.toString());
}
branchReturn(insns, trueSuccessor);
m.instructions = insns;
}
return buildBridge(m);
}
use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class LiftConstructorCallsPass method split.
private void split(ControlFlowGraph cfg, BasicBlock b, Stmt at) {
BasicBlock newBlock = new BasicBlock(cfg, cfg.vertices().size() + 1, new LabelNode());
cfg.addVertex(newBlock);
System.out.println(ControlFlowGraph.printBlock(b));
System.out.println(" to " + at);
int index = b.indexOf(at) + 1;
int size = b.size();
for (int i = index; i < size; i++) {
Stmt stmt = b.remove(index);
stmt.setBlock(newBlock);
newBlock.add(stmt);
}
}
use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class LineNumberNodeSerializer method deserialize.
@Override
public LineNumberNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
int line = jsonObject.get("line").getAsInt();
LabelNode start = context.deserialize(jsonObject.get("start"), LabelNode.class);
return new LineNumberNode(line, start);
}
use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class TableSwitchInsnNodeSerializer method deserialize.
@Override
public TableSwitchInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
int min = jsonObject.get("min").getAsInt();
int max = jsonObject.get("max").getAsInt();
LabelNode dflt = context.deserialize(jsonObject.get("dflt"), LabelNode.class);
List<LabelNode> labelList = context.deserialize(jsonObject.get("labels"), List.class);
LabelNode[] labels = new LabelNode[labelList.size()];
for (int i = 0; i < labels.length; i++) {
labels[i] = labelList.get(i);
}
return new TableSwitchInsnNode(min, max, dflt, labels);
}
use of org.objectweb.asm.tree.LabelNode in project jacoco by jacoco.
the class SynchronizedFilterTest method ecj.
@Test
public void ecj() {
final Label start = new Label();
final Label end = new Label();
final Label handler = new Label();
final Label handlerEnd = new Label();
m.visitTryCatchBlock(start, end, handler, null);
m.visitTryCatchBlock(handler, handlerEnd, handler, null);
m.visitVarInsn(Opcodes.ALOAD, 0);
m.visitFieldInsn(Opcodes.GETFIELD, "Target", "lock", "Ljava/lang/Object;");
m.visitInsn(Opcodes.DUP);
m.visitVarInsn(Opcodes.ASTORE, 1);
m.visitInsn(Opcodes.MONITORENTER);
m.visitLabel(start);
m.visitVarInsn(Opcodes.ALOAD, 0);
m.visitInsn(Opcodes.NOP);
m.visitVarInsn(Opcodes.ALOAD, 1);
m.visitInsn(Opcodes.MONITOREXIT);
m.visitLabel(end);
final Label exit = new Label();
m.visitJumpInsn(Opcodes.GOTO, exit);
m.visitLabel(handler);
m.visitVarInsn(Opcodes.ALOAD, 1);
m.visitInsn(Opcodes.MONITOREXIT);
m.visitLabel(handlerEnd);
m.visitInsn(Opcodes.ATHROW);
m.visitLabel(exit);
m.visitInsn(Opcodes.RETURN);
filter.filter(m, context, output);
assertIgnored(new Range((LabelNode) handler.info, ((LabelNode) exit.info).getPrevious()));
}
Aggregations