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