hotspot/test/compiler/uncommontrap/DeoptReallocFailure.java
author duke
Wed, 05 Jul 2017 22:24:41 +0200
changeset 41867 d62173b931bf
parent 40631 ed82623d7831
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     1
/*
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     4
 *
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     8
 *
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    13
 * accompanied this code).
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    14
 *
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    18
 *
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    21
 * questions.
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    22
 */
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    23
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    24
/*
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    25
 * @test
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    26
 * @bug 8146416
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    27
 * @library /test/lib /
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    28
 *
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    29
 * @build sun.hotspot.WhiteBox
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    30
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    31
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    32
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    33
 *      -XX:+WhiteBoxAPI -Xbatch -Xmx100m
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    34
 *      -XX:CompileCommand=exclude,compiler.uncommontrap.DeoptReallocFailure::main
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    35
 *      compiler.uncommontrap.DeoptReallocFailure
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    36
 *
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    37
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    38
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    39
package compiler.uncommontrap;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    40
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    41
import sun.hotspot.WhiteBox;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    42
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    43
import java.lang.reflect.Method;
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    44
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    45
public class DeoptReallocFailure {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    46
    static class MemoryChunk {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    47
        MemoryChunk other;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    48
        Object[][] array;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    49
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    50
        MemoryChunk(MemoryChunk other) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    51
            this.other = other;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    52
            array = new Object[1024 * 256][];
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    53
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    54
    }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    55
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    56
    static class NoEscape {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    57
        long f1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39261
diff changeset
    58
    }
39261
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    59
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    60
    static MemoryChunk root;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    61
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    62
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    63
    public static synchronized long  test() {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    64
        NoEscape[] noEscape = new NoEscape[45];
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    65
        noEscape[0] = new NoEscape();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    66
        for (int i=0;i<1024*256;i++) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    67
           root.array[i]= new Object[45];
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    68
        }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    69
        return noEscape[0].f1;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    70
    }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    71
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    72
    public static void main(String[] args) throws Throwable {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    73
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    74
        //Exhaust Memory
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    75
        root = null;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    76
        try {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    77
            while (true) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    78
                root = new MemoryChunk(root);
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    79
            }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    80
        } catch (OutOfMemoryError oom) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    81
        }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    82
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    83
        if (root == null) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    84
          return;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    85
        }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    86
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    87
        try {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    88
            NoEscape dummy = new NoEscape();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    89
            Method m = DeoptReallocFailure.class.getMethod("test");
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    90
            WB.enqueueMethodForCompilation(m, 4);
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    91
            test();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    92
        } catch (OutOfMemoryError oom) {
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    93
            root = null;
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    94
            oom.printStackTrace();
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    95
        }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    96
        System.out.println("TEST PASSED");
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    97
    }
18f007610de6 8146416: java.lang.OutOfMemoryError triggers: assert(current_bci == 0) failed: bci isn't zero for do_not_unlock_if_synchronized
jcm
parents:
diff changeset
    98
}