changeset 14060:96946b41aae7

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 26 Feb 2014 13:07:38 +0100
parents ff5aca1b2878 (current diff) 39f5ea16e13a (diff)
children a3cd3403a958
files
diffstat 17 files changed, 84 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Wed Feb 26 13:07:38 2014 +0100
@@ -147,6 +147,15 @@
     }
 
     /**
+     * Checks whether this represent an Object of some sort.
+     * 
+     * @return {@code true} if this is {@link #Object} or {@link #NarrowOop}.
+     */
+    public boolean isObject() {
+        return this == Kind.Object || this == Kind.NarrowOop;
+    }
+
+    /**
      * Returns the kind corresponding to the Java type string.
      * 
      * @param typeString the Java type string
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java	Wed Feb 26 13:07:38 2014 +0100
@@ -41,4 +41,8 @@
      */
     LocationIdentity FINAL_LOCATION = new NamedLocationIdentity("FINAL_LOCATION");
 
+    /**
+     * Denotes the location of the length field of a Java array.
+     */
+    LocationIdentity ARRAY_LENGTH_LOCATION = new NamedLocationIdentity("[].length");
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Wed Feb 26 13:07:38 2014 +0100
@@ -165,6 +165,11 @@
         return toValue(state.lockAt(i));
     }
 
+    private static final DebugMetric STATE_VIRTUAL_OBJECTS = Debug.metric("StateVirtualObjects");
+    private static final DebugMetric STATE_ILLEGALS = Debug.metric("StateIllegals");
+    private static final DebugMetric STATE_VARIABLES = Debug.metric("StateVariables");
+    private static final DebugMetric STATE_CONSTANTS = Debug.metric("StateConstants");
+
     protected Value toValue(ValueNode value) {
         if (value instanceof VirtualObjectNode) {
             VirtualObjectNode obj = (VirtualObjectNode) value;
@@ -182,22 +187,22 @@
                     vobject = VirtualObject.get(obj.type(), null, virtualObjects.size());
                     virtualObjects.put(obj, vobject);
                 }
-                Debug.metric("StateVirtualObjects").increment();
+                STATE_VIRTUAL_OBJECTS.increment();
                 return vobject;
             }
         } else if (value instanceof ConstantNode) {
-            Debug.metric("StateConstants").increment();
+            STATE_CONSTANTS.increment();
             return ((ConstantNode) value).getValue();
 
         } else if (value != null) {
-            Debug.metric("StateVariables").increment();
+            STATE_VARIABLES.increment();
             Value operand = nodeOperands.get(value);
             assert operand != null && (operand instanceof Variable || operand instanceof Constant) : operand + " for " + value;
             return operand;
 
         } else {
             // return a dummy value because real value not needed
-            Debug.metric("StateIllegals").increment();
+            STATE_ILLEGALS.increment();
             return Value.ILLEGAL;
         }
     }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Feb 26 13:07:38 2014 +0100
@@ -87,10 +87,10 @@
         }
     }
 
-    private static ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>();
-    private static ThreadLocal<DebugScope> lastClosedTL = new ThreadLocal<>();
-    private static ThreadLocal<DebugConfig> configTL = new ThreadLocal<>();
-    private static ThreadLocal<Throwable> lastExceptionThrownTL = new ThreadLocal<>();
+    private static final ThreadLocal<DebugScope> instanceTL = new ThreadLocal<>();
+    private static final ThreadLocal<DebugScope> lastClosedTL = new ThreadLocal<>();
+    private static final ThreadLocal<DebugConfig> configTL = new ThreadLocal<>();
+    private static final ThreadLocal<Throwable> lastExceptionThrownTL = new ThreadLocal<>();
 
     private final DebugScope parent;
     private final DebugConfig parentConfig;
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Wed Feb 26 13:07:38 2014 +0100
@@ -41,7 +41,7 @@
     /**
      * Records the most recent active timer.
      */
-    private static ThreadLocal<AbstractTimer> currentTimer = new ThreadLocal<>();
+    private static final ThreadLocal<AbstractTimer> currentTimer = new ThreadLocal<>();
 
     private final DebugValue flat;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Feb 26 13:07:38 2014 +0100
@@ -52,6 +52,8 @@
 
 public class CompilationTask implements Runnable, Comparable {
 
+    private static final DebugMetric BAILOUTS = Debug.metric("Bailouts");
+
     public static final ThreadLocal<Boolean> withinEnqueue = new ThreadLocal<Boolean>() {
 
         @Override
@@ -254,7 +256,7 @@
             }
             stats.finish(method);
         } catch (BailoutException bailout) {
-            Debug.metric("Bailouts").increment();
+            BAILOUTS.increment();
             if (ExitVMOnBailout.getValue()) {
                 TTY.cachedOut.println(MetaUtil.format("Bailout in %H.%n(%p)", method));
                 bailout.printStackTrace(TTY.cachedOut);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Wed Feb 26 13:07:38 2014 +0100
@@ -104,7 +104,7 @@
         if (n instanceof ArrayLengthNode) {
             ArrayLengthNode arrayLengthNode = (ArrayLengthNode) n;
             ValueNode array = arrayLengthNode.array();
-            ReadNode arrayLengthRead = graph.add(new ReadNode(array, ConstantLocationNode.create(FINAL_LOCATION, Kind.Int, config.arrayLengthOffset, graph), StampFactory.positiveInt(),
+            ReadNode arrayLengthRead = graph.add(new ReadNode(array, ConstantLocationNode.create(ARRAY_LENGTH_LOCATION, Kind.Int, config.arrayLengthOffset, graph), StampFactory.positiveInt(),
                             BarrierType.NONE, false));
             arrayLengthRead.setGuard(createNullCheck(array, arrayLengthNode, tool));
             graph.replaceFixedWithFixed(arrayLengthNode, arrayLengthRead);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Feb 26 13:07:38 2014 +0100
@@ -1049,6 +1049,8 @@
             }
         }
 
+        private static final DebugMetric EXPLICIT_EXCEPTIONS = Debug.metric("ExplicitExceptions");
+
         protected void emitExplicitExceptions(ValueNode receiver, ValueNode outOfBoundsIndex) {
             assert receiver != null;
             if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbabilityForOperations() && profilingInfo.getExceptionSeen(bci()) == TriState.FALSE)) {
@@ -1060,7 +1062,7 @@
                 ValueNode length = append(new ArrayLengthNode(receiver));
                 emitBoundsCheck(outOfBoundsIndex, length);
             }
-            Debug.metric("ExplicitExceptions").increment();
+            EXPLICIT_EXCEPTIONS.increment();
         }
 
         private void genPutField(JavaField field) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java	Wed Feb 26 13:07:38 2014 +0100
@@ -45,6 +45,8 @@
     private ControlFlowOptimizer() {
     }
 
+    private static final DebugMetric BLOCKS_DELETED = Debug.metric("BlocksDeleted");
+
     /**
      * Checks whether a block can be deleted. Only blocks with exactly one successor and an
      * unconditional branch to this successor are eligable.
@@ -102,7 +104,7 @@
                     alignBlock(lir, other);
                 }
 
-                Debug.metric("BlocksDeleted").increment();
+                BLOCKS_DELETED.increment();
                 iterator.remove();
             }
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DirectCallTargetNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DirectCallTargetNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -36,6 +36,6 @@
 
     @Override
     public String targetName() {
-        return "Direct#" + ((JavaMethod) target()).getName();
+        return MetaUtil.format("Direct#%h.%n", target());
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiArrayNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiArrayNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -30,7 +30,7 @@
 
 /**
  * A {@link PiNode} that also provides an array length in addition to a more refined stamp. A usage
- * that reads the array length, such as an {@link ArrayLengthNode}, can be canonicalized base on
+ * that reads the array length, such as an {@link ArrayLengthNode}, can be canonicalized based on
  * this information.
  */
 public final class PiArrayNode extends PiNode implements ArrayLengthProvider {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -74,26 +74,36 @@
             // Read without usages can be safely removed.
             return null;
         }
-        if (tool.canonicalizeReads() && metaAccess != null && object != null && object.isConstant()) {
-            if (location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION && location instanceof ConstantLocationNode) {
-                long displacement = ((ConstantLocationNode) location).getDisplacement();
-                Kind kind = location.getValueKind();
-                if (object.kind() == Kind.Object) {
-                    Object base = object.asConstant().asObject();
-                    if (base != null) {
-                        Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, base, displacement, compressible);
-                        if (constant != null) {
-                            return ConstantNode.forConstant(constant, metaAccess, read.graph());
+        if (tool.canonicalizeReads()) {
+            if (metaAccess != null && object != null && object.isConstant()) {
+                if ((location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION || location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION) &
+                                location instanceof ConstantLocationNode) {
+                    long displacement = ((ConstantLocationNode) location).getDisplacement();
+                    Kind kind = location.getValueKind();
+                    if (object.kind() == Kind.Object) {
+                        Object base = object.asConstant().asObject();
+                        if (base != null) {
+                            Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, base, displacement, compressible);
+                            if (constant != null) {
+                                return ConstantNode.forConstant(constant, metaAccess, read.graph());
+                            }
+                        }
+                    } else if (object.kind().isNumericInteger()) {
+                        long base = object.asConstant().asLong();
+                        if (base != 0L) {
+                            Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, null, base + displacement, compressible);
+                            if (constant != null) {
+                                return ConstantNode.forConstant(constant, metaAccess, read.graph());
+                            }
                         }
                     }
-                } else if (object.kind().isNumericInteger()) {
-                    long base = object.asConstant().asLong();
-                    if (base != 0L) {
-                        Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, null, base + displacement, compressible);
-                        if (constant != null) {
-                            return ConstantNode.forConstant(constant, metaAccess, read.graph());
-                        }
-                    }
+                }
+            }
+            if (location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION && object instanceof ArrayLengthProvider) {
+                ValueNode length = ((ArrayLengthProvider) object).length();
+                if (length != null) {
+                    // TODO Does this need a PiCastNode to the positive range?
+                    return length;
                 }
             }
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -60,7 +60,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty() && (isStatic() || ObjectStamp.isObjectNonNull(object().stamp()))) {
+        if (usages().isEmpty() && !isVolatile() && (isStatic() || ObjectStamp.isObjectNonNull(object().stamp()))) {
             return null;
         }
         MetaAccessProvider metaAccess = tool.getMetaAccess();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -160,7 +160,7 @@
         if (targetMethod() == null) {
             return "??Invalid!";
         }
-        return targetMethod().getName();
+        return MetaUtil.format("%h.%n", targetMethod());
     }
 
     public static MethodCallTargetNode find(StructuredGraph graph, ResolvedJavaMethod method) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.nodes.virtual;
 
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -30,7 +31,7 @@
  * Selects one object from a {@link CommitAllocationNode}. The object is identified by its
  * {@link VirtualObjectNode}.
  */
-public class AllocatedObjectNode extends FloatingNode implements Virtualizable {
+public class AllocatedObjectNode extends FloatingNode implements Virtualizable, ArrayLengthProvider {
 
     @Input private VirtualObjectNode virtualObject;
     @Input private CommitAllocationNode commit;
@@ -57,4 +58,11 @@
     public void virtualize(VirtualizerTool tool) {
         tool.replaceWithVirtual(getVirtualObject());
     }
+
+    public ValueNode length() {
+        if (virtualObject instanceof ArrayLengthProvider) {
+            return ((ArrayLengthProvider) virtualObject).length();
+        }
+        return null;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Wed Feb 26 13:07:38 2014 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(nameTemplate = "VirtualArray {p#componentType/s}[{p#length}]")
-public class VirtualArrayNode extends VirtualObjectNode {
+public class VirtualArrayNode extends VirtualObjectNode implements ArrayLengthProvider {
 
     private final ResolvedJavaType componentType;
     private final int length;
@@ -144,4 +144,8 @@
     public ValueNode getMaterializedRepresentation(FixedNode fixed, ValueNode[] entries, LockState locks) {
         return new AllocatedObjectNode(this);
     }
+
+    public ValueNode length() {
+        return ConstantNode.forInt(length, graph());
+    }
 }
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Tue Feb 25 18:17:08 2014 +0100
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Wed Feb 26 13:07:38 2014 +0100
@@ -128,7 +128,7 @@
         return new MultipleOverridesScope(current, map);
     }
 
-    private static ThreadLocal<OverrideScope> overrideScopes = new ThreadLocal<>();
+    private static final ThreadLocal<OverrideScope> overrideScopes = new ThreadLocal<>();
 
     /**
      * The raw option value.