test/hotspot/jtreg/compiler/types/TestSpeculationFailedHigherEqual.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 47216 71c04702a3d5
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:
22799
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     1
/*
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     4
 *
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     8
 *
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    13
 * accompanied this code).
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    14
 *
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    18
 *
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    21
 * questions.
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    22
 */
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    23
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    24
/*
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    25
 * @test
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    26
 * @bug 8027422
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    27
 * @summary type methods shouldn't always operate on speculative part
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    29
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    30
 *                   -XX:+UseTypeSpeculation -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    31
 *                   compiler.types.TestSpeculationFailedHigherEqual
22799
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    32
 */
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    33
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    34
package compiler.types;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    35
22799
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    36
public class TestSpeculationFailedHigherEqual {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    37
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    38
    static class A {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    39
        void m() {}
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    40
        int i;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    41
    }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    42
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    43
    static class C extends A {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    44
    }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    45
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    46
    static C c;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    47
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    48
    static A m1(A a, boolean cond) {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    49
        // speculative type for a is C not null
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    50
        if (cond ) {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    51
            a = c;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    52
        }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    53
        // speculative type for a is C (may be null)
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    54
        int i = a.i;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    55
        return a;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    56
    }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    57
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    58
    static public void main(String[] args) {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    59
        C c = new C();
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    60
        TestSpeculationFailedHigherEqual.c = c;
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    61
        for (int i = 0; i < 20000; i++) {
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    62
            m1(c, i%2 == 0);
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    63
        }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    64
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    65
        System.out.println("TEST PASSED");
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    66
    }
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
diff changeset
    67
}