use of org.objectweb.asm.tree.FrameNode in project phosphor by gmu-swe.
the class TaintPassingMV method visitJumpInsn.
@Override
public void visitJumpInsn(int opcode, Label label) {
if (isIgnoreAllInstrumenting) {
super.visitJumpInsn(opcode, label);
return;
}
if ((Configuration.IMPLICIT_TRACKING || Configuration.IMPLICIT_LIGHT_TRACKING) && !isIgnoreAllInstrumenting && !Configuration.WITHOUT_PROPOGATION) {
if (!boxAtNextJump.isEmpty()) {
Label origDest = label;
Label newDest = new Label();
Label origFalseLoc = new Label();
Configuration.taintTagFactory.jumpOp(opcode, branchStarting, newDest, mv, lvs, this);
FrameNode fn = getCurrentFrameNode();
super.visitJumpInsn(GOTO, origFalseLoc);
// System.out.println("taint passing mv monkeying with jump");
super.visitLabel(newDest);
fn.accept(this);
for (Integer var : boxAtNextJump) {
super.visitVarInsn(ALOAD, lvs.varToShadowVar.get(var));
super.visitVarInsn(ASTORE, var);
}
super.visitJumpInsn(GOTO, origDest);
super.visitLabel(origFalseLoc);
fn.accept(this);
boxAtNextJump.clear();
} else
Configuration.taintTagFactory.jumpOp(opcode, branchStarting, label, mv, lvs, this);
} else {
if (!boxAtNextJump.isEmpty() && opcode != Opcodes.GOTO) {
Label origDest = label;
Label newDest = new Label();
Label origFalseLoc = new Label();
Configuration.taintTagFactory.jumpOp(opcode, branchStarting, newDest, mv, lvs, this);
FrameNode fn = getCurrentFrameNode();
fn.type = F_NEW;
super.visitJumpInsn(GOTO, origFalseLoc);
// System.out.println("taint passing mv monkeying with jump");
super.visitLabel(newDest);
fn.accept(this);
for (Integer var : boxAtNextJump) {
super.visitVarInsn(ALOAD, lvs.varToShadowVar.get(var));
super.visitVarInsn(ASTORE, var);
}
super.visitJumpInsn(GOTO, origDest);
super.visitLabel(origFalseLoc);
fn.accept(this);
boxAtNextJump.clear();
} else {
Configuration.taintTagFactory.jumpOp(opcode, branchStarting, label, mv, lvs, this);
}
}
}
use of org.objectweb.asm.tree.FrameNode in project cassandra by apache.
the class MonitorMethodTransformer method writeInnerTryCatchSynchronized.
// alternative approach (with writeOuterUnsynchronized)
@SuppressWarnings("unused")
void writeInnerTryCatchSynchronized() {
access |= Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_SYNTHETIC;
name = baseName + "$catch";
Label start = new Label();
Label normal = new Label();
Label except = new Label();
Label end = new Label();
reset(start, end);
// must load self or class onto stack, and return value (if any)
maxStack = Math.max(maxLocalParams, returnCode == Opcodes.RETURN ? 1 : 2);
++maxLocals;
tryCatchBlocks.add(new TryCatchBlockNode(getLabelNode(start), getLabelNode(normal), getLabelNode(except), null));
instructions.add(getLabelNode(start));
int invokeCode = loadParamsAndReturnInvokeCode();
instructions.add(new MethodInsnNode(invokeCode, className, baseName + "$unsync", desc));
instructions.add(getLabelNode(normal));
invokePreMonitorExit();
instructions.add(new InsnNode(returnCode()));
instructions.add(getLabelNode(except));
instructions.add(new FrameNode(Opcodes.F_SAME1, 0, null, 1, new Object[] { "java/lang/Throwable" }));
instructions.add(new IntInsnNode(Opcodes.ASTORE, maxLocalParams));
invokePreMonitorExit();
instructions.add(new IntInsnNode(Opcodes.ALOAD, maxLocalParams));
instructions.add(new InsnNode(Opcodes.ATHROW));
instructions.add(getLabelNode(end));
methodWriterSink.writeSyntheticMethod(MONITOR, this);
}
use of org.objectweb.asm.tree.FrameNode in project openj9 by eclipse.
the class ClassFileCompare method compareInstructions.
private void compareInstructions(ClassNode clazz1, MethodNode method1, ClassNode clazz2, MethodNode method2) {
if (nullCheck(method1.instructions, method2.instructions, "Instructions (" + method1.name + ")")) {
return;
}
if (method1.instructions.size() != method2.instructions.size()) {
reportDifference("Method " + method1.name + ": instructions differ: " + method1.instructions.size() + ", " + method2.instructions.size());
} else {
@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> iter1 = method1.instructions.iterator();
@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> iter2 = method2.instructions.iterator();
int index = 0;
while (iter1.hasNext()) {
AbstractInsnNode instruction1 = iter1.next();
AbstractInsnNode instruction2 = iter2.next();
if (instruction1.getOpcode() != instruction2.getOpcode()) {
/* Check for J9 opcode mapping */
compareJ9OpcodeMapping(clazz2, method2, instruction1, instruction2, index);
} else {
switch(instruction1.getType()) {
case INSN:
/* Do nothing */
break;
case INT_INSN:
compare(((IntInsnNode) instruction1).operand, ((IntInsnNode) instruction2).operand, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
case VAR_INSN:
compare(((VarInsnNode) instruction1).var, ((VarInsnNode) instruction2).var, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
case TYPE_INSN:
compare(((TypeInsnNode) instruction1).desc, ((TypeInsnNode) instruction2).desc, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
case FIELD_INSN:
{
FieldInsnNode fieldInsn1 = (FieldInsnNode) instruction1;
FieldInsnNode fieldInsn2 = (FieldInsnNode) instruction2;
compare(fieldInsn1.owner, fieldInsn2.owner, "Owning class name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(fieldInsn1.name, fieldInsn2.name, "Field name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(fieldInsn1.desc, fieldInsn2.desc, "Descriptor of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
}
case METHOD_INSN:
{
MethodInsnNode methodInsn1 = (MethodInsnNode) instruction1;
MethodInsnNode methodInsn2 = (MethodInsnNode) instruction2;
compare(methodInsn1.owner, methodInsn2.owner, "Owning class name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(methodInsn1.name, methodInsn2.name, "Method name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(methodInsn1.desc, methodInsn2.desc, "Descriptor of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
}
case INVOKE_DYNAMIC_INSN:
compareInvokeDynamic((InvokeDynamicInsnNode) instruction1, (InvokeDynamicInsnNode) instruction2, method1, index);
break;
case JUMP_INSN:
compare(method1, ((JumpInsnNode) instruction1).label, method2, ((JumpInsnNode) instruction2).label, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
case LABEL:
/* Do nothing */
break;
case LDC_INSN:
if (!((LdcInsnNode) instruction1).cst.equals(((LdcInsnNode) instruction2).cst)) {
reportDifference("Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") differ: " + ((LdcInsnNode) instruction1).cst + ", " + ((LdcInsnNode) instruction2).cst);
}
break;
case IINC_INSN:
{
IincInsnNode iincInsn1 = (IincInsnNode) instruction1;
IincInsnNode iincInsn2 = (IincInsnNode) instruction2;
compare(iincInsn1.var, iincInsn2.var, "Variable operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
compare(iincInsn1.incr, iincInsn2.incr, "Increment operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
}
case TABLESWITCH_INSN:
{
TableSwitchInsnNode tableSwitchInsn1 = (TableSwitchInsnNode) instruction1;
TableSwitchInsnNode tableSwitchInsn2 = (TableSwitchInsnNode) instruction2;
compare(tableSwitchInsn1.min, tableSwitchInsn2.min, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") minimum key value", false);
compare(tableSwitchInsn1.max, tableSwitchInsn2.max, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") maximum key value", false);
compare(method1, tableSwitchInsn1.dflt, method2, tableSwitchInsn2.dflt, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") default_handler_block");
compareLabels(method1, tableSwitchInsn1.labels, method2, tableSwitchInsn2.labels, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") handler_blocks");
break;
}
case LOOKUPSWITCH_INSN:
{
LookupSwitchInsnNode lookupSwitchInsn1 = (LookupSwitchInsnNode) instruction1;
LookupSwitchInsnNode lookupSwitchInsn2 = (LookupSwitchInsnNode) instruction2;
compare(method1, lookupSwitchInsn1.dflt, method2, lookupSwitchInsn2.dflt, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") default_handler_block");
compare(lookupSwitchInsn1.keys, lookupSwitchInsn2.keys, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") key values");
compareLabels(method1, lookupSwitchInsn1.labels, method2, lookupSwitchInsn2.labels, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") handler_blocks");
break;
}
case MULTIANEWARRAY_INSN:
{
MultiANewArrayInsnNode arrayInsn1 = (MultiANewArrayInsnNode) instruction1;
MultiANewArrayInsnNode arrayInsn2 = (MultiANewArrayInsnNode) instruction2;
compare(arrayInsn1.desc, arrayInsn2.desc, "Desc operand of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(arrayInsn1.dims, arrayInsn2.dims, "Dimension operand of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
}
case FRAME:
{
FrameNode frameInsn1 = (FrameNode) instruction1;
FrameNode frameInsn2 = (FrameNode) instruction2;
compare(frameInsn1.type, frameInsn2.type, "Stack map frame (" + method1.name + ":" + index + ") frame type", false);
compareFrames(frameInsn1.local, frameInsn2.local, "Stack map frame (" + method1.name + ":" + index + ") types of the local variables");
compareFrames(frameInsn1.stack, frameInsn2.stack, "Stack map frame (" + method1.name + ":" + index + ") types of the operand stack elements");
}
break;
case LINE:
{
assert shouldCompareDebugInfo;
LineNumberNode lineInsn1 = (LineNumberNode) instruction1;
LineNumberNode lineInsn2 = (LineNumberNode) instruction2;
compare(lineInsn1.line, lineInsn2.line, "Line number (" + method1.name + ":" + index + ") line No.", false);
compare(method1, lineInsn1.start, method2, lineInsn2.start, "Line number (" + method1.name + ":" + index + ") offset of the 1st instruction");
break;
}
default:
assert false;
}
}
index++;
}
}
}
use of org.objectweb.asm.tree.FrameNode in project phosphor by gmu-swe.
the class TaintAdapter method getCurrentFrameNode.
public static FrameNode getCurrentFrameNode(NeverNullArgAnalyzerAdapter a) {
if (a.locals == null || a.stack == null)
throw new IllegalArgumentException();
Object[] locals = removeLongsDoubleTopVal(a.locals);
Object[] stack = removeLongsDoubleTopVal(a.stackTagStatus);
FrameNode ret = new FrameNode(Opcodes.F_NEW, locals.length, locals, stack.length, stack);
ret.type = TaintUtils.RAW_INSN;
return ret;
}
use of org.objectweb.asm.tree.FrameNode in project phosphor by gmu-swe.
the class TaintPassingMV method registerTaintedArray.
/**
* @param descOfDest
*/
public void registerTaintedArray() {
super.visitInsn(SWAP);
Label isnull = new Label();
Label ok = new Label();
FrameNode fn2 = getCurrentFrameNode();
super.visitInsn(DUP);
super.visitJumpInsn(IFNULL, isnull);
super.visitInsn(DUP_X1);
super.visitInsn(SWAP);
Type onTop = getTopOfStackType();
String wrapper = (String) TaintUtils.getShadowTaintTypeForFrame(onTop.getDescriptor());
super.visitMethodInsn(INVOKEVIRTUAL, wrapper, "ensureVal", "(" + onTop.getDescriptor() + ")V", false);
FrameNode fn = getCurrentFrameNode();
super.visitJumpInsn(GOTO, ok);
super.visitLabel(isnull);
acceptFn(fn2);
super.visitInsn(SWAP);
super.visitInsn(POP);
super.visitLabel(ok);
acceptFn(fn);
// A
}
Aggregations