< prev index next >

src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JIInliner.java

Print this page
rev 52456 : imported patch asm.additional


  43 @Deprecated
  44 final class JIInliner extends ClassVisitor {
  45     private final String targetClassName;
  46     private final String instrumentationClassName;
  47     private final ClassNode targetClassNode;
  48     private final List<Method> instrumentationMethods;
  49 
  50     /**
  51      * A ClassVisitor which will check all methods of the class it visits against the instrumentationMethods
  52      * list. If a method is on that list, the method will be further processed for inlining into that
  53      * method.
  54      */
  55     JIInliner(int api, ClassVisitor cv, String targetClassName, String instrumentationClassName,
  56             ClassReader targetClassReader,
  57             List<Method> instrumentationMethods) {
  58         super(api, cv);
  59         this.targetClassName = targetClassName;
  60         this.instrumentationClassName = instrumentationClassName;
  61         this.instrumentationMethods = instrumentationMethods;
  62 
  63         ClassNode cn = new ClassNode(Opcodes.ASM5);
  64         targetClassReader.accept(cn, ClassReader.EXPAND_FRAMES);
  65         this.targetClassNode = cn;
  66     }
  67 
  68     @Override
  69     public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
  70         MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
  71 
  72         if (isInstrumentationMethod(name, desc)) {
  73             MethodNode methodToInline = findTargetMethodNode(name, desc);
  74             if (methodToInline == null) {
  75                 throw new IllegalArgumentException("Could not find the method to instrument in the target class");
  76             }
  77             if (Modifier.isNative(methodToInline.access)) {
  78                 throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc);
  79             }
  80 
  81             Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc);
  82 
  83             JIMethodCallInliner mci = new JIMethodCallInliner(access,




  43 @Deprecated
  44 final class JIInliner extends ClassVisitor {
  45     private final String targetClassName;
  46     private final String instrumentationClassName;
  47     private final ClassNode targetClassNode;
  48     private final List<Method> instrumentationMethods;
  49 
  50     /**
  51      * A ClassVisitor which will check all methods of the class it visits against the instrumentationMethods
  52      * list. If a method is on that list, the method will be further processed for inlining into that
  53      * method.
  54      */
  55     JIInliner(int api, ClassVisitor cv, String targetClassName, String instrumentationClassName,
  56             ClassReader targetClassReader,
  57             List<Method> instrumentationMethods) {
  58         super(api, cv);
  59         this.targetClassName = targetClassName;
  60         this.instrumentationClassName = instrumentationClassName;
  61         this.instrumentationMethods = instrumentationMethods;
  62 
  63         ClassNode cn = new ClassNode(Opcodes.ASM7);
  64         targetClassReader.accept(cn, ClassReader.EXPAND_FRAMES);
  65         this.targetClassNode = cn;
  66     }
  67 
  68     @Override
  69     public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
  70         MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
  71 
  72         if (isInstrumentationMethod(name, desc)) {
  73             MethodNode methodToInline = findTargetMethodNode(name, desc);
  74             if (methodToInline == null) {
  75                 throw new IllegalArgumentException("Could not find the method to instrument in the target class");
  76             }
  77             if (Modifier.isNative(methodToInline.access)) {
  78                 throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc);
  79             }
  80 
  81             Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc);
  82 
  83             JIMethodCallInliner mci = new JIMethodCallInliner(access,


< prev index next >