Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java
41153 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* @bug 813642126* @requires vm.jvmci27* @library /test/lib /28* @library ../common/patches29* @library ../common/patches30* @modules java.base/jdk.internal.misc31* @modules java.base/jdk.internal.org.objectweb.asm32* java.base/jdk.internal.org.objectweb.asm.tree33* jdk.internal.vm.ci/jdk.vm.ci.hotspot34* jdk.internal.vm.ci/jdk.vm.ci.code35* jdk.internal.vm.ci/jdk.vm.ci.meta36* jdk.internal.vm.ci/jdk.vm.ci.runtime37*38* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper39* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI40* -XX:-UseJVMCICompiler41* compiler.jvmci.compilerToVM.GetLineNumberTableTest42*/4344package compiler.jvmci.compilerToVM;4546import compiler.jvmci.common.CTVMUtilities;47import compiler.jvmci.common.testcases.TestCase;48import jdk.test.lib.Asserts;49import jdk.vm.ci.hotspot.CompilerToVMHelper;50import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;5152import java.lang.reflect.Executable;53import java.util.Arrays;54import java.util.Map;5556public class GetLineNumberTableTest {57public static void main(String[] args) {58TestCase.getAllExecutables()59.forEach(GetLineNumberTableTest::runSanityTest);60}6162public static void runSanityTest(Executable aMethod) {63HotSpotResolvedJavaMethod method = CTVMUtilities64.getResolvedMethod(aMethod);65long[] lineNumbers = CompilerToVMHelper.getLineNumberTable(method);66long[] expectedLineNumbers = getExpectedLineNumbers(aMethod);6768Asserts.assertTrue(Arrays.equals(lineNumbers, expectedLineNumbers),69String.format("%s : unequal table values : %n%s%n%s%n",70aMethod,71Arrays.toString(lineNumbers),72Arrays.toString(expectedLineNumbers)));73}7475public static long[] getExpectedLineNumbers(Executable aMethod) {76Map<Integer, Integer> bciToLine = CTVMUtilities77.getBciToLineNumber(aMethod);78long[] result = null;79if (!bciToLine.isEmpty()) {80result = new long[2 * bciToLine.size()];81int i = 0;82for (Integer key : bciToLine.keySet()) {83result[i++] = key.longValue();84result[i++] = bciToLine.get(key).longValue();85}86}87// compilerToVM::getLineNumberTable returns null in case empty table88return result;89}9091}929394