List of usage examples for org.objectweb.asm Opcodes ISTORE
int ISTORE
To view the source code for org.objectweb.asm Opcodes ISTORE.
Click Source Link
From source file:co.paralleluniverse.fibers.instrument.InstrumentMethod.java
License:Open Source License
private void emitStoreResumed(MethodVisitor mv, boolean value) { mv.visitInsn(value ? Opcodes.ICONST_1 : Opcodes.ICONST_0); mv.visitVarInsn(Opcodes.ISTORE, lvarResumed); }
From source file:co.paralleluniverse.fibers.instrument.InstrumentMethod.java
License:Open Source License
private void emitNewAndDup(MethodVisitor mv, Frame frame, int stackIndex, MethodInsnNode min) { int arguments = frame.getStackSize() - stackIndex - 1; int neededLocals = 0; for (int i = arguments; i >= 1; i--) { BasicValue v = (BasicValue) frame.getStack(stackIndex + i); mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), lvarStack + NUM_LOCALS + neededLocals); neededLocals += v.getSize();//from ww w.j a v a2s .co m } db.log(LogLevel.DEBUG, "Inserting NEW & DUP for constructor call %s%s with %d arguments (%d locals)", min.owner, min.desc, arguments, neededLocals); if (additionalLocals < neededLocals) { additionalLocals = neededLocals; } ((NewValue) frame.getStack(stackIndex - 1)).insn.accept(mv); ((NewValue) frame.getStack(stackIndex)).insn.accept(mv); for (int i = 1; i <= arguments; i++) { BasicValue v = (BasicValue) frame.getStack(stackIndex + i); neededLocals -= v.getSize(); mv.visitVarInsn(v.getType().getOpcode(Opcodes.ILOAD), lvarStack + NUM_LOCALS + neededLocals); } }
From source file:co.paralleluniverse.fibers.instrument.InstrumentMethod.java
License:Open Source License
private void emitRestoreState(MethodVisitor mv, int idx, FrameInfo fi, int numArgsPreserved) { Frame f = frames[fi.endInstruction]; // restore local vars for (int i = firstLocal; i < f.getLocals(); i++) { BasicValue v = (BasicValue) f.getLocal(i); if (!isNullType(v)) { int slotIdx = fi.localSlotIndices[i]; assert slotIdx >= 0 && slotIdx < fi.numSlots; emitRestoreValue(mv, v, lvarStack, slotIdx, i); mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), i); } else if (v != BasicValue.UNINITIALIZED_VALUE) { mv.visitInsn(Opcodes.ACONST_NULL); mv.visitVarInsn(Opcodes.ASTORE, i); }/*from w w w .j a v a 2 s. c om*/ } // restore operand stack for (int i = 0; i < f.getStackSize() - numArgsPreserved; i++) { BasicValue v = (BasicValue) f.getStack(i); if (!isOmitted(v)) { if (!isNullType(v)) { int slotIdx = fi.stackSlotIndices[i]; assert slotIdx >= 0 && slotIdx < fi.numSlots; emitRestoreValue(mv, v, lvarStack, slotIdx, -1); } else { mv.visitInsn(Opcodes.ACONST_NULL); } } } if (fi.lAfter != null) { fi.lAfter.accept(mv); } }
From source file:com.alibaba.hotswap.processor.constructor.ConstructorVisitor.java
License:Open Source License
private void storeArgs(GeneratorAdapter adapter, MethodVisitor hotswapInit, MethodMeta methodMeta) { Type[] argTypes = Type.getArgumentTypes(methodMeta.desc); if (argTypes.length == 0) { return;//from w ww . j a va2s. c o m } adapter.loadArg(2);// Object[] int nextIndex = 4; for (int i = 0; i < argTypes.length; i++) { adapter.dup(); adapter.push(i); adapter.arrayLoad(Type.getType(Object.class));// Object[i] adapter.unbox(argTypes[i]); hotswapInit.visitVarInsn(argTypes[i].getOpcode(Opcodes.ISTORE), nextIndex); nextIndex += argTypes[i].getSize(); } adapter.pop(); }
From source file:com.alibaba.hotswap.processor.jdk.classloader.modifier.DefineClassMethodModifier.java
License:Open Source License
@Override public void visitCode() { super.visitCode(); mv.visitVarInsn(Opcodes.ALOAD, 1);// w w w. j av a 2 s . c o m mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(HotswapConfiguration.class), "getClassPathInWorkspace", "(Ljava/lang/String;)Ljava/lang/String;"); mv.visitInsn(Opcodes.DUP); Label old = new Label(); mv.visitJumpInsn(Opcodes.IFNULL, old); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(HotswapRuntime.class), "updateClassMeta", "(Ljava/lang/String;Ljava/lang/ClassLoader;)V"); mv.visitVarInsn(Opcodes.ALOAD, 1); // className mv.visitInsn(Opcodes.SWAP); mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(CustomerLoadClassBytes.class), "loadBytesFromPath", "(Ljava/lang/String;Ljava/lang/String;)[B"); mv.visitVarInsn(Opcodes.ASTORE, 2);// store class bytes into 2 mv.visitVarInsn(Opcodes.ALOAD, 2);// load class bytes mv.visitInsn(Opcodes.ARRAYLENGTH); // length of the class bytes mv.visitVarInsn(Opcodes.ISTORE, 4);// store length into 4 Label end = new Label(); mv.visitJumpInsn(Opcodes.GOTO, end); mv.visitLabel(old); mv.visitInsn(Opcodes.POP); mv.visitLabel(end); }
From source file:com.android.build.gradle.internal.incremental.ByteCodeUtils.java
License:Apache License
/** * Given an array with values at the top of the stack, the values are unboxed and stored * on the given variables. The array is popped from the stack. *//*from w ww.ja v a 2s . com*/ static void restoreVariables(@NonNull GeneratorAdapter mv, @NonNull List<LocalVariable> variables) { for (int i = 0; i < variables.size(); i++) { LocalVariable variable = variables.get(i); // Duplicates the array on the stack; mv.dup(); // Sets up the index mv.push(i); // Gets the Object value mv.arrayLoad(Type.getType(Object.class)); // Unboxes to the type of the local variable mv.unbox(variable.type); // Restores the local variable mv.visitVarInsn(variable.type.getOpcode(Opcodes.ISTORE), variable.var); } // Pops the array from the stack. mv.pop(); }
From source file:com.android.build.gradle.internal.incremental.ByteCodeUtils.java
License:Apache License
/** * Given a *STORE opcode, it returns the type associated to the variable, or null if * not a valid opcode./*from ww w . j a va 2s . com*/ */ static Type getTypeForStoreOpcode(int opcode) { switch (opcode) { case Opcodes.ISTORE: return Type.INT_TYPE; case Opcodes.LSTORE: return Type.LONG_TYPE; case Opcodes.FSTORE: return Type.FLOAT_TYPE; case Opcodes.DSTORE: return Type.DOUBLE_TYPE; case Opcodes.ASTORE: return Type.getType(Object.class); } return null; }
From source file:com.android.build.gradle.internal.incremental.ConstructorArgsRedirection.java
License:Apache License
@Override protected void restore(GeneratorAdapter mv, List<Type> args) { // At this point, init$args has been called and the result Object is on the stack. // The value of that Object is Object[] with exactly n + 1 elements. // The first element is a string with the qualified name of the constructor to call. // The remaining elements are the constructtor arguments. // Create a new local that holds the result of init$args call. mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/lang/Object;"); int constructorArgs = mv.newLocal(Type.getType("[Ljava/lang/Object;")); mv.storeLocal(constructorArgs);/* w w w. j av a2s. com*/ // Reinstate local values mv.loadLocal(locals); int stackIndex = 0; for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) { Type arg = args.get(arrayIndex); // Do not restore "this" if (arrayIndex > 0) { // duplicates the array mv.dup(); // index in the array of objects to restore the boxed parameter. mv.push(arrayIndex); // get it from the array mv.arrayLoad(Type.getType(Object.class)); // unbox the argument ByteCodeUtils.unbox(mv, arg); // restore the argument mv.visitVarInsn(arg.getOpcode(Opcodes.ISTORE), stackIndex); } // stack index must progress according to the parameter type we just processed. stackIndex += arg.getSize(); } // pops the array mv.pop(); // Push a null for the marker parameter. mv.loadLocal(constructorArgs); mv.visitInsn(Opcodes.ACONST_NULL); // Invoke the constructor mv.visitMethodInsn(Opcodes.INVOKESPECIAL, thisClassName, "<init>", DISPATCHING_THIS_SIGNATURE, false); mv.goTo(end.getLabel()); }
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Performs {@code T_STORE} instruction. * @param method the target method/* w ww . ja v a 2 s. c om*/ * @param sort the target type sort * @param index the target local variable index * @return the target local variable ref */ public static LocalVarRef putLocalVar(MethodVisitor method, int sort, int index) { int load; int store; switch (sort) { case Type.BOOLEAN: case Type.BYTE: case Type.SHORT: case Type.CHAR: case Type.INT: load = Opcodes.ILOAD; store = Opcodes.ISTORE; break; case Type.LONG: load = Opcodes.LLOAD; store = Opcodes.LSTORE; break; case Type.FLOAT: load = Opcodes.FLOAD; store = Opcodes.FSTORE; break; case Type.DOUBLE: load = Opcodes.DLOAD; store = Opcodes.DSTORE; break; case Type.ARRAY: case Type.OBJECT: load = Opcodes.ALOAD; store = Opcodes.ASTORE; break; default: throw new AssertionError(sort); } method.visitVarInsn(store, index); return new LocalVarRef(load, index); }
From source file:com.codename1.tools.translator.BytecodeMethod.java
License:Open Source License
public void addVariableOperation(int opcode, int var) { VarOp op = new VarOp(opcode, var); LocalVariable lv = null;//from ww w .j a v a2s. c o m switch (opcode) { case Opcodes.ISTORE: lv = new LocalVariable("v" + var, "I", "I", null, null, var); break; case Opcodes.LSTORE: lv = new LocalVariable("v" + var, "J", "J", null, null, var); break; case Opcodes.FSTORE: lv = new LocalVariable("v" + var, "F", "F", null, null, var); break; case Opcodes.DSTORE: lv = new LocalVariable("v" + var, "D", "D", null, null, var); break; } if (lv != null && !localVariables.contains(lv)) { localVariables.add(lv); } addInstruction(op); }