Path: blob/master/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidOopMap.java
41152 views
/*1* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @requires vm.jvmci26* @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot27* jdk.internal.vm.ci/jdk.vm.ci.code28* jdk.internal.vm.ci/jdk.vm.ci.code.site29* jdk.internal.vm.ci/jdk.vm.ci.meta30* jdk.internal.vm.ci/jdk.vm.ci.runtime31* jdk.internal.vm.ci/jdk.vm.ci.common32* @compile CodeInstallerTest.java33* @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI34* -XX:-UseJVMCICompiler compiler.jvmci.errors.TestInvalidOopMap35*/3637package compiler.jvmci.errors;3839import jdk.vm.ci.code.BytecodePosition;40import jdk.vm.ci.code.DebugInfo;41import jdk.vm.ci.code.Location;42import jdk.vm.ci.code.ReferenceMap;43import jdk.vm.ci.code.Register;44import jdk.vm.ci.code.StackSlot;45import jdk.vm.ci.code.site.DataPatch;46import jdk.vm.ci.code.site.Infopoint;47import jdk.vm.ci.code.site.InfopointReason;48import jdk.vm.ci.code.site.Site;49import jdk.vm.ci.common.JVMCIError;50import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;51import jdk.vm.ci.hotspot.HotSpotReferenceMap;52import jdk.vm.ci.meta.Assumptions.Assumption;53import jdk.vm.ci.meta.JavaKind;54import jdk.vm.ci.meta.PlatformKind;55import org.junit.Test;5657/**58* Tests for errors in oop maps.59*/60public class TestInvalidOopMap extends CodeInstallerTest {6162private static class InvalidReferenceMap extends ReferenceMap {63}6465private void test(ReferenceMap refMap) {66BytecodePosition pos = new BytecodePosition(null, dummyMethod, 0);67DebugInfo info = new DebugInfo(pos);68info.setReferenceMap(refMap);69installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], StackSlot.get(null, 0, true));70}7172@Test(expected = NullPointerException.class)73public void testMissingReferenceMap() {74test(null);75}7677@Test(expected = JVMCIError.class)78public void testInvalidReferenceMap() {79test(new InvalidReferenceMap());80}8182@Test(expected = NullPointerException.class)83public void testNullOops() {84test(new HotSpotReferenceMap(null, new Location[0], new int[0], 8));85}8687@Test(expected = NullPointerException.class)88public void testNullBase() {89test(new HotSpotReferenceMap(new Location[0], null, new int[0], 8));90}9192@Test(expected = NullPointerException.class)93public void testNullSize() {94test(new HotSpotReferenceMap(new Location[0], new Location[0], null, 8));95}9697@Test(expected = JVMCIError.class)98public void testInvalidLength() {99test(new HotSpotReferenceMap(new Location[1], new Location[2], new int[3], 8));100}101102@Test(expected = JVMCIError.class)103public void testInvalidShortOop() {104PlatformKind kind = arch.getPlatformKind(JavaKind.Short);105Register reg = getRegister(kind, 0);106107Location[] oops = new Location[]{Location.register(reg)};108Location[] base = new Location[]{null};109int[] size = new int[]{kind.getSizeInBytes()};110111test(new HotSpotReferenceMap(oops, base, size, 8));112}113}114115116