hotspot/test/compiler/jvmci/code/DataPatchTest.java
changeset 36842 8f0d0faa51e2
parent 36508 5f9eee6b383b
--- a/hotspot/test/compiler/jvmci/code/DataPatchTest.java	Tue Mar 29 21:33:26 2016 +0300
+++ b/hotspot/test/compiler/jvmci/code/DataPatchTest.java	Fri Mar 25 12:43:23 2016 +0100
@@ -40,6 +40,8 @@
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.site.DataSectionReference;
 import jdk.vm.ci.hotspot.HotSpotConstant;
+import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;
+import jdk.vm.ci.hotspot.HotSpotSymbol;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
 import jdk.vm.ci.meta.ResolvedJavaType;
 
@@ -155,4 +157,33 @@
             asm.emitPointerRet(ret);
         });
     }
+
+
+    public static long getConstSymbol(HotSpotMetaAccessProvider meta) {
+        HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object");
+        return symbol.getMetaspacePointer();
+    }
+
+    private void testSymbol(TestCompiler compiler) {
+        test(compiler, getMethod("getConstSymbol", HotSpotMetaAccessProvider.class), (HotSpotMetaAccessProvider) metaAccess);
+    }
+
+    @Test
+    public void testInlineSymbol() {
+        testSymbol(asm -> {
+            HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
+            Register ret = asm.emitLoadPointer((HotSpotConstant) symbol.asConstant());
+            asm.emitPointerRet(ret);
+        });
+    }
+
+    @Test
+    public void testSymbolInDataSection() {
+        testSymbol(asm -> {
+            HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
+            DataSectionReference ref = asm.emitDataItem((HotSpotConstant) symbol.asConstant());
+            Register ret = asm.emitLoadPointer(ref);
+            asm.emitPointerRet(ret);
+        });
+    }
 }