# HG changeset patch # User Christian Humer # Date 1427985052 -7200 # Node ID d7d33c72fdc89d4251a4648a65734987767a2014 # Parent b91ba8932cb6f1a60e2fa13aeed9977edb50e73f Truffle: cache threshold in constant to speed up defer compilation check. diff -r b91ba8932cb6 -r d7d33c72fdc8 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java Thu Apr 02 16:30:52 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java Thu Apr 02 16:30:52 2015 +0200 @@ -28,6 +28,8 @@ public class CompilationProfile { + private static final int TIMESTAMP_THRESHOLD = Math.max(TruffleCompilationThreshold.getValue() / 2, 1); + /** * Number of times an installed code for this tree was invalidated. */ @@ -110,7 +112,7 @@ interpreterCallAndLoopCount++; int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount; - if (callsMissing == getTimestampThreshold()) { + if (callsMissing == TIMESTAMP_THRESHOLD) { timestamp = System.nanoTime(); } } @@ -128,7 +130,7 @@ } public void deferCompilation() { - ensureProfiling(0, getTimestampThreshold() + 1); + ensureProfiling(0, TIMESTAMP_THRESHOLD + 1); timestamp = 0; deferedCount++; } @@ -137,7 +139,7 @@ interpreterCallAndLoopCount += count; int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount; - if (callsMissing <= getTimestampThreshold() && callsMissing + count > getTimestampThreshold()) { + if (callsMissing <= TIMESTAMP_THRESHOLD && callsMissing + count > TIMESTAMP_THRESHOLD) { timestamp = System.nanoTime(); } } @@ -152,7 +154,4 @@ return timestamp; } - private static int getTimestampThreshold() { - return Math.max(TruffleCompilationThreshold.getValue() / 2, 1); - } }