Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6689060/Test.java
32285 views
/*1* Copyright (c) 2008, 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 668906026* @summary Escape Analysis does not work with Compressed Oops27* @run main/othervm -Xbatch -XX:CompileCommand=exclude,Test.dummy -XX:+AggressiveOpts Test28*/2930import java.lang.reflect.Array;3132class Point {33int x;34int y;35Point next;36int ax[];37int ay[];38Point pax[];39Point pay[];40public Point getNext() {41return next;42}43}4445public class Test {4647void dummy() {48// Empty method to verify correctness of DebugInfo.49// Use -XX:CompileCommand=exclude,Test.dummy50}5152int ival(int i) {53return i*2;54}5556int test80(int y, int l, int i) {57Point p = new Point();58p.ax = new int[2];59p.ay = new int[2];60int x = 3;61p.ax[0] = x;62p.ay[1] = 3 * x + y;63dummy();64return p.ax[0] * p.ay[1];65}6667int test81(int y, int l, int i) {68Point p = new Point();69p.ax = new int[2];70p.ay = new int[2];71int x = 3;72p.ax[0] = x;73p.ay[1] = 3 * x + y;74dummy();75return p.ax[0] * p.ay[1];76}777879int test44(int y) {80Point p1 = new Point();81p1.x = ival(3);82dummy();83p1.y = 3 * p1.x + y;84return p1.y;85}8687int test43(int y) {88Point p1 = new Point();89if ( (y & 1) == 1 ) {90p1.x = ival(3);91} else {92p1.x = ival(5);93}94dummy();95p1.y = 3 * p1.x + y;96return p1.y;97}9899int test42(int y) {100Point p1 = new Point();101p1.x = 3;102for (int i = 0; i < y; i++) {103if ( (i & 1) == 1 ) {104p1.x += 4;105}106}107p1.y = 3 * y + p1.x;108return p1.y;109}110111int test40(int y) {112Point p1 = new Point();113if ( (y & 1) == 1 ) {114p1.x = 3;115} else {116p1.x = 5;117}118p1.y = 3 * p1.x + y;119return p1.y;120}121122int test41(int y) {123Point p1 = new Point();124if ( (y & 1) == 1 ) {125p1.x += 4;126} else {127p1.x += 5;128}129p1.y = 3 * p1.x + y;130return p1.y;131}132133Point test00(int y) {134int x = 3;135Point p = new Point();136p.x = x;137p.y = 3 * x + y;138return p;139}140141Point test01(int y) {142int x = 3;143Point p = new Point();144p.x = x;145p.y = 3 * x + y;146dummy();147return p;148}149150Point test02(int y) {151int x = 3;152Point p1 = null;153for (int i = 0; i < y; i++) {154Point p2 = new Point();155p2.x = x;156p2.y = 3 * y + x;157p2.next = p1;158p1 = p2;159}160return p1;161}162163Point test03(int y) {164int x = 3;165Point p1 = null;166for (int i = 0; i < y; i++) {167Point p2 = new Point();168p2.x = x;169p2.y = 3 * y + x;170p2.next = p1;171p1 = p2;172}173dummy();174return p1;175}176177Point test04(int y) {178int x = 3;179Point p1 = null;180for (int i = 0; i < y; i++) {181Point p2 = new Point();182p2.x = x;183p2.y = 3 * y + x;184p2.next = p1;185dummy();186p1 = p2;187}188return p1;189}190191int test05(int y) {192int x = 3;193Point p1 = new Point();194for (int i = 0; i < y; i++) {195Point p2 = new Point();196p2.x = x;197p2.y = 3 * y + x;198p1.next = p2;199p1 = p2;200}201return p1.y;202}203204int test0(int y) {205int x = 3;206Point p = new Point();207p.x = x;208p.y = 3 * x + y;209dummy();210return p.x * p.y;211}212213int test1(int y) {214Point p = new Point();215if ( (y & 1) == 1 ) {216p = new Point(); // Kill previous217}218int x = 3;219p.x = x;220p.y = 3 * x + y;221dummy();222return p.x * p.y;223}224225int test2(int y) {226Point p1 = new Point();227Point p2 = new Point();228p1.x = 3;229p2.x = 4;230p1.y = 3 * p2.x + y;231p2.y = 3 * p1.x + y;232dummy();233return p1.y * p2.y;234}235236int test3(int y, Point p1) {237Point p2 = new Point();238p1.x = 3;239p2.x = 4;240p1.y = 3 * p2.x + y;241p2.y = 3 * p1.x + y;242dummy();243return p1.y * p2.y;244}245246int test4(int y) {247Point p1 = new Point();248Point p2 = new Point();249if ( (y & 1) == 1 ) {250p1.x = 3;251p2.x = 4;252} else {253p1.x = 5;254p2.x = 6;255}256p1.y = 3 * p2.x + y;257p2.y = 3 * p1.x + y;258dummy();259return p1.y * p2.y;260}261262int test5(int y, Point p1) {263Point p2 = new Point();264if ( (y & 1) == 1 ) {265p1.x = 3;266p2.x = 4;267} else {268p1.x = 5;269p2.x = 6;270}271p1.y = 3 * p2.x + y;272p2.y = 3 * p1.x + y;273dummy();274return p1.y * p2.y;275}276277int test6(int y) {278Point p1 = new Point();279Point p2 = new Point();280p1.next = p2;281if ( (y & 1) == 1 ) {282p1.x = 3;283p1.getNext().x = 4;284} else {285p1.x = 5;286p1.getNext().x = 6;287}288p1.y = 3 * p2.x + y;289p2.y = 3 * p1.x + y;290dummy();291return p1.y * p2.y;292}293294int test7(int y, Point p1) {295Point p2 = new Point();296p1.next = p2;297if ( (y & 1) == 1 ) {298p1.x = 3;299p1.getNext().x = 4;300} else {301p1.x = 5;302p1.getNext().x = 6;303}304p1.y = 3 * p2.x + y;305p2.y = 3 * p1.x + y;306dummy();307return p1.y * p2.y;308}309310int test8(int y, int l, int i) {311Point p = new Point();312p.ax = new int[l];313p.ay = new int[l];314int x = 3;315p.ax[i] = x;316p.ay[i] = 3 * x + y;317dummy();318return p.ax[i] * p.ay[i];319}320321int test9(int y, int l, int i) {322Point p = new Point();323p.pax = new Point[l];324p.pay = new Point[l];325p.pax[i] = new Point();326p.pay[i] = new Point();327p.pax[i].x = 3;328p.pay[i].x = 4;329p.pax[i].y = 3 * p.pay[i].x + y;330p.pay[i].y = 3 * p.pax[i].x + y;331dummy();332return p.pax[i].y * p.pay[i].y;333}334335int test10(int y, int l, int i, Class cls) {336Point p = new Point();337try {338p.pax = (Point[])Array.newInstance(cls, l);339p.pax[i] = (Point)cls.newInstance();340}341catch(java.lang.InstantiationException ex) {342return 0;343}344catch(java.lang.IllegalAccessException ex) {345return 0;346}347p.pax[i].x = 3;348p.pax[i].y = 3 * p.pax[i].x + y;349dummy();350return p.pax[i].x * p.pax[i].y;351}352353int test11(int y) {354Point p1 = new Point();355Point p2 = new Point();356p1.next = p2;357if ( (y & 1) == 1 ) {358p1.x = 3;359p1.next.x = 4;360} else {361p1.x = 5;362p1.next.x = 6;363}364p1.y = 3 * p1.next.x + y;365p1.next.y = 3 * p1.x + y;366dummy();367return p1.y * p1.next.y;368}369370int test12(int y) {371Point p1 = new Point();372p1.next = p1;373if ( (y & 1) == 1 ) {374p1.x = 3;375p1.next.x = 4;376} else {377p1.x = 5;378p1.next.x = 6;379}380p1.y = 3 * p1.next.x + y;381p1.next.y = 3 * p1.x + y;382dummy();383return p1.y * p1.next.y;384}385386387public static void main(String args[]) {388Test tsr = new Test();389Point p = new Point();390Point ptmp = p;391Class cls = Point.class;392int y = 0;393for (int i=0; i<10000; i++) {394ptmp.next = tsr.test00(1);395ptmp.next = tsr.test01(1);396ptmp.next = tsr.test02(1);397ptmp.next = tsr.test03(1);398ptmp.next = tsr.test04(1);399400y = tsr.test05(1);401402y = tsr.test80(y, 1, 0);403y = tsr.test81(y, 1, 0);404405y = tsr.test44(y);406y = tsr.test43(y);407y = tsr.test42(y);408y = tsr.test40(y);409y = tsr.test41(y);410411y = tsr.test0(y);412y = tsr.test1(y);413y = tsr.test2(y);414y = tsr.test3(y, p);415y = tsr.test4(y);416y = tsr.test5(y, p);417y = tsr.test6(y);418y = tsr.test7(y, p);419y = tsr.test8(y, 1, 0);420y = tsr.test9(y, 1, 0);421y = tsr.test10(y, 1, 0, cls);422y = tsr.test11(y);423y = tsr.test12(y);424}425for (int i=0; i<10000; i++) {426ptmp.next = tsr.test00(1);427ptmp.next = tsr.test01(1);428ptmp.next = tsr.test02(1);429ptmp.next = tsr.test03(1);430ptmp.next = tsr.test04(1);431432y = tsr.test05(1);433434y = tsr.test80(y, 1, 0);435y = tsr.test81(y, 1, 0);436437y = tsr.test44(y);438y = tsr.test43(y);439y = tsr.test42(y);440y = tsr.test40(y);441y = tsr.test41(y);442443y = tsr.test0(y);444y = tsr.test1(y);445y = tsr.test2(y);446y = tsr.test3(y, p);447y = tsr.test4(y);448y = tsr.test5(y, p);449y = tsr.test6(y);450y = tsr.test7(y, p);451y = tsr.test8(y, 1, 0);452y = tsr.test9(y, 1, 0);453y = tsr.test10(y, 1, 0, cls);454y = tsr.test11(y);455y = tsr.test12(y);456}457for (int i=0; i<10000; i++) {458ptmp.next = tsr.test00(1);459ptmp.next = tsr.test01(1);460ptmp.next = tsr.test02(1);461ptmp.next = tsr.test03(1);462ptmp.next = tsr.test04(1);463464y = tsr.test05(1);465466y = tsr.test80(y, 1, 0);467y = tsr.test81(y, 1, 0);468469y = tsr.test44(y);470y = tsr.test43(y);471y = tsr.test42(y);472y = tsr.test40(y);473y = tsr.test41(y);474475y = tsr.test0(y);476y = tsr.test1(y);477y = tsr.test2(y);478y = tsr.test3(y, p);479y = tsr.test4(y);480y = tsr.test5(y, p);481y = tsr.test6(y);482y = tsr.test7(y, p);483y = tsr.test8(y, 1, 0);484y = tsr.test9(y, 1, 0);485y = tsr.test10(y, 1, 0, cls);486y = tsr.test11(y);487y = tsr.test12(y);488}489490int z = 0;491y = tsr.test80(0, 1, 0);492z += y;493System.out.println("After 'test80' y=" + y);494y = tsr.test81(0, 1, 0);495z += y;496System.out.println("After 'test81' y=" + y);497498y = tsr.test44(0);499z += y;500System.out.println("After 'test44' y=" + y);501y = tsr.test43(0);502z += y;503System.out.println("After 'test43' y=" + y);504y = tsr.test42(0);505z += y;506System.out.println("After 'test42' y=" + y);507y = tsr.test40(0);508z += y;509System.out.println("After 'test40' y=" + y);510y = tsr.test41(0);511z += y;512System.out.println("After 'test41' y=" + y);513514ptmp.next = tsr.test00(1);515z += y;516System.out.println("After 'test00' p.y=" + ptmp.next.y);517ptmp.next = tsr.test01(1);518z += y;519System.out.println("After 'test01' p.y=" + ptmp.next.y);520ptmp.next = tsr.test02(1);521z += y;522System.out.println("After 'test02' p.y=" + ptmp.next.y);523ptmp.next = tsr.test03(1);524z += y;525System.out.println("After 'test03' p.y=" + ptmp.next.y);526ptmp.next = tsr.test04(1);527z += y;528System.out.println("After 'test04' p.y=" + ptmp.next.y);529530y = tsr.test05(1);531z += y;532System.out.println("After 'test05' y=" + y);533534y = tsr.test0(0);535z += y;536System.out.println("After 'test0' y=" + y);537y = tsr.test1(0);538z += y;539System.out.println("After 'test1' y=" + y);540y = tsr.test2(0);541z += y;542System.out.println("After 'test2' y=" + y);543y = tsr.test3(0, new Point());544z += y;545System.out.println("After 'test3' y=" + y);546y = tsr.test4(0);547z += y;548System.out.println("After 'test4' y=" + y);549y = tsr.test5(0, new Point());550z += y;551System.out.println("After 'test5' y=" + y);552y = tsr.test6(0);553z += y;554System.out.println("After 'test6' y=" + y);555y = tsr.test7(0, new Point());556z += y;557System.out.println("After 'test7' y=" + y);558y = tsr.test8(0, 1, 0);559z += y;560System.out.println("After 'test8' y=" + y);561y = tsr.test9(0, 1, 0);562z += y;563System.out.println("After 'test9' y=" + y);564y = tsr.test10(0, 1, 0, cls);565z += y;566System.out.println("After 'test10' y=" + y);567y = tsr.test11(0);568z += y;569System.out.println("After 'test11' y=" + y);570y = tsr.test12(0);571z += y;572System.out.println("After 'test12' y=" + y);573System.out.println("Sum of y =" + z);574}575}576577578