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 * @build compiler.jvmci.errors.TestInvalidCompilationResult 35 * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidCompilationResult 36 */ 37 38 package compiler.jvmci.errors; 39 40 import jdk.vm.ci.code.StackSlot; 41 import jdk.vm.ci.code.site.ConstantReference; 42 import jdk.vm.ci.code.site.DataPatch; 43 import jdk.vm.ci.code.site.DataSectionReference; 44 import jdk.vm.ci.code.site.Infopoint; 45 import jdk.vm.ci.code.site.InfopointReason; 46 import jdk.vm.ci.code.site.Mark; 47 import jdk.vm.ci.code.site.Reference; 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.HotSpotConstant; 52 import jdk.vm.ci.meta.Assumptions.Assumption; 53 import jdk.vm.ci.meta.VMConstant; 54 55 import org.junit.Test; 56 57 /** 58 * Tests for errors in the code installer. 59 */ 60 public class TestInvalidCompilationResult extends CodeInstallerTest { 61 62 private static class InvalidAssumption extends Assumption { 63 } 64 65 private static class InvalidVMConstant implements VMConstant { 66 67 public boolean isDefaultForKind() { 68 return false; 69 } 70 71 public String toValueString() { 72 return null; 73 } 74 } 75 76 private static class InvalidReference extends Reference { 77 78 @Override 79 public int hashCode() { 80 return 0; 81 } 82 83 @Override 84 public boolean equals(Object obj) { 85 return false; 86 } 87 } 88 89 @Test(expected = JVMCIError.class) 90 public void testInvalidAssumption() { 91 installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], 16, new DataPatch[0], null); 92 } 93 94 @Test(expected = JVMCIError.class) 95 public void testInvalidAlignment() { 96 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0], null); 97 } 98 99 @Test(expected = NullPointerException.class) 100 public void testNullDataPatchInDataSection() { 101 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{null}, null); 102 } 103 104 @Test(expected = NullPointerException.class) 105 public void testNullReferenceInDataSection() { 106 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, null)}, null); 107 } 108 109 @Test(expected = JVMCIError.class) 110 public void testInvalidDataSectionReference() { 111 DataSectionReference ref = new DataSectionReference(); 112 ref.setOffset(0); 113 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 114 } 115 116 @Test(expected = JVMCIError.class) 117 public void testInvalidNarrowMethodInDataSection() { 118 HotSpotConstant c = (HotSpotConstant) dummyMethod.getEncoding(); 119 ConstantReference ref = new ConstantReference((VMConstant) c.compress()); 120 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 121 } 122 123 @Test(expected = NullPointerException.class) 124 public void testNullConstantInDataSection() { 125 ConstantReference ref = new ConstantReference(null); 126 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 127 } 128 129 @Test(expected = JVMCIError.class) 130 public void testInvalidConstantInDataSection() { 131 ConstantReference ref = new ConstantReference(new InvalidVMConstant()); 132 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 133 } 134 135 @Test(expected = NullPointerException.class) 136 public void testNullReferenceInCode() { 137 installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 138 } 139 140 @Test(expected = NullPointerException.class) 141 public void testNullConstantInCode() { 142 ConstantReference ref = new ConstantReference(null); 143 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 144 } 145 146 @Test(expected = JVMCIError.class) 147 public void testInvalidConstantInCode() { 148 ConstantReference ref = new ConstantReference(new InvalidVMConstant()); 149 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 150 } 151 152 @Test(expected = JVMCIError.class) 153 public void testInvalidReference() { 154 InvalidReference ref = new InvalidReference(); 155 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 156 } 157 158 @Test(expected = JVMCIError.class) 159 public void testOutOfBoundsDataSectionReference() { 160 DataSectionReference ref = new DataSectionReference(); 161 ref.setOffset(0x1000); 162 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 163 } 164 165 @Test(expected = JVMCIError.class) 166 public void testInvalidMark() { 167 installEmptyCode(new Site[]{new Mark(0, new Object())}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 168 } 169 170 @Test(expected = JVMCIError.class) 171 public void testInvalidMarkInt() { 172 installEmptyCode(new Site[]{new Mark(0, -1)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 173 } 174 175 @Test(expected = NullPointerException.class) 176 public void testNullSite() { 177 installEmptyCode(new Site[]{null}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 178 } 179 180 @Test(expected = JVMCIError.class) 181 public void testInfopointMissingDebugInfo() { 182 Infopoint info = new Infopoint(0, null, InfopointReason.METHOD_START); 183 installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 184 } 185 186 @Test(expected = JVMCIError.class) 187 public void testSafepointMissingDebugInfo() { 188 Infopoint info = new Infopoint(0, null, InfopointReason.SAFEPOINT); 189 StackSlot deoptRescueSlot = StackSlot.get(null, 0, true); 190 installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot); 191 } 192 193 @Test(expected = JVMCIError.class) 194 public void testInvalidDeoptRescueSlot() { 195 StackSlot deoptRescueSlot = StackSlot.get(null, -1, false); 196 installEmptyCode(new Site[]{}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot); 197 } 198 } | 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 * @build compiler.jvmci.errors.TestInvalidCompilationResult 34 * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidCompilationResult 35 */ 36 37 package compiler.jvmci.errors; 38 39 import jdk.vm.ci.code.StackSlot; 40 import jdk.vm.ci.code.site.ConstantReference; 41 import jdk.vm.ci.code.site.DataPatch; 42 import jdk.vm.ci.code.site.DataSectionReference; 43 import jdk.vm.ci.code.site.Infopoint; 44 import jdk.vm.ci.code.site.InfopointReason; 45 import jdk.vm.ci.code.site.Mark; 46 import jdk.vm.ci.code.site.Reference; 47 import jdk.vm.ci.code.site.Site; 48 import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; 49 import jdk.vm.ci.hotspot.HotSpotConstant; 50 import jdk.vm.ci.meta.Assumptions.Assumption; 51 import jdk.vm.ci.meta.VMConstant; 52 53 import org.junit.Test; 54 55 /** 56 * Tests for errors in the code installer. 57 */ 58 public class TestInvalidCompilationResult extends CodeInstallerTest { 59 60 private static class InvalidAssumption extends Assumption { 61 } 62 63 private static class InvalidVMConstant implements VMConstant { 64 65 public boolean isDefaultForKind() { 66 return false; 67 } 68 69 public String toValueString() { 70 return null; 71 } 72 } 73 74 private static class InvalidReference extends Reference { 75 76 @Override 77 public int hashCode() { 78 return 0; 79 } 80 81 @Override 82 public boolean equals(Object obj) { 83 return false; 84 } 85 } 86 87 @Test(expected = InternalError.class) 88 public void testInvalidAssumption() { 89 installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], 16, new DataPatch[0], null); 90 } 91 92 @Test(expected = InternalError.class) 93 public void testInvalidAlignment() { 94 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0], null); 95 } 96 97 @Test(expected = NullPointerException.class) 98 public void testNullDataPatchInDataSection() { 99 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{null}, null); 100 } 101 102 @Test(expected = NullPointerException.class) 103 public void testNullReferenceInDataSection() { 104 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, null)}, null); 105 } 106 107 @Test(expected = InternalError.class) 108 public void testInvalidDataSectionReference() { 109 DataSectionReference ref = new DataSectionReference(); 110 ref.setOffset(0); 111 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 112 } 113 114 @Test(expected = InternalError.class) 115 public void testInvalidNarrowMethodInDataSection() { 116 HotSpotConstant c = (HotSpotConstant) dummyMethod.getEncoding(); 117 ConstantReference ref = new ConstantReference((VMConstant) c.compress()); 118 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 119 } 120 121 @Test(expected = NullPointerException.class) 122 public void testNullConstantInDataSection() { 123 ConstantReference ref = new ConstantReference(null); 124 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 125 } 126 127 @Test(expected = InternalError.class) 128 public void testInvalidConstantInDataSection() { 129 ConstantReference ref = new ConstantReference(new InvalidVMConstant()); 130 installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null); 131 } 132 133 @Test(expected = NullPointerException.class) 134 public void testNullReferenceInCode() { 135 installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 136 } 137 138 @Test(expected = NullPointerException.class) 139 public void testNullConstantInCode() { 140 ConstantReference ref = new ConstantReference(null); 141 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 142 } 143 144 @Test(expected = InternalError.class) 145 public void testInvalidConstantInCode() { 146 ConstantReference ref = new ConstantReference(new InvalidVMConstant()); 147 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 148 } 149 150 @Test(expected = InternalError.class) 151 public void testInvalidReference() { 152 InvalidReference ref = new InvalidReference(); 153 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 154 } 155 156 @Test(expected = InternalError.class) 157 public void testOutOfBoundsDataSectionReference() { 158 DataSectionReference ref = new DataSectionReference(); 159 ref.setOffset(0x1000); 160 installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 161 } 162 163 @Test(expected = InternalError.class) 164 public void testInvalidMark() { 165 installEmptyCode(new Site[]{new Mark(0, new Object())}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 166 } 167 168 @Test(expected = InternalError.class) 169 public void testInvalidMarkInt() { 170 installEmptyCode(new Site[]{new Mark(0, -1)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 171 } 172 173 @Test(expected = NullPointerException.class) 174 public void testNullSite() { 175 installEmptyCode(new Site[]{null}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 176 } 177 178 @Test(expected = InternalError.class) 179 public void testInfopointMissingDebugInfo() { 180 Infopoint info = new Infopoint(0, null, InfopointReason.METHOD_START); 181 installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null); 182 } 183 184 @Test(expected = InternalError.class) 185 public void testSafepointMissingDebugInfo() { 186 Infopoint info = new Infopoint(0, null, InfopointReason.SAFEPOINT); 187 StackSlot deoptRescueSlot = StackSlot.get(null, 0, true); 188 installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot); 189 } 190 191 @Test(expected = InternalError.class) 192 public void testInvalidDeoptRescueSlot() { 193 StackSlot deoptRescueSlot = StackSlot.get(null, -1, false); 194 installEmptyCode(new Site[]{}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot); 195 } 196 } |