changeset 19018:52be1821f533

Merge
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 28 Jan 2015 19:56:03 -0800
parents f7375de5eaa0 (current diff) b7797e485eb8 (diff)
children a11dcfb15695
files
diffstat 9 files changed, 74 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/ClassSubstitution.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/ClassSubstitution.java	Wed Jan 28 19:56:03 2015 -0800
@@ -41,7 +41,8 @@
     Class<?> value() default ClassSubstitution.class;
 
     /**
-     * Specifies the original class.
+     * Specifies the original class or classes if a single class is being used for multiple
+     * substitutions.
      * <p>
      * This method is provided for cases where the original class is not accessible (according to
      * Java language access control rules).
@@ -49,7 +50,7 @@
      * If the default value is specified for this element, then a non-default value must be given
      * for the {@link #value()} element.
      */
-    String className() default "";
+    String[] className() default {};
 
     /**
      * Determines if the substitutions are for classes that may not be part of the runtime.
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeNodeMap.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeNodeMap.java	Wed Jan 28 19:56:03 2015 -0800
@@ -55,7 +55,11 @@
     }
 
     public Set<Node> keySet() {
-        throw new UnsupportedOperationException("Cannot get key set from this map");
+        HashSet<Node> entries = new HashSet<>();
+        for (Map.Entry<Node, Node> entry : entries()) {
+            entries.add(entry.getKey());
+        }
+        return entries;
     }
 
     public Collection<Node> values() {
@@ -69,7 +73,11 @@
         return result;
     }
 
-    public Set<java.util.Map.Entry<Node, Node>> entrySet() {
-        throw new UnsupportedOperationException("Cannot get entry set for this map");
+    public Set<Map.Entry<Node, Node>> entrySet() {
+        HashSet<Map.Entry<Node, Node>> entries = new HashSet<>();
+        for (Map.Entry<Node, Node> entry : entries()) {
+            entries.add(entry);
+        }
+        return entries;
     }
 }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java	Wed Jan 28 19:56:03 2015 -0800
@@ -74,6 +74,13 @@
                 if (loop.isOutsideLoop(op)) {
                     continue;
                 }
+                if (op.usages().count() == 1 && op.usages().first() == baseIvNode) {
+                    /*
+                     * This is just the base induction variable increment with no other uses so
+                     * don't bother reporting it.
+                     */
+                    continue;
+                }
                 InductionVariable iv = null;
                 ValueNode offset = addSub(op, baseIvNode);
                 ValueNode scale;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Wed Jan 28 19:56:03 2015 -0800
@@ -70,13 +70,13 @@
     @Override
     public void lower(LoweringTool tool) {
         /*
-         * Don't allow guards with action None to float. In cases where 2 guards are testing
-         * equivalent conditions they might be lowered at the same location. If the guard with the
-         * None action is lowered before the the other guard then the code will be stuck repeatedly
-         * deoptimizing without invalidating the code. Conditional elimination will eliminate the
-         * guard if it's truly redundant in this case.
+         * Don't allow guards with action None and reason RuntimeConstraint to float. In cases where
+         * 2 guards are testing equivalent conditions they might be lowered at the same location. If
+         * the guard with the None action is lowered before the the other guard then the code will
+         * be stuck repeatedly deoptimizing without invalidating the code. Conditional elimination
+         * will eliminate the guard if it's truly redundant in this case.
          */
-        if (graph().getGuardsStage().allowsFloatingGuards() && getAction() != DeoptimizationAction.None) {
+        if (graph().getGuardsStage().allowsFloatingGuards() && (getAction() != DeoptimizationAction.None || getReason() != DeoptimizationReason.RuntimeConstraint)) {
             ValueNode guard = tool.createGuard(this, condition(), getReason(), getAction(), isNegated()).asNode();
             this.replaceAtUsages(guard);
             ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode()));
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/AbstractVerifier.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/AbstractVerifier.java	Wed Jan 28 19:56:03 2015 -0800
@@ -23,6 +23,8 @@
 package com.oracle.graal.replacements.verifier;
 
 import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
 
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
@@ -46,6 +48,14 @@
         if (value == null) {
             return null;
         }
+        if (expectedType.isArray()) {
+            ArrayList<Object> result = new ArrayList<>();
+            List<AnnotationValue> l = (List<AnnotationValue>) value.getValue();
+            for (AnnotationValue el : l) {
+                result.add(resolveAnnotationValue(expectedType.getComponentType(), el));
+            }
+            return (T) result.toArray((Object[]) Array.newInstance(expectedType.getComponentType(), result.size()));
+        }
         Object unboxedValue = value.getValue();
         if (unboxedValue != null) {
             if (expectedType == TypeMirror.class && unboxedValue instanceof String) {
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Wed Jan 28 19:56:03 2015 -0800
@@ -36,7 +36,6 @@
     private static final String TYPE_VALUE = "value";
     private static final String STRING_VALUE = "className";
     private static final String OPTIONAL = "optional";
-    private static final String STRING_VALUE_DEFAULT = "";
 
     public ClassSubstitutionVerifier(ProcessingEnvironment env) {
         super(env);
@@ -69,7 +68,7 @@
         assert typeValue != null && stringValue != null && optionalValue != null;
 
         TypeMirror type = resolveAnnotationValue(TypeMirror.class, typeValue);
-        String className = resolveAnnotationValue(String.class, stringValue);
+        String[] classNames = resolveAnnotationValue(String[].class, stringValue);
         boolean optional = resolveAnnotationValue(Boolean.class, optionalValue);
 
         if (type.getKind() != TypeKind.DECLARED) {
@@ -78,7 +77,7 @@
         }
 
         if (!classSubstition.getAnnotationType().asElement().equals(((DeclaredType) type).asElement())) {
-            if (!className.equals(STRING_VALUE_DEFAULT)) {
+            if (classNames.length != 0) {
                 String msg = "The usage of value and className is exclusive.";
                 env.getMessager().printMessage(Kind.ERROR, msg, sourceElement, classSubstition, stringValue);
                 env.getMessager().printMessage(Kind.ERROR, msg, sourceElement, classSubstition, typeValue);
@@ -87,11 +86,15 @@
             return (TypeElement) ((DeclaredType) type).asElement();
         }
 
-        if (!className.equals(STRING_VALUE_DEFAULT)) {
-            TypeElement typeElement = env.getElementUtils().getTypeElement(className);
-            if (typeElement == null && !optional) {
-                env.getMessager().printMessage(Kind.ERROR, String.format("The class '%s' was not found on the classpath.", stringValue), sourceElement, classSubstition, stringValue);
+        if (classNames.length != 0) {
+            TypeElement typeElement = null;
+            for (String className : classNames) {
+                typeElement = env.getElementUtils().getTypeElement(className);
+                if (typeElement == null && !optional) {
+                    env.getMessager().printMessage(Kind.ERROR, String.format("The class '%s' was not found on the classpath.", stringValue), sourceElement, classSubstition, stringValue);
+                }
             }
+
             return typeElement;
         }
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BlackholeSubstitutions.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BlackholeSubstitutions.java	Wed Jan 28 19:56:03 2015 -0800
@@ -25,7 +25,10 @@
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.replacements.nodes.*;
 
-@ClassSubstitution(className = "org.openjdk.jmh.infra.Blackhole", optional = true)
+/**
+ * Substitutions for both the old and new versions of JMH Blackhole helper classes.
+ */
+@ClassSubstitution(className = {"org.openjdk.jmh.infra.Blackhole", "org.openjdk.jmh.logic.BlackHole"}, optional = true)
 public class BlackholeSubstitutions {
 
     @SuppressWarnings("unused")
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Wed Jan 28 19:56:03 2015 -0800
@@ -66,6 +66,11 @@
                         return "org.openjdk.jmh.infra.Blackhole";
                     }
                 }, BlackholeSubstitutions.class);
+                replacements.registerSubstitutions(new Type() {
+                    public String getTypeName() {
+                        return "org.openjdk.jmh.logic.BlackHole";
+                    }
+                }, BlackholeSubstitutions.class);
             }
         }
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Thu Jan 29 03:13:15 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Jan 28 19:56:03 2015 -0800
@@ -162,7 +162,12 @@
         private Executable originalMethod(ClassSubstitution classSubstitution, boolean optional, String name, JavaSignature signature) {
             Class<?> originalClass = classSubstitution.value();
             if (originalClass == ClassSubstitution.class) {
-                originalClass = resolveClass(classSubstitution.className(), classSubstitution.optional());
+                for (String className : classSubstitution.className()) {
+                    originalClass = resolveClass(className, classSubstitution.optional());
+                    if (originalClass != null) {
+                        break;
+                    }
+                }
                 if (originalClass == null) {
                     // optional class was not found
                     return null;
@@ -334,18 +339,26 @@
         return null;
     }
 
-    private static String getOriginalInternalName(Class<?> substitutions) {
+    private static boolean checkSubstitutionInternalName(Class<?> substitutions, String internalName) {
         ClassSubstitution cs = substitutions.getAnnotation(ClassSubstitution.class);
         assert cs != null : substitutions + " must be annotated by " + ClassSubstitution.class.getSimpleName();
         if (cs.value() == ClassSubstitution.class) {
-            return toInternalName(cs.className());
+            for (String className : cs.className()) {
+                if (toInternalName(className).equals(internalName)) {
+                    return true;
+                }
+            }
+            assert false : internalName + " not found in " + Arrays.toString(cs.className());
+        } else {
+            String originalInternalName = toInternalName(cs.value().getName());
+            assert originalInternalName.equals(internalName) : originalInternalName + " != " + internalName;
         }
-        return toInternalName(cs.value().getName());
+        return true;
     }
 
     public void registerSubstitutions(Type original, Class<?> substitutionClass) {
         String internalName = toInternalName(original.getTypeName());
-        assert getOriginalInternalName(substitutionClass).equals(internalName) : getOriginalInternalName(substitutionClass) + " != " + (internalName);
+        assert checkSubstitutionInternalName(substitutionClass, internalName);
         Class<?>[] classes = internalNameToSubstitutionClasses.get(internalName);
         if (classes == null) {
             classes = new Class<?>[]{substitutionClass};