Mercurial > hg > graal-compiler
changeset 10016:7709bb831916
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
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 12 Jun 2013 18:15:30 +0200 |
parents | deb5bd841422 |
children | 53f090c5975a |
files | 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 |
diffstat | 2 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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<Integer> 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<Double> 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<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); + }