List of usage examples for org.objectweb.asm Opcodes DLOAD
int DLOAD
To view the source code for org.objectweb.asm Opcodes DLOAD.
Click Source Link
From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.Inlining.java
License:Open Source License
public static List<Insn> convertInsns(MethodInsn mi, List<Insn> insns, int[] args, int _index, Label end) { List<Insn> result = new ArrayList<Insn>(); HashMap labels = new HashMap(); int index = _index; for (Insn i : insns) { if (i.isExpanded()) { MethodInsn expanded = (MethodInsn) i; // This use of end should be OK because all returns should have been removed when inlined before. // What could go wrong? result.addAll(convertInsns(expanded, expanded.inlineExpansionInsns, args, _index, end)); } else if (i instanceof SingleInsn) { SingleInsn si = (SingleInsn) i; switch (si.opcode) { case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: case Opcodes.RETURN: result.add(new JumpInsn("RETURN->GOTO", Opcodes.GOTO, end, newIndex(mi, index++))); break; default: result.add(i.copy(newIndex(mi, index++))); }// w w w . ja v a2s. co m } else if (i instanceof VarInsn) { VarInsn vi = (VarInsn) i; switch (vi.opcode) { case Opcodes.ILOAD: case Opcodes.LLOAD: case Opcodes.FLOAD: case Opcodes.DLOAD: case Opcodes.ALOAD: case Opcodes.ISTORE: case Opcodes.LSTORE: case Opcodes.FSTORE: case Opcodes.DSTORE: case Opcodes.ASTORE: VarInsn newVarInsn = new VarInsn(vi.name, vi.opcode, args[vi.var], newIndex(mi, index++)); result.add(newVarInsn); break; default: result.add(i.copy(newIndex(mi, index++))); } } else if (i instanceof VisitMaxs) { } else if (i instanceof VisitEnd) { } else if (i instanceof VisitCode) { } else if (i instanceof VisitFrame) { } else if (i instanceof LabelInsn) { LabelInsn li = (LabelInsn) i; if (labels.containsKey(li.label)) result.add(new LabelInsn(li.name, (Label) labels.get(li.label), newIndex(mi, index++))); else { Label l = new Label(); labels.put(li.label, l); result.add(new LabelInsn(li.name, l, newIndex(mi, index++))); } } else if (i instanceof JumpInsn) { JumpInsn ji = (JumpInsn) i; if (labels.containsKey(ji.label)) result.add( new JumpInsn(ji.name, ji.opcode, (Label) labels.get(ji.label), newIndex(mi, index++))); else { Label l = new Label(); labels.put(ji.label, l); result.add(new JumpInsn(ji.name, ji.opcode, l, newIndex(mi, index++))); } } else if (i instanceof VisitLineNumberInsn) { VisitLineNumberInsn vlni = (VisitLineNumberInsn) i; if (labels.containsKey(vlni.start)) result.add(new VisitLineNumberInsn(vlni.name, vlni.line, (Label) labels.get(vlni.start), newIndex(mi, index++))); else { Label l = new Label(); labels.put(vlni.start, l); result.add(new VisitLineNumberInsn(vlni.name, vlni.line, l, newIndex(mi, index++))); } } else if (i instanceof LocalVariableInsn) { LocalVariableInsn lvi = (LocalVariableInsn) i; if (labels.containsKey(lvi.start) && labels.containsKey(lvi.end)) { result.add(new LocalVariableInsn(lvi.name, lvi._name, lvi.desc, lvi.sig, (Label) labels.get(lvi.start), (Label) labels.get(lvi.end), args[lvi._index], newIndex(mi, index++))); } else throw new RuntimeException("NYI"); } else if (i instanceof TryCatchBlock) { TryCatchBlock tcb = (TryCatchBlock) i; if (labels.containsKey(tcb.start) && labels.containsKey(tcb.end) && labels.containsKey(tcb.handler)) { result.add( new TryCatchBlock(tcb.name, (Label) labels.get(tcb.start), (Label) labels.get(tcb.end), (Label) labels.get(tcb.handler), tcb.type, newIndex(mi, index++))); } else if (!labels.containsKey(tcb.start) && !labels.containsKey(tcb.end) && !labels.containsKey(tcb.handler)) { Label s = new Label(); Label e = new Label(); Label h = new Label(); labels.put(tcb.start, s); labels.put(tcb.end, e); labels.put(tcb.handler, h); result.add(new TryCatchBlock(tcb.name, s, e, h, tcb.type, newIndex(mi, index++))); } else throw new RuntimeException("NYI"); // Need to add TableSwitch, LookupSwitch } else { result.add(i.copy(newIndex(mi, index++))); } } return result; }
From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java
License:Apache License
@Override public void visitVarInsn(int opcode, int var) { if (_me != null) { if (var == 0) { _exprStack.push(_me);//www .j ava2s.c o m return; } var--; } Class<?> type; switch (opcode) { case Opcodes.ISTORE: case Opcodes.LSTORE: case Opcodes.FSTORE: case Opcodes.DSTORE: case Opcodes.ASTORE: case Opcodes.RET: default: throw notLambda(opcode); case Opcodes.ILOAD: type = Integer.TYPE; break; case Opcodes.LLOAD: type = Long.TYPE; break; case Opcodes.FLOAD: type = Float.TYPE; break; case Opcodes.DLOAD: type = Double.TYPE; break; case Opcodes.ALOAD: type = _argTypes[var]; break; } _exprStack.push(Expression.parameter(type, var)); }
From source file:de.sanandrew.core.manpack.transformer.TransformEntityCollision.java
License:Creative Commons License
private static byte[] transformWorld(byte[] bytes) { ClassNode clazz = ASMHelper.createClassNode(bytes); MethodNode method = ASMHelper.findMethod(clazz, ASMNames.MD_WORLD_GET_COLLIDING_BB); InsnList needle = new InsnList(); LabelNode ln = new LabelNode(); needle.add(ln);//from ww w .j a v a 2 s .c o m needle.add(new LineNumberNode(-1, ln)); needle.add(new VarInsnNode(Opcodes.ALOAD, 0)); needle.add(new VarInsnNode(Opcodes.ALOAD, 1)); needle.add(new VarInsnNode(Opcodes.ALOAD, 2)); needle.add(new VarInsnNode(Opcodes.DLOAD, -1)); needle.add(new VarInsnNode(Opcodes.DLOAD, -1)); needle.add(new VarInsnNode(Opcodes.DLOAD, -1)); needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_AABB_EXPAND, false)); needle.add( ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_WORLD_GET_ENTITIES_EXCLUDE, false)); needle.add(new VarInsnNode(Opcodes.ASTORE, -1)); VarInsnNode insertPoint = (VarInsnNode) ASMHelper.findLastNodeFromNeedle(method.instructions, needle); InsnList injectList = new InsnList(); injectList.add(new LabelNode()); injectList.add(ASMHelper.getFieldInsnNode(Opcodes.GETSTATIC, ASMNames.FD_SAPUTILS_EVENT_BUS)); injectList.add(new TypeInsnNode(Opcodes.NEW, ASMNames.CL_COLLIDING_ENTITY_CHECK_EVENT)); injectList.add(new InsnNode(Opcodes.DUP)); injectList.add(new VarInsnNode(Opcodes.ALOAD, 0)); injectList.add(new VarInsnNode(Opcodes.ALOAD, insertPoint.var)); injectList.add(new VarInsnNode(Opcodes.ALOAD, 1)); injectList.add(new VarInsnNode(Opcodes.ALOAD, 2)); injectList.add( ASMHelper.getMethodInsnNode(Opcodes.INVOKESPECIAL, ASMNames.MD_SAP_COLLENTITYCHKEVT_INIT, false)); injectList.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_EVENT_BUS_POST, false)); injectList.add(new InsnNode(Opcodes.POP)); method.instructions.insert(insertPoint, injectList); // insert entity-sensitive bounding box method needle = new InsnList(); ln = new LabelNode(); needle.add(ln); needle.add(new LineNumberNode(-1, ln)); needle.add(new VarInsnNode(Opcodes.ALOAD, 11)); needle.add(new VarInsnNode(Opcodes.ILOAD, 12)); needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEINTERFACE, ASMNames.MD_LIST_GET, true)); needle.add(new TypeInsnNode(Opcodes.CHECKCAST, ASMNames.CL_ENTITY)); needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_ENTITY_GET_BOUNDING_BOX, false)); needle.add(new VarInsnNode(Opcodes.ASTORE, -1)); insertPoint = (VarInsnNode) ASMHelper.findLastNodeFromNeedle(method.instructions, needle); injectList = new InsnList(); injectList.add(new LabelNode()); injectList.add(new VarInsnNode(Opcodes.ALOAD, 11)); injectList.add(new VarInsnNode(Opcodes.ILOAD, 12)); injectList.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEINTERFACE, ASMNames.MD_LIST_GET, true)); injectList.add(new TypeInsnNode(Opcodes.CHECKCAST, ASMNames.CL_ENTITY)); injectList.add(new VarInsnNode(Opcodes.ALOAD, 1)); injectList.add(new VarInsnNode(Opcodes.ALOAD, insertPoint.var)); injectList.add( ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_SAP_ENTITY_GET_BOUNDING_BOX, false)); injectList.add(new VarInsnNode(Opcodes.ASTORE, insertPoint.var)); method.instructions.insert(insertPoint, injectList); bytes = ASMHelper.createBytes(clazz, /*ClassWriter.COMPUTE_FRAMES |*/ ClassWriter.COMPUTE_MAXS); return bytes; }
From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.Block.java
License:Open Source License
private int getOpcode(final Type type) { if (Type.BOOLEAN_TYPE.equals(type)) { return Opcodes.ILOAD; }/* w w w .ja v a2 s .c o m*/ if (Type.INT_TYPE.equals(type)) { return Opcodes.ILOAD; } if (Type.FLOAT_TYPE.equals(type)) { return Opcodes.FLOAD; } if (Type.LONG_TYPE.equals(type)) { return Opcodes.LLOAD; } if (Type.DOUBLE_TYPE.equals(type)) { return Opcodes.DLOAD; } if (Type.CHAR_TYPE.equals(type)) { return Opcodes.ILOAD; } return Opcodes.ALOAD; }
From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.Block.java
License:Open Source License
private Type getTypeIfSimpleType(final AbstractInsnNode node) { final int opcode = node.getOpcode(); if ((opcode == Opcodes.ILOAD) || (opcode == Opcodes.ISTORE) || (opcode == Opcodes.IRETURN)) { return Type.INT_TYPE; }/*from w ww . jav a 2s .com*/ if ((opcode == Opcodes.FLOAD) || (opcode == Opcodes.FSTORE) || (opcode == Opcodes.FRETURN)) { return Type.FLOAT_TYPE; } if ((opcode == Opcodes.LLOAD) || (opcode == Opcodes.LSTORE) || (opcode == Opcodes.LRETURN)) { return Type.LONG_TYPE; } if ((opcode == Opcodes.DLOAD) || (opcode == Opcodes.DSTORE) || (opcode == Opcodes.DRETURN)) { return Type.DOUBLE_TYPE; } return null; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.VarInstruction.java
License:Open Source License
public VarInstruction(final ReadMethod readMethod, final int opcode, final int lineNumber, final int localVarIndex) { super(readMethod, opcode, lineNumber); assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE || opcode == Opcodes.ASTORE || opcode == Opcodes.RET; this.localVarIndex = localVarIndex; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.VarInstruction.java
License:Open Source License
private VarInstruction(final ReadMethod readMethod, final int lineNumber, final int opcode, final int localVarIndex, final int index) { super(readMethod, opcode, lineNumber, index); assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE || opcode == Opcodes.ASTORE || opcode == Opcodes.RET; this.localVarIndex = localVarIndex; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.VarInstruction.java
License:Open Source License
@Override public String toString() { String instruction;//from w w w. j a va2 s . c o m switch (getOpcode()) { case Opcodes.ILOAD: instruction = "ILOAD"; break; case Opcodes.LLOAD: instruction = "LLOAD"; break; case Opcodes.FLOAD: instruction = "FLOAD"; break; case Opcodes.DLOAD: instruction = "DLOAD"; break; case Opcodes.ALOAD: instruction = "ALOAD"; break; case Opcodes.ISTORE: instruction = "ISTORE"; break; case Opcodes.LSTORE: instruction = "LSTORE"; break; case Opcodes.FSTORE: instruction = "FSTORE"; break; case Opcodes.DSTORE: instruction = "DSTORE"; break; case Opcodes.ASTORE: instruction = "ASTORE"; break; case Opcodes.RET: instruction = "RET"; break; default: instruction = "-ERROR-"; } return new StringBuilder(instruction.length() + 11).append(instruction).append(' ') .append(this.localVarIndex).toString(); }
From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java
License:BSD License
@Override public void visitVarInsn(final int opcode, final int var) { super.visitVarInsn(opcode, var); switch (opcode) { case Opcodes.ILOAD: case Opcodes.FLOAD: this.stackFrame.push(OTHER); break;// ww w . ja v a2s. com case Opcodes.LLOAD: case Opcodes.DLOAD: this.stackFrame.push(OTHER); this.stackFrame.push(OTHER); break; case Opcodes.ALOAD: this.stackFrame.push(var == 0 ? THIS : OTHER); break; case Opcodes.ASTORE: case Opcodes.ISTORE: case Opcodes.FSTORE: this.stackFrame.pop(); break; case Opcodes.LSTORE: case Opcodes.DSTORE: this.stackFrame.pop(); this.stackFrame.pop(); break; } }
From source file:dyco4j.instrumentation.LoggingHelper.java
License:BSD License
public static int emitLogArgument(final MethodVisitor mv, final int position, final OptionalInt localVarIndex, final Type argType) { mv.visitLdcInsn(position);/* ww w .j a va2s .c om*/ int _typeLength = 1; if (localVarIndex.isPresent()) { final int _tmp = localVarIndex.getAsInt(); switch (argType.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.INT: case Type.SHORT: mv.visitVarInsn(Opcodes.ILOAD, _tmp); break; case Type.LONG: mv.visitVarInsn(Opcodes.LLOAD, _tmp); _typeLength++; break; case Type.FLOAT: mv.visitVarInsn(Opcodes.FLOAD, _tmp); break; case Type.DOUBLE: mv.visitVarInsn(Opcodes.DLOAD, _tmp); _typeLength++; break; case Type.ARRAY: case Type.OBJECT: mv.visitVarInsn(Opcodes.ALOAD, _tmp); break; } } else { mv.visitLdcInsn(Logger.UNINITIALIZED_THIS); } emitConvertToString(mv, argType); emitInvokeLog(mv, LOG_ARGUMENT); return _typeLength; }