< prev index next >

test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java

Print this page




  27  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  28  * @library / /testlibrary
  29  * @compile ../common/CompilerToVMHelper.java
  30  * @build compiler.jvmci.compilerToVM.InitializeConfigurationTest
  31  * @run main ClassFileInstaller
  32  *      jdk.vm.ci.hotspot.CompilerToVMHelper
  33  * @run main/othervm -Xbootclasspath/a:.
  34  *     -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  35  *     compiler.jvmci.compilerToVM.InitializeConfigurationTest
  36  */
  37 
  38 package compiler.jvmci.compilerToVM;
  39 
  40 import java.util.ArrayList;
  41 import java.util.Iterator;
  42 import java.util.List;
  43 import java.util.NoSuchElementException;
  44 import java.util.Objects;
  45 import java.util.function.Consumer;
  46 import jdk.vm.ci.hotspot.CompilerToVMHelper;

  47 import jdk.test.lib.Asserts;
  48 import jdk.test.lib.Utils;
  49 import sun.misc.Unsafe;
  50 
  51 public class InitializeConfigurationTest {
  52     private static final Unsafe UNSAFE = Utils.getUnsafe();
  53 
  54     public static void main(String args[]) {
  55         new InitializeConfigurationTest().runTest(generateTestCases());
  56     }
  57 
  58     private static List<TestCase> generateTestCases() {
  59         List<TestCase> result = new ArrayList<>();
  60         result.add(new TestCase("CodeCache", "_high_bound", "address",
  61                 InitializeConfigurationTest::verifyLongIsNotZero));
  62         result.add(new TestCase("StubRoutines", "_jint_arraycopy", "address",
  63                 InitializeConfigurationTest::verifyLongIsNotZero));
  64         return result;
  65     }
  66 
  67     private static void verifyLongIsNotZero(Object o) {
  68         Asserts.assertNotNull(o, "Got null value");
  69         Asserts.assertEQ(o.getClass(), Long.class, "Unexpected value type");
  70         Asserts.assertNE(o, 0L, "Got null address");
  71     }
  72 
  73     private void runTest(List<TestCase> tcases) {
  74         VMStructDataReader reader = new VMStructDataReader(
  75                 CompilerToVMHelper.initializeConfiguration());
  76         while (reader.hasNext()) {
  77             VMFieldData data = reader.next();
  78             for (TestCase tcase : tcases) {
  79                 tcase.check(data);
  80             }
  81         }
  82         // now check if all passed
  83         for (TestCase tcase: tcases) {
  84             Asserts.assertTrue(tcase.isFound(), "Case failed: " + tcase);
  85         }
  86     }
  87 
  88     private static class VMStructDataReader implements Iterator<VMFieldData> {
  89         // see jvmciCompilerToVM:105 static uintptr_t ciHotSpotVMData[28];
  90         private static final int HOTSPOT_VM_DATA_INDEX_COUNT = 28;
  91         private final long addresses[];
  92         private final long vmStructsBase;
  93         private final long entityNameFieldOffset;
  94         private final long nameFieldOffset;
  95         private final long typeStringFieldOffset;




  27  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  28  * @library / /testlibrary
  29  * @compile ../common/CompilerToVMHelper.java
  30  * @build compiler.jvmci.compilerToVM.InitializeConfigurationTest
  31  * @run main ClassFileInstaller
  32  *      jdk.vm.ci.hotspot.CompilerToVMHelper
  33  * @run main/othervm -Xbootclasspath/a:.
  34  *     -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
  35  *     compiler.jvmci.compilerToVM.InitializeConfigurationTest
  36  */
  37 
  38 package compiler.jvmci.compilerToVM;
  39 
  40 import java.util.ArrayList;
  41 import java.util.Iterator;
  42 import java.util.List;
  43 import java.util.NoSuchElementException;
  44 import java.util.Objects;
  45 import java.util.function.Consumer;
  46 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  47 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  48 import jdk.test.lib.Asserts;
  49 import jdk.test.lib.Utils;
  50 import sun.misc.Unsafe;
  51 
  52 public class InitializeConfigurationTest {
  53     private static final Unsafe UNSAFE = Utils.getUnsafe();
  54 
  55     public static void main(String args[]) {
  56         new InitializeConfigurationTest().runTest(generateTestCases());
  57     }
  58 
  59     private static List<TestCase> generateTestCases() {
  60         List<TestCase> result = new ArrayList<>();
  61         result.add(new TestCase("CodeCache", "_high_bound", "address",
  62                 InitializeConfigurationTest::verifyLongIsNotZero));
  63         result.add(new TestCase("StubRoutines", "_jint_arraycopy", "address",
  64                 InitializeConfigurationTest::verifyLongIsNotZero));
  65         return result;
  66     }
  67 
  68     private static void verifyLongIsNotZero(Object o) {
  69         Asserts.assertNotNull(o, "Got null value");
  70         Asserts.assertEQ(o.getClass(), Long.class, "Unexpected value type");
  71         Asserts.assertNE(o, 0L, "Got null address");
  72     }
  73 
  74     private void runTest(List<TestCase> tcases) {
  75         VMStructDataReader reader = new VMStructDataReader(
  76                 CompilerToVMHelper.initializeConfiguration(HotSpotJVMCIRuntime.runtime().getConfig()));
  77         while (reader.hasNext()) {
  78             VMFieldData data = reader.next();
  79             for (TestCase tcase : tcases) {
  80                 tcase.check(data);
  81             }
  82         }
  83         // now check if all passed
  84         for (TestCase tcase: tcases) {
  85             Asserts.assertTrue(tcase.isFound(), "Case failed: " + tcase);
  86         }
  87     }
  88 
  89     private static class VMStructDataReader implements Iterator<VMFieldData> {
  90         // see jvmciCompilerToVM:105 static uintptr_t ciHotSpotVMData[28];
  91         private static final int HOTSPOT_VM_DATA_INDEX_COUNT = 28;
  92         private final long addresses[];
  93         private final long vmStructsBase;
  94         private final long entityNameFieldOffset;
  95         private final long nameFieldOffset;
  96         private final long typeStringFieldOffset;


< prev index next >