< prev index next >

test/compiler/jvmci/errors/TestInvalidOopMap.java

Print this page




  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 /**
  25  * @test
  26  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  27  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  28  *          jdk.vm.ci/jdk.vm.ci.code
  29  *          jdk.vm.ci/jdk.vm.ci.code.site
  30  *          jdk.vm.ci/jdk.vm.ci.meta
  31  *          jdk.vm.ci/jdk.vm.ci.runtime
  32  *          jdk.vm.ci/jdk.vm.ci.common
  33  * @compile CodeInstallerTest.java
  34  * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidOopMap
  35  */
  36 
  37 package compiler.jvmci.errors;
  38 
  39 import jdk.vm.ci.code.BytecodePosition;
  40 import jdk.vm.ci.code.DebugInfo;
  41 import jdk.vm.ci.code.Location;
  42 import jdk.vm.ci.code.ReferenceMap;
  43 import jdk.vm.ci.code.Register;
  44 import jdk.vm.ci.code.StackSlot;
  45 import jdk.vm.ci.code.site.DataPatch;
  46 import jdk.vm.ci.code.site.Infopoint;
  47 import jdk.vm.ci.code.site.InfopointReason;
  48 import jdk.vm.ci.code.site.Site;
  49 import jdk.vm.ci.common.JVMCIError;
  50 import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
  51 import jdk.vm.ci.hotspot.HotSpotReferenceMap;
  52 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  53 import jdk.vm.ci.meta.Assumptions.Assumption;
  54 import jdk.vm.ci.meta.JavaKind;
  55 import jdk.vm.ci.meta.PlatformKind;
  56 
  57 import org.junit.Test;
  58 
  59 /**
  60  * Tests for errors in oop maps.
  61  */
  62 public class TestInvalidOopMap extends CodeInstallerTest {
  63 
  64     private static class InvalidReferenceMap extends ReferenceMap {
  65     }
  66 
  67     private void test(ReferenceMap refMap) {
  68         BytecodePosition pos = new BytecodePosition(null, dummyMethod, 0);
  69         DebugInfo info = new DebugInfo(pos);
  70         info.setReferenceMap(refMap);
  71         installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], StackSlot.get(null, 0, true));
  72     }
  73 
  74     @Test(expected = NullPointerException.class)
  75     public void testMissingReferenceMap() {
  76         test(null);
  77     }
  78 
  79     @Test(expected = JVMCIError.class)
  80     public void testInvalidReferenceMap() {
  81         test(new InvalidReferenceMap());
  82     }
  83 
  84     @Test(expected = NullPointerException.class)
  85     public void testNullOops() {
  86         test(new HotSpotReferenceMap(null, new Location[0], new int[0], 8));
  87     }
  88 
  89     @Test(expected = NullPointerException.class)
  90     public void testNullBase() {
  91         test(new HotSpotReferenceMap(new Location[0], null, new int[0], 8));
  92     }
  93 
  94     @Test(expected = NullPointerException.class)
  95     public void testNullSize() {
  96         test(new HotSpotReferenceMap(new Location[0], new Location[0], null, 8));
  97     }
  98 
  99     @Test(expected = JVMCIError.class)
 100     public void testInvalidLength() {
 101         test(new HotSpotReferenceMap(new Location[1], new Location[2], new int[3], 8));
 102     }
 103 
 104     @Test(expected = JVMCIError.class)
 105     public void testInvalidShortOop() {
 106         PlatformKind kind = arch.getPlatformKind(JavaKind.Short);
 107         Register reg = getRegister(kind, 0);
 108 
 109         Location[] oops = new Location[]{Location.register(reg)};
 110         Location[] base = new Location[]{null};
 111         int[] size = new int[]{kind.getSizeInBytes()};
 112 
 113         test(new HotSpotReferenceMap(oops, base, size, 8));
 114     }
 115 
 116     @Test(expected = JVMCIError.class)
 117     public void testInvalidNarrowDerivedOop() {
 118         if (!HotSpotVMConfig.config().useCompressedOops) {
 119             throw new JVMCIError("skipping test");
 120         }
 121 
 122         PlatformKind kind = arch.getPlatformKind(JavaKind.Int);
 123         Register reg = getRegister(kind, 0);
 124         Register baseReg = getRegister(arch.getPlatformKind(JavaKind.Object), 1);
 125 
 126         Location[] oops = new Location[]{Location.register(reg)};
 127         Location[] base = new Location[]{Location.register(baseReg)};
 128         int[] size = new int[]{kind.getSizeInBytes()};
 129 
 130         test(new HotSpotReferenceMap(oops, base, size, 8));
 131     }
 132 }


  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 /**
  25  * @test
  26  * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
  27  * @modules jdk.vm.ci/jdk.vm.ci.hotspot
  28  *          jdk.vm.ci/jdk.vm.ci.code
  29  *          jdk.vm.ci/jdk.vm.ci.code.site
  30  *          jdk.vm.ci/jdk.vm.ci.meta
  31  *          jdk.vm.ci/jdk.vm.ci.runtime

  32  * @compile CodeInstallerTest.java
  33  * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidOopMap
  34  */
  35 
  36 package compiler.jvmci.errors;
  37 
  38 import jdk.vm.ci.code.BytecodePosition;
  39 import jdk.vm.ci.code.DebugInfo;
  40 import jdk.vm.ci.code.Location;
  41 import jdk.vm.ci.code.ReferenceMap;
  42 import jdk.vm.ci.code.Register;
  43 import jdk.vm.ci.code.StackSlot;
  44 import jdk.vm.ci.code.site.DataPatch;
  45 import jdk.vm.ci.code.site.Infopoint;
  46 import jdk.vm.ci.code.site.InfopointReason;
  47 import jdk.vm.ci.code.site.Site;

  48 import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
  49 import jdk.vm.ci.hotspot.HotSpotReferenceMap;
  50 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  51 import jdk.vm.ci.meta.Assumptions.Assumption;
  52 import jdk.vm.ci.meta.JavaKind;
  53 import jdk.vm.ci.meta.PlatformKind;
  54 
  55 import org.junit.Test;
  56 
  57 /**
  58  * Tests for errors in oop maps.
  59  */
  60 public class TestInvalidOopMap extends CodeInstallerTest {
  61 
  62     private static class InvalidReferenceMap extends ReferenceMap {
  63     }
  64 
  65     private void test(ReferenceMap refMap) {
  66         BytecodePosition pos = new BytecodePosition(null, dummyMethod, 0);
  67         DebugInfo info = new DebugInfo(pos);
  68         info.setReferenceMap(refMap);
  69         installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], StackSlot.get(null, 0, true));
  70     }
  71 
  72     @Test(expected = NullPointerException.class)
  73     public void testMissingReferenceMap() {
  74         test(null);
  75     }
  76 
  77     @Test(expected = InternalError.class)
  78     public void testInvalidReferenceMap() {
  79         test(new InvalidReferenceMap());
  80     }
  81 
  82     @Test(expected = NullPointerException.class)
  83     public void testNullOops() {
  84         test(new HotSpotReferenceMap(null, new Location[0], new int[0], 8));
  85     }
  86 
  87     @Test(expected = NullPointerException.class)
  88     public void testNullBase() {
  89         test(new HotSpotReferenceMap(new Location[0], null, new int[0], 8));
  90     }
  91 
  92     @Test(expected = NullPointerException.class)
  93     public void testNullSize() {
  94         test(new HotSpotReferenceMap(new Location[0], new Location[0], null, 8));
  95     }
  96 
  97     @Test(expected = InternalError.class)
  98     public void testInvalidLength() {
  99         test(new HotSpotReferenceMap(new Location[1], new Location[2], new int[3], 8));
 100     }
 101 
 102     @Test(expected = InternalError.class)
 103     public void testInvalidShortOop() {
 104         PlatformKind kind = arch.getPlatformKind(JavaKind.Short);
 105         Register reg = getRegister(kind, 0);
 106 
 107         Location[] oops = new Location[]{Location.register(reg)};
 108         Location[] base = new Location[]{null};
 109         int[] size = new int[]{kind.getSizeInBytes()};
 110 
 111         test(new HotSpotReferenceMap(oops, base, size, 8));
 112     }
 113 
 114     @Test(expected = InternalError.class)
 115     public void testInvalidNarrowDerivedOop() {
 116         if (!HotSpotVMConfig.config().useCompressedOops) {
 117             throw new InternalError("skipping test");
 118         }
 119 
 120         PlatformKind kind = arch.getPlatformKind(JavaKind.Int);
 121         Register reg = getRegister(kind, 0);
 122         Register baseReg = getRegister(arch.getPlatformKind(JavaKind.Object), 1);
 123 
 124         Location[] oops = new Location[]{Location.register(reg)};
 125         Location[] base = new Location[]{Location.register(baseReg)};
 126         int[] size = new int[]{kind.getSizeInBytes()};
 127 
 128         test(new HotSpotReferenceMap(oops, base, size, 8));
 129     }
 130 }
< prev index next >