changeset 18964:c1f8125b4207

Various adjustments to simplify future merges Do not keep values in static final fields that can be different in other execution contexts. Make callRootMethod and callInlinedMethod accessible for subclasses of TruffleCacheImpl.
author Paul Woegerer <paul.woegerer@oracle.com>
date Tue, 27 Jan 2015 15:10:32 +0100
parents 892e466d28f3
children 88083bb2e0f8
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java
diffstat 4 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Tue Jan 27 14:28:13 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Tue Jan 27 15:10:32 2015 +0100
@@ -28,8 +28,6 @@
 
 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.
      */
@@ -112,7 +110,7 @@
         interpreterCallAndLoopCount++;
 
         int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount;
-        if (callsMissing == TIMESTAMP_THRESHOLD) {
+        if (callsMissing == getTimestampThreshold()) {
             timestamp = System.nanoTime();
         }
     }
@@ -130,7 +128,7 @@
     }
 
     public void deferCompilation() {
-        ensureProfiling(0, TIMESTAMP_THRESHOLD + 1);
+        ensureProfiling(0, getTimestampThreshold() + 1);
         timestamp = 0;
         deferedCount++;
     }
@@ -139,7 +137,7 @@
         interpreterCallAndLoopCount += count;
 
         int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount;
-        if (callsMissing <= TIMESTAMP_THRESHOLD && callsMissing + count > TIMESTAMP_THRESHOLD) {
+        if (callsMissing <= getTimestampThreshold() && callsMissing + count > getTimestampThreshold()) {
             timestamp = System.nanoTime();
         }
     }
@@ -153,4 +151,8 @@
     public long getTimestamp() {
         return timestamp;
     }
+
+    private static int getTimestampThreshold() {
+        return Math.max(TruffleCompilationThreshold.getValue() / 2, 1);
+    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Tue Jan 27 14:28:13 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Tue Jan 27 15:10:32 2015 +0100
@@ -38,11 +38,6 @@
  * frame object would show up very late and would be hard to identify.
  */
 public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame {
-    private static final long OBJECT_BASE_OFFSET = Unsafe.ARRAY_OBJECT_BASE_OFFSET;
-    private static final long OBJECT_INDEX_SCALE = Unsafe.ARRAY_OBJECT_INDEX_SCALE;
-    private static final long PRIMITIVE_BASE_OFFSET = Unsafe.ARRAY_LONG_BASE_OFFSET;
-    private static final long PRIMITIVE_INDEX_SCALE = Unsafe.ARRAY_LONG_INDEX_SCALE;
-
     private final FrameDescriptor descriptor;
     private final Object[] arguments;
     private Object[] locals;
@@ -89,7 +84,7 @@
 
     private Object getObjectUnsafe(FrameSlot slot) {
         int slotIndex = slot.getIndex();
-        return unsafeGetObject(getLocals(), OBJECT_BASE_OFFSET + slotIndex * OBJECT_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot);
+        return unsafeGetObject(getLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slotIndex * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot);
     }
 
     @Override
@@ -99,7 +94,7 @@
     }
 
     private void setObjectUnsafe(FrameSlot slot, Object value) {
-        unsafePutObject(getLocals(), OBJECT_BASE_OFFSET + slot.getIndex() * OBJECT_INDEX_SCALE, value, slot);
+        unsafePutObject(getLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, slot);
     }
 
     @Override
@@ -272,11 +267,11 @@
     }
 
     private static long alignPrimitive(FrameSlot slot, Kind forKind) {
-        long offset = PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE;
+        long offset = Unsafe.ARRAY_LONG_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_LONG_INDEX_SCALE;
         if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
             // On big endian, we use int in long type, which means, when byteCount() <=4, the value
             // is right aligned in the 4 byte half, which has the lower address.
-            offset += Kind.Long.getByteCount() - Math.min(PRIMITIVE_INDEX_SCALE, 4 + forKind.getByteCount());
+            offset += Kind.Long.getByteCount() - Math.min((long) Unsafe.ARRAY_LONG_INDEX_SCALE, 4 + forKind.getByteCount());
         }
         return offset;
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Tue Jan 27 14:28:13 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Tue Jan 27 15:10:32 2015 +0100
@@ -68,8 +68,8 @@
     private final ResolvedJavaType errorClass;
     private final ResolvedJavaType controlFlowExceptionClass;
 
-    private final ResolvedJavaMethod callRootMethod;
-    private final ResolvedJavaMethod callInlinedMethod;
+    protected final ResolvedJavaMethod callRootMethod;
+    protected final ResolvedJavaMethod callInlinedMethod;
 
     private long counter;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java	Tue Jan 27 14:28:13 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java	Tue Jan 27 15:10:32 2015 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.truffle;
 
+import java.util.concurrent.atomic.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 import com.oracle.truffle.api.*;
@@ -31,6 +33,8 @@
  * {@linkplain Debug#scope(Object) debug scopes}.
  */
 public class TruffleDebugJavaMethod implements JavaMethod {
+    private static final AtomicInteger nextId = new AtomicInteger();
+    private final int id;
     private final RootCallTarget compilable;
 
     private static final JavaType declaringClass = new JavaType() {
@@ -86,6 +90,7 @@
 
     public TruffleDebugJavaMethod(RootCallTarget compilable) {
         this.compilable = compilable;
+        this.id = nextId.incrementAndGet();
     }
 
     @Override
@@ -107,7 +112,7 @@
     }
 
     public String getName() {
-        return compilable.toString().replace('.', '_').replace(' ', '_');
+        return compilable.toString().replace('.', '_').replace(' ', '_') + "_" + id;
     }
 
     public JavaType getDeclaringClass() {