test/hotspot/jtreg/compiler/c2/SubsumingLoadsCauseFlagSpill.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 51521 76a51e26d0ac
permissions -rw-r--r--
8219157: vm/mlvm/mixed/stress/java/findDeadlock should be problem-listed only on mac Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51521
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     1
/*
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     2
 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     4
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     8
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    13
 * accompanied this code).
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    14
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    18
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    21
 * questions.
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    22
 */
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    23
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    24
/**
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    25
 * @test
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    26
 * @bug 8209639
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    27
 * @summary assert failure in coalesce.cpp: attempted to spill a non-spillable item
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    28
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,SubsumingLoadsCauseFlagSpill::not_inlined -Xmx1024m SubsumingLoadsCauseFlagSpill
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    30
 *
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    31
 */
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    32
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    33
public class SubsumingLoadsCauseFlagSpill {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    34
    private static Object field;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    35
    private static boolean do_throw;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    36
    private static volatile boolean barrier;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    37
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    38
    public static void main(String[] args) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    39
        for (int i = 0; i < 20_000; i++) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    40
            do_throw = true;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    41
            field = null;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    42
            test(0);
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    43
            do_throw = false;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    44
            field = new Object();
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    45
            test(0);
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    46
        }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    47
    }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    48
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    49
    private static float test(float f) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    50
        Object v = null;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    51
        try {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    52
            not_inlined();
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    53
            v = field;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    54
        } catch (MyException me) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    55
            v = field;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    56
            barrier = true;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    57
        }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    58
        if (v == null) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    59
            return f * f;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    60
        }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    61
        return f;
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    62
    }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    63
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    64
    private static void not_inlined() throws MyException{
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    65
        if (do_throw) {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    66
            throw new MyException();
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    67
        }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    68
    }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    69
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    70
    private static class MyException extends Throwable {
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    71
    }
76a51e26d0ac 8209639: assert failure in coalesce.cpp: attempted to spill a non-spillable item
roland
parents:
diff changeset
    72
}