Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java @ 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 | 0b30da13d86b |
children | e04f128d719c |
line wrap: on
line diff
--- 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;