protected int newLocalMapping(final Type type) { int local = getNextLocal(); memento.nextLocal += type.getSize(); return local; }
/** * Creates a new {@link LocalVariablesSorter}. * * @param access access flags of the adapted method. * @param desc the method's descriptor (see {@link Type Type}). * @param mv the method visitor to which this adapter delegates calls. */ public LocalVariablesSorter( final int access, final String desc, final MethodVisitor mv, final Memento memento) { super(Opcodes.ASM4, mv); this.memento = memento; Type[] args = Type.getArgumentTypes(desc); memento.nextLocal = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0; for (int i = 0; i < args.length; i++) { memento.nextLocal += args[i].getSize(); } memento.firstLocal = memento.nextLocal; }
public void dupValue(Type type) { switch (type.getSize()) { case 1: dup(); break; case 2: dup2(); break; } }
private int generateClinit(MethodVisitor mv) { Type clazz = Type.getType("L" + cname + ";"); // the client name (the BTrace script class name) mv.visitLdcInsn(runtime); // the name of the currently processed class mv.visitLdcInsn(clazz); // NOI18N // invocatio nof BTraceRuntime.retransform() method mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(BTraceRuntime.class), "retransform", "(Ljava/lang/String;Ljava/lang/Class;)V"); // NOI18N return clazz.getSize() + Type.getType(String.class).getSize(); } }
public int remap(final int var, final Type type) { if (frozen) { return var; } if (var < getFirstLocal()) return var; int key = 2 * var + type.getSize() - 1; int size = memento.mapping.length; if (key >= size) { int[] newMapping = new int[Math.max(2 * size, key + 1)]; System.arraycopy(memento.mapping, 0, newMapping, 0, size); memento.mapping = newMapping; } int value = memento.mapping[key]; if (value == 0) { value = newLocalMapping(type); setLocalType(value, type); memento.mapping[key] = value + 1; } else { value--; } if (value != var) { memento.changed = true; } return value; }
for(int i=0;i<t.getSize();i++) { simulatedStack.poll();
for(int i=0;i<t.getSize();i++) { simulatedStack.poll();
public void doProvide() { push(myArgTypes.length); visitTypeInsn(ANEWARRAY, TypeUtils.objectType.getInternalName()); for (int j = 0; j < myArgTypes.length; j++) { dup(); push(j); Type argType = myArgTypes[j]; loadLocal(argType, argPtr); box(argType); arrayStore(TypeUtils.objectType); argPtr += argType.getSize(); } }
@Override public void visitEnd() { if (isExtension) { MethodVisitor mv = visitMethod(Opcodes.ACC_STATIC, CLINIT, "()V", null, null); mv.visitCode(); for(InitializerBlock ib : initBlocks) { ib.apply(mv); } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(Type.getType(BTraceRuntimeBridge.class).getSize(), 0); mv.visitEnd(); } super.visitEnd(); } }
memento.nextLocal += type.getSize(); setLocalType(local, type); setFrameLocal(local, t);
for (FieldDescriptor fd : threadLocalFields.values()) { fd.var = nextVar; nextVar += Type.getType(fd.desc).getSize();
private void injectBtrace(ValidationResult vr) { lvs.freeze(); try { ArgumentProvider[] actionArgs = new ArgumentProvider[actionArgTypes.length + 3]; int ptr = isStatic() ? 0 : 1; for(int i=0;i<vr.getArgCnt();i++) { int index = vr.getArgIdx(i); Type t = actionArgTypes[index]; if (TypeUtils.isAnyTypeArray(t)) { actionArgs[i] = new AnyTypeArgProvider(index, ptr); ptr++; } else { actionArgs[i] = new LocalVarArgProvider(index, t, ptr); ptr += actionArgTypes[index].getSize(); } } actionArgs[actionArgTypes.length] = new ConstantArgProvider(om.getMethodParameter(), getName(om.isMethodFqn())); actionArgs[actionArgTypes.length + 1] = new ConstantArgProvider(om.getClassNameParameter(), className.replace("/", ".")); actionArgs[actionArgTypes.length + 2] = new LocalVarArgProvider(om.getSelfParameter(), Type.getObjectType(className), 0); loadArguments(actionArgs); invokeBTraceAction(this, om); } finally { lvs.unfreeze(); } }
} else { actionArgs[i] = new LocalVarArgProvider(index, t, ptr); ptr += actionArgTypes[index].getSize();