< prev index next >

test/compiler/jvmci/errors/TestInvalidDebugInfo.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.TestInvalidDebugInfo
  35  */
  36 
  37 package compiler.jvmci.errors;
  38 
  39 import jdk.vm.ci.code.BytecodeFrame;
  40 import jdk.vm.ci.code.DebugInfo;
  41 import jdk.vm.ci.code.Location;
  42 import jdk.vm.ci.code.Register;
  43 import jdk.vm.ci.code.StackSlot;
  44 import jdk.vm.ci.code.VirtualObject;
  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.meta.Assumptions.Assumption;
  53 import jdk.vm.ci.meta.JavaConstant;
  54 import jdk.vm.ci.meta.JavaKind;
  55 import jdk.vm.ci.meta.JavaValue;
  56 import jdk.vm.ci.meta.LIRKind;
  57 import jdk.vm.ci.meta.ResolvedJavaType;
  58 import jdk.vm.ci.meta.Value;
  59 
  60 import org.junit.Test;
  61 
  62 /**
  63  * Tests for errors in debug info.
  64  */
  65 public class TestInvalidDebugInfo extends CodeInstallerTest {
  66 
  67     private static class UnknownJavaValue implements JavaValue {
  68     }
  69 


  75         test(vobj, values, slotKinds, locals, stack, locks, StackSlot.get(null, 0, true));
  76     }
  77 
  78     private void test(VirtualObject[] vobj, JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks, StackSlot deoptRescueSlot) {
  79         BytecodeFrame frame = new BytecodeFrame(null, dummyMethod, 0, false, false, values, slotKinds, locals, stack, locks);
  80         DebugInfo info = new DebugInfo(frame, vobj);
  81         info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
  82         installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot);
  83     }
  84 
  85     @Test(expected = NullPointerException.class)
  86     public void testNullValues() {
  87         test(null, new JavaKind[0], 0, 0, 0);
  88     }
  89 
  90     @Test(expected = NullPointerException.class)
  91     public void testNullSlotKinds() {
  92         test(new JavaValue[0], null, 0, 0, 0);
  93     }
  94 
  95     @Test(expected = JVMCIError.class)
  96     public void testMissingDeoptRescueSlot() {
  97         test(null, new JavaValue[0], new JavaKind[0], 0, 0, 0, null);
  98     }
  99 
 100     @Test(expected = JVMCIError.class)
 101     public void testUnexpectedScopeValuesLength() {
 102         test(new JavaValue[]{JavaConstant.FALSE}, new JavaKind[0], 0, 0, 0);
 103     }
 104 
 105     @Test(expected = JVMCIError.class)
 106     public void testUnexpectedScopeSlotKindsLength() {
 107         test(new JavaValue[0], new JavaKind[]{JavaKind.Boolean}, 0, 0, 0);
 108     }
 109 
 110     @Test(expected = NullPointerException.class)
 111     public void testNullValue() {
 112         test(new JavaValue[]{null}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 113     }
 114 
 115     @Test(expected = NullPointerException.class)
 116     public void testNullSlotKind() {
 117         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{null}, 1, 0, 0);
 118     }
 119 
 120     @Test(expected = NullPointerException.class)
 121     public void testNullMonitor() {
 122         test(new JavaValue[]{null}, new JavaKind[0], 0, 0, 1);
 123     }
 124 
 125     @Test(expected = JVMCIError.class)
 126     public void testWrongMonitorType() {
 127         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[0], 0, 0, 1);
 128     }
 129 
 130     @Test(expected = JVMCIError.class)
 131     public void testUnexpectedIllegalValue() {
 132         test(new JavaValue[]{Value.ILLEGAL}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 133     }
 134 
 135     @Test(expected = JVMCIError.class)
 136     public void testUnexpectedTypeInCPURegister() {
 137         Register reg = getRegister(arch.getPlatformKind(JavaKind.Int), 0);
 138         test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 139     }
 140 
 141     @Test(expected = JVMCIError.class)
 142     public void testUnexpectedTypeInFloatRegister() {
 143         Register reg = getRegister(arch.getPlatformKind(JavaKind.Float), 0);
 144         test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 145     }
 146 
 147     @Test(expected = JVMCIError.class)
 148     public void testUnexpectedTypeOnStack() {
 149         LIRKind kind = codeCache.getTarget().getLIRKind(JavaKind.Int);
 150         StackSlot value = StackSlot.get(kind, 8, false);
 151         test(new JavaValue[]{value}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 152     }
 153 
 154     @Test(expected = JVMCIError.class)
 155     public void testWrongConstantType() {
 156         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{JavaKind.Object}, 1, 0, 0);
 157     }
 158 
 159     @Test(expected = JVMCIError.class)
 160     public void testUnsupportedConstantType() {
 161         test(new JavaValue[]{JavaConstant.forShort((short) 0)}, new JavaKind[]{JavaKind.Short}, 1, 0, 0);
 162     }
 163 
 164     @Test(expected = JVMCIError.class)
 165     public void testUnexpectedNull() {
 166         test(new JavaValue[]{JavaConstant.NULL_POINTER}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 167     }
 168 
 169     @Test(expected = JVMCIError.class)
 170     public void testUnexpectedObject() {
 171         JavaValue wrapped = constantReflection.forObject(this);
 172         test(new JavaValue[]{wrapped}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 173     }
 174 
 175     @Test(expected = JVMCIError.class)
 176     public void testUnknownJavaValue() {
 177         test(new JavaValue[]{new UnknownJavaValue()}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 178     }
 179 
 180     @Test(expected = JVMCIError.class)
 181     public void testMissingIllegalAfterDouble() {
 182         test(new JavaValue[]{JavaConstant.DOUBLE_0, JavaConstant.INT_0}, new JavaKind[]{JavaKind.Double, JavaKind.Int}, 2, 0, 0);
 183     }
 184 
 185     @Test(expected = JVMCIError.class)
 186     public void testInvalidVirtualObjectId() {
 187         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 188         VirtualObject o = VirtualObject.get(obj, 5);
 189         o.setValues(new JavaValue[0], new JavaKind[0]);
 190 
 191         test(new VirtualObject[]{o}, new JavaValue[0], new JavaKind[0], 0, 0, 0);
 192     }
 193 
 194     @Test(expected = JVMCIError.class)
 195     public void testDuplicateVirtualObject() {
 196         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 197         VirtualObject o1 = VirtualObject.get(obj, 0);
 198         o1.setValues(new JavaValue[0], new JavaKind[0]);
 199 
 200         VirtualObject o2 = VirtualObject.get(obj, 0);
 201         o2.setValues(new JavaValue[0], new JavaKind[0]);
 202 
 203         test(new VirtualObject[]{o1, o2}, new JavaValue[0], new JavaKind[0], 0, 0, 0);
 204     }
 205 
 206     @Test(expected = JVMCIError.class)
 207     public void testUnexpectedVirtualObject() {
 208         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 209         VirtualObject o = VirtualObject.get(obj, 0);
 210         o.setValues(new JavaValue[0], new JavaKind[0]);
 211 
 212         test(new VirtualObject[]{o}, new JavaValue[]{o}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 213     }
 214 
 215     @Test(expected = JVMCIError.class)
 216     public void testUndefinedVirtualObject() {
 217         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 218         VirtualObject o0 = VirtualObject.get(obj, 0);
 219         o0.setValues(new JavaValue[0], new JavaKind[0]);
 220 
 221         VirtualObject o1 = VirtualObject.get(obj, 1);
 222         o1.setValues(new JavaValue[0], new JavaKind[0]);
 223 
 224         test(new VirtualObject[]{o0}, new JavaValue[]{o1}, new JavaKind[]{JavaKind.Object}, 1, 0, 0);
 225     }
 226 }


  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.TestInvalidDebugInfo
  34  */
  35 
  36 package compiler.jvmci.errors;
  37 
  38 import jdk.vm.ci.code.BytecodeFrame;
  39 import jdk.vm.ci.code.DebugInfo;
  40 import jdk.vm.ci.code.Location;
  41 import jdk.vm.ci.code.Register;
  42 import jdk.vm.ci.code.StackSlot;
  43 import jdk.vm.ci.code.VirtualObject;
  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.meta.Assumptions.Assumption;
  51 import jdk.vm.ci.meta.JavaConstant;
  52 import jdk.vm.ci.meta.JavaKind;
  53 import jdk.vm.ci.meta.JavaValue;
  54 import jdk.vm.ci.meta.LIRKind;
  55 import jdk.vm.ci.meta.ResolvedJavaType;
  56 import jdk.vm.ci.meta.Value;
  57 
  58 import org.junit.Test;
  59 
  60 /**
  61  * Tests for errors in debug info.
  62  */
  63 public class TestInvalidDebugInfo extends CodeInstallerTest {
  64 
  65     private static class UnknownJavaValue implements JavaValue {
  66     }
  67 


  73         test(vobj, values, slotKinds, locals, stack, locks, StackSlot.get(null, 0, true));
  74     }
  75 
  76     private void test(VirtualObject[] vobj, JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks, StackSlot deoptRescueSlot) {
  77         BytecodeFrame frame = new BytecodeFrame(null, dummyMethod, 0, false, false, values, slotKinds, locals, stack, locks);
  78         DebugInfo info = new DebugInfo(frame, vobj);
  79         info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
  80         installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot);
  81     }
  82 
  83     @Test(expected = NullPointerException.class)
  84     public void testNullValues() {
  85         test(null, new JavaKind[0], 0, 0, 0);
  86     }
  87 
  88     @Test(expected = NullPointerException.class)
  89     public void testNullSlotKinds() {
  90         test(new JavaValue[0], null, 0, 0, 0);
  91     }
  92 
  93     @Test(expected = InternalError.class)
  94     public void testMissingDeoptRescueSlot() {
  95         test(null, new JavaValue[0], new JavaKind[0], 0, 0, 0, null);
  96     }
  97 
  98     @Test(expected = InternalError.class)
  99     public void testUnexpectedScopeValuesLength() {
 100         test(new JavaValue[]{JavaConstant.FALSE}, new JavaKind[0], 0, 0, 0);
 101     }
 102 
 103     @Test(expected = InternalError.class)
 104     public void testUnexpectedScopeSlotKindsLength() {
 105         test(new JavaValue[0], new JavaKind[]{JavaKind.Boolean}, 0, 0, 0);
 106     }
 107 
 108     @Test(expected = NullPointerException.class)
 109     public void testNullValue() {
 110         test(new JavaValue[]{null}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 111     }
 112 
 113     @Test(expected = NullPointerException.class)
 114     public void testNullSlotKind() {
 115         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{null}, 1, 0, 0);
 116     }
 117 
 118     @Test(expected = NullPointerException.class)
 119     public void testNullMonitor() {
 120         test(new JavaValue[]{null}, new JavaKind[0], 0, 0, 1);
 121     }
 122 
 123     @Test(expected = InternalError.class)
 124     public void testWrongMonitorType() {
 125         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[0], 0, 0, 1);
 126     }
 127 
 128     @Test(expected = InternalError.class)
 129     public void testUnexpectedIllegalValue() {
 130         test(new JavaValue[]{Value.ILLEGAL}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 131     }
 132 
 133     @Test(expected = InternalError.class)
 134     public void testUnexpectedTypeInCPURegister() {
 135         Register reg = getRegister(arch.getPlatformKind(JavaKind.Int), 0);
 136         test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 137     }
 138 
 139     @Test(expected = InternalError.class)
 140     public void testUnexpectedTypeInFloatRegister() {
 141         Register reg = getRegister(arch.getPlatformKind(JavaKind.Float), 0);
 142         test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 143     }
 144 
 145     @Test(expected = InternalError.class)
 146     public void testUnexpectedTypeOnStack() {
 147         LIRKind kind = codeCache.getTarget().getLIRKind(JavaKind.Int);
 148         StackSlot value = StackSlot.get(kind, 8, false);
 149         test(new JavaValue[]{value}, new JavaKind[]{JavaKind.Illegal}, 1, 0, 0);
 150     }
 151 
 152     @Test(expected = InternalError.class)
 153     public void testWrongConstantType() {
 154         test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{JavaKind.Object}, 1, 0, 0);
 155     }
 156 
 157     @Test(expected = InternalError.class)
 158     public void testUnsupportedConstantType() {
 159         test(new JavaValue[]{JavaConstant.forShort((short) 0)}, new JavaKind[]{JavaKind.Short}, 1, 0, 0);
 160     }
 161 
 162     @Test(expected = InternalError.class)
 163     public void testUnexpectedNull() {
 164         test(new JavaValue[]{JavaConstant.NULL_POINTER}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 165     }
 166 
 167     @Test(expected = InternalError.class)
 168     public void testUnexpectedObject() {
 169         JavaValue wrapped = constantReflection.forObject(this);
 170         test(new JavaValue[]{wrapped}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 171     }
 172 
 173     @Test(expected = InternalError.class)
 174     public void testUnknownJavaValue() {
 175         test(new JavaValue[]{new UnknownJavaValue()}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 176     }
 177 
 178     @Test(expected = InternalError.class)
 179     public void testMissingIllegalAfterDouble() {
 180         test(new JavaValue[]{JavaConstant.DOUBLE_0, JavaConstant.INT_0}, new JavaKind[]{JavaKind.Double, JavaKind.Int}, 2, 0, 0);
 181     }
 182 
 183     @Test(expected = InternalError.class)
 184     public void testInvalidVirtualObjectId() {
 185         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 186         VirtualObject o = VirtualObject.get(obj, 5);
 187         o.setValues(new JavaValue[0], new JavaKind[0]);
 188 
 189         test(new VirtualObject[]{o}, new JavaValue[0], new JavaKind[0], 0, 0, 0);
 190     }
 191 
 192     @Test(expected = InternalError.class)
 193     public void testDuplicateVirtualObject() {
 194         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 195         VirtualObject o1 = VirtualObject.get(obj, 0);
 196         o1.setValues(new JavaValue[0], new JavaKind[0]);
 197 
 198         VirtualObject o2 = VirtualObject.get(obj, 0);
 199         o2.setValues(new JavaValue[0], new JavaKind[0]);
 200 
 201         test(new VirtualObject[]{o1, o2}, new JavaValue[0], new JavaKind[0], 0, 0, 0);
 202     }
 203 
 204     @Test(expected = InternalError.class)
 205     public void testUnexpectedVirtualObject() {
 206         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 207         VirtualObject o = VirtualObject.get(obj, 0);
 208         o.setValues(new JavaValue[0], new JavaKind[0]);
 209 
 210         test(new VirtualObject[]{o}, new JavaValue[]{o}, new JavaKind[]{JavaKind.Int}, 1, 0, 0);
 211     }
 212 
 213     @Test(expected = InternalError.class)
 214     public void testUndefinedVirtualObject() {
 215         ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class);
 216         VirtualObject o0 = VirtualObject.get(obj, 0);
 217         o0.setValues(new JavaValue[0], new JavaKind[0]);
 218 
 219         VirtualObject o1 = VirtualObject.get(obj, 1);
 220         o1.setValues(new JavaValue[0], new JavaKind[0]);
 221 
 222         test(new VirtualObject[]{o0}, new JavaValue[]{o1}, new JavaKind[]{JavaKind.Object}, 1, 0, 0);
 223     }
 224 }
< prev index next >