< prev index next >

test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java

Print this page
rev 52456 : imported patch asm.additional


 355         MethodDesc md = new MethodDesc(executable);
 356         calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.put(c, false));
 357     }
 358 
 359     public void forceInline(Executable executable) {
 360         WHITE_BOX.testSetForceInlineMethod(executable, true);
 361         MethodDesc md = new MethodDesc(executable);
 362         calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.putIfAbsent(c, true));
 363     }
 364 
 365     private static Collection<Call> getCalls(Class<?> aClass) {
 366         List<Call> calls = new ArrayList<>();
 367         ClassWriter cw;
 368         ClassReader cr;
 369         try {
 370             cr = new ClassReader(aClass.getName());
 371         } catch (IOException e) {
 372             throw new Error("TESTBUG : unexpected IOE during class reading", e);
 373         }
 374         cw = new ClassWriter(cr, 0);
 375         ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
 376             @Override
 377             public MethodVisitor visitMethod(int access, String name, String desc, String descriptor, String[] exceptions) {
 378                 System.out.println("Method: " +name);
 379                 MethodVisitor mv = super.visitMethod(access, name, desc, descriptor, exceptions);
 380                 return new CallTracer(aClass, name, desc, mv, calls);
 381             }
 382         };
 383         cr.accept(cv, 0);
 384 
 385         return calls;
 386     }
 387 
 388     private static class CallTracer extends MethodVisitor {
 389         private final MethodDesc caller;
 390         private Collection<Call> calls;
 391 
 392         public CallTracer(Class<?> aClass, String name, String desc, MethodVisitor mv, Collection<Call> calls) {
 393             super(Opcodes.ASM5, mv);
 394             caller = new MethodDesc(aClass.getName(), name, desc);
 395             this.calls = calls;
 396         }
 397 
 398         @Override
 399         public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
 400             Label label = new Label();
 401             visitLabel(label);
 402             super.visitMethodInsn(opcode, owner, name, desc, itf);
 403             calls.add(new Call(caller, new MethodDesc(owner, name, desc), label.getOffset()));
 404         }
 405     }
 406 }


 355         MethodDesc md = new MethodDesc(executable);
 356         calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.put(c, false));
 357     }
 358 
 359     public void forceInline(Executable executable) {
 360         WHITE_BOX.testSetForceInlineMethod(executable, true);
 361         MethodDesc md = new MethodDesc(executable);
 362         calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.putIfAbsent(c, true));
 363     }
 364 
 365     private static Collection<Call> getCalls(Class<?> aClass) {
 366         List<Call> calls = new ArrayList<>();
 367         ClassWriter cw;
 368         ClassReader cr;
 369         try {
 370             cr = new ClassReader(aClass.getName());
 371         } catch (IOException e) {
 372             throw new Error("TESTBUG : unexpected IOE during class reading", e);
 373         }
 374         cw = new ClassWriter(cr, 0);
 375         ClassVisitor cv = new ClassVisitor(Opcodes.ASM7, cw) {
 376             @Override
 377             public MethodVisitor visitMethod(int access, String name, String desc, String descriptor, String[] exceptions) {
 378                 System.out.println("Method: " +name);
 379                 MethodVisitor mv = super.visitMethod(access, name, desc, descriptor, exceptions);
 380                 return new CallTracer(aClass, name, desc, mv, calls);
 381             }
 382         };
 383         cr.accept(cv, 0);
 384 
 385         return calls;
 386     }
 387 
 388     private static class CallTracer extends MethodVisitor {
 389         private final MethodDesc caller;
 390         private Collection<Call> calls;
 391 
 392         public CallTracer(Class<?> aClass, String name, String desc, MethodVisitor mv, Collection<Call> calls) {
 393             super(Opcodes.ASM7, mv);
 394             caller = new MethodDesc(aClass.getName(), name, desc);
 395             this.calls = calls;
 396         }
 397 
 398         @Override
 399         public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
 400             Label label = new Label();
 401             visitLabel(label);
 402             super.visitMethodInsn(opcode, owner, name, desc, itf);
 403             calls.add(new Call(caller, new MethodDesc(owner, name, desc), label.getOffset()));
 404         }
 405     }
 406 }
< prev index next >