changeset 20133:d7d33c72fdc8

Truffle: cache threshold in constant to speed up defer compilation check.
author Christian Humer <christian.humer@gmail.com>
date Thu, 02 Apr 2015 16:30:52 +0200
parents b91ba8932cb6
children 3424e06e4951
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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);
-    }
 }