hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java
author ykantser
Mon, 04 May 2015 16:30:07 +0200
changeset 30604 b8d532cb6420
parent 29678 dd2f3932c21e
child 31587 e48945b7849c
permissions -rw-r--r--
8067013: Rename the com.oracle.java.testlibary package Reviewed-by: dholmes, gtriantafill, sla Contributed-by: alexander.kulyakhtin@oracle.com
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
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28040
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
27700
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
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    28
import jdk.test.lib.*;
27700
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
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28040
diff changeset
    35
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28040
diff changeset
    36
 *          java.management
27700
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    37
 * @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    38
 * @run main TestMonomorphicObjectCall
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    39
 */
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    40
public class TestMonomorphicObjectCall {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    41
    final static String testClasses = System.getProperty("test.classes") + File.separator;
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    42
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    43
    private static void callFinalize(Object object) throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    44
        // Call modified version of java.lang.Object::finalize() that is
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    45
        // 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
    46
        // as monomorphic and inline the method.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    47
        object.finalizeObject();
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    48
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    49
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    50
    public static void main(String[] args) throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    51
        if (args.length == 0) {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    52
            // Execute new instance with modified java.lang.Object
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    53
            executeTestJvm();
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    54
        } else {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    55
            // Trigger compilation of 'callFinalize'
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    56
            callFinalize(new Object());
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
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    59
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    60
    public static void executeTestJvm() throws Throwable {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    61
        // Execute test with modified version of java.lang.Object
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    62
        // in -Xbootclasspath.
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    63
        String[] vmOpts = new String[] {
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    64
                "-Xbootclasspath/p:" + testClasses,
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    65
                "-Xcomp",
28040
e68bdf210a7e 8066250: compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java fails product
iignatyev
parents: 27700
diff changeset
    66
                "-XX:+IgnoreUnrecognizedVMOptions",
27700
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    67
                "-XX:-VerifyDependencies",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    68
                "-XX:CompileOnly=TestMonomorphicObjectCall::callFinalize",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    69
                "-XX:CompileOnly=Object::finalizeObject",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    70
                "-XX:TieredStopAtLevel=1",
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    71
                TestMonomorphicObjectCall.class.getName(),
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    72
                "true"};
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    73
        OutputAnalyzer output = ProcessTools.executeTestJvm(vmOpts);
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    74
        output.shouldHaveExitValue(0);
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    75
    }
a402738ebfcf 8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer
thartmann
parents:
diff changeset
    76
}