# HG changeset patch # User Gilles Duboscq # Date 1424182573 -3600 # Node ID 66b058e073967ecd7ec95d845dc5d7f5ee43498d # Parent 2a914f764cfa0cb0e2747054715d67a64ac91e87 Change threshold at which deopt is used diff -r 2a914f764cfa -r 66b058e07396 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 Tue Feb 17 15:13:14 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Tue Feb 17 15:16:13 2015 +0100 @@ -61,17 +61,26 @@ */ public class InstanceOfSnippets implements Snippets { + private static final double COMPILED_VS_INTERPRETER_SPEEDUP = 50; + private static final double INSTANCEOF_DEOPT_SPEEDUP = 1.01; // generous 1% speedup + + private static final int DEOPT_THRESHOLD_FACTOR = (int) (COMPILED_VS_INTERPRETER_SPEEDUP / (INSTANCEOF_DEOPT_SPEEDUP - 1.0)); + /** * 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 Options#TypeCheckMaxHints}). + * computed to be an order of greater than the configured compilation threshold by a + * {@linkplain #DEOPT_THRESHOLD_FACTOR factor}. + * + *

+ * This factor is such that the additional executions we get from using the deoptimizing snippet + * (({@linkplain #INSTANCEOF_DEOPT_SPEEDUP speedup} - 1) / probability threshold) is greater + * than the time lost during re-interpretation ({@linkplain #COMPILED_VS_INTERPRETER_SPEEDUP + * compiled code speedup} × compilation threshold). + *

*/ public static double hintHitProbabilityThresholdForDeoptimizingSnippet(long compilationThreshold) { - return 1.0D - (1.0D / (compilationThreshold * 10)); + return 1.0D - (1.0D / (compilationThreshold * DEOPT_THRESHOLD_FACTOR)); } /**