6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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 package jdk.vm.ci.hotspot.test;
25
26 import java.lang.reflect.Field;
27
28 import org.testng.annotations.DataProvider;
29
30 import jdk.internal.misc.Unsafe;
31 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
32 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
33 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
34 import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
35 import jdk.vm.ci.meta.Constant;
36 import jdk.vm.ci.meta.JavaConstant;
37 import jdk.vm.ci.meta.JavaKind;
38 import jdk.vm.ci.runtime.JVMCI;
39
40 public class MemoryAccessProviderData {
41 private static final Unsafe UNSAFE = getUnsafe();
42 private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
43 private static final TestClass TEST_OBJECT = new TestClass();
44 private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
45 private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
46
47 private static Unsafe getUnsafe() {
48 try {
49 Field f = Unsafe.class.getDeclaredField("theUnsafe");
50 f.setAccessible(true);
51 return (Unsafe) f.get(null);
52 } catch (NoSuchFieldException | IllegalAccessException e) {
53 throw new RuntimeException("Unable to get Unsafe instance.", e);
54 }
55 }
56
57 @DataProvider(name = "positiveObject")
58 public static Object[][] getPositiveObjectJavaKind() {
59 HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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 package jdk.vm.ci.hotspot.test;
25
26 import jdk.internal.misc.Unsafe;
27 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
28 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
29 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
30 import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
31 import jdk.vm.ci.meta.Constant;
32 import jdk.vm.ci.meta.JavaConstant;
33 import jdk.vm.ci.meta.JavaKind;
34 import jdk.vm.ci.runtime.JVMCI;
35 import org.testng.annotations.DataProvider;
36
37 import java.lang.reflect.Field;
38
39 public class MemoryAccessProviderData {
40 private static final Unsafe UNSAFE = getUnsafe();
41 private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
42 private static final TestClass TEST_OBJECT = new TestClass();
43 private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
44 private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
45
46 private static Unsafe getUnsafe() {
47 try {
48 Field f = Unsafe.class.getDeclaredField("theUnsafe");
49 f.setAccessible(true);
50 return (Unsafe) f.get(null);
51 } catch (NoSuchFieldException | IllegalAccessException e) {
52 throw new RuntimeException("Unable to get Unsafe instance.", e);
53 }
54 }
55
56 @DataProvider(name = "positiveObject")
57 public static Object[][] getPositiveObjectJavaKind() {
58 HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
|