# HG changeset patch # User Doug Simon # Date 1371053730 -7200 # Node ID 7709bb83191682c7902ec2e64acc96353b32857d # Parent deb5bd8414222db81bdcb7414c0e078ddf0976f9 adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling diff -r deb5bd841422 -r 7709bb831916 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Wed Jun 12 17:24:20 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Wed Jun 12 18:15:30 2013 +0200 @@ -39,6 +39,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.graal.phases.*; import com.oracle.graal.replacements.*; import com.oracle.graal.replacements.Snippet.ConstantParameter; import com.oracle.graal.replacements.Snippet.VarargsParameter; @@ -58,8 +59,10 @@ public class InstanceOfSnippets implements Snippets { /** - * A test against a set of hints derived from a profile with 100% precise coverage of seen - * types. This snippet deoptimizes on any path that contradicts the profile. + * 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 */ @Snippet public static Object instanceofWithProfile(Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, @@ -67,6 +70,8 @@ if (probability(NOT_FREQUENT_PROBABILITY, checkNull && object == null)) { isNull.inc(); if (!nullSeen) { + // In this case, the execution is contradicting the profile + // so invalidating and re-profiling is justified. DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated); } return falseValue; @@ -82,6 +87,8 @@ return positive ? trueValue : falseValue; } } + // Don't throw away the code as we assume this is a rare event + // that will periodically occur. DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated); return falseValue; } @@ -189,7 +196,7 @@ ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, instanceOf.graph()); Arguments args; - if (hintInfo.hintHitProbability == 1.0D) { + if (hintInfo.hintHitProbability >= InstanceOfFullCoverageSpeculationThreshold.getValue()) { Hints hints = createHints(hintInfo, runtime, false, hub.graph()); args = new Arguments(instanceofWithProfile); args.add("object", object); @@ -215,7 +222,7 @@ args.add("trueValue", replacer.trueValue); args.add("falseValue", replacer.falseValue); args.addConst("checkNull", !object.stamp().nonNull()); - if (hintInfo.hintHitProbability == 1.0D) { + if (hintInfo.hintHitProbability >= InstanceOfFullCoverageSpeculationThreshold.getValue()) { args.addConst("nullSeen", hintInfo.profile.getNullSeen() != TriState.FALSE); } return args; diff -r deb5bd841422 -r 7709bb831916 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Jun 12 17:24:20 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Jun 12 18:15:30 2013 +0200 @@ -332,14 +332,25 @@ public static final OptionValue CheckcastMaxHints = new OptionValue<>(2); /** - * @see #CheckcastMinHintHitProbability + * If the probability that an instanceof will hit one the profiled types (up to {@link #InstanceOfMaxHints}) + * is below this value, the instanceof will be compiled without hints. */ @Option(help = "") public static final OptionValue InstanceOfMinHintHitProbability = new OptionValue<>(0.5); /** - * @see #CheckcastMaxHints + * The maximum number of hint types that will be used when compiling an instanceof for which + * profiling information is available. Note that {@link #InstanceOfMinHintHitProbability} + * also influences whether hints are used. */ @Option(help = "") public static final OptionValue 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 InstanceOfFullCoverageSpeculationThreshold = new OptionValue<>(0.998); + }