test/hotspot/jtreg/compiler/c2/Test6843752.java
author epavlova
Mon, 02 Oct 2017 14:31:34 -0700
changeset 47576 7645833d326f
parent 47216 71c04702a3d5
child 50235 ff5d0ea58d9b
permissions -rw-r--r--
8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal Reviewed-by: kvn, dnsimon
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
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    28
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    29
 * @run main/othervm -Xbatch compiler.c2.Test6843752
2875
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
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    32
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    33
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    34
public class Test6843752 {
2875
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    35
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    36
    Item list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    37
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    38
    static class Item {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    39
        public Item    next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    40
        public Item    prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    41
        public boolean remove;
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
        Item(boolean r) { remove = r; }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    44
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    45
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    46
    private void linkIn(Item item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    47
        Item head = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    48
        if (head == null) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    49
            item.next = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    50
            item.prev = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    51
            list = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    52
        } else {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    53
            item.next = head;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    54
            item.prev = head.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    55
            head.prev.next = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    56
            head.prev = item;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    57
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    58
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    59
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    60
    private void linkOut(Item item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    61
        Item head = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    62
        if (item.next == item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    63
            list = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    64
        } else {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    65
            item.prev.next = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    66
            item.next.prev = item.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    67
            if (head == item) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    68
                list = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    69
            }
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
        item.next = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    72
        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
    73
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    74
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    75
    private void removeItems(int numItems) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    76
        Item item = list;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    77
        if (item == null) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    78
            return;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    79
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    80
        Item last = item.prev;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    81
        boolean done = false;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    82
        while (!done && numItems > 1) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    83
            // 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
    84
            // 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
    85
            done = (item.next == last.next);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    86
            item = item.next;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    87
            if (item.prev.remove) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    88
                linkOut(item.prev);
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
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    91
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    92
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    93
    public void perform(int numItems) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    94
        for (int i = 0; i < numItems; i++) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    95
            linkIn(new Item(i == 0));
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
        removeItems(numItems);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    98
        list = null;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
    99
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   100
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   101
    static public void main(String[] args) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   102
        int caseCnt = 0;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   103
        Test6843752 bj = new Test6843752();
2875
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   104
        try {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   105
            for (; caseCnt < 500000;) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   106
                int numItems = (++caseCnt % 2);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   107
                if ((caseCnt % 64) == 0) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   108
                    numItems = 5;
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   109
                }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   110
                bj.perform(numItems);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   111
                if ((caseCnt % 100000) == 0) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   112
                    System.out.println("successfully performed " + caseCnt + " cases");
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   113
                }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   114
            }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   115
        } catch (Exception e) {
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   116
            System.out.println("ERROR: crashed during case " + caseCnt);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   117
            e.printStackTrace(System.out);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   118
            System.exit(97);
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   119
        }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   120
    }
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   121
}
549b4d80b29e 6843752: missing code for an anti-dependent Phi in GCM
kvn
parents:
diff changeset
   122