use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class JumpInsnNodeSerializer method deserialize.
@Override
public JumpInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = (JsonObject) json;
int opcode = jsonObject.get("opcode").getAsInt();
LabelNode labelNode = context.deserialize(jsonObject.get("local"), List.class);
return new JumpInsnNode(opcode, labelNode);
}
use of org.objectweb.asm.tree.LabelNode in project maple-ir by LLVM-but-worse.
the class ControlFlowGraphDumper method verifyRanges.
private void verifyRanges() {
for (TryCatchBlockNode tc : m.tryCatchBlocks) {
int start = -1, end = -1, handler = -1;
for (int i = 0; i < m.instructions.size(); i++) {
AbstractInsnNode ain = m.instructions.get(i);
if (!(ain instanceof LabelNode))
continue;
Label l = ((LabelNode) ain).getLabel();
if (l == tc.start.getLabel())
start = i;
if (l == tc.end.getLabel()) {
if (start == -1)
throw new IllegalStateException("Try block end before start " + m);
end = i;
}
if (l == tc.handler.getLabel()) {
handler = i;
}
}
if (start == -1 || end == -1 || handler == -1)
throw new IllegalStateException("Try/catch endpoints missing: " + start + " " + end + " " + handler + m);
}
}
use of org.objectweb.asm.tree.LabelNode in project bytecode-viewer by Konloch.
the class InstructionPrinter method printLookupSwitchInsnNode.
protected String printLookupSwitchInsnNode(LookupSwitchInsnNode lin) {
StringBuilder line = new StringBuilder(nameOpcode(lin.getOpcode()) + ": \n");
List<?> keys = lin.keys;
List<?> labels = lin.labels;
for (int i = 0; i < keys.size(); i++) {
int key = (Integer) keys.get(i);
LabelNode label = (LabelNode) labels.get(i);
line.append(" val: ").append(key).append(" -> ").append("L").append(resolveLabel(label)).append("\n");
}
line.append(" default" + " -> L").append(resolveLabel(lin.dflt));
return line.toString();
}
use of org.objectweb.asm.tree.LabelNode in project atlas by alibaba.
the class TBIncrementalSupportVisitor method visitMethod.
/**
* Insert Constructor specific logic({@link ConstructorRedirection} and
* {@link ConstructorBuilder}) for constructor redirecting or
* normal method redirecting ({@link MethodRedirection}) for other methods.
*/
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
access = transformAccessForInstantRun(access);
MethodVisitor defaultVisitor = super.visitMethod(access, name, desc, signature, exceptions);
MethodNode method = checkNotNull(getMethodByNameInClass(name, desc, classNode), "Method found by visitor but not in the pre-parsed class node.");
if (!supportAddCallSuper) {
method.instructions.accept(new MethodVisitor(api) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKESPECIAL && !owner.equals(visitedClassName)) {
visitSuperMethods.add(name + "." + desc);
}
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
});
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
return defaultVisitor;
}
boolean hasIncompatibleChange = InstantRunMethodVerifier.verifyMethod(method) != InstantRunVerifierStatus.COMPATIBLE;
if (hasIncompatibleChange || disableRedirectionForClass || !isAccessCompatibleWithInstantRun(access) || name.equals(ByteCodeUtils.CLASS_INITIALIZER)) {
return defaultVisitor;
} else {
ArrayList<Type> args = new ArrayList<>(Arrays.asList(Type.getArgumentTypes(desc)));
boolean isStatic = (access & Opcodes.ACC_STATIC) != 0;
if (!isStatic) {
args.add(0, Type.getType(Object.class));
}
// Install the Jsr/Ret inliner adapter, we have had reports of code still using the
// Jsr/Ret deprecated byte codes.
// see https://code.google.com/p/android/issues/detail?id=220019
JSRInlinerAdapter jsrInlinerAdapter = new JSRInlinerAdapter(defaultVisitor, access, name, desc, signature, exceptions);
ISMethodVisitor mv = new ISMethodVisitor(jsrInlinerAdapter, access, name, desc);
if (name.equals(ByteCodeUtils.CONSTRUCTOR)) {
if (patchInitMethod) {
Constructor constructor = ConstructorBuilder.build(visitedClassName, method);
LabelNode start = new LabelNode();
method.instructions.insert(constructor.loadThis, start);
if (constructor.lineForLoad != -1) {
// Record the line number from the start of LOAD_0 for uninitialized 'this'.
// This allows a breakpoint to be set at the line with this(...) or super(...)
// call in the constructor.
method.instructions.insert(constructor.loadThis, new LineNumberNode(constructor.lineForLoad, start));
}
mv.addRedirection(new TBConstructorRedirection(start, constructor, args));
} else {
return defaultVisitor;
}
} else {
mv.addRedirection(new TBMethodRedirection(new LabelNode(mv.getStartLabel()), name + "." + desc, args, Type.getReturnType(desc)));
}
method.accept(mv);
return null;
}
}
Aggregations