return new Size( 4, instrumentedMethod.getStackSize() );
@Override protected void onComplete(Implementation.Context implementationContext) { mv.visitLabel(label); frameWriter.emitFrame(mv); ByteCodeAppender.Size size = record.applyCode(mv, implementationContext); stackSize = Math.max(stackSize, size.getOperandStackSize()); localVariableLength = Math.max(localVariableLength, size.getLocalVariableSize()); }
return new Size( 4 + 2 * persistentFieldAsDefined.getType().getStackSize().getSize(), instrumentedMethod.getStackSize() );
methodVisitor.visitFrame( Opcodes.F_SAME, 0, null, 0, null ); return new Size( 1 + 2 * persistentField.getType().asErasure().getStackSize().getSize(), instrumentedMethod.getStackSize() );
return new Size( 4 + persistentFieldAsDefined.getType().getStackSize().getSize(), instrumentedMethod.getStackSize() );
return new Size( 4, instrumentedMethod.getStackSize() );
return new Size( 6, instrumentedMethod.getStackSize() );
@Override public Size apply( MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod ) { methodVisitor.visitVarInsn( Opcodes.ALOAD, 0 ); methodVisitor.visitMethodInsn( Opcodes.INVOKESPECIAL, managedCtClass.getSuperClass().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentField.getName(), Type.getMethodDescriptor( Type.getType( persistentField.getType().asErasure().getDescriptor() ) ), false ); methodVisitor.visitInsn( Type.getType( persistentField.getType().asErasure().getDescriptor() ).getOpcode( Opcodes.IRETURN ) ); return new Size( persistentField.getType().getStackSize().getSize(), instrumentedMethod.getStackSize() ); } }
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { if (!instrumentedMethod.getReturnType().represents(void.class)) { throw new IllegalArgumentException(instrumentedMethod + " must return void"); } // TODO Check we have two arguments copy(Object dest, long src); try { StackManipulation stack = buildStack(); StackManipulation.Size finalStackSize = stack.apply(methodVisitor, implementationContext); return new Size( finalStackSize.getMaximalSize(), instrumentedMethod.getStackSize() + 2); // 2 stack slots for a single local variable } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } }
@Override public Size apply( MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod ) { methodVisitor.visitVarInsn( Opcodes.ALOAD, 0 ); methodVisitor.visitVarInsn( Type.getType( persistentField.getType().asErasure().getDescriptor() ).getOpcode( Opcodes.ILOAD ), 1 ); methodVisitor.visitMethodInsn( Opcodes.INVOKESPECIAL, managedCtClass.getSuperClass().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + persistentField.getName(), Type.getMethodDescriptor( Type.getType( void.class ), Type.getType( persistentField.getType().asErasure().getDescriptor() ) ), false ); methodVisitor.visitInsn( Opcodes.RETURN ); return new Size( 1 + persistentField.getType().getStackSize().getSize(), instrumentedMethod.getStackSize() ); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { int numArgs = instrumentedMethod.getParameters().asTypeList().getStackSize(); /** * Load the desired id * relative to the method arguments. * The idea here would be to load references * to declared variables */ //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 int start = instrumentedMethod.isStatic() ? 1 : 0; StackManipulation arg0 = MethodVariableAccess.REFERENCE .loadOffset(numArgs + start + OpCodeUtil.getAloadInstructionForReference(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) { switch (returnType) { case REFERENCE: return new Size(MethodReturn.REFERENCE.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize()); case VOID: return new Size(MethodReturn.VOID.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize()); case INT: return new Size(MethodReturn.INTEGER.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize()); default: throw new IllegalStateException("Illegal type"); } } }
@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)); //set the return type (ALWAYS REMEMBER TO DO THIS) StackManipulation returnOp = MethodReturn.VOID; size = size.aggregate(returnOp.apply(methodVisitor, implementationContext)); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); }
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { checkMethodSignature(instrumentedMethod); try { StackManipulation stack = buildStack(); StackManipulation.Size finalStackSize = stack.apply(methodVisitor, implementationContext); return new Size(finalStackSize.getMaximalSize(), instrumentedMethod.getStackSize() + 2); // 2 stack slots for a single local variable } catch (NoSuchMethodException | NoSuchFieldException e) { throw new RuntimeException(e); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation.Size size = MethodVariableAccess.INTEGER.loadOffset(offset).apply(methodVisitor, implementationContext); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { StackManipulation createArray = RelativeIntArrayCreation.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 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) { StackManipulation.Size size = MethodVariableAccess.REFERENCE.loadOffset(offset).apply(methodVisitor, implementationContext); return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize()); } }
@Override public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { if (!instrumentedMethod.getReturnType().represents(int.class)) { throw new IllegalArgumentException(instrumentedMethod + " must return int"); } StackManipulation.Size operandStackSize = new StackManipulation.Compound(IntegerConstant.forValue(val1), IntegerConstant.forValue(val2), op, MethodReturn.INTEGER).apply(methodVisitor, implementationContext); return new Size(operandStackSize.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, MethodReturn.REFERENCE); StackManipulation.Size size1 = size.apply(methodVisitor, implementationContext); return new Size(size1.getMaximalSize(), instrumentedMethod.getStackSize()); }