Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6724218.java
41149 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 672421826* @summary Fix raise_LCA_above_marks() early termination27*28* @run main/othervm -Xbatch29* -XX:CompileCommand=exclude,compiler.c2.Test6724218::update30* compiler.c2.Test672421831*/3233package compiler.c2;3435public class Test6724218 {36Test6724218 next = null;37Object value = null;3839static boolean _closed = false;40static int size = 0;41static Test6724218 list = null;42static int cache_size = 0;43static Test6724218 cache = null;4445Object get(int i) {46Test6724218 t = list;47list = t.next;48size -= 1;49Object o = t.value;50if (i > 0) {51t.next = cache;52t.value = null;53cache = t;54cache_size = +1;55}56return o;57}5859void update() {60// Exclude compilation of this one.61if (size == 0) {62Test6724218 t;63if (cache_size > 0) {64t = cache;65cache = t.next;66cache_size = -1;67} else {68t = new Test6724218();69}70t.value = new Object();71t.next = list;72list = t;73size += 1;74}75}7677synchronized Object test(int i) {78while (true) {79if (_closed) {80return null;81} else if (size > 0) {82return get(i);83}84update();85}86}8788public static void main(String argv[]) throws Exception {89Test6724218 t = new Test6724218();90int lim = 500000;91Object o;92for (int j = 0; j < lim; j++) {93o = t.test(j&1);94if (o == null) {95throw new Exception("*** Failed on iteration " + j);96}97if ((j&1) == 0) {98t.update();99}100}101}102}103104105