test/hotspot/jtreg/compiler/c2/Test7024475.java
author epavlova
Mon, 02 Oct 2017 14:31:34 -0700
changeset 47576 7645833d326f
parent 47216 71c04702a3d5
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:
8870
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     1
/*
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     4
 *
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     8
 *
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    13
 * accompanied this code).
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    14
 *
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    18
 *
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    21
 * questions.
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    22
 */
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    23
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    24
/**
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    25
 * @test
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    26
 * @bug 7024475
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    27
 * @summary loop doesn't terminate when compiled
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    29
 * @run main compiler.c2.Test7024475
8870
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    30
 */
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
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
8870
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    34
public class Test7024475 {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    35
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    36
    static int i;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    37
    static int x1;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    38
    static int[] bucket_B;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    39
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    40
    static void test(Test7024475 test, int i, int c0, int j, int c1) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    41
        for (;;) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    42
            if (c1 > c0) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    43
                if (c0 > 253) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    44
                    throw new InternalError("c0 = " + c0);
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    45
                }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    46
                int index = c0 * 256 + c1;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    47
                if (index == -1) return;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    48
                i = bucket_B[index];
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    49
                if (1 < j - i && test != null)
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    50
                    x1 = 0;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    51
                j = i;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    52
                c1--;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    53
            } else {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    54
                c0--;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    55
                if (j <= 0)
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    56
                    break;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    57
                c1 = 255;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    58
            }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    59
        }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    60
    }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    61
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    62
    public static void main(String args[]) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    63
        Test7024475 t = new Test7024475();
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    64
        bucket_B = new int[256*256];
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    65
        for (int i = 1; i < 256*256; i++) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    66
            bucket_B[i] = 1;
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    67
        }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    68
        for (int n = 0; n < 100000; n++) {
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    69
            test(t, 2, 85, 1, 134);
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    70
        }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    71
    }
119881dc9d0b 7024475: loop doesn't terminate when compiled
never
parents:
diff changeset
    72
}