src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/AOTInliningPolicy.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/AOTInliningPolicy.java

Print this page




  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.phases.aot;
  24 
  25 import static org.graalvm.compiler.core.common.GraalOptions.InlineEverything;
  26 import static org.graalvm.compiler.core.common.GraalOptions.TrivialInliningSize;
  27 
  28 import java.util.Map;
  29 
  30 import org.graalvm.compiler.hotspot.FingerprintUtil;
  31 import org.graalvm.compiler.nodes.Invoke;
  32 import org.graalvm.compiler.nodes.spi.Replacements;
  33 import org.graalvm.compiler.options.Option;
  34 import org.graalvm.compiler.options.OptionKey;
  35 import org.graalvm.compiler.options.OptionType;
  36 import org.graalvm.compiler.options.OptionValues;
  37 import org.graalvm.compiler.phases.common.inlining.InliningUtil;
  38 import org.graalvm.compiler.phases.common.inlining.info.InlineInfo;
  39 import org.graalvm.compiler.phases.common.inlining.policy.GreedyInliningPolicy;
  40 import org.graalvm.compiler.phases.common.inlining.walker.MethodInvocation;
  41 
  42 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  43 
  44 public class AOTInliningPolicy extends GreedyInliningPolicy {
  45     public static class Options {
  46         // @formatter:off
  47         @Option(help = "", type = OptionType.Expert)
  48         public static final OptionKey<Double> AOTInliningDepthToSizeRate = new OptionKey<>(2.5);
  49         @Option(help = "", type = OptionType.Expert)
  50         public static final OptionKey<Integer> AOTInliningSizeMaximum = new OptionKey<>(300);
  51         @Option(help = "", type = OptionType.Expert)
  52         public static final OptionKey<Integer> AOTInliningSizeMinimum = new OptionKey<>(50);
  53         // @formatter:on
  54     }
  55 
  56     public AOTInliningPolicy(Map<Invoke, Double> hints) {
  57         super(hints);
  58     }
  59 
  60     protected double maxInliningSize(int inliningDepth, OptionValues options) {
  61         return Math.max(Options.AOTInliningSizeMaximum.getValue(options) / (inliningDepth * Options.AOTInliningDepthToSizeRate.getValue(options)), Options.AOTInliningSizeMinimum.getValue(options));
  62     }
  63 
  64     @Override
  65     public boolean isWorthInlining(Replacements replacements, MethodInvocation invocation, int inliningDepth, boolean fullyProcessed) {
  66         final InlineInfo info = invocation.callee();
  67 
  68         for (int i = 0; i < info.numberOfMethods(); ++i) {
  69             HotSpotResolvedObjectType t = (HotSpotResolvedObjectType) info.methodAt(i).getDeclaringClass();
  70             if (FingerprintUtil.getFingerprint(t) == 0) {
  71                 return false;
  72             }
  73         }
  74 
  75         final double probability = invocation.probability();
  76         final double relevance = invocation.relevance();
  77 
  78         OptionValues options = info.graph().getOptions();
  79         if (InlineEverything.getValue(options)) {
  80             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
  81             return true;
  82         }
  83 
  84         if (isIntrinsic(replacements, info)) {
  85             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
  86             return true;
  87         }
  88 
  89         if (info.shouldInline()) {
  90             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "forced inlining");




  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.phases.aot;
  24 
  25 import static org.graalvm.compiler.core.common.GraalOptions.InlineEverything;
  26 import static org.graalvm.compiler.core.common.GraalOptions.TrivialInliningSize;
  27 
  28 import java.util.Map;
  29 

  30 import org.graalvm.compiler.nodes.Invoke;
  31 import org.graalvm.compiler.nodes.spi.Replacements;
  32 import org.graalvm.compiler.options.Option;
  33 import org.graalvm.compiler.options.OptionKey;
  34 import org.graalvm.compiler.options.OptionType;
  35 import org.graalvm.compiler.options.OptionValues;
  36 import org.graalvm.compiler.phases.common.inlining.InliningUtil;
  37 import org.graalvm.compiler.phases.common.inlining.info.InlineInfo;
  38 import org.graalvm.compiler.phases.common.inlining.policy.GreedyInliningPolicy;
  39 import org.graalvm.compiler.phases.common.inlining.walker.MethodInvocation;
  40 
  41 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  42 
  43 public class AOTInliningPolicy extends GreedyInliningPolicy {
  44     public static class Options {
  45         // @formatter:off
  46         @Option(help = "", type = OptionType.Expert)
  47         public static final OptionKey<Double> AOTInliningDepthToSizeRate = new OptionKey<>(2.5);
  48         @Option(help = "", type = OptionType.Expert)
  49         public static final OptionKey<Integer> AOTInliningSizeMaximum = new OptionKey<>(300);
  50         @Option(help = "", type = OptionType.Expert)
  51         public static final OptionKey<Integer> AOTInliningSizeMinimum = new OptionKey<>(50);
  52         // @formatter:on
  53     }
  54 
  55     public AOTInliningPolicy(Map<Invoke, Double> hints) {
  56         super(hints);
  57     }
  58 
  59     protected double maxInliningSize(int inliningDepth, OptionValues options) {
  60         return Math.max(Options.AOTInliningSizeMaximum.getValue(options) / (inliningDepth * Options.AOTInliningDepthToSizeRate.getValue(options)), Options.AOTInliningSizeMinimum.getValue(options));
  61     }
  62 
  63     @Override
  64     public boolean isWorthInlining(Replacements replacements, MethodInvocation invocation, int inliningDepth, boolean fullyProcessed) {
  65         final InlineInfo info = invocation.callee();
  66 
  67         for (int i = 0; i < info.numberOfMethods(); ++i) {
  68             HotSpotResolvedObjectType t = (HotSpotResolvedObjectType) info.methodAt(i).getDeclaringClass();
  69             if (t.getFingerprint() == 0) {
  70                 return false;
  71             }
  72         }
  73 
  74         final double probability = invocation.probability();
  75         final double relevance = invocation.relevance();
  76 
  77         OptionValues options = info.graph().getOptions();
  78         if (InlineEverything.getValue(options)) {
  79             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
  80             return true;
  81         }
  82 
  83         if (isIntrinsic(replacements, info)) {
  84             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
  85             return true;
  86         }
  87 
  88         if (info.shouldInline()) {
  89             InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "forced inlining");


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/aot/AOTInliningPolicy.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File