List of usage examples for org.objectweb.asm Opcodes F_NEW
int F_NEW
To view the source code for org.objectweb.asm Opcodes F_NEW.
Click Source Link
From source file:br.usp.each.saeg.badua.core.internal.instr.ClassInstrumenter.java
License:Open Source License
@Override public void visitEnd() { // not instrument interfaces or // classes with probe count equals to zero if (interfaceType || classProbeCount == 0) { super.visitEnd(); return;/*w w w . java2s. c o m*/ } final FieldVisitor fv = cv.visitField(InstrSupport.DATAFIELD_ACC, InstrSupport.DATAFIELD_NAME, InstrSupport.DATAFIELD_DESC, null, null); fv.visitEnd(); final MethodVisitor mv = cv.visitMethod(InstrSupport.DATAMETHOD_ACC, InstrSupport.DATAMETHOD_NAME, InstrSupport.DATAMETHOD_DESC, null, null); mv.visitCode(); // Load the value of the static data field: mv.visitFieldInsn(Opcodes.GETSTATIC, className, InstrSupport.DATAFIELD_NAME, InstrSupport.DATAFIELD_DESC); mv.visitInsn(Opcodes.DUP); // Stack[1]: [J // Stack[0]: [J // Skip initialization when we already have a data array: final Label alreadyInitialized = new Label(); mv.visitJumpInsn(Opcodes.IFNONNULL, alreadyInitialized); // Stack[0]: [J mv.visitInsn(Opcodes.POP); mv.visitLdcInsn(classId); InstrSupport.push(mv, classProbeCount); mv.visitMethodInsn(Opcodes.INVOKESTATIC, InstrSupport.RUNTIME_OWNER, InstrSupport.RUNTIME_NAME, InstrSupport.RUNTIME_DESC, false); // Stack[0]: [J mv.visitInsn(Opcodes.DUP); // Stack[1]: [J // Stack[0]: [J mv.visitFieldInsn(Opcodes.PUTSTATIC, className, InstrSupport.DATAFIELD_NAME, InstrSupport.DATAFIELD_DESC); // Stack[0]: [J if (withFrames) { mv.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 1, new Object[] { InstrSupport.DATAFIELD_DESC }); } mv.visitLabel(alreadyInitialized); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(3, 0); mv.visitEnd(); super.visitEnd(); }
From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java
License:Open Source License
@Override public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { final StringBuilder sb = new StringBuilder(); sb.append("frame "); switch (type) { case Opcodes.F_NEW: case Opcodes.F_FULL: sb.append("full ["); appendFrameTypes(sb, nLocal, local); sb.append("] ["); appendFrameTypes(sb, nStack, stack); sb.append(']'); break;/*from ww w . j a v a 2s . co m*/ case Opcodes.F_APPEND: sb.append("append ["); appendFrameTypes(sb, nLocal, local); sb.append(']'); break; case Opcodes.F_CHOP: sb.append("chop ").append(nLocal); break; case Opcodes.F_SAME: sb.append("same"); break; case Opcodes.F_SAME1: sb.append("same1 "); appendFrameTypes(sb, 1, stack); break; default: assert false; break; } sb.append('\n'); sb.append('\n'); addText(sb); }
From source file:com.google.code.jconts.instrument.gen.AsyncMethodAdapter.java
License:Apache License
@Override public void visitFrame(int type, int nLocal, Object[] locs, int nStack, Object[] stack) { if (type == Opcodes.F_NEW) { throw new IllegalArgumentException("Expanded frames are not supported!"); }//from w w w.j a v a2 s . c o m mv.visitFrame(type, nLocal, locs, nStack, stack); if (type == Opcodes.F_APPEND) { for (int i = 0; i < nLocal; ++i) { locals.add(Frames.fromFrameType(locs[i])); } } else if (type == Opcodes.F_CHOP) { for (int i = 0; i < nLocal; ++i) { locals.remove(locals.size() - 1); } } else if (type == Opcodes.F_FULL) { locals.clear(); for (int i = 0; i < nLocal; ++i) { locals.add(Frames.fromFrameType(locs[i])); } } }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
@Override public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { switch (type) { case Opcodes.F_NEW: // Expanded form. previousFrame = FrameInfo.create(convertTypesInStackMapFrame(nLocal, local), convertTypesInStackMapFrame(nStack, stack)); break;/*from ww w . ja v a 2 s. c om*/ case Opcodes.F_SAME: // This frame type indicates that the frame has exactly the same local variables as the // previous frame and that the operand stack is empty. previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.of()); break; case Opcodes.F_SAME1: // This frame type indicates that the frame has exactly the same local variables as the // previous frame and that the operand stack has one entry. previousFrame = FrameInfo.create(previousFrame.locals(), convertTypesInStackMapFrame(nStack, stack)); break; case Opcodes.F_APPEND: // This frame type indicates that the frame has the same locals as the previous frame except // that k additional locals are defined, and that the operand stack is empty. previousFrame = FrameInfo.create(appendArrayToList(previousFrame.locals(), nLocal, local), ImmutableList.of()); break; case Opcodes.F_CHOP: // This frame type indicates that the frame has the same local variables as the previous // frame except that the last k local variables are absent, and that the operand stack is // empty. previousFrame = FrameInfo.create(removeBackFromList(previousFrame.locals(), nLocal), ImmutableList.of()); break; case Opcodes.F_FULL: previousFrame = FrameInfo.create(convertTypesInStackMapFrame(nLocal, local), convertTypesInStackMapFrame(nStack, stack)); break; default: // continue below } // Update types for operand stack and local variables. operandStack.clear(); operandStack.addAll(previousFrame.stack()); localVariableSlots.clear(); localVariableSlots.addAll(previousFrame.locals()); super.visitFrame(type, nLocal, local, nStack, stack); }
From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.VisitFrame.java
License:Open Source License
public String toString() { String result = "VisitFrame: type = "; switch (type) { case Opcodes.F_NEW: result = result + " F_NEW "; break;/*from w w w . j av a2s.c om*/ case Opcodes.F_FULL: result = result + " F_FULL "; break; case Opcodes.F_APPEND: result = result + " F_APPEND "; break; case Opcodes.F_CHOP: result = result + " F_CHOP "; break; case Opcodes.F_SAME: result = result + " F_SAME "; break; case Opcodes.F_SAME1: result = result + " F_SAME1 "; break; default: throw new RuntimeException("Unknown Frame Type " + type); } result = result + "locals = ["; for (int i = 0; i < nLocal; i++) result = result + local[i] + " "; result = result + "] Stack = ["; for (int i = 0; i < nStack; i++) result = result + stack[i] + " "; result = result + "]"; return result; }
From source file:de.scoopgmbh.copper.instrument.BuildStackInfoAdapter.java
License:Apache License
@Override public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3, Object[] arg4) { savePreviousFrame();/* w w w .jav a2 s . com*/ if (logger.isDebugEnabled()) logger.debug("stackBefore: " + currentFrame.stack); if (logger.isDebugEnabled()) logger.debug("localBefore: " + currentFrame.localsToString()); currentFrame = new StackInfo(lastDeclaredFrame); switch (arg0) { case F_SAME: // representing frame with exactly the same locals as the previous frame and with the empty stack. currentFrame.stack.clear(); break; case F_SAME1: //representing frame with exactly the same locals as the previous frame and with single value on the stack (nStack is 1 and stack[0] contains value for the type of the stack item). Type t = StackInfo.deferLocalDesc(arg4[0]); currentFrame.stack.clear(); currentFrame.stack.push(t); break; case F_APPEND: // representing frame with current locals are the same as the locals in the previous frame, except that additional locals are defined (nLocal is 1, 2 or 3 and local elements contains values representing added types). currentFrame.appendLocals(arg1, arg2); break; case F_CHOP: //Opcodes.F_CHOP representing frame with current locals are the same as the locals in the previous frame, except that the last 1-3 locals are absent and with the empty stack (nLocals is 1, 2 or 3). currentFrame.removeLocals(arg1); currentFrame.stack.clear(); break; case Opcodes.F_FULL: //representing complete frame data. case Opcodes.F_NEW: currentFrame.clearFrame(); currentFrame.appendLocals(arg1, arg2); currentFrame.appendStack(arg3, arg4); break; default: throw new BuildStackFrameException("Unkwnon frame type " + arg0); } lastDeclaredFrame = new StackInfo(currentFrame); if (logger.isDebugEnabled()) logger.debug("stack: " + currentFrame.stack); if (logger.isDebugEnabled()) logger.debug("local: " + currentFrame.localsToString()); if (logger.isDebugEnabled()) logger.debug("frame " + getFrameType(arg0) + " '" + arg1 + "' '" + Arrays.asList(arg2) + "' '" + arg3 + "' '" + Arrays.asList(arg4) + "'"); delegate.visitFrame(arg0, arg1, arg2, arg3, arg4); }
From source file:edu.ubc.mirrors.holograms.FrameAnalyzer.java
License:Open Source License
private FrameNode toFrameNode(Frame<FrameValue> frame) { int numLocals = frame.getLocals(); List<Object> localsList = new ArrayList<Object>(frame.getLocals()); for (int i = 0; i < numLocals; i++) { FrameValue value = frame.getLocal(i); localsList.add(toFrameObject(value)); if (value.getSize() == 2) { // Skip the next TOP - the visitor API represents locals // with one element instead. i++;/*from www .jav a 2 s . c o m*/ } } Object[] locals = localsList.toArray(); int stackSize = frame.getStackSize(); Object[] stack = new Object[stackSize]; for (int i = 0; i < stackSize; i++) { FrameValue value = frame.getStack(i); stack[i] = toFrameObject(value); } return new FrameNode(Opcodes.F_NEW, locals.length, locals, stack.length, stack); }
From source file:edu.ubc.mirrors.holograms.HologramMethodGenerator.java
License:Open Source License
@Override public void visitCode() { super.visitCode(); if (name.equals("<clinit>")) { initializeStaticFields(owner, this); // Skip the static initializer for classes that were already defined - // these will have already been executed when // loading the original class and state will be proxied by ClassMirrors instead. Label afterEarlyReturn = new Label(); new MethodHandle() { protected void methodCall() throws Throwable { ((ClassMirror) null).initialized(); }//ww w.j a v a 2 s . c om }.invoke(this); ifeq(afterEarlyReturn); areturn(Type.VOID_TYPE); mark(afterEarlyReturn); visitFrame(Opcodes.F_NEW, 0, new Object[0], 0, new Object[0]); } if (name.equals("<init>")) { lvs.newLocal(instanceMirrorType); if (owner.equals(getHologramType(Throwable.class))) { load(0, owner); load((methodType.getArgumentsAndReturnSizes() >> 2) - 1, instanceMirrorType); putfield(owner.getInternalName(), "mirror", Type.getDescriptor(ObjectMirror.class)); } } }
From source file:jaspex.speculation.newspec.FlowFrame.java
License:Open Source License
/** Computa FlowFrame a partir de um FrameNode **/ FlowFrame frameFromFrameNode(FrameNode frameNode) { if (frameNode.type != Opcodes.F_FULL && frameNode.type != Opcodes.F_NEW) { throw new AssertionError(); }// www . ja v a2s . c o m FlowFrame f = new FlowFrame(_mn.maxLocals, _mn.maxStack); List<BasicValue> locals = convertFromFrame(frameNode.local, true); List<BasicValue> stack = convertFromFrame(frameNode.stack, false); for (int i = 0; i < locals.size(); i++) f.setLocal(i, locals.get(i)); // Inicializar os locals restantes for (int i = locals.size(); i < _mn.maxLocals; i++) { f.setLocal(i, BasicValue.UNINITIALIZED_VALUE); } for (int i = 0; i < stack.size(); i++) f.push(stack.get(i)); return f; }
From source file:org.apache.maven.shared.dependency.analyzer.asm.DependencyVisitorTest.java
License:Apache License
public void testVisitFrame() { visitor.visitFrame(Opcodes.F_NEW, 0, new Object[0], 0, new Object[0]); assertNoClasses(); }