Path: blob/master/test/hotspot/jtreg/compiler/escapeAnalysis/Test6689060.java
41152 views
/*1* Copyright (c) 2008, 2018, 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*28* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:+EliminateAutoBox -XX:AutoBoxCacheMax=2000029* -XX:CompileCommand=exclude,compiler.escapeAnalysis.Test6689060::dummy30* compiler.escapeAnalysis.Test668906031*/3233package compiler.escapeAnalysis;3435import java.lang.reflect.Array;3637public class Test6689060 {38static class Point {39int x;40int y;41Point next;42int ax[];43int ay[];44Point pax[];45Point pay[];4647public Point getNext() {48return next;49}50}5152void dummy() {53// Empty method to verify correctness of DebugInfo.54// Use -XX:CompileCommand=exclude,Test.dummy55}5657int ival(int i) {58return i * 2;59}6061int test80(int y, int l, int i) {62Point p = new Point();63p.ax = new int[2];64p.ay = new int[2];65int x = 3;66p.ax[0] = x;67p.ay[1] = 3 * x + y;68dummy();69return p.ax[0] * p.ay[1];70}7172int test81(int y, int l, int i) {73Point p = new Point();74p.ax = new int[2];75p.ay = new int[2];76int x = 3;77p.ax[0] = x;78p.ay[1] = 3 * x + y;79dummy();80return p.ax[0] * p.ay[1];81}828384int test44(int y) {85Point p1 = new Point();86p1.x = ival(3);87dummy();88p1.y = 3 * p1.x + y;89return p1.y;90}9192int test43(int y) {93Point p1 = new Point();94if ((y & 1) == 1) {95p1.x = ival(3);96} else {97p1.x = ival(5);98}99dummy();100p1.y = 3 * p1.x + y;101return p1.y;102}103104int test42(int y) {105Point p1 = new Point();106p1.x = 3;107for (int i = 0; i < y; i++) {108if ((i & 1) == 1) {109p1.x += 4;110}111}112p1.y = 3 * y + p1.x;113return p1.y;114}115116int test40(int y) {117Point p1 = new Point();118if ((y & 1) == 1) {119p1.x = 3;120} else {121p1.x = 5;122}123p1.y = 3 * p1.x + y;124return p1.y;125}126127int test41(int y) {128Point p1 = new Point();129if ((y & 1) == 1) {130p1.x += 4;131} else {132p1.x += 5;133}134p1.y = 3 * p1.x + y;135return p1.y;136}137138Point test00(int y) {139int x = 3;140Point p = new Point();141p.x = x;142p.y = 3 * x + y;143return p;144}145146Point test01(int y) {147int x = 3;148Point p = new Point();149p.x = x;150p.y = 3 * x + y;151dummy();152return p;153}154155Point test02(int y) {156int x = 3;157Point p1 = null;158for (int i = 0; i < y; i++) {159Point p2 = new Point();160p2.x = x;161p2.y = 3 * y + x;162p2.next = p1;163p1 = p2;164}165return p1;166}167168Point test03(int y) {169int x = 3;170Point p1 = null;171for (int i = 0; i < y; i++) {172Point p2 = new Point();173p2.x = x;174p2.y = 3 * y + x;175p2.next = p1;176p1 = p2;177}178dummy();179return p1;180}181182Point test04(int y) {183int x = 3;184Point p1 = null;185for (int i = 0; i < y; i++) {186Point p2 = new Point();187p2.x = x;188p2.y = 3 * y + x;189p2.next = p1;190dummy();191p1 = p2;192}193return p1;194}195196int test05(int y) {197int x = 3;198Point p1 = new Point();199for (int i = 0; i < y; i++) {200Point p2 = new Point();201p2.x = x;202p2.y = 3 * y + x;203p1.next = p2;204p1 = p2;205}206return p1.y;207}208209int test0(int y) {210int x = 3;211Point p = new Point();212p.x = x;213p.y = 3 * x + y;214dummy();215return p.x * p.y;216}217218int test1(int y) {219Point p = new Point();220if ((y & 1) == 1) {221p = new Point(); // Kill previous222}223int x = 3;224p.x = x;225p.y = 3 * x + y;226dummy();227return p.x * p.y;228}229230int test2(int y) {231Point p1 = new Point();232Point p2 = new Point();233p1.x = 3;234p2.x = 4;235p1.y = 3 * p2.x + y;236p2.y = 3 * p1.x + y;237dummy();238return p1.y * p2.y;239}240241int test3(int y, Point p1) {242Point p2 = new Point();243p1.x = 3;244p2.x = 4;245p1.y = 3 * p2.x + y;246p2.y = 3 * p1.x + y;247dummy();248return p1.y * p2.y;249}250251int test4(int y) {252Point p1 = new Point();253Point p2 = new Point();254if ((y & 1) == 1) {255p1.x = 3;256p2.x = 4;257} else {258p1.x = 5;259p2.x = 6;260}261p1.y = 3 * p2.x + y;262p2.y = 3 * p1.x + y;263dummy();264return p1.y * p2.y;265}266267int test5(int y, Point p1) {268Point p2 = new Point();269if ((y & 1) == 1) {270p1.x = 3;271p2.x = 4;272} else {273p1.x = 5;274p2.x = 6;275}276p1.y = 3 * p2.x + y;277p2.y = 3 * p1.x + y;278dummy();279return p1.y * p2.y;280}281282int test6(int y) {283Point p1 = new Point();284Point p2 = new Point();285p1.next = p2;286if ((y & 1) == 1) {287p1.x = 3;288p1.getNext().x = 4;289} else {290p1.x = 5;291p1.getNext().x = 6;292}293p1.y = 3 * p2.x + y;294p2.y = 3 * p1.x + y;295dummy();296return p1.y * p2.y;297}298299int test7(int y, Point p1) {300Point p2 = new Point();301p1.next = p2;302if ((y & 1) == 1) {303p1.x = 3;304p1.getNext().x = 4;305} else {306p1.x = 5;307p1.getNext().x = 6;308}309p1.y = 3 * p2.x + y;310p2.y = 3 * p1.x + y;311dummy();312return p1.y * p2.y;313}314315int test8(int y, int l, int i) {316Point p = new Point();317p.ax = new int[l];318p.ay = new int[l];319int x = 3;320p.ax[i] = x;321p.ay[i] = 3 * x + y;322dummy();323return p.ax[i] * p.ay[i];324}325326int test9(int y, int l, int i) {327Point p = new Point();328p.pax = new Point[l];329p.pay = new Point[l];330p.pax[i] = new Point();331p.pay[i] = new Point();332p.pax[i].x = 3;333p.pay[i].x = 4;334p.pax[i].y = 3 * p.pay[i].x + y;335p.pay[i].y = 3 * p.pax[i].x + y;336dummy();337return p.pax[i].y * p.pay[i].y;338}339340int test10(int y, int l, int i, Class cls) {341Point p = new Point();342try {343p.pax = (Point[]) Array.newInstance(cls, l);344p.pax[i] = (Point) cls.newInstance();345} catch (java.lang.InstantiationException ex) {346return 0;347} catch (java.lang.IllegalAccessException ex) {348return 0;349}350p.pax[i].x = 3;351p.pax[i].y = 3 * p.pax[i].x + y;352dummy();353return p.pax[i].x * p.pax[i].y;354}355356int test11(int y) {357Point p1 = new Point();358Point p2 = new Point();359p1.next = p2;360if ((y & 1) == 1) {361p1.x = 3;362p1.next.x = 4;363} else {364p1.x = 5;365p1.next.x = 6;366}367p1.y = 3 * p1.next.x + y;368p1.next.y = 3 * p1.x + y;369dummy();370return p1.y * p1.next.y;371}372373int test12(int y) {374Point p1 = new Point();375p1.next = p1;376if ((y & 1) == 1) {377p1.x = 3;378p1.next.x = 4;379} else {380p1.x = 5;381p1.next.x = 6;382}383p1.y = 3 * p1.next.x + y;384p1.next.y = 3 * p1.x + y;385dummy();386return p1.y * p1.next.y;387}388389390public static void main(String args[]) {391Test6689060 tsr = new Test6689060();392Point p = new Point();393Point ptmp = p;394Class cls = Point.class;395int y = 0;396for (int i = 0; i < 10000; i++) {397ptmp.next = tsr.test00(1);398ptmp.next = tsr.test01(1);399ptmp.next = tsr.test02(1);400ptmp.next = tsr.test03(1);401ptmp.next = tsr.test04(1);402403y = tsr.test05(1);404405y = tsr.test80(y, 1, 0);406y = tsr.test81(y, 1, 0);407408y = tsr.test44(y);409y = tsr.test43(y);410y = tsr.test42(y);411y = tsr.test40(y);412y = tsr.test41(y);413414y = tsr.test0(y);415y = tsr.test1(y);416y = tsr.test2(y);417y = tsr.test3(y, p);418y = tsr.test4(y);419y = tsr.test5(y, p);420y = tsr.test6(y);421y = tsr.test7(y, p);422y = tsr.test8(y, 1, 0);423y = tsr.test9(y, 1, 0);424y = tsr.test10(y, 1, 0, cls);425y = tsr.test11(y);426y = tsr.test12(y);427}428for (int i = 0; i < 10000; i++) {429ptmp.next = tsr.test00(1);430ptmp.next = tsr.test01(1);431ptmp.next = tsr.test02(1);432ptmp.next = tsr.test03(1);433ptmp.next = tsr.test04(1);434435y = tsr.test05(1);436437y = tsr.test80(y, 1, 0);438y = tsr.test81(y, 1, 0);439440y = tsr.test44(y);441y = tsr.test43(y);442y = tsr.test42(y);443y = tsr.test40(y);444y = tsr.test41(y);445446y = tsr.test0(y);447y = tsr.test1(y);448y = tsr.test2(y);449y = tsr.test3(y, p);450y = tsr.test4(y);451y = tsr.test5(y, p);452y = tsr.test6(y);453y = tsr.test7(y, p);454y = tsr.test8(y, 1, 0);455y = tsr.test9(y, 1, 0);456y = tsr.test10(y, 1, 0, cls);457y = tsr.test11(y);458y = tsr.test12(y);459}460for (int i = 0; i < 10000; i++) {461ptmp.next = tsr.test00(1);462ptmp.next = tsr.test01(1);463ptmp.next = tsr.test02(1);464ptmp.next = tsr.test03(1);465ptmp.next = tsr.test04(1);466467y = tsr.test05(1);468469y = tsr.test80(y, 1, 0);470y = tsr.test81(y, 1, 0);471472y = tsr.test44(y);473y = tsr.test43(y);474y = tsr.test42(y);475y = tsr.test40(y);476y = tsr.test41(y);477478y = tsr.test0(y);479y = tsr.test1(y);480y = tsr.test2(y);481y = tsr.test3(y, p);482y = tsr.test4(y);483y = tsr.test5(y, p);484y = tsr.test6(y);485y = tsr.test7(y, p);486y = tsr.test8(y, 1, 0);487y = tsr.test9(y, 1, 0);488y = tsr.test10(y, 1, 0, cls);489y = tsr.test11(y);490y = tsr.test12(y);491}492493int z = 0;494y = tsr.test80(0, 1, 0);495z += y;496System.out.println("After 'test80' y=" + y);497y = tsr.test81(0, 1, 0);498z += y;499System.out.println("After 'test81' y=" + y);500501y = tsr.test44(0);502z += y;503System.out.println("After 'test44' y=" + y);504y = tsr.test43(0);505z += y;506System.out.println("After 'test43' y=" + y);507y = tsr.test42(0);508z += y;509System.out.println("After 'test42' y=" + y);510y = tsr.test40(0);511z += y;512System.out.println("After 'test40' y=" + y);513y = tsr.test41(0);514z += y;515System.out.println("After 'test41' y=" + y);516517ptmp.next = tsr.test00(1);518z += y;519System.out.println("After 'test00' p.y=" + ptmp.next.y);520ptmp.next = tsr.test01(1);521z += y;522System.out.println("After 'test01' p.y=" + ptmp.next.y);523ptmp.next = tsr.test02(1);524z += y;525System.out.println("After 'test02' p.y=" + ptmp.next.y);526ptmp.next = tsr.test03(1);527z += y;528System.out.println("After 'test03' p.y=" + ptmp.next.y);529ptmp.next = tsr.test04(1);530z += y;531System.out.println("After 'test04' p.y=" + ptmp.next.y);532533y = tsr.test05(1);534z += y;535System.out.println("After 'test05' y=" + y);536537y = tsr.test0(0);538z += y;539System.out.println("After 'test0' y=" + y);540y = tsr.test1(0);541z += y;542System.out.println("After 'test1' y=" + y);543y = tsr.test2(0);544z += y;545System.out.println("After 'test2' y=" + y);546y = tsr.test3(0, new Point());547z += y;548System.out.println("After 'test3' y=" + y);549y = tsr.test4(0);550z += y;551System.out.println("After 'test4' y=" + y);552y = tsr.test5(0, new Point());553z += y;554System.out.println("After 'test5' y=" + y);555y = tsr.test6(0);556z += y;557System.out.println("After 'test6' y=" + y);558y = tsr.test7(0, new Point());559z += y;560System.out.println("After 'test7' y=" + y);561y = tsr.test8(0, 1, 0);562z += y;563System.out.println("After 'test8' y=" + y);564y = tsr.test9(0, 1, 0);565z += y;566System.out.println("After 'test9' y=" + y);567y = tsr.test10(0, 1, 0, cls);568z += y;569System.out.println("After 'test10' y=" + y);570y = tsr.test11(0);571z += y;572System.out.println("After 'test11' y=" + y);573y = tsr.test12(0);574z += y;575System.out.println("After 'test12' y=" + y);576System.out.println("Sum of y =" + z);577}578}579580581