@@ -501,6 +501,8 @@ public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState frameS
501501 }
502502 }
503503
504+ private static final double JUMP_TABLE_THRESHOLD = 3 ;
505+
504506 public void emitStrategySwitch (JavaConstant [] keyConstants , double [] keyProbabilities , LabelRef [] keyTargets , LabelRef defaultTarget , AllocatableValue value ) {
505507 SwitchStrategy strategy = SwitchStrategy .getBestStrategy (keyProbabilities , keyConstants , keyTargets );
506508
@@ -513,12 +515,12 @@ public void emitStrategySwitch(JavaConstant[] keyConstants, double[] keyProbabil
513515
514516 /*
515517 * This heuristic tries to find a compromise between the effort for the best switch strategy
516- * and the density of a tableswitch. If the effort for the strategy is at least 4, then a
517- * tableswitch is preferred if better than a certain value that starts at 0.5 and lowers
518- * gradually with additional effort.
518+ * and the density of a tableswitch. If the effort for the strategy is at least
519+ * JUMP_TABLE_THRESHOLD, then a tableswitch is preferred if the density is larger than a
520+ * certain value that gradually decreases as the aforementioned effort rises .
519521 */
520522 double minDensity = 1 / Math .sqrt (strategy .getAverageEffort ());
521- if (strategy .getAverageEffort () < 4d || (tableSwitchDensity < minDensity && hashTableSwitchDensity < minDensity )) {
523+ if (strategy .getAverageEffort () < JUMP_TABLE_THRESHOLD || (tableSwitchDensity < minDensity && hashTableSwitchDensity < minDensity )) {
522524 emitStrategySwitch (strategy , value , keyTargets , defaultTarget );
523525 } else {
524526 if (hashTableSwitchDensity > tableSwitchDensity ) {
0 commit comments