Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6905845.java
41152 views
/*1* Copyright (c) 2011, 2013, 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 690584526* @summary Server VM improperly optimizing away loop.27*28* @run main/timeout=480 compiler.c2.Test690584529*/3031package compiler.c2;3233public class Test6905845 {3435public static void main(String[] args) {36for (int asdf = 0; asdf < 5; asdf++) {37//test block38{39StringBuilder strBuf1 = new StringBuilder(65);40long start = System.currentTimeMillis();41int count = 0;4243for (int i = Integer.MIN_VALUE; i < (Integer.MAX_VALUE - 80); i += 79) {44strBuf1.append(i);45count++;46strBuf1.delete(0, 65);47}4849System.out.println(count);50if (count != 54366674) {51System.out.println("wrong count: " + count + ", should be 54366674");52System.exit(97);53}54}55//test block56{57StringBuilder strBuf1 = new StringBuilder(65);58long start = System.currentTimeMillis();59int count = 0;6061for (int i = Integer.MIN_VALUE; i < (Integer.MAX_VALUE - 80); i += 79) {62strBuf1.append(i);63count++;64strBuf1.delete(0, 65);65}6667System.out.println(count);68if (count != 54366674) {69System.out.println("wrong count: " + count + ", should be 54366674");70System.exit(97);71}72}73}74}75}76777879