Mercurial > hg > graal-jvmci-8
changeset 10069:abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 17 Jun 2013 17:55:19 +0200 |
parents | 529570e20aff |
children | a555af792411 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java src/share/vm/graal/graalCompilerToVM.cpp |
diffstat | 4 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Jun 17 14:53:37 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Jun 17 17:55:19 2013 +0200 @@ -38,6 +38,7 @@ public int codeEntryAlignment; public boolean verifyOops; public boolean ciTime; + public int compileThreshold; public boolean compileTheWorld; public int compileTheWorldStartAt; public int compileTheWorldStopAt;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Mon Jun 17 14:53:37 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Mon Jun 17 17:55:19 2013 +0200 @@ -59,10 +59,23 @@ public class InstanceOfSnippets implements Snippets { /** + * Gets the minimum required probability of a profiled instanceof hitting one the profiled types + * for use of the {@linkplain #instanceofWithProfile deoptimizing} snippet. The value is + * computed to be an order of magnitude greater than the configured compilation threshold. For + * example, if a method is compiled after being interpreted 10000 times, the deoptimizing + * snippet will only be used for an instanceof if its profile indicates that less than 1 in + * 100000 executions are for an object whose type is not one of the top N profiled types (where + * {@code N == } {@link GraalOptions#InstanceOfMaxHints}). + */ + public static double hintHitProbabilityThresholdForDeoptimizingSnippet() { + return 1.0D - (1.0D / (graalRuntime().getConfig().compileThreshold * 10)); + } + + /** * A test against a set of hints derived from a profile with very close to 100% precise coverage * of seen types. This snippet deoptimizes on hint miss paths. * - * @see GraalOptions#InstanceOfFullCoverageSpeculationThreshold + * @see #hintHitProbabilityThresholdForDeoptimizingSnippet() */ @Snippet public static Object instanceofWithProfile(Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, @@ -196,7 +209,8 @@ ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, instanceOf.graph()); Arguments args; - if (hintInfo.hintHitProbability >= InstanceOfFullCoverageSpeculationThreshold.getValue()) { + + if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) { Hints hints = createHints(hintInfo, runtime, false, hub.graph()); args = new Arguments(instanceofWithProfile); args.add("object", object); @@ -222,7 +236,7 @@ args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); args.addConst("checkNull", !object.stamp().nonNull()); - if (hintInfo.hintHitProbability >= InstanceOfFullCoverageSpeculationThreshold.getValue()) { + if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) { args.addConst("nullSeen", hintInfo.profile.getNullSeen() != TriState.FALSE); } return args;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Jun 17 14:53:37 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Jun 17 17:55:19 2013 +0200 @@ -343,12 +343,4 @@ */ @Option(help = "") public static final OptionValue<Integer> InstanceOfMaxHints = new OptionValue<>(2); - - /** - * If the probability that an instanceof will hit one the profiled types (up to {@link #InstanceOfMaxHints}) - * is above this value, the compiled instanceof will deoptimize if all hints are missed. - */ - @Option(help = "") - public static final OptionValue<Double> InstanceOfFullCoverageSpeculationThreshold = new OptionValue<>(0.998); - }
--- a/src/share/vm/graal/graalCompilerToVM.cpp Mon Jun 17 14:53:37 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon Jun 17 17:55:19 2013 +0200 @@ -668,6 +668,7 @@ set_boolean("cAssertions", DEBUG_ONLY(true) NOT_DEBUG(false)); set_boolean("verifyOops", VerifyOops); set_boolean("ciTime", CITime); + set_int("compileThreshold", CompileThreshold); set_boolean("compileTheWorld", CompileTheWorld); set_int("compileTheWorldStartAt", CompileTheWorldStartAt); set_int("compileTheWorldStopAt", CompileTheWorldStopAt);