Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6843752.java
41149 views
/*1* Copyright (c) 2009, 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 6843752 819299226* @summary missing code for an anti-dependent Phi in GCM27*28* @run main/othervm -Xbatch compiler.c2.Test684375229*/3031package compiler.c2;3233public class Test6843752 {3435Item list;3637static class Item {38public Item next;39public Item prev;40public boolean remove;4142Item(boolean r) { remove = r; }43}4445private void linkIn(Item item) {46Item head = list;47if (head == null) {48item.next = item;49item.prev = item;50list = item;51} else {52item.next = head;53item.prev = head.prev;54head.prev.next = item;55head.prev = item;56}57}5859private void linkOut(Item item) {60Item head = list;61if (item.next == item) {62list = null;63} else {64item.prev.next = item.next;65item.next.prev = item.prev;66if (head == item) {67list = item.next;68}69}70item.next = null;71item.prev = null; // this is the null pointer we are seeing72}7374private void removeItems(int numItems) {75Item item = list;76if (item == null) {77return;78}79Item last = item.prev;80boolean done = false;81while (!done && numItems > 1) {82// the original code "done = (item == last);" triggered an infinite loop83// and was changed slightly in order to produce an exception instead.84done = (item.next == last.next);85item = item.next;86if (item.prev.remove) {87linkOut(item.prev);88}89}90}9192public void perform(int numItems) {93for (int i = 0; i < numItems; i++) {94linkIn(new Item(i == 0));95}96removeItems(numItems);97list = null;98}99100static public void main(String[] args) {101int caseCnt = 0;102Test6843752 bj = new Test6843752();103try {104for (; caseCnt < 500000;) {105int numItems = (++caseCnt % 2);106if ((caseCnt % 64) == 0) {107numItems = 5;108}109bj.perform(numItems);110if ((caseCnt % 100000) == 0) {111System.out.println("successfully performed " + caseCnt + " cases");112}113}114} catch (Exception e) {115System.out.println("ERROR: crashed during case " + caseCnt);116e.printStackTrace(System.out);117System.exit(97);118}119}120}121122123124