1 /*
   2  * Copyright (c) 2015, 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 org.graalvm.compiler.hotspot;
  24 
  25 import org.graalvm.compiler.options.Option;
  26 import org.graalvm.compiler.options.OptionType;
  27 import org.graalvm.compiler.options.OptionValue;
  28 
  29 /**
  30  * Options related to {@link CompileTheWorld}.
  31  *
  32  * Note: This must be a top level class to work around for
  33  * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=477597">Eclipse bug 477597</a>.
  34  */
  35 public class CompileTheWorldOptions {
  36     // @formatter:off
  37     @Option(help = "Class path denoting methods to compile", type = OptionType.Debug)
  38     public static final OptionValue<String> CompileTheWorldClasspath = new OptionValue<>(CompileTheWorld.SUN_BOOT_CLASS_PATH);
  39     @Option(help = "Verbose CompileTheWorld operation", type = OptionType.Debug)
  40     public static final OptionValue<Boolean> CompileTheWorldVerbose = new OptionValue<>(true);
  41     @Option(help = "The number of CompileTheWorld iterations to perform", type = OptionType.Debug)
  42     public static final OptionValue<Integer> CompileTheWorldIterations = new OptionValue<>(1);
  43     @Option(help = "Only compile methods matching this filter", type = OptionType.Debug)
  44     public static final OptionValue<String> CompileTheWorldMethodFilter = new OptionValue<>(null);
  45     @Option(help = "Exclude methods matching this filter from compilation", type = OptionType.Debug)
  46     public static final OptionValue<String> CompileTheWorldExcludeMethodFilter = new OptionValue<>(null);
  47     @Option(help = "First class to consider when using -XX:+CompileTheWorld", type = OptionType.Debug)
  48     public static final OptionValue<Integer> CompileTheWorldStartAt = new OptionValue<>(1);
  49     @Option(help = "Last class to consider when using -XX:+CompileTheWorld", type = OptionType.Debug)
  50     public static final OptionValue<Integer> CompileTheWorldStopAt = new OptionValue<>(Integer.MAX_VALUE);
  51     @Option(help = "Option value overrides to use during compile the world. For example, " +
  52                    "to disable inlining and partial escape analysis specify 'PartialEscapeAnalysis=false Inline=false'. " +
  53                    "The format for each option is the same as on the command line just without the '-Dgraal.' prefix.", type = OptionType.Debug)
  54     public static final OptionValue<String> CompileTheWorldConfig = new OptionValue<>(null);
  55 
  56     @Option(help = "Run CTW using as many threads as there are processors on the system", type = OptionType.Debug)
  57     public static final OptionValue<Boolean> CompileTheWorldMultiThreaded = new OptionValue<>(false);
  58     @Option(help = "Number of threads to use for multithreaded CTW.  Defaults to Runtime.getRuntime().availableProcessors()", type = OptionType.Debug)
  59     public static final OptionValue<Integer> CompileTheWorldThreads = new OptionValue<>(0);
  60     // @formatter:on
  61 
  62     /**
  63      * Overrides {@link #CompileTheWorldStartAt} and {@link #CompileTheWorldStopAt} from {@code -XX}
  64      * HotSpot options of the same name if the latter have non-default values.
  65      */
  66     public static void overrideWithNativeOptions(GraalHotSpotVMConfig c) {
  67         if (c.compileTheWorldStartAt != 1) {
  68             CompileTheWorldStartAt.setValue(c.compileTheWorldStartAt);
  69         }
  70         if (c.compileTheWorldStopAt != Integer.MAX_VALUE) {
  71             CompileTheWorldStopAt.setValue(c.compileTheWorldStopAt);
  72         }
  73     }
  74 }