< prev index next >

test/compiler/jvmci/code/DataPatchTest.java

Print this page




  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 /**
  25  * @test
  26  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
  27  * @compile CodeInstallationTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java
  28  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.DataPatchTest
  29  */
  30 
  31 package compiler.jvmci.code;
  32 
  33 import jdk.vm.ci.code.Register;
  34 import jdk.vm.ci.code.site.DataSectionReference;
  35 import jdk.vm.ci.hotspot.HotSpotConstant;


  36 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  37 import jdk.vm.ci.meta.ResolvedJavaType;
  38 
  39 import org.junit.Assume;
  40 import org.junit.Test;
  41 
  42 /**
  43  * Test code installation with data patches.
  44  */
  45 public class DataPatchTest extends CodeInstallationTest {
  46 
  47     public static Class<?> getConstClass() {
  48         return DataPatchTest.class;
  49     }
  50 
  51     private void test(TestCompiler compiler) {
  52         test(compiler, getMethod("getConstClass"));
  53     }
  54 
  55     @Test


 128             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 129             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 130             DataSectionReference ref = asm.emitDataItem(hub);
 131             Register klass = asm.emitLoadPointer(ref);
 132             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
 133             asm.emitPointerRet(ret);
 134         });
 135     }
 136 
 137     @Test
 138     public void testNarrowMetadataInDataSection() {
 139         Assume.assumeTrue(HotSpotVMConfig.config().useCompressedClassPointers);
 140         test(asm -> {
 141             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
 142             HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type);
 143             HotSpotConstant narrowHub = (HotSpotConstant) hub.compress();
 144             DataSectionReference ref = asm.emitDataItem(narrowHub);
 145             Register narrowKlass = asm.emitLoadNarrowPointer(ref);
 146             Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift);
 147             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);





























 148             asm.emitPointerRet(ret);
 149         });
 150     }
 151 }


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


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