hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java
author thartmann
Thu, 20 Nov 2014 11:06:26 +0100
changeset 27700 a402738ebfcf
child 28040 e68bdf210a7e
permissions -rw-r--r--
8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer Summary: Ignore non-instance Klasses in the subclass hierarchy. Reviewed-by: kvn, iignatyev, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27700
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     1
/*
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     4
 *
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     8
 *
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    13
 * accompanied this code).
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    14
 *
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    18
 *
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    21
 * questions.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    22
 */
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    23
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    24
import java.io.File;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    25
import java.util.ArrayList;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    26
import java.util.Collections;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    27
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    28
import com.oracle.java.testlibrary.*;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    29
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    30
/*
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    31
 * @test
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    32
 * @bug 8050079
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    33
 * @summary Compiles a monomorphic call to finalizeObject() on a modified java.lang.Object to test C1 CHA.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    34
 * @library /testlibrary
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    35
 * @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    36
 * @run main TestMonomorphicObjectCall
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    37
 */
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    38
public class TestMonomorphicObjectCall {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    39
    final static String testClasses = System.getProperty("test.classes") + File.separator;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    40
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    41
    private static void callFinalize(Object object) throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    42
        // Call modified version of java.lang.Object::finalize() that is
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    43
        // not overridden by any subclass. C1 CHA should mark the call site
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    44
        // as monomorphic and inline the method.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    45
        object.finalizeObject();
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    46
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    47
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    48
    public static void main(String[] args) throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    49
        if (args.length == 0) {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    50
            // Execute new instance with modified java.lang.Object
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    51
            executeTestJvm();
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    52
        } else {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    53
            // Trigger compilation of 'callFinalize'
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    54
            callFinalize(new Object());
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    55
        }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    56
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    57
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    58
    public static void executeTestJvm() throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    59
        // Execute test with modified version of java.lang.Object
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    60
        // in -Xbootclasspath.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    61
        String[] vmOpts = new String[] {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    62
                "-Xbootclasspath/p:" + testClasses,
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    63
                "-Xcomp",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    64
                "-XX:-VerifyDependencies",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    65
                "-XX:CompileOnly=TestMonomorphicObjectCall::callFinalize",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    66
                "-XX:CompileOnly=Object::finalizeObject",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    67
                "-XX:TieredStopAtLevel=1",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    68
                TestMonomorphicObjectCall.class.getName(),
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    69
                "true"};
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    70
        OutputAnalyzer output = ProcessTools.executeTestJvm(vmOpts);
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    71
        output.shouldHaveExitValue(0);
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    72
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    73
}