< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompilerFactory.java

Print this page




   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 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static jdk.vm.ci.common.InitTimer.timer;

  28 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX;
  29 
  30 import java.io.PrintStream;
  31 
  32 import org.graalvm.compiler.api.runtime.GraalRuntime;
  33 import org.graalvm.compiler.debug.MethodFilter;
  34 import org.graalvm.compiler.options.Option;
  35 import org.graalvm.compiler.options.OptionKey;
  36 import org.graalvm.compiler.options.OptionType;
  37 import org.graalvm.compiler.options.OptionValues;
  38 import org.graalvm.compiler.options.OptionsParser;
  39 import org.graalvm.compiler.phases.tiers.CompilerConfiguration;
  40 
  41 import jdk.vm.ci.common.InitTimer;
  42 import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
  43 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  44 import jdk.vm.ci.hotspot.HotSpotSignature;
  45 import jdk.vm.ci.runtime.JVMCIRuntime;
  46 
  47 public final class HotSpotGraalCompilerFactory extends HotSpotJVMCICompilerFactory {


  54     private final HotSpotGraalJVMCIServiceLocator locator;
  55 
  56     HotSpotGraalCompilerFactory(HotSpotGraalJVMCIServiceLocator locator) {
  57         this.locator = locator;
  58     }
  59 
  60     @Override
  61     public String getCompilerName() {
  62         return "graal";
  63     }
  64 
  65     /**
  66      * Initialized when this factory is {@linkplain #onSelection() selected}.
  67      */
  68     private OptionValues options;
  69 
  70     @Override
  71     public void onSelection() {
  72         JVMCIVersionCheck.check(false);
  73         assert options == null : "cannot select " + getClass() + " service more than once";
  74         options = HotSpotGraalOptionValues.HOTSPOT_OPTIONS;
  75         initializeGraalCompilePolicyFields(options);
  76         isGraalPredicate = compileGraalWithC1Only ? new IsGraalPredicate() : null;
  77         /*
  78          * Exercise this code path early to encourage loading now. This doesn't solve problem of
  79          * deadlock during class loading but seems to eliminate it in practice.
  80          */
  81         adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.FullOptimization);
  82         adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.Simple);




  83     }
  84 
  85     private static void initializeGraalCompilePolicyFields(OptionValues options) {
  86         compileGraalWithC1Only = Options.CompileGraalWithC1Only.getValue(options);
  87         String optionValue = Options.GraalCompileOnly.getValue(options);
  88         if (optionValue != null) {
  89             MethodFilter[] filter = MethodFilter.parse(optionValue);
  90             if (filter.length == 0) {
  91                 filter = null;
  92             }
  93             graalCompileOnlyFilter = filter;
  94         }
  95     }
  96 
  97     @Override
  98     public void printProperties(PrintStream out) {
  99         out.println("[Graal properties]");
 100         options.printHelp(OptionsParser.getOptionsLoader(), out, GRAAL_OPTION_PROPERTY_PREFIX);
 101     }
 102 




   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 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static jdk.vm.ci.common.InitTimer.timer;
  28 import static jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE;
  29 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX;
  30 
  31 import java.io.PrintStream;
  32 
  33 import org.graalvm.compiler.api.runtime.GraalRuntime;
  34 import org.graalvm.compiler.debug.MethodFilter;
  35 import org.graalvm.compiler.options.Option;
  36 import org.graalvm.compiler.options.OptionKey;
  37 import org.graalvm.compiler.options.OptionType;
  38 import org.graalvm.compiler.options.OptionValues;
  39 import org.graalvm.compiler.options.OptionsParser;
  40 import org.graalvm.compiler.phases.tiers.CompilerConfiguration;
  41 
  42 import jdk.vm.ci.common.InitTimer;
  43 import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
  44 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  45 import jdk.vm.ci.hotspot.HotSpotSignature;
  46 import jdk.vm.ci.runtime.JVMCIRuntime;
  47 
  48 public final class HotSpotGraalCompilerFactory extends HotSpotJVMCICompilerFactory {


  55     private final HotSpotGraalJVMCIServiceLocator locator;
  56 
  57     HotSpotGraalCompilerFactory(HotSpotGraalJVMCIServiceLocator locator) {
  58         this.locator = locator;
  59     }
  60 
  61     @Override
  62     public String getCompilerName() {
  63         return "graal";
  64     }
  65 
  66     /**
  67      * Initialized when this factory is {@linkplain #onSelection() selected}.
  68      */
  69     private OptionValues options;
  70 
  71     @Override
  72     public void onSelection() {
  73         JVMCIVersionCheck.check(false);
  74         assert options == null : "cannot select " + getClass() + " service more than once";
  75         options = HotSpotGraalOptionValues.defaultOptions();
  76         initializeGraalCompilePolicyFields(options);
  77         isGraalPredicate = compileGraalWithC1Only ? new IsGraalPredicate() : null;
  78         /*
  79          * Exercise this code path early to encourage loading now. This doesn't solve problem of
  80          * deadlock during class loading but seems to eliminate it in practice.
  81          */
  82         adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.FullOptimization);
  83         adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.Simple);
  84         if (IS_BUILDING_NATIVE_IMAGE) {
  85             // Triggers initialization of all option descriptors
  86             Options.CompileGraalWithC1Only.getName();
  87         }
  88     }
  89 
  90     private static void initializeGraalCompilePolicyFields(OptionValues options) {
  91         compileGraalWithC1Only = Options.CompileGraalWithC1Only.getValue(options);
  92         String optionValue = Options.GraalCompileOnly.getValue(options);
  93         if (optionValue != null) {
  94             MethodFilter[] filter = MethodFilter.parse(optionValue);
  95             if (filter.length == 0) {
  96                 filter = null;
  97             }
  98             graalCompileOnlyFilter = filter;
  99         }
 100     }
 101 
 102     @Override
 103     public void printProperties(PrintStream out) {
 104         out.println("[Graal properties]");
 105         options.printHelp(OptionsParser.getOptionsLoader(), out, GRAAL_OPTION_PROPERTY_PREFIX);
 106     }
 107 


< prev index next >