test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 8767
7b8c8cd1ee71
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

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

mercurial