< prev index next >

test/hotspot/jtreg/compiler/valhalla/valuetypes/TestCallingConventionC1.java

Print this page


  27 import jdk.test.lib.Asserts;
  28 
  29 /*
  30  * @test
  31  * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa.
  32  * @library /testlibrary /test/lib /compiler/whitebox /
  33  * @requires os.simpleArch == "x64"
  34  * @compile TestCallingConventionC1.java
  35  * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
  36  * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
  37  *                               -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
  38  *                               compiler.valhalla.valuetypes.ValueTypeTest
  39  *                               compiler.valhalla.valuetypes.TestCallingConventionC1
  40  */
  41 public class TestCallingConventionC1 extends ValueTypeTest {
  42     public static final int C1 = COMP_LEVEL_SIMPLE;
  43     public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION;
  44 
  45     @Override
  46     public int getNumScenarios() {
  47         return 2;
  48     }
  49 
  50     @Override
  51     public String[] getVMParameters(int scenario) {
  52         switch (scenario) {
  53 
  54         // Default: both C1 and C2 are enabled, tierd compilation enabled
  55         case 0: return new String[] {"-XX:+EnableValhallaC1", "-XX:CICompilerCount=2"
  56                                    //  , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test78*"
  57                                    //, "-XX:CompileCommand=print,*::func_c1"






  58                                      };

  59         // Only C1. Tierd compilation disabled.
  60         case 1: return new String[] {"-XX:+EnableValhallaC1", "-XX:TieredStopAtLevel=1"
  61                                    //  , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test76*"





  62                                      };
  63         }
  64         return null;
  65     }
  66 
  67     public static void main(String[] args) throws Throwable {
  68         System.gc(); // Resolve this call, to avoid C1 code patching in the test cases.
  69         TestCallingConventionC1 test = new TestCallingConventionC1();
  70         test.run(args,
  71                  Point.class,
  72                  Functor.class,
  73                  Functor1.class,
  74                  Functor2.class,
  75                  Functor3.class,
  76                  Functor4.class,
  77                  MyImplPojo0.class,
  78                  MyImplPojo1.class,
  79                  MyImplPojo2.class,
  80                  MyImplVal1.class,
  81                  MyImplVal2.class,


1873         return p;
1874     }
1875 
1876     @DontInline @ForceCompile(compLevel = C2)
1877     public RefPoint test96_helper(RefPoint rp) {
1878         return rp;
1879     }
1880 
1881     @DontCompile
1882     public void test96_verifier(boolean warmup) {
1883         int count = warmup ? 1 : 20000; // Do enough iteration to cause GC inside StubRoutines::store_value_type_fields_to_buf
1884         Number x = new Number(10); // old object
1885         for (int i=0; i<count; i++) {
1886             Number y = new Number(i); // new object for each iteraton
1887             RefPoint rp1 = new RefPoint(x, y);
1888             RefPoint rp2 = test96(rp1, warmup);
1889 
1890             Asserts.assertEQ(rp1.x, x);
1891             Asserts.assertEQ(rp1.y, y);
1892             Asserts.assertEQ(rp1.y.n, i);


































































1893         }
1894     }
1895 }


  27 import jdk.test.lib.Asserts;
  28 
  29 /*
  30  * @test
  31  * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa.
  32  * @library /testlibrary /test/lib /compiler/whitebox /
  33  * @requires os.simpleArch == "x64"
  34  * @compile TestCallingConventionC1.java
  35  * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
  36  * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
  37  *                               -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
  38  *                               compiler.valhalla.valuetypes.ValueTypeTest
  39  *                               compiler.valhalla.valuetypes.TestCallingConventionC1
  40  */
  41 public class TestCallingConventionC1 extends ValueTypeTest {
  42     public static final int C1 = COMP_LEVEL_SIMPLE;
  43     public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION;
  44 
  45     @Override
  46     public int getNumScenarios() {
  47         return 4;
  48     }
  49 
  50     @Override
  51     public String[] getVMParameters(int scenario) {
  52         switch (scenario) {
  53         case 0: return new String[] {
  54                 // Default: both C1 and C2 are enabled, tierd compilation enabled
  55                 "-XX:+EnableValhallaC1",
  56                 "-XX:CICompilerCount=2"
  57             };
  58         case 1: return new String[] {
  59                 // Same as above, but flip all the compLevel=C1 and compLevel=C2, so we test
  60                 // the compliment of the above scenario.
  61                 "-XX:+EnableValhallaC1",
  62                 "-XX:CICompilerCount=2",
  63                 "-DFlipC1C2=true"
  64             };
  65         case 2: return new String[] {
  66                 // Only C1. Tierd compilation disabled.
  67                 "-XX:+EnableValhallaC1",
  68                 "-XX:TieredStopAtLevel=1",
  69             };
  70         case 3: return new String[] {
  71                 // Only C2.
  72                 "-XX:-EnableValhallaC1",
  73                 "-XX:TieredStopAtLevel=4",
  74             };
  75         }
  76         return null;
  77     }
  78 
  79     public static void main(String[] args) throws Throwable {
  80         System.gc(); // Resolve this call, to avoid C1 code patching in the test cases.
  81         TestCallingConventionC1 test = new TestCallingConventionC1();
  82         test.run(args,
  83                  Point.class,
  84                  Functor.class,
  85                  Functor1.class,
  86                  Functor2.class,
  87                  Functor3.class,
  88                  Functor4.class,
  89                  MyImplPojo0.class,
  90                  MyImplPojo1.class,
  91                  MyImplPojo2.class,
  92                  MyImplVal1.class,
  93                  MyImplVal2.class,


1885         return p;
1886     }
1887 
1888     @DontInline @ForceCompile(compLevel = C2)
1889     public RefPoint test96_helper(RefPoint rp) {
1890         return rp;
1891     }
1892 
1893     @DontCompile
1894     public void test96_verifier(boolean warmup) {
1895         int count = warmup ? 1 : 20000; // Do enough iteration to cause GC inside StubRoutines::store_value_type_fields_to_buf
1896         Number x = new Number(10); // old object
1897         for (int i=0; i<count; i++) {
1898             Number y = new Number(i); // new object for each iteraton
1899             RefPoint rp1 = new RefPoint(x, y);
1900             RefPoint rp2 = test96(rp1, warmup);
1901 
1902             Asserts.assertEQ(rp1.x, x);
1903             Asserts.assertEQ(rp1.y, y);
1904             Asserts.assertEQ(rp1.y.n, i);
1905         }
1906     }
1907 
1908     // C1->C1  - caller is compiled first. It invokes callee(test97) a few times while the
1909     //           callee is executed by the interpreter. Then, callee is compiled
1910     //           and SharedRuntime::fixup_callers_callsite is called to fix up the
1911     //           callsite from test97_verifier->test97.
1912     @Test(compLevel = C1)
1913     public int test97(Point p1, Point p2) {
1914         return test97_helper(p1, p2);
1915     }
1916 
1917     @DontInline @DontCompile
1918     public int test97_helper(Point p1, Point p2) {
1919         return p1.x + p1.y + p2.x + p2.y;
1920     }
1921 
1922     @ForceCompile(compLevel = C1)
1923     public void test97_verifier(boolean warmup) {
1924         int count = warmup ? 1 : 20;
1925         for (int i=0; i<count; i++) {
1926             int result = test97(pointField1, pointField2);
1927             int n = test97_helper(pointField1, pointField2);
1928             Asserts.assertEQ(result, n);
1929         }
1930     }
1931 
1932     // C1->C2  - same as test97, except the callee is compiled by c2.
1933     @Test(compLevel = C2)
1934     public int test98(Point p1, Point p2) {
1935         return test98_helper(p1, p2);
1936     }
1937 
1938     @DontInline @DontCompile
1939     public int test98_helper(Point p1, Point p2) {
1940         return p1.x + p1.y + p2.x + p2.y;
1941     }
1942 
1943     @ForceCompile(compLevel = C1)
1944     public void test98_verifier(boolean warmup) {
1945         int count = warmup ? 1 : 20;
1946         for (int i=0; i<count; i++) {
1947             int result = test98(pointField1, pointField2);
1948             int n = test98_helper(pointField1, pointField2);
1949             Asserts.assertEQ(result, n);
1950         }
1951     }
1952 
1953     // C1->C2  - same as test97, except the callee is a static method.
1954     @Test(compLevel = C1)
1955     public static int test99(Point p1, Point p2) {
1956         return test99_helper(p1, p2);
1957     }
1958 
1959     @DontInline @DontCompile
1960     public static int test99_helper(Point p1, Point p2) {
1961         return p1.x + p1.y + p2.x + p2.y;
1962     }
1963 
1964     @ForceCompile(compLevel = C1)
1965     public void test99_verifier(boolean warmup) {
1966         int count = warmup ? 1 : 20;
1967         for (int i=0; i<count; i++) {
1968             int result = test99(pointField1, pointField2);
1969             int n = test99_helper(pointField1, pointField2);
1970             Asserts.assertEQ(result, n);
1971         }
1972     }
1973 }
< prev index next >