< prev index next >

test/compiler/jsr292/NonInlinedCall/RedefineTest.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8072008
  27  * @modules java.base/jdk.internal.org.objectweb.asm
  28  *          java.base/jdk.internal.misc
  29  *          java.base/jdk.internal.vm.annotation
  30  * @library /testlibrary /test/lib / ../patches
  31  * @requires vm.flavor != "minimal"

  32  * @build sun.hotspot.WhiteBox
  33  * @build java.base/java.lang.invoke.MethodHandleHelper
  34  * @build compiler.jsr292.NonInlinedCall.RedefineTest
  35  * @run main compiler.jsr292.NonInlinedCall.Agent agent.jar compiler.jsr292.NonInlinedCall.RedefineTest
  36  * @run main ClassFileInstaller sun.hotspot.WhiteBox


  37  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  38  *                              compiler.jsr292.NonInlinedCall.RedefineTest
  39  * @run main/bootclasspath/othervm -javaagent:agent.jar
  40  *                                 -XX:+IgnoreUnrecognizedVMOptions
  41  *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  42  *                                 -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
  43  *                                 compiler.jsr292.NonInlinedCall.RedefineTest
  44  */
  45 
  46 package compiler.jsr292.NonInlinedCall;
  47 




  48 import sun.hotspot.WhiteBox;
  49 
  50 import java.lang.instrument.ClassDefinition;
  51 import java.lang.instrument.Instrumentation;
  52 import java.lang.invoke.MethodHandle;
  53 import java.lang.invoke.MethodHandles;
  54 import java.lang.invoke.MethodHandleHelper;

  55 import java.lang.invoke.MethodType;
  56 
  57 import jdk.internal.misc.Unsafe;
  58 import jdk.internal.vm.annotation.DontInline;
  59 import jdk.internal.org.objectweb.asm.*;

  60 
  61 import static jdk.internal.org.objectweb.asm.Opcodes.*;
  62 
  63 public class RedefineTest {
  64     static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP;
  65     static final Unsafe UNSAFE = Unsafe.getUnsafe();
  66 
  67     static final String NAME = "compiler/jsr292/NonInlinedCall/RedefineTest$T";
  68 
  69     static Class<?> getClass(int r) {
  70         byte[] classFile = getClassFile(r);
  71         return UNSAFE.defineClass(NAME, classFile, 0, classFile.length, null, null);
  72     }
  73 
  74     /**
  75      * Generates a class of the following shape:
  76      *     static class T {
  77      *         @DontInline public static int f() { return $r; }
  78      *     }
  79      */
  80     static byte[] getClassFile(int r) {
  81         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
  82         MethodVisitor mv;




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8072008
  27  * @modules java.base/jdk.internal.org.objectweb.asm
  28  *          java.base/jdk.internal.misc
  29  *          java.base/jdk.internal.vm.annotation
  30  * @library /testlibrary /test/lib / ../patches
  31  * @requires vm.flavor != "minimal"
  32  *
  33  * @build sun.hotspot.WhiteBox
  34  *        java.base/java.lang.invoke.MethodHandleHelper
  35  *        compiler.jsr292.NonInlinedCall.RedefineTest
  36  * @run driver compiler.jsr292.NonInlinedCall.Agent
  37  *             agent.jar
  38  *             compiler.jsr292.NonInlinedCall.RedefineTest
  39  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  40  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  41  *                                compiler.jsr292.NonInlinedCall.RedefineTest
  42  * @run main/bootclasspath/othervm -javaagent:agent.jar
  43  *                                 -XX:+IgnoreUnrecognizedVMOptions
  44  *                                 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  45  *                                 -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1
  46  *                                 compiler.jsr292.NonInlinedCall.RedefineTest
  47  */
  48 
  49 package compiler.jsr292.NonInlinedCall;
  50 
  51 import jdk.internal.misc.Unsafe;
  52 import jdk.internal.org.objectweb.asm.ClassWriter;
  53 import jdk.internal.org.objectweb.asm.MethodVisitor;
  54 import jdk.internal.vm.annotation.DontInline;
  55 import sun.hotspot.WhiteBox;
  56 
  57 import java.lang.instrument.ClassDefinition;
  58 import java.lang.instrument.Instrumentation;
  59 import java.lang.invoke.MethodHandle;

  60 import java.lang.invoke.MethodHandleHelper;
  61 import java.lang.invoke.MethodHandles;
  62 import java.lang.invoke.MethodType;
  63 
  64 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
  65 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
  66 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
  67 import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN;
  68 


  69 public class RedefineTest {
  70     static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP;
  71     static final Unsafe UNSAFE = Unsafe.getUnsafe();
  72 
  73     static final String NAME = "compiler/jsr292/NonInlinedCall/RedefineTest$T";
  74 
  75     static Class<?> getClass(int r) {
  76         byte[] classFile = getClassFile(r);
  77         return UNSAFE.defineClass(NAME, classFile, 0, classFile.length, null, null);
  78     }
  79 
  80     /**
  81      * Generates a class of the following shape:
  82      *     static class T {
  83      *         @DontInline public static int f() { return $r; }
  84      *     }
  85      */
  86     static byte[] getClassFile(int r) {
  87         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
  88         MethodVisitor mv;


< prev index next >