Path: blob/master/test/hotspot/jtreg/compiler/inlining/InlineAccessors.java
41149 views
/*1* Copyright (c) 2015, 2021, 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 814065026* @summary Method::is_accessor should cover getters and setters for all types27* @library /test/lib28* @requires vm.flagless29*30* @run driver compiler.inlining.InlineAccessors31*/3233package compiler.inlining;3435import jdk.test.lib.process.OutputAnalyzer;36import jdk.test.lib.process.ProcessTools;3738public class InlineAccessors {39public static void main(String[] args) throws Exception {40ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(41"-XX:+IgnoreUnrecognizedVMOptions", "-showversion",42"-server", "-XX:-TieredCompilation", "-Xbatch",43"-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining",44Launcher.class.getName());4546OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());4748analyzer.shouldHaveExitValue(0);4950// The test is applicable only to C2 (present in Server VM).51if (analyzer.getStderr().contains("Server VM")) {52analyzer.shouldContain("InlineAccessors::setBool (6 bytes) accessor");53analyzer.shouldContain("InlineAccessors::setByte (6 bytes) accessor");54analyzer.shouldContain("InlineAccessors::setChar (6 bytes) accessor");55analyzer.shouldContain("InlineAccessors::setShort (6 bytes) accessor");56analyzer.shouldContain("InlineAccessors::setInt (6 bytes) accessor");57analyzer.shouldContain("InlineAccessors::setFloat (6 bytes) accessor");58analyzer.shouldContain("InlineAccessors::setLong (6 bytes) accessor");59analyzer.shouldContain("InlineAccessors::setDouble (6 bytes) accessor");60analyzer.shouldContain("InlineAccessors::setObject (6 bytes) accessor");61analyzer.shouldContain("InlineAccessors::setArray (6 bytes) accessor");6263analyzer.shouldContain("InlineAccessors::getBool (5 bytes) accessor");64analyzer.shouldContain("InlineAccessors::getByte (5 bytes) accessor");65analyzer.shouldContain("InlineAccessors::getChar (5 bytes) accessor");66analyzer.shouldContain("InlineAccessors::getShort (5 bytes) accessor");67analyzer.shouldContain("InlineAccessors::getInt (5 bytes) accessor");68analyzer.shouldContain("InlineAccessors::getFloat (5 bytes) accessor");69analyzer.shouldContain("InlineAccessors::getLong (5 bytes) accessor");70analyzer.shouldContain("InlineAccessors::getDouble (5 bytes) accessor");71analyzer.shouldContain("InlineAccessors::getObject (5 bytes) accessor");72analyzer.shouldContain("InlineAccessors::getArray (5 bytes) accessor");73}74}7576boolean bool;77byte b;78char c;79short s;80int i;81float f;82long l;83double d;84Object o;85Object[] a;8687public void setBool(boolean v) { bool = v; }88public void setByte(byte v) { b = v; }89public void setChar(char v) { c = v; }90public void setShort(short v) { s = v; }91public void setInt(int v) { i = v; }92public void setFloat(float v) { f = v; }93public void setLong(long v) { l = v; }94public void setDouble(double v) { d = v; }95public void setObject(Object v) { o = v; }96public void setArray(Object[] v) { a = v; }9798public boolean getBool() { return bool; }99public byte getByte() { return b; }100public char getChar() { return c; }101public short getShort() { return s; }102public int getInt() { return i; }103public float getFloat() { return f; }104public long getLong() { return l; }105public double getDouble() { return d; }106public Object getObject() { return o; }107public Object[] getArray() { return a; }108109static void doTest() {110InlineAccessors o = new InlineAccessors();111o.setBool(false);112o.setByte((byte)0);113o.setChar('a');114o.setShort((short)0);115o.setInt(0);116o.setFloat(0F);117o.setLong(0L);118o.setDouble(0D);119o.setObject(new Object());120o.setArray(new Object[1]);121122o.getBool();123o.getByte();124o.getChar();125o.getShort();126o.getInt();127o.getFloat();128o.getLong();129o.getDouble();130o.getObject();131o.getArray();132}133134static class Launcher {135public static void main(String[] args) throws Exception {136for (int c = 0; c < 20_000; c++) {137doTest();138}139}140}141}142143144