# HG changeset patch # User Tom Rodriguez # Date 1422503763 28800 # Node ID 52be1821f533910879bee22f95f98f3d67486418 # Parent f7375de5eaa03473f2f3795ab477dc9487f94704# Parent b7797e485eb87d4af60c1b604555e53c05533140 Merge diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/ClassSubstitution.java --- 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. *

* 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. diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeNodeMap.java --- 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 keySet() { - throw new UnsupportedOperationException("Cannot get key set from this map"); + HashSet entries = new HashSet<>(); + for (Map.Entry entry : entries()) { + entries.add(entry.getKey()); + } + return entries; } public Collection values() { @@ -69,7 +73,11 @@ return result; } - public Set> entrySet() { - throw new UnsupportedOperationException("Cannot get entry set for this map"); + public Set> entrySet() { + HashSet> entries = new HashSet<>(); + for (Map.Entry entry : entries()) { + entries.add(entry); + } + return entries; } } diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java --- 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; diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- 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())); diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/AbstractVerifier.java --- 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 result = new ArrayList<>(); + List l = (List) 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) { diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java --- 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; } diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BlackholeSubstitutions.java --- 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") diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java --- 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); } } } diff -r f7375de5eaa0 -r 52be1821f533 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- 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};