Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/CEETest/CEETest.java
40948 views
/*1* Copyright (c) 2008, 2020, 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*26* @summary converted from VM Testbase jit/CEETest.27* VM Testbase keywords: [jit, quick]28*29* @library /vmTestbase30* /test/lib31* @run main/othervm jit.CEETest.CEETest32*/3334package jit.CEETest;3536import java.io.PrintStream;37import nsk.share.TestFailure;3839public class CEETest {4041public static final long WarmUp = 1500;42public static final long Iterations = 100000;4344public static void main(String args[]) {45boolean pass = true;46for (int i=0; ( i < WarmUp ) & pass; i++) {47pass = pass & doInt();48pass = pass & doBoolean();49pass = pass & doByte();50pass = pass & doChar();51pass = pass & doShort();52pass = pass & doLong();53pass = pass & doFloat();54pass = pass & doDouble();55pass = pass & doObject();56pass = pass & doBitOps();57}5859long start = System.currentTimeMillis() ;60for (int i=0; i<Iterations & pass; i++) {61pass = pass & doInt();62pass = pass & doBoolean();63pass = pass & doByte();64pass = pass & doChar();65pass = pass & doShort();66pass = pass & doLong();67pass = pass & doFloat();68pass = pass & doDouble();69pass = pass & doObject();70pass = pass & doBitOps();71}7273long duration = System.currentTimeMillis() - start;7475if (true == pass) {76System.out.println ("CEETest PASSed in " + duration + " ms.");77}78else {79throw new TestFailure("CEETest FAILed in " + duration + " ms.");80}81}8283public static boolean doInt () {8485int x = 0;86int y = 1;8788int a = (x == y) ? x : y;89int b = (x != y) ? y : x;90int c = (x < y) ? y : x;91int d = (x > y) ? x : y;92int e = (x <= y) ? y : x;93int f = (x >= y) ? x : y;9495if ( (a != y) ||96(b != y) ||97(c != y) ||98(d != y) ||99(e != y) ||100(f != y) ) {101System.err.println ("doInt() failed");102return false;103}104else {105return true;106}107}108109public static boolean doBoolean () {110111boolean x = false;112boolean y = !x;113boolean a = (x == y) ? x : y;114boolean b = (x != y) ? y : x;115116if ( (a == y) &&117(b == y) ) {118return true;119}120else {121System.err.println ("doBoolean() failed");122return false;123}124}125126public static boolean doByte () {127128byte x = 0;129byte y = 1;130131byte a = (x == y) ? x : y;132byte b = (x != y) ? y : x;133byte c = (x < y) ? y : x;134byte d = (x > y) ? x : y;135byte e = (x <= y) ? y : x;136byte f = (x >= y) ? x : y;137138if ( (a != y) ||139(b != y) ||140(c != y) ||141(d != y) ||142(e != y) ||143(f != y) ) {144System.err.println ("doByte() failed");145return false;146}147else {148return true;149}150}151152public static boolean doChar () {153154char x = 0;155char y = 1;156157char a = (x == y) ? x : y;158char b = (x != y) ? y : x;159char c = (x < y) ? y : x;160char d = (x > y) ? x : y;161char e = (x <= y) ? y : x;162char f = (x >= y) ? x : y;163164if ( (a == y) &&165(b == y) &&166(c == y) &&167(d == y) &&168(e == y) &&169(f == y) ) {170return true;171}172else {173System.err.println ("doChar() failed");174return false;175}176}177178public static boolean doShort () {179180short x = 0;181short y = 1;182183short a = (x == y) ? x : y;184short b = (x != y) ? y : x;185short c = (x < y) ? y : x;186short d = (x > y) ? x : y;187short e = (x <= y) ? y : x;188short f = (x >= y) ? x : y;189190if ( (a != y) ||191(b != y) ||192(c != y) ||193(d != y) ||194(e != y) ||195(f != y) ) {196System.err.println ("doShort() failed");197return false;198}199else {200return true;201}202}203204public static boolean doLong () {205206long x = 0;207long y = 1;208long a = (x == y) ? x : y;209long b = (x != y) ? y : x;210long c = (x < y) ? y : x;211long d = (x > y) ? x : y;212long e = (x <= y) ? y : x;213long f = (x >= y) ? x : y;214215if ( (a == y) &&216(b == y) &&217(c == y) &&218(d == y) &&219(e == y) &&220(f == y) ) {221return true;222}223else {224System.err.println ("doLong() failed");225return false;226}227}228229public static boolean doFloat () {230231float x = 0.0f;232float y = 1.0f;233float a = (x == y) ? x : y;234float b = (x != y) ? y : x;235float c = (x < y) ? y : x;236float d = (x > y) ? x : y;237float e = (x <= y) ? y : x;238float f = (x >= y) ? x : y;239240if ( (a != y) ||241(b != y) ||242(c != y) ||243(d != y) ||244(e != y) ||245(f != y) ) {246System.err.println ("doFloat() failed");247return false;248}249else {250return true;251}252}253254public static boolean doDouble () {255256double x = 0.0;257double y = 1.0;258double a = (x == y) ? x : y;259double b = (x != y) ? y : x;260double c = (x < y) ? y : x;261double d = (x <= y) ? y : x;262double e = (x > y) ? x : y;263double f = (x >= y) ? x : y;264265if ( (a == y) &&266(b == y) &&267(c == y) &&268(d == y) &&269(e == y) &&270(f == y) ) {271return true;272}273else {274System.err.println ("doDouble() failed");275return false;276}277}278279public static boolean doObject () {280281String x = new String("x");282String y = new String("y");283String a = (x == y) ? x : y;284String b = (x != y) ? y : x;285String c = (x instanceof String) ? y : x;286287if ( (a != y) ||288(b != y) ||289(c != y) ) {290System.err.println ("doBoolean() failed");291return false;292}293else {294return true;295}296}297298public static boolean doBitOps () {299int x = 0;300int y = 1;301302int a = x; a += y;303int b = (x == y) ? x : (x | y);304int c = (x == y) ? x : (x ^ y);305int d = (x == y) ? x : (y & y);306int e = (x == y) ? x : (y % 2);307int f = (x == y) ? x : (2 >> y);308int g = (x == y) ? x : (~-2);309310if ( (a == y) &&311(b == y) &&312(c == y) &&313(d == y) &&314(e == y) &&315(f == y) &&316(g == y) ) {317return true;318} else {319System.err.println ("doBoolean() failed");320return false;321}322}323324}325326327