hotspot/test/runtime/handlerInTry/LoadHandlerInTry.java
author tschatzl
Wed, 19 Aug 2015 13:47:40 +0200
changeset 32377 5ee15c417d02
parent 30102 d932845db0fe
child 43179 06ccf3bfd0a3
permissions -rw-r--r--
8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure Summary: Remember for every generation whether the memory for that generation has already been exhausted. If so, do not try to get a new region for these generations. Further, if the last generation is full, early exit from copy_to_survivor_space. Reviewed-by: jmasa, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30102
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     1
/*
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     4
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     8
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    13
 * accompanied this code).
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    14
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    18
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    21
 * questions.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    22
 */
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    23
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    24
/*
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    25
 * @test
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    26
 * @bug 8075118
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    27
 * @summary Allow a ctor to call super() from a switch bytecode.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    28
 * @compile HandlerInTry.jasm
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    29
 * @compile IsolatedHandlerInTry.jasm
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    30
 * @run main/othervm -Xverify:all LoadHandlerInTry
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    31
 */
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    32
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    33
/*
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    34
 * This test has two cases:
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    35
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    36
 * 1. class HandlerInTry:  Class HandlerInTry contains a TRY block in a
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    37
 *    constructor whose handler is inside the same TRY block.  The last
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    38
 *    few bytecodes and exception table look like this:
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    39
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    40
 *         ...
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    41
 *      87: athrow
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    42
 *      88: astore        4
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    43
 *      90: invokestatic  #9
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    44
 *      93: aload         4
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    45
 *      95: athrow
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    46
 *      96: return
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    47
 *    Exception table:
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    48
 *       from    to  target type
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    49
 *          36    46    53   Class java/lang/Throwable
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    50
 *          36    46    88   any
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    51
 *          53    90    88   any
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    52
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    53
 * Note that the target for the third handler in the Exception table is
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    54
 * inside its TRY block.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    55
 * Without the fix for bug JDK-8075118, this test will time out.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    56
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    57
 *
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    58
 * 2. class IsolatedHandlerInTry: Class IsolatedHandlerInTry also contains
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    59
 *    a TRY block in a constructoer whose handler is inside its TRY block.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    60
 *    But the handler is only reachable if an exception is thrown.  The
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    61
 *    handler's bytecodes will not get parsed as part of parsing the TRY
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    62
 *    block.  They will only get parsed as a handler for the TRY block.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    63
 *    Since the isolated handler does a 'return', a VerifyError exception
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    64
 *    should get thrown.
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    65
 */
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    66
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    67
public class LoadHandlerInTry {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    68
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    69
    public static void main(String[] args) throws Exception {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    70
        System.out.println("Regression test for bug 8075118");
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    71
        try {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    72
            Class newClass = Class.forName("HandlerInTry");
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    73
        } catch (Exception e) {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    74
            System.out.println("Failed: Exception was thrown: " + e.toString());
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    75
            throw e;
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    76
        }
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    77
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    78
        try {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    79
            Class newClass = Class.forName("IsolatedHandlerInTry");
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    80
            throw new RuntimeException(
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    81
                 "Failed to throw VerifyError for IsolatedHandlerInTry");
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    82
        } catch (java.lang.VerifyError e) {
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    83
            System.out.println("Passed: VerifyError exception was thrown");
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    84
        }
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    85
    }
d932845db0fe 8075118: JVM stuck in infinite loop during verification
hseigel
parents:
diff changeset
    86
}