Path: blob/master/test/hotspot/jtreg/compiler/eliminateAutobox/TestEliminateBoxInDebugInfo.java
41149 views
/*1* Copyright (c) 2021, Huawei Technologies Co., Ltd. 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 826113726* @requires vm.flagless27* @requires vm.debug == true & vm.compiler2.enabled28* @summary Verify that box object is scalarized in case it is directly referenced by debug info.29* @library /test/lib30*31* @run driver compiler.eliminateAutobox.TestEliminateBoxInDebugInfo32*/33package compiler.eliminateAutobox;3435import jdk.test.lib.process.OutputAnalyzer;36import jdk.test.lib.process.ProcessTools;3738public class TestEliminateBoxInDebugInfo {39public static void runTest() throws Exception {40String[] arguments = {41"-XX:CompileCommand=compileonly,compiler/eliminateAutobox/TestEliminateBoxInDebugInfo$Test.foo",42"-XX:CompileCommand=dontinline,compiler/eliminateAutobox/TestEliminateBoxInDebugInfo$Test.black",43"-Xbatch",44"-XX:+PrintEliminateAllocations",45Test.class.getName()46};47ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);48OutputAnalyzer output = new OutputAnalyzer(pb.start());49output.shouldHaveExitValue(0)50.stdoutShouldContain("++++ Eliminated: ");51}5253public static void main(String[] args) throws Exception {54runTest();55}5657static class Test {58public static void main(String[] args) throws Exception {59// warmup60for (int i = 0; i < 100000; i++) {61foo(1000 + (i % 1000));62}63}6465public static int foo(int value) {66Integer ii = Integer.valueOf(value);67int sum = 0;68if (value > 999) {69sum += ii.intValue();70}71black();72return sum;73}7475public static void black() {}76}77}787980