hotspot/test/compiler/loopopts/TestCountedLoopSafepointBackedge.java
author roland
Mon, 25 Jul 2016 14:31:42 -0700
changeset 40087 33cbd46c3241
child 40092 50da4636cb1c
permissions -rw-r--r--
8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled Summary: don't convert loop with safepoint on the backedge to Counted loop Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40087
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     1
/*
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     2
 * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     4
 *
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     8
 *
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    13
 * accompanied this code).
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    14
 *
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    18
 *
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    21
 * questions.
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    22
 */
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    23
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    24
/**
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    25
 * @test
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    26
 * @bug 8161147
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    27
 * @summary Safepoint on backedge breaks UseCountedLoopSafepoints
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+UseCountedLoopSafepoints TestCountedLoopSafepointBackedge
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    29
 *
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    30
 */
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    31
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    32
public class TestCountedLoopSafepointBackedge {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    33
    static void test(int[] arr, int inc) {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    34
        int i = 0;
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    35
        for (;;) {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    36
            for (int j = 0; j < 10; j++);
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    37
            arr[i] = i;
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    38
            i++;
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    39
            if (i >= 100) {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    40
                break;
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    41
            }
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    42
            for (int j = 0; j < 10; j++);
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    43
        }
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    44
    }
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    45
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    46
    static public void main(String[] args) {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    47
        int[] arr = new int[100];
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    48
        for (int i = 0; i < 20000; i++) {
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    49
             test(arr, 1);
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    50
        }
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    51
    }
33cbd46c3241 8161147: jvm crashes when -XX:+UseCountedLoopSafepoints is enabled
roland
parents:
diff changeset
    52
}