< prev index next >

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java

Print this page




  47     private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
  48     private static final TestClass TEST_OBJECT = new TestClass();
  49     private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
  50     private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
  51     private static KindData[] PRIMITIVE_KIND_DATA = {
  52         new KindData(JavaKind.Boolean, TEST_OBJECT),
  53         new KindData(JavaKind.Byte, TEST_OBJECT),
  54         new KindData(JavaKind.Char, TEST_OBJECT),
  55         new KindData(JavaKind.Short, TEST_OBJECT),
  56         new KindData(JavaKind.Int, TEST_OBJECT),
  57         new KindData(JavaKind.Float, TEST_OBJECT),
  58         new KindData(JavaKind.Long, TEST_OBJECT),
  59         new KindData(JavaKind.Double, TEST_OBJECT)
  60     };
  61     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  62 
  63 
  64     @DataProvider(name = "positiveObject")
  65     public static Object[][] getPositiveObjectJavaKind() {
  66         HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
  67         int offset = new HotSpotVMConfigAccess(runtime.getConfigStore()).getFieldOffset("Klass::_java_mirror", Integer.class, "oop");
  68         Constant wrappedKlassPointer = ((HotSpotResolvedObjectType) runtime.fromClass(TestClass.class)).klass();

  69         return new Object[][]{new Object[]{JavaKind.Object, wrappedKlassPointer, (long) offset, TEST_CLASS_CONSTANT, 0}};
  70     }
  71 
  72     @DataProvider(name = "positivePrimitive")
  73     public static Object[][] getPositivePrimitiveJavaKinds() {
  74         List<Object[]> result = new ArrayList<>();
  75         for (KindData k : PRIMITIVE_KIND_DATA) {
  76             result.add(new Object[] {k.kind, TEST_CONSTANT, k.instanceFieldOffset, k.instanceFieldValue, Math.max(8, k.kind.getBitCount())});
  77             result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, k.staticFieldOffset, k.staticFieldValue, Math.max(8, k.kind.getBitCount())});
  78         }
  79         return result.toArray(new Object[result.size()][]);
  80     }
  81 
  82     @DataProvider(name = "outOfBoundsInstanceFields")
  83     public static Object[][] getOutOfBoundsStaticFieldReads() {
  84         long instanceSize = WHITE_BOX.getObjectSize(TEST_OBJECT);
  85         List<Object[]> result = new ArrayList<>();
  86         for (KindData k : PRIMITIVE_KIND_DATA) {
  87             long lastValidOffset = instanceSize - (k.kind.getByteCount());
  88             result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset, false});




  47     private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
  48     private static final TestClass TEST_OBJECT = new TestClass();
  49     private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
  50     private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
  51     private static KindData[] PRIMITIVE_KIND_DATA = {
  52         new KindData(JavaKind.Boolean, TEST_OBJECT),
  53         new KindData(JavaKind.Byte, TEST_OBJECT),
  54         new KindData(JavaKind.Char, TEST_OBJECT),
  55         new KindData(JavaKind.Short, TEST_OBJECT),
  56         new KindData(JavaKind.Int, TEST_OBJECT),
  57         new KindData(JavaKind.Float, TEST_OBJECT),
  58         new KindData(JavaKind.Long, TEST_OBJECT),
  59         new KindData(JavaKind.Double, TEST_OBJECT)
  60     };
  61     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  62 
  63 
  64     @DataProvider(name = "positiveObject")
  65     public static Object[][] getPositiveObjectJavaKind() {
  66         HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
  67         int offset = new HotSpotVMConfigAccess(runtime.getConfigStore()).getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle");
  68         Constant wrappedKlassPointer = ((HotSpotResolvedObjectType) runtime.fromClass(TestClass.class)).klass();
  69         // this doesn't work. what is this?
  70         return new Object[][]{new Object[]{JavaKind.Object, wrappedKlassPointer, (long) offset, TEST_CLASS_CONSTANT, 0}};
  71     }
  72 
  73     @DataProvider(name = "positivePrimitive")
  74     public static Object[][] getPositivePrimitiveJavaKinds() {
  75         List<Object[]> result = new ArrayList<>();
  76         for (KindData k : PRIMITIVE_KIND_DATA) {
  77             result.add(new Object[] {k.kind, TEST_CONSTANT, k.instanceFieldOffset, k.instanceFieldValue, Math.max(8, k.kind.getBitCount())});
  78             result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, k.staticFieldOffset, k.staticFieldValue, Math.max(8, k.kind.getBitCount())});
  79         }
  80         return result.toArray(new Object[result.size()][]);
  81     }
  82 
  83     @DataProvider(name = "outOfBoundsInstanceFields")
  84     public static Object[][] getOutOfBoundsStaticFieldReads() {
  85         long instanceSize = WHITE_BOX.getObjectSize(TEST_OBJECT);
  86         List<Object[]> result = new ArrayList<>();
  87         for (KindData k : PRIMITIVE_KIND_DATA) {
  88             long lastValidOffset = instanceSize - (k.kind.getByteCount());
  89             result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset, false});


< prev index next >