hotspot/test/compiler/escapeAnalysis/TestEABadMergeMem.java
author ppunegov
Tue, 24 Nov 2015 21:03:39 +0300
changeset 34218 4b22b04519e6
parent 32579 268acc7bc111
child 40059 c2304140ed64
permissions -rw-r--r--
8142967: [TESTBUG] Compiler control tests get NullPointerException Summary: Fix incoorect build jtreg tags Reviewed-by: iignatyev, neliasso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32579
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     1
/*
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     4
 *
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     8
 *
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    13
 * accompanied this code).
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    14
 *
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    18
 *
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    21
 * questions.
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    22
 */
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    23
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    24
/*
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    25
 * @test
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    26
 * @bug 8134031
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    27
 * @summary Bad rewiring of memory edges when we split unique types during EA
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestEABadMergeMem::m_notinlined TestEABadMergeMem
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    29
 *
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    30
 */
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    31
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    32
public class TestEABadMergeMem {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    33
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    34
    static class Box {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    35
        int i;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    36
    }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    37
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    38
    static void m_notinlined() {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    39
    }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    40
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    41
    static float dummy1;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    42
    static float dummy2;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    43
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    44
    static int test(Box a, Box c, int i, int j, int k, boolean flag1, boolean flag2) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    45
        Box b = new Box(); // non escaping
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    46
        a.i = i;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    47
        b.i = j;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    48
        c.i = k;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    49
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    50
        m_notinlined();
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    51
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    52
        boolean flag3 = false;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    53
        if (flag1) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    54
            for (int ii = 0; ii < 100; ii++) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    55
                if (flag2) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    56
                    dummy1 = (float)ii;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    57
                } else {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    58
                    dummy2 = (float)ii;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    59
                }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    60
            }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    61
            flag3 = true;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    62
        }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    63
        // Memory Phi here with projection of not inlined call as one edge, MergeMem as other
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    64
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    65
        if (flag3) { // will split through Phi during loopopts
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    66
            int res = c.i + b.i;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    67
            m_notinlined(); // prevents split through phi during igvn
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    68
            return res;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    69
        } else {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    70
            return 44 + 43;
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    71
        }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    72
    }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    73
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    74
    static public void main(String[] args) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    75
        for (int i = 0; i < 20000; i++) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    76
            // m(2);
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    77
            Box a = new Box();
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    78
            Box c = new Box();
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    79
            int res = test(a, c, 42, 43, 44, (i%2) == 0, (i%3) == 0);
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    80
            if (res != 44 + 43) {
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    81
                throw new RuntimeException("Bad result " + res);
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    82
            }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    83
        }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    84
    }
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    85
268acc7bc111 8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff changeset
    86
}