Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6724218/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 672421826* @summary Fix raise_LCA_above_marks() early termination27* @run main/othervm -Xbatch -XX:CompileCommand=exclude,Test.update Test28*/2930public class Test {31Test next = null;32Object value = null;3334static boolean _closed = false;35static int size = 0;36static Test list = null;37static int cache_size = 0;38static Test cache = null;3940Object get(int i) {41Test t = list;42list = t.next;43size -= 1;44Object o = t.value;45if (i > 0) {46t.next = cache;47t.value = null;48cache = t;49cache_size = +1;50}51return o;52}5354void update() {55// Exclude compilation of this one.56if (size == 0) {57Test t;58if (cache_size > 0) {59t = cache;60cache = t.next;61cache_size = -1;62} else {63t = new Test();64}65t.value = new Object();66t.next = list;67list = t;68size += 1;69}70}7172synchronized Object test(int i) {73while (true) {74if (_closed) {75return null;76} else if (size > 0) {77return get(i);78}79update();80}81}8283public static void main(String argv[]) throws Exception {84Test t = new Test();85int lim = 500000;86Object o;87for (int j = 0; j < lim; j++) {88o = t.test(j&1);89if (o == null) {90throw new Exception("*** Failed on iteration " + j);91}92if ((j&1) == 0) {93t.update();94}95}96}97}9899100