< prev index next >

test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java

Print this page




  25  * @test
  26  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  27  * @library /
  28  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  29  *          jdk.vm.ci/jdk.vm.ci.meta
  30  *          jdk.vm.ci/jdk.vm.ci.code
  31  *          jdk.vm.ci/jdk.vm.ci.code.site
  32  *          jdk.vm.ci/jdk.vm.ci.runtime
  33  *          jdk.vm.ci/jdk.vm.ci.amd64
  34  *          jdk.vm.ci/jdk.vm.ci.sparc
  35  * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
  36  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest
  37  */
  38 
  39 package jdk.vm.ci.code.test;
  40 
  41 import jdk.vm.ci.code.Register;
  42 import jdk.vm.ci.code.site.DataSectionReference;
  43 import jdk.vm.ci.hotspot.HotSpotConstant;
  44 import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;
  45 import jdk.vm.ci.hotspot.HotSpotSymbol;
  46 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  47 import jdk.vm.ci.meta.ResolvedJavaType;
  48 
  49 import org.junit.Assume;
  50 import org.junit.Test;
  51 
  52 /**
  53  * Test code installation with data patches.
  54  */
  55 public class DataPatchTest extends CodeInstallationTest {
  56 
  57     public static Class<?> getConstClass() {
  58         return DataPatchTest.class;
  59     }
  60 
  61     private void test(TestCompiler compiler) {
  62         test(compiler, getMethod("getConstClass"));
  63     }
  64 
  65     @Test


 138             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 139             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 140             DataSectionReference ref = asm.emitDataItem(hub);
 141             Register klass = asm.emitLoadPointer(ref);
 142             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
 143             asm.emitPointerRet(ret);
 144         });
 145     }
 146 
 147     @Test
 148     public void testNarrowMetadataInDataSection() {
 149         Assume.assumeTrue(HotSpotVMConfig.config().useCompressedClassPointers);
 150         test(asm -> {
 151             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 152             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 153             HotSpotConstant narrowHub = (HotSpotConstant) hub.compress();
 154             DataSectionReference ref = asm.emitDataItem(narrowHub);
 155             Register narrowKlass = asm.emitLoadNarrowPointer(ref);
 156             Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift);
 157             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
 158             asm.emitPointerRet(ret);
 159         });
 160     }
 161 
 162     public static long getConstSymbol(HotSpotMetaAccessProvider meta) {
 163         HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object");
 164         return symbol.getMetaspacePointer();
 165     }
 166 
 167     private void testSymbol(TestCompiler compiler) {
 168         test(compiler, getMethod("getConstSymbol", HotSpotMetaAccessProvider.class), (HotSpotMetaAccessProvider) metaAccess);
 169     }
 170 
 171     @Test
 172     public void testInlineSymbol() {
 173         testSymbol(asm -> {
 174             HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
 175             Register ret = asm.emitLoadPointer((HotSpotConstant) symbol.asConstant());
 176             asm.emitPointerRet(ret);
 177         });
 178     }
 179 
 180     @Test
 181     public void testSymbolInDataSection() {
 182         testSymbol(asm -> {
 183             HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
 184             DataSectionReference ref = asm.emitDataItem((HotSpotConstant) symbol.asConstant());
 185             Register ret = asm.emitLoadPointer(ref);
 186             asm.emitPointerRet(ret);
 187         });
 188     }
 189 }


  25  * @test
  26  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  27  * @library /
  28  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  29  *          jdk.vm.ci/jdk.vm.ci.meta
  30  *          jdk.vm.ci/jdk.vm.ci.code
  31  *          jdk.vm.ci/jdk.vm.ci.code.site
  32  *          jdk.vm.ci/jdk.vm.ci.runtime
  33  *          jdk.vm.ci/jdk.vm.ci.amd64
  34  *          jdk.vm.ci/jdk.vm.ci.sparc
  35  * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
  36  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest
  37  */
  38 
  39 package jdk.vm.ci.code.test;
  40 
  41 import jdk.vm.ci.code.Register;
  42 import jdk.vm.ci.code.site.DataSectionReference;
  43 import jdk.vm.ci.hotspot.HotSpotConstant;
  44 import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;

  45 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  46 import jdk.vm.ci.meta.ResolvedJavaType;
  47 
  48 import org.junit.Assume;
  49 import org.junit.Test;
  50 
  51 /**
  52  * Test code installation with data patches.
  53  */
  54 public class DataPatchTest extends CodeInstallationTest {
  55 
  56     public static Class<?> getConstClass() {
  57         return DataPatchTest.class;
  58     }
  59 
  60     private void test(TestCompiler compiler) {
  61         test(compiler, getMethod("getConstClass"));
  62     }
  63 
  64     @Test


 137             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 138             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 139             DataSectionReference ref = asm.emitDataItem(hub);
 140             Register klass = asm.emitLoadPointer(ref);
 141             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
 142             asm.emitPointerRet(ret);
 143         });
 144     }
 145 
 146     @Test
 147     public void testNarrowMetadataInDataSection() {
 148         Assume.assumeTrue(HotSpotVMConfig.config().useCompressedClassPointers);
 149         test(asm -> {
 150             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 151             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 152             HotSpotConstant narrowHub = (HotSpotConstant) hub.compress();
 153             DataSectionReference ref = asm.emitDataItem(narrowHub);
 154             Register narrowKlass = asm.emitLoadNarrowPointer(ref);
 155             Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift);
 156             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);




























 157             asm.emitPointerRet(ret);
 158         });
 159     }
 160 }
< prev index next >