/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, METHOD_HANDLE_NAME, INVOKE_EXACT, methodType.getDescriptor(), false); int size = methodType.getReturnType().getStackSize().getSize() - methodType.getParameterTypes().getStackSize(); return new Size(size, Math.max(size, 0)); } }
? candidates.getOnly().getDeclaringType().asGenericType() : candidates.getOnly().getReturnType()) .apply(mv, implementationContext).getMaximalSize() - (candidates.getOnly().isConstructor() ? StackSize.SINGLE : candidates.getOnly().getReturnType().getStackSize()).getSize()); Removal.SINGLE, Removal.SINGLE ).apply(mv, implementationContext).getMaximalSize() + StackSize.SINGLE.getSize());
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { Size size = IntegerConstant.forValue(stackManipulations.size()).apply(methodVisitor, implementationContext); // The array's construction does not alter the stack's size. size = size.aggregate(arrayCreator.apply(methodVisitor, implementationContext)); int index = 0; for (StackManipulation stackManipulation : stackManipulations) { methodVisitor.visitInsn(Opcodes.DUP); size = size.aggregate(StackSize.SINGLE.toIncreasingSize()); size = size.aggregate(IntegerConstant.forValue(index++).apply(methodVisitor, implementationContext)); size = size.aggregate(stackManipulation.apply(methodVisitor, implementationContext)); methodVisitor.visitInsn(arrayCreator.getStorageOpcode()); size = size.aggregate(sizeDecrease); } return size; } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1 StackManipulation compound = assignOperation(); StackManipulation.Size size = compound.apply(methodVisitor, implementationContext); //resolve the type to store in the array and retrieve the store command StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).store(); size = size.aggregate(store.apply(methodVisitor, implementationContext)); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { //resolve the type to store in the array and retrieve the store command StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).load(); StackManipulation.Size size = store.apply(methodVisitor, implementationContext); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1 StackManipulation compound = assignOperation(); StackManipulation.Size size = compound.apply(methodVisitor, implementationContext); //resolve the type to store in the array and retrieve the store command StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).store(); size = size.aggregate(store.apply(methodVisitor, implementationContext)); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { //references start with zero if its an instance or zero if its static //think of it like an implicit self in python without actually being defined StackManipulation arg0 = MethodVariableAccess.INTEGER.loadOffset(refId); StackManipulation.Size size = arg0.apply(methodVisitor, implementationContext); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation.Size size = loadThis ? MethodVariableAccess.loadThisReferenceAndArguments(instrumentedMethod).apply(methodVisitor, implementationContext) : MethodVariableAccess.loadArguments(instrumentedMethod).apply(methodVisitor, implementationContext); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation createArray = IntArrayCreation.intCreationOfLength(length); StackManipulation.Compound size = new StackManipulation.Compound(createArray); StackManipulation.Size size1 = size.apply(methodVisitor, implementationContext); return new Size(size1.getMaximalSize(), instrumentedMethod.getStackSize()); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1 StackManipulation compound = assignOperation(); StackManipulation.Size size = compound.apply(methodVisitor, implementationContext); //resolve the type to store in the array and retrieve the load command StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).load(); size = size.aggregate(store.apply(methodVisitor, implementationContext)); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation.Size size = IntegerConstant.forValue(length).apply(methodVisitor, implementationContext); methodVisitor.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_INT); return new Size(size.getMaximalSize(), size.getSizeImpact()); } }
.getMaximalSize() - result.getStackSize().getSize()); return;
throw new IllegalStateException("Cannot set or get value of " + instrumentedMethod + " using " + fieldDescription); return new Size(implementation.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize());
maximumStackSize = Math.max(maximumStackSize, currentStackSize + offsetMapping.resolveRead() .apply(methodVisitor, implementationContext) .getMaximalSize());
stackManipulations.add(MethodInvocation.invoke(TO_STRING)); stackManipulations.add(MethodReturn.REFERENCE); return new Size(new StackManipulation.Compound(stackManipulations).apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize());
MethodReturn.of(instrumentedMethod.getReturnType()) ).apply(methodVisitor, implementationContext); return new ByteCodeAppender.Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
return new Size(new StackManipulation.Compound(stackManipulations).apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize() + padding);
MethodReturn.REFERENCE ).apply(methodVisitor, implementationContext); return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
FieldAccess.forField(instrumentedType.getDeclaredFields().filter(named(ENUM_VALUES)).getOnly()).write() ); return new Size(stackManipulation.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize());
throw new IllegalStateException("Unexpected opcode: " + opcode); methodSizeHandler.requireStackSizePadding(stackManipulation.apply(mv, implementationContext).getMaximalSize() - expectedGrowth.getSize()); } else { mv.visitVarInsn(opcode, argumentHandler.mapped(offset));