test/hotspot/jtreg/compiler/inlining/StringConcatInfiniteLoop.java
author roland
Fri, 07 Dec 2018 17:56:51 +0100
changeset 53220 c14b7b6a9b2f
permissions -rw-r--r--
8214862: assert(proj != __null) at compile.cpp:3251 Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53220
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     1
/*
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     2
 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     4
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     8
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    13
 * accompanied this code).
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    14
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    18
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    21
 * questions.
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    22
 */
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    23
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    24
/*
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    25
 * @test 8214862
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    26
 * @summary Multiple passes of PhaseRemoveUseless causes infinite loop to be optimized out
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    27
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-TieredCompilation -Xcomp -XX:CompileOnly=StringConcatInfiniteLoop::test -XX:CompileCommand=dontinline,*StringBuilder::* StringConcatInfiniteLoop
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    29
 *
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    30
 */
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    31
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    32
public class StringConcatInfiniteLoop {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    33
    public static void main(String[] args) {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    34
        StringBuilder sb = new StringBuilder();
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    35
        test(sb, "foo", "bar", true);
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    36
    }
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    37
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    38
    private static void test(Object v, String s1, String s2, boolean flag) {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    39
        if (flag) {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    40
            return;
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    41
        }
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    42
        int i = 0;
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    43
        for (; i < 10; i++);
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    44
        if (i == 10) {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    45
            v = null;
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    46
        }
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    47
        StringBuilder sb = new StringBuilder(s1);
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    48
        sb.append(s2);
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    49
        while (v == null);
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    50
    }
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    51
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    52
    private static class A {
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    53
    }
c14b7b6a9b2f 8214862: assert(proj != __null) at compile.cpp:3251
roland
parents:
diff changeset
    54
}