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;
  24 
  25 import java.util.Collections;
  26 import java.util.Map;
  27 import jdk.vm.ci.runtime.JVMCICompilerFactory;
  28 
  29 /**
  30  * HotSpot extensions to {@link JVMCICompilerFactory}.
  31  */
  32 public abstract class HotSpotJVMCICompilerFactory implements JVMCICompilerFactory {
  33 
  34     /**
  35      * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode
  36      * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The
  37      * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci".
  38      *
  39      * @return 0 or more Strings identifying packages that should by compiled by the first tier only
  40      *         or null if no redirection to C1 should be performed.
  41      */
  42     public String[] getTrivialPrefixes() {
  43         return null;
  44     }
  45 
  46     public enum CompilationLevelAdjustment {
  47         /**
  48          * No adjustment.
  49          */
  50         None,
  51 
  52         /**
  53          * Adjust based on declaring class of method.
  54          */
  55         ByHolder,
  56 
  57         /**
  58          * Adjust based on declaring class, name and signature of method.
  59          */
  60         ByFullSignature
  61     }
  62 
  63     /**
  64      * Determines if this object may want to adjust the compilation level for a method that is being
  65      * scheduled by the VM for compilation.
  66      */
  67     public CompilationLevelAdjustment getCompilationLevelAdjustment() {
  68         return CompilationLevelAdjustment.None;
  69     }
  70 
  71     public enum CompilationLevel {
  72         None,
  73         Simple,
  74         LimitedProfile,
  75         FullProfile,
  76         FullOptimization
  77     }
  78 
  79     /**
  80      * Potentially modifies the compilation level currently selected by the VM compilation policy
  81      * for a method.
  82      *
  83      * @param declaringClass the class in which the method is declared
  84      * @param name the name of the method or {@code null} depending on the value that was returned
  85      *            by {@link #getCompilationLevelAdjustment()}
  86      * @param signature the signature of the method or {@code null} depending on the value that was
  87      *            returned by {@link #getCompilationLevelAdjustment()}
  88      * @param isOsr specifies if the compilation being scheduled in an OSR compilation
  89      * @param level the compilation level currently selected by the VM compilation policy
  90      * @return the compilation level to use for the compilation being scheduled (must be a valid
  91      *         {@code CompLevel} enum value)
  92      */
  93     public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) {
  94         throw new InternalError("Should not reach here");
  95     }
  96 
  97     /**
  98      * Provides compiler specific platform MBeans. These MBeans will be automatically
  99      * exposed once the management system gets initialized.
 100      *
 101      * @return map from MBean names to their instances
 102      */
 103     public Map<String, Object> mbeans() {
 104         return Collections.emptyMap();
 105     }
 106 }