1 /*
   2  * Copyright (c) 2016, 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  */
  23 package jdk.vm.ci.hotspot.services;
  24 
  25 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  26 import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
  27 
  28 /**
  29  * HotSpot extensions to {@link JVMCICompilerFactory}.
  30  */
  31 public abstract class HotSpotJVMCICompilerFactory extends JVMCICompilerFactory {
  32 
  33     /**
  34      * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
  35      * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
  36      * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
  37      *
  38      * @return 0 or more Strings identifying packages that should by compiled by the first tier only
  39      *         or null if no redirection to C1 should be performed.
  40      */
  41     public String[] getTrivialPrefixes() {
  42         return null;
  43     }
  44 
  45     /**
  46      * Determines if this object may want to adjust the compilation level for a method that is being
  47      * scheduled by the VM for compilation. The legal return values and their meanings are:
  48      * <ul>
  49      * <li>0 - no adjustment</li>
  50      * <li>1 - adjust based on declaring class of method</li>
  51      * <li>2 - adjust based on declaring class, name and signature of method</li>
  52      * </ul>
  53      */
  54     @SuppressWarnings("unexportedinapi")
  55     public int getCompilationLevelAdjustment(HotSpotVMConfig config) {
  56         return config.compLevelAdjustmentNone;
  57     }
  58 
  59     /**
  60      * Potentially modifies the compilation level currently selected by the VM compilation policy
  61      * for a method.
  62      *
  63      * @param config object for reading HotSpot {@code CompLevel} enum values
  64      * @param declaringClass the class in which the method is declared
  65      * @param name the name of the method or {@code null} depending on the value that was returned
  66      *            by {@link #getCompilationLevelAdjustment(HotSpotVMConfig)}
  67      * @param signature the signature of the method or {@code null} depending on the value that was
  68      *            returned by {@link #getCompilationLevelAdjustment(HotSpotVMConfig)}
  69      * @param isOsr specifies if the compilation being scheduled in an OSR compilation
  70      * @param level the compilation level currently selected by the VM compilation policy
  71      * @return the compilation level to use for the compilation being scheduled (must be a valid
  72      *         {@code CompLevel} enum value)
  73      */
  74     @SuppressWarnings("unexportedinapi")
  75     public int adjustCompilationLevel(HotSpotVMConfig config, Class<?> declaringClass, String name, String signature, boolean isOsr, int level) {
  76         throw new InternalError("Should not reach here");
  77     }
  78 }