hotspot/test/compiler/c2/TestReplacedNodesOSR.java
author roland
Thu, 16 Feb 2017 15:14:44 -0800
changeset 43971 2b2aaae30f0c
permissions -rw-r--r--
8175097: [TESTBUG] 8174164 fix missed the test Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43971
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     1
/*
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     2
 * Copyright (c) 2017, Red Hat, Inc. All rights reserved.
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     4
 *
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     8
 *
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    13
 * accompanied this code).
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    14
 *
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    18
 *
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    21
 * questions.
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    22
 */
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    23
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    24
/**
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    25
 * @test
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    26
 * @bug 8174164
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    27
 * @summary SafePointNode::_replaced_nodes breaks with irreducible loops
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-BackgroundCompilation TestReplacedNodesOSR
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    29
 *
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    30
 */
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    31
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    32
public class TestReplacedNodesOSR {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    33
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    34
    static Object dummy;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    35
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    36
    static interface I {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    37
    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    38
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    39
    static class A implements I {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    40
    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    41
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    42
    static final class MyException extends Exception {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    43
    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    44
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    45
    static final A obj = new A();
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    46
    static I static_field() { return obj; }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    47
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    48
    // When OSR compiled, this method has an irreducible loop
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    49
    static void test(int v, MyException e) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    50
        int i = 0;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    51
        for (;;) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    52
            if (i == 1000) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    53
                break;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    54
            }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    55
            try {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    56
                if ((i%2) == 0) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    57
                    int j = 0;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    58
                    for (;;) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    59
                        j++;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    60
                        if (i+j != v) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    61
                            if (j == 1000) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    62
                                break;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    63
                            }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    64
                        } else {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    65
                            A a = (A)static_field();
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    66
                            // replaced node recorded here
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    67
                            throw e;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    68
                        }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    69
                    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    70
                }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    71
            } catch(MyException ex) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    72
            }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    73
            i++;
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    74
            // replaced node applied on return of the method
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    75
            // replaced node used here
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    76
            dummy = static_field();
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    77
        }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    78
    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    79
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    80
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    81
    static public void main(String[] args) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    82
        for (int i = 0; i < 1000; i++) {
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    83
            test(1100, new MyException());
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    84
        }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    85
    }
2b2aaae30f0c 8175097: [TESTBUG] 8174164 fix missed the test
roland
parents:
diff changeset
    86
}