Java Code Examples for org.objectweb.asm.Opcodes#LLOAD

The following examples show how to use org.objectweb.asm.Opcodes#LLOAD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 6 votes vote down vote up
public static int getVariableLoadOpcode(Type type) {
		if (type.getSort() >= Type.BOOLEAN && type.getSort() <= Type.INT) {
			return Opcodes.ILOAD;
		} else if (type == Type.LONG_TYPE) {
			return Opcodes.LLOAD;
		} else if (type == Type.FLOAT_TYPE) {
			return Opcodes.FLOAD;
		} else if (type == Type.DOUBLE_TYPE) {
			return Opcodes.DLOAD;
		} else if (type.getSort() >= Type.ARRAY && type.getSort() <= Type.OBJECT) {
			return Opcodes.ALOAD;
		} else {
			return getVariableLoadOpcode(asSimpleType(type));
//			throw new IllegalArgumentException(type.toString());
		}
	}
 
Example 2
Source File: ASMUtils.java    From radon with GNU General Public License v3.0 6 votes vote down vote up
public static int getVarOpcode(Type type, boolean store) {
    switch (type.getSort()) {
        case Type.BOOLEAN:
        case Type.CHAR:
        case Type.BYTE:
        case Type.SHORT:
        case Type.INT:
            return store ? Opcodes.ISTORE : Opcodes.ILOAD;
        case Type.FLOAT:
            return store ? Opcodes.FSTORE : Opcodes.FLOAD;
        case Type.LONG:
            return store ? Opcodes.LSTORE : Opcodes.LLOAD;
        case Type.DOUBLE:
            return store ? Opcodes.DSTORE : Opcodes.DLOAD;
        case Type.ARRAY:
        case Type.OBJECT:
            return store ? Opcodes.ASTORE : Opcodes.ALOAD;
        default:
            throw new AssertionError("Unknown type: " + type.getClassName());
    }
}
 
Example 3
Source File: Asm.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void visitBaseType(char c) {
    int idx = paramIndex++;
    int opcode;

    switch (c) {
        // two-word data
        case 'J': opcode = Opcodes.LLOAD; paramIndex++; localSize++; break;
        case 'D': opcode = Opcodes.DLOAD; paramIndex++; localSize++; break;
        // float has a special opcode
        case 'F': opcode = Opcodes.FLOAD; break;
        default: opcode = Opcodes.ILOAD; break;

    }
    load(opcode, idx);
    localSize++;
}
 
Example 4
Source File: LocalVariablesSorter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  Type varType;
  switch (opcode) {
    case Opcodes.LLOAD:
    case Opcodes.LSTORE:
      varType = Type.LONG_TYPE;
      break;
    case Opcodes.DLOAD:
    case Opcodes.DSTORE:
      varType = Type.DOUBLE_TYPE;
      break;
    case Opcodes.FLOAD:
    case Opcodes.FSTORE:
      varType = Type.FLOAT_TYPE;
      break;
    case Opcodes.ILOAD:
    case Opcodes.ISTORE:
      varType = Type.INT_TYPE;
      break;
    case Opcodes.ALOAD:
    case Opcodes.ASTORE:
    case Opcodes.RET:
      varType = OBJECT_TYPE;
      break;
    default:
      throw new IllegalArgumentException("Invalid opcode " + opcode);
  }
  super.visitVarInsn(opcode, remap(var, varType));
}
 
Example 5
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  switch (opcode) {
    case Opcodes.ILOAD:
      load(var, Type.INT_TYPE);
      break;
    case Opcodes.LLOAD:
      load(var, Type.LONG_TYPE);
      break;
    case Opcodes.FLOAD:
      load(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DLOAD:
      load(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ALOAD:
      load(var, OBJECT_TYPE);
      break;
    case Opcodes.ISTORE:
      store(var, Type.INT_TYPE);
      break;
    case Opcodes.LSTORE:
      store(var, Type.LONG_TYPE);
      break;
    case Opcodes.FSTORE:
      store(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DSTORE:
      store(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ASTORE:
      store(var, OBJECT_TYPE);
      break;
    case Opcodes.RET:
      ret(var);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 6
Source File: LightFlowObfuscationTransformer.java    From deobfuscator with Apache License 2.0 5 votes vote down vote up
private boolean willPush(AbstractInsnNode ain)
{
	if(ain.getOpcode() == Opcodes.LDC && (((LdcInsnNode)ain).cst instanceof Long || ((LdcInsnNode)ain).cst instanceof Double))
		return false;
	return Utils.willPushToStack(ain.getOpcode()) && ain.getOpcode() != Opcodes.GETSTATIC
		&& ain.getOpcode() != Opcodes.LLOAD && ain.getOpcode() != Opcodes.DLOAD;
}
 
Example 7
Source File: TreeInstructions.java    From instrumentation with Apache License 2.0 5 votes vote down vote up
public static VarInsnNode getLoadInst(Type type, int position) {
    int opCode = -1;
    switch (type.getDescriptor().charAt(0)) {
        case 'B':
            opCode = Opcodes.ILOAD;
            break;
        case 'C':
            opCode = Opcodes.ILOAD;
            break;
        case 'D':
            opCode = Opcodes.DLOAD;
            break;
        case 'F':
            opCode = Opcodes.FLOAD;
            break;
        case 'I':
            opCode = Opcodes.ILOAD;
            break;
        case 'J':
            opCode = Opcodes.LLOAD;
            break;
        case 'L':
            opCode = Opcodes.ALOAD;
            break;
        case '[':
            opCode = Opcodes.ALOAD;
            break;
        case 'Z':
            opCode = Opcodes.ILOAD;
            break;
        case 'S':
            opCode = Opcodes.ILOAD;
            break;
        default:
            throw new ClassFormatError("Invalid method signature: "
                    + type.getDescriptor());
    }
    return new VarInsnNode(opCode, position);
}
 
Example 8
Source File: FlowObfuscationTransformer.java    From deobfuscator with Apache License 2.0 5 votes vote down vote up
private boolean willPush(AbstractInsnNode ain)
{
	if(ain.getOpcode() == Opcodes.LDC && (((LdcInsnNode)ain).cst instanceof Long || ((LdcInsnNode)ain).cst instanceof Double))
		return false;
	return (Utils.willPushToStack(ain.getOpcode()) || ain.getOpcode() == Opcodes.NEW) && ain.getOpcode() != Opcodes.GETSTATIC
		&& ain.getOpcode() != Opcodes.LLOAD && ain.getOpcode() != Opcodes.DLOAD;
}
 
Example 9
Source File: UOI1Mutator.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var);

    switch (opcode) {
        case Opcodes.ILOAD:
            if (this.shouldMutate("Incremented (a++) integer local variable number " + var)) {
                mv.visitIincInsn(var, 1);
            }
            break;
        case Opcodes.FLOAD:
            if (this.shouldMutate("Incremented (a++) float local variable number " + var)) {
                mv.visitInsn(Opcodes.DUP);
                mv.visitInsn(Opcodes.FCONST_1);
                mv.visitInsn(Opcodes.FADD);
                mv.visitVarInsn(Opcodes.FSTORE, var);
            }
            break;
        case Opcodes.LLOAD:
            if (this.shouldMutate("Incremented (a++) long local variable number " + var)) {
                mv.visitInsn(Opcodes.DUP2);
                mv.visitInsn(Opcodes.LCONST_1);
                mv.visitInsn(Opcodes.LADD);
                mv.visitVarInsn(Opcodes.LSTORE, var);
            }
            break;
        case Opcodes.DLOAD:
            if (this.shouldMutate("Incremented (a++) double local variable number " + var)) {
                mv.visitInsn(Opcodes.DUP2);
                mv.visitInsn(Opcodes.DCONST_1);
                mv.visitInsn(Opcodes.DADD);
                mv.visitVarInsn(Opcodes.DSTORE, var);
            }
            break;

        default:
            break;
    }
}
 
Example 10
Source File: ArithmeticExpression.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isArg(Instruction instr) {
    if (instr instanceof ArithmeticExpression) {
        return true;
    }
    if (instr instanceof AssignableExpression) {
        StringBuilder dummy = new StringBuilder();
        
        if (((AssignableExpression)instr).assignTo(null, dummy)) {
            return true;
        }
    }
    int opcode = instr.getOpcode();
    switch (opcode) {
        
        case Opcodes.FLOAD:
        case Opcodes.DLOAD:
        case Opcodes.ILOAD:
        case Opcodes.LLOAD:
        case org.objectweb.asm.Opcodes.ICONST_0:
        case org.objectweb.asm.Opcodes.ICONST_1: 
        case org.objectweb.asm.Opcodes.ICONST_2:
        case org.objectweb.asm.Opcodes.ICONST_3: 
        case org.objectweb.asm.Opcodes.ICONST_4: 
        case org.objectweb.asm.Opcodes.ICONST_5:
        case org.objectweb.asm.Opcodes.ICONST_M1:
        case org.objectweb.asm.Opcodes.LCONST_0:
        case org.objectweb.asm.Opcodes.LCONST_1: 
        case Opcodes.DCONST_0:
        case Opcodes.DCONST_1:
        case Opcodes.FCONST_0:
        case Opcodes.FCONST_1:
        case Opcodes.FCONST_2:
        case org.objectweb.asm.Opcodes.BIPUSH:
        case org.objectweb.asm.Opcodes.SIPUSH:
        case Opcodes.LDC:
            return true;
    }
    return false;
}
 
Example 11
Source File: InstructionAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  switch (opcode) {
    case Opcodes.ILOAD:
      load(var, Type.INT_TYPE);
      break;
    case Opcodes.LLOAD:
      load(var, Type.LONG_TYPE);
      break;
    case Opcodes.FLOAD:
      load(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DLOAD:
      load(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ALOAD:
      load(var, OBJECT_TYPE);
      break;
    case Opcodes.ISTORE:
      store(var, Type.INT_TYPE);
      break;
    case Opcodes.LSTORE:
      store(var, Type.LONG_TYPE);
      break;
    case Opcodes.FSTORE:
      store(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DSTORE:
      store(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ASTORE:
      store(var, OBJECT_TYPE);
      break;
    case Opcodes.RET:
      ret(var);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 12
Source File: AnalyzerAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  super.visitVarInsn(opcode, var);
  boolean isLongOrDouble =
      opcode == Opcodes.LLOAD
          || opcode == Opcodes.DLOAD
          || opcode == Opcodes.LSTORE
          || opcode == Opcodes.DSTORE;
  maxLocals = Math.max(maxLocals, var + (isLongOrDouble ? 2 : 1));
  execute(opcode, var, null);
}
 
Example 13
Source File: ABSMutator.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var); // push the variable.

    switch (opcode) {
        case Opcodes.ILOAD:
            if (this.shouldMutate("Negated integer local variable number " + var)) {
                mv.visitInsn(Opcodes.INEG);
            }
            break;

        case Opcodes.FLOAD:
            if (this.shouldMutate("Negated float local variable number " + var)) {
                mv.visitInsn(Opcodes.FNEG);
            }
            break;

        case Opcodes.LLOAD:
            if (this.shouldMutate("Negated long local variable number " + var)) {
                mv.visitInsn(Opcodes.LNEG);
            }
            break;

        case Opcodes.DLOAD:
            if (this.shouldMutate("Negated double local variable number " + var)) {
                mv.visitInsn(Opcodes.DNEG);
            }
            break;
        default:
            break;
    }
}
 
Example 14
Source File: InstructionAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  switch (opcode) {
    case Opcodes.ILOAD:
      load(var, Type.INT_TYPE);
      break;
    case Opcodes.LLOAD:
      load(var, Type.LONG_TYPE);
      break;
    case Opcodes.FLOAD:
      load(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DLOAD:
      load(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ALOAD:
      load(var, OBJECT_TYPE);
      break;
    case Opcodes.ISTORE:
      store(var, Type.INT_TYPE);
      break;
    case Opcodes.LSTORE:
      store(var, Type.LONG_TYPE);
      break;
    case Opcodes.FSTORE:
      store(var, Type.FLOAT_TYPE);
      break;
    case Opcodes.DSTORE:
      store(var, Type.DOUBLE_TYPE);
      break;
    case Opcodes.ASTORE:
      store(var, OBJECT_TYPE);
      break;
    case Opcodes.RET:
      ret(var);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 15
Source File: AnalyzerAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
public void visitVarInsn(final int opcode, final int var) {
  super.visitVarInsn(opcode, var);
  boolean isLongOrDouble =
      opcode == Opcodes.LLOAD
          || opcode == Opcodes.DLOAD
          || opcode == Opcodes.LSTORE
          || opcode == Opcodes.DSTORE;
  maxLocals = Math.max(maxLocals, var + (isLongOrDouble ? 2 : 1));
  execute(opcode, var, null);
}
 
Example 16
Source File: ANFTransform.java    From Concurnas with MIT License 5 votes vote down vote up
public static int getLoadOp(char c){ 
	switch(c){
		case 'Z': return Opcodes.ILOAD ;
		case 'B': return Opcodes.ILOAD ;
		case 'S': return Opcodes.ILOAD;
		case 'I': return Opcodes.ILOAD ;
		case 'J': return Opcodes.LLOAD ;
		case 'F': return Opcodes.FLOAD ;
		case 'D': return Opcodes.DLOAD ;
		case 'C': return Opcodes.ILOAD ;
		default:
			return Opcodes.ALOAD;
	}
}
 
Example 17
Source File: VarOp.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void appendInstruction(StringBuilder b) {
    b.append("    ");
    switch(opcode) {
        case Opcodes.ILOAD:
            b.append("(*SP).type = CN1_TYPE_INT; /* ILOAD */ \n" +
                    "    (*SP).data.i = ilocals_");
            b.append(var);
            b.append("_; \n    SP++;\n");
            return;
        case Opcodes.LLOAD:
            b.append("BC_LLOAD(");
            break;
        case Opcodes.FLOAD:
            b.append("BC_FLOAD(");
            break;
        case Opcodes.DLOAD:
            b.append("BC_DLOAD(");
            break;
        case Opcodes.ALOAD:
            b.append("BC_ALOAD(");
            break;
        case Opcodes.ISTORE:
            b.append("BC_ISTORE(");
            break;
        case Opcodes.LSTORE:
            b.append("BC_LSTORE(");
            break;
        case Opcodes.FSTORE:
            b.append("BC_FSTORE(");
            break;
        case Opcodes.DSTORE:
            b.append("BC_DSTORE(");
            break;
        case Opcodes.ASTORE:
            b.append("BC_ASTORE(");
            break;
        case Opcodes.RET:
            b.append("/* RET TODO */");
            //b.append("goto label_");
            //b.append(var);
            //b.append("; /* RET */\n");
            return;
        case Opcodes.SIPUSH:
        case Opcodes.BIPUSH:
            b.append("PUSH_INT(");
            break;
        case Opcodes.NEWARRAY:
            switch(var) {
                case 4: // boolean
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BOOLEAN, sizeof(JAVA_ARRAY_BOOLEAN), 1));\n");
                    break;
                case 5: // char
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_CHAR, sizeof(JAVA_ARRAY_CHAR), 1));\n");
                    break;
                case 6: // float
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_FLOAT, sizeof(JAVA_ARRAY_FLOAT), 1));\n");
                    break;
                case 7: // double
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_DOUBLE, sizeof(JAVA_ARRAY_DOUBLE), 1));\n");
                    break;
                case 8: // byte
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_BYTE, sizeof(JAVA_ARRAY_BYTE), 1));\n");
                    break;
                case 9: // short
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_SHORT, sizeof(JAVA_ARRAY_SHORT), 1));\n");
                    break;
                case 10: // int
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_INT, sizeof(JAVA_ARRAY_INT), 1));\n");
                    break;
                case 11: // long 
                    b.append("PUSH_OBJ(allocArray(threadStateData, POP_INT(), &class_array1__JAVA_LONG, sizeof(JAVA_ARRAY_LONG), 1));\n");
                    break;
            }
            return;
        default:
            throw new RuntimeException("Missing opcode: " + opcode);
    }
    b.append(var);
    b.append(");\n");
}
 
Example 18
Source File: VarOp.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean assignTo(String varName, StringBuilder sb) {
    StringBuilder b = new StringBuilder();
    
    /*
    if (typeVarName != null) {
        switch (opcode) {
            case Opcodes.ALOAD:
                b.append("locals[");
                b.append(var);
                b.append("].type = CN1_TYPE_OBJECT; ");
                break;
        }
    }*/
    if (varName != null) {
        b.append("    ");
        b.append(varName).append(" = ");
    }
    switch(opcode) {
        case Opcodes.ILOAD:
            b.append("ilocals_");
            b.append(var);
            b.append("_");
            break;
        case Opcodes.LLOAD:
            b.append("llocals_");
            b.append(var);
            b.append("_");
            break;
        case Opcodes.FLOAD:
            b.append("flocals_");
            b.append(var);
            b.append("_");
            break;
        case Opcodes.DLOAD:
            b.append("dlocals_");
            b.append(var);
            b.append("_");
            break;
        case Opcodes.ALOAD:
            if (getMethod() != null && !getMethod().isStatic() && var == 0) {
                b.append("__cn1ThisObject");
            } else {
                b.append("locals[");
                b.append(var);
                b.append("].data.o");
            }
            break;
        default:
            return false;
            
    }
    if (varName != null) {
        b.append(";\n");
    }
    sb.append(b);
    return true;
}
 
Example 19
Source File: UOI4Mutator.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public void visitVarInsn(int opcode, int var) {
    switch (opcode) {
        case Opcodes.ILOAD:
            if (this.shouldMutate("Decremented (--a) integer local variable number " + var)) {
                mv.visitIincInsn(var, -1);
            }
            mv.visitVarInsn(opcode, var);

            break;

        case Opcodes.FLOAD:
            if (this.shouldMutate("Decremented (--a) float local variable number " + var)) {
                mv.visitVarInsn(opcode, var);
                mv.visitInsn(Opcodes.FCONST_1);
                mv.visitInsn(Opcodes.FSUB);
                mv.visitVarInsn(Opcodes.FSTORE, var);
            }
            mv.visitVarInsn(opcode, var);

            break;

        case Opcodes.LLOAD:
            if (this.shouldMutate("Decremented (--a) long local variable number " + var)) {
                mv.visitVarInsn(opcode, var);
                mv.visitInsn(Opcodes.LCONST_1);
                mv.visitInsn(Opcodes.LSUB);
                mv.visitVarInsn(Opcodes.LSTORE, var);
            }
            mv.visitVarInsn(opcode, var);
            break;

        case Opcodes.DLOAD:
            if (this.shouldMutate("Decremented (--a) double local variable number " + var)) {
                mv.visitVarInsn(opcode, var);
                mv.visitInsn(Opcodes.DCONST_1);
                mv.visitInsn(Opcodes.DSUB);
                mv.visitVarInsn(Opcodes.DSTORE, var);
            }
            mv.visitVarInsn(opcode, var);
            break;

        default:
            mv.visitVarInsn(opcode, var);
            break;
    }
}
 
Example 20
Source File: MethodVisitorBuilder.java    From testability-explorer with Apache License 2.0 4 votes vote down vote up
public void visitVarInsn(final int opcode, final int var) {
  switch (opcode) {
    case Opcodes.ILOAD :
      load(var, JavaType.INT);
      break;
    case Opcodes.LLOAD :
      load(var, JavaType.LONG);
      break;
    case Opcodes.FLOAD :
      load(var, JavaType.FLOAT);
      break;
    case Opcodes.DLOAD :
      load(var, JavaType.DOUBLE);
      break;
    case Opcodes.ALOAD :
      load(var, JavaType.OBJECT);
      break;

    case Opcodes.ISTORE :
      store(var, JavaType.INT);
      break;
    case Opcodes.LSTORE :
      store(var, JavaType.LONG);
      break;
    case Opcodes.FSTORE :
      store(var, JavaType.FLOAT);
      break;
    case Opcodes.DSTORE :
      store(var, JavaType.DOUBLE);
      break;
    case Opcodes.ASTORE :
      store(var, JavaType.OBJECT);
      break;

    case Opcodes.RET :
      recorder.add(new Runnable() {
        public void run() {
          block.addOp(new RetSub(lineNumber));
        }
      });
      break;
    default :
      throw new UnsupportedOperationException("opcode: " + opcode);
  }
}