hotspot/test/compiler/6843752/Test.java
author adlertz
Fri, 24 Jan 2014 13:06:52 +0100
changeset 22804 401135897b65
parent 5547 f4b087cbb361
permissions -rw-r--r--
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical Summary: Created sub-functions, added data structures, improved naming and removed unnecessary code Reviewed-by: kvn, roland, rbackman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2875
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2875
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
2875
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     4
 *
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     8
 *
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    13
 * accompanied this code).
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    14
 *
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2875
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2875
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2875
diff changeset
    21
 * questions.
2875
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    22
 */
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    23
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    24
/*
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    25
 * @test
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    26
 * @bug 6843752
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    27
 * @summary missing code for an anti-dependent Phi in GCM
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    28
 * @run main/othervm -Xbatch Test
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    29
 */
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    30
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    31
public class Test {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    32
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    33
    Item list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    34
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    35
    static class Item {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    36
        public Item    next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    37
        public Item    prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    38
        public boolean remove;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    39
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    40
        Item(boolean r) { remove = r; }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    41
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    42
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    43
    private void linkIn(Item item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    44
        Item head = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    45
        if (head == null) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    46
            item.next = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    47
            item.prev = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    48
            list = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    49
        } else {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    50
            item.next = head;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    51
            item.prev = head.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    52
            head.prev.next = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    53
            head.prev = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    54
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    55
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    56
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    57
    private void linkOut(Item item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    58
        Item head = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    59
        if (item.next == item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    60
            list = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    61
        } else {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    62
            item.prev.next = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    63
            item.next.prev = item.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    64
            if (head == item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    65
                list = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    66
            }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    67
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    68
        item.next = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    69
        item.prev = null; // this is the null pointer we are seeing
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    70
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    71
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    72
    private void removeItems(int numItems) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    73
        Item item = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    74
        if (item == null) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    75
            return;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    76
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    77
        Item last = item.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    78
        boolean done = false;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    79
        while (!done && numItems > 1) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    80
            // the original code "done = (item == last);" triggered an infinite loop
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    81
            // and was changed slightly in order to produce an exception instead.
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    82
            done = (item.next == last.next);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    83
            item = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    84
            if (item.prev.remove) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    85
                linkOut(item.prev);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    86
            }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    87
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    88
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    89
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    90
    public void perform(int numItems) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    91
        for (int i = 0; i < numItems; i++) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    92
            linkIn(new Item(i == 0));
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    93
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    94
        removeItems(numItems);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    95
        list = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    96
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    97
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    98
    static public void main(String[] args) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    99
        int caseCnt = 0;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   100
        Test bj = new Test();
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   101
        try {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   102
            for (; caseCnt < 500000;) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   103
                int numItems = (++caseCnt % 2);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   104
                if ((caseCnt % 64) == 0) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   105
                    numItems = 5;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   106
                }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   107
                bj.perform(numItems);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   108
                if ((caseCnt % 100000) == 0) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   109
                    System.out.println("successfully performed " + caseCnt + " cases");
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   110
                }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   111
            }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   112
        } catch (Exception e) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   113
            System.out.println("ERROR: crashed during case " + caseCnt);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   114
            e.printStackTrace(System.out);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   115
            System.exit(97);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   116
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   117
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   118
}
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   119