< prev index next >

test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java

Print this page




  28  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  29  * @library /testlibrary /../../test/lib /
  30  * @compile ../common/CompilerToVMHelper.java
  31  * @build sun.hotspot.WhiteBox
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  *                              jdk.vm.ci.hotspot.CompilerToVMHelper
  35  * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  36  *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
  37  *      compiler.jvmci.compilerToVM.CanInlineMethodTest
  38  */
  39 
  40 package compiler.jvmci.compilerToVM;
  41 
  42 import compiler.jvmci.common.CTVMUtilities;
  43 import java.lang.reflect.Executable;
  44 import java.util.ArrayList;
  45 import java.util.Arrays;
  46 import java.util.List;
  47 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  48 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl;
  49 import jdk.test.lib.Asserts;
  50 import sun.hotspot.WhiteBox;
  51 
  52 public class CanInlineMethodTest {
  53 
  54     private static final WhiteBox WB = WhiteBox.getWhiteBox();
  55 
  56     public static void main(String[] args) {
  57         List<Executable> testCases = createTestCases();
  58         testCases.forEach(CanInlineMethodTest::runSanityTest);
  59     }
  60 
  61     private static void runSanityTest(Executable aMethod) {
  62         HotSpotResolvedJavaMethodImpl method = CTVMUtilities
  63                 .getResolvedMethod(aMethod);
  64         boolean canInline = CompilerToVMHelper.canInlineMethod(method);
  65         boolean expectedCanInline = !WB.testSetDontInlineMethod(aMethod,
  66                 true);
  67         Asserts.assertEQ(canInline, expectedCanInline, "Unexpected initial " +
  68                 "value of property 'can inline'");
  69 
  70         canInline = CompilerToVMHelper.canInlineMethod(method);
  71         Asserts.assertFalse(canInline, aMethod + "Unexpected value of " +
  72                 "property 'can inline' after setting 'do not inline' to true");
  73         WB.testSetDontInlineMethod(aMethod, false);
  74         canInline = CompilerToVMHelper.canInlineMethod(method);
  75         Asserts.assertTrue(canInline, "Unexpected value of " +
  76                 "property 'can inline' after setting 'do not inline' to false");
  77     }
  78 
  79     private static List<Executable> createTestCases() {
  80         List<Executable> testCases = new ArrayList<>();
  81 
  82         Class<?> aClass = DummyClass.class;


  28  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  29  * @library /testlibrary /../../test/lib /
  30  * @compile ../common/CompilerToVMHelper.java
  31  * @build sun.hotspot.WhiteBox
  32  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  33  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  34  *                              jdk.vm.ci.hotspot.CompilerToVMHelper
  35  * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  36  *      -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
  37  *      compiler.jvmci.compilerToVM.CanInlineMethodTest
  38  */
  39 
  40 package compiler.jvmci.compilerToVM;
  41 
  42 import compiler.jvmci.common.CTVMUtilities;
  43 import java.lang.reflect.Executable;
  44 import java.util.ArrayList;
  45 import java.util.Arrays;
  46 import java.util.List;
  47 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  48 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  49 import jdk.test.lib.Asserts;
  50 import sun.hotspot.WhiteBox;
  51 
  52 public class CanInlineMethodTest {
  53 
  54     private static final WhiteBox WB = WhiteBox.getWhiteBox();
  55 
  56     public static void main(String[] args) {
  57         List<Executable> testCases = createTestCases();
  58         testCases.forEach(CanInlineMethodTest::runSanityTest);
  59     }
  60 
  61     private static void runSanityTest(Executable aMethod) {
  62         HotSpotResolvedJavaMethod method = CTVMUtilities
  63                 .getResolvedMethod(aMethod);
  64         boolean canInline = CompilerToVMHelper.canInlineMethod(method);
  65         boolean expectedCanInline = !WB.testSetDontInlineMethod(aMethod,
  66                 true);
  67         Asserts.assertEQ(canInline, expectedCanInline, "Unexpected initial " +
  68                 "value of property 'can inline'");
  69 
  70         canInline = CompilerToVMHelper.canInlineMethod(method);
  71         Asserts.assertFalse(canInline, aMethod + "Unexpected value of " +
  72                 "property 'can inline' after setting 'do not inline' to true");
  73         WB.testSetDontInlineMethod(aMethod, false);
  74         canInline = CompilerToVMHelper.canInlineMethod(method);
  75         Asserts.assertTrue(canInline, "Unexpected value of " +
  76                 "property 'can inline' after setting 'do not inline' to false");
  77     }
  78 
  79     private static List<Executable> createTestCases() {
  80         List<Executable> testCases = new ArrayList<>();
  81 
  82         Class<?> aClass = DummyClass.class;
< prev index next >