# HG changeset patch # User Josef Eisl # Date 1422526467 -3600 # Node ID a11dcfb156953739739ea44dcb3ffb006aa7d2df # Parent 9a3bde73e05a2fb8de1de3fc7edf86e7d1aae0bb# Parent 52be1821f533910879bee22f95f98f3d67486418 StackSlotAllocation: merge with upstream. diff -r 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/ClassSubstitution.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeNodeMap.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/AbstractVerifier.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BlackholeSubstitutions.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java Thu Jan 29 11:14:27 2015 +0100 @@ -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 9a3bde73e05a -r a11dcfb15695 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 10:56:07 2015 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Jan 29 11:14:27 2015 +0100 @@ -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}; diff -r 9a3bde73e05a -r a11dcfb15695 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Thu Jan 29 10:56:07 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Thu Jan 29 11:14:27 2015 +0100 @@ -664,7 +664,7 @@ * Marks a method that it is considered as a boundary for Truffle partial evaluation. */ @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) + @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) public @interface TruffleBoundary { } diff -r 9a3bde73e05a -r a11dcfb15695 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Thu Jan 29 10:56:07 2015 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Thu Jan 29 11:14:27 2015 +0100 @@ -362,15 +362,6 @@ return childrenFields; } - public NodeField findField(long fieldOffset) { - for (NodeField field : getFields()) { - if (field.getOffset() == fieldOffset) { - return field; - } - } - return null; - } - @Override public int hashCode() { return clazz.hashCode(); @@ -665,20 +656,18 @@ NodeClass parentNodeClass = NodeClass.get(parent.getClass()); for (NodeField field : parentNodeClass.getChildFields()) { - final long fieldOffset = field.getOffset(); - if (unsafe.getObject(parent, fieldOffset) == child) { - return parentNodeClass.findField(fieldOffset); + if (field.getObject(parent) == child) { + return field; } } for (NodeField field : parentNodeClass.getChildrenFields()) { - final long fieldOffset = field.getOffset(); - Object arrayObject = unsafe.getObject(parent, fieldOffset); + Object arrayObject = field.getObject(parent); if (arrayObject != null) { Object[] array = (Object[]) arrayObject; for (int i = 0; i < array.length; i++) { if (array[i] == child) { - return parentNodeClass.findField(fieldOffset); + return field; } } } @@ -1091,6 +1080,7 @@ final StringBuilder sb = new StringBuilder(); sb.append("source:"); sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); + sb.append(" line=" + section.getLineLocation().getLineNumber()); sb.append(" len=" + srcText.length()); sb.append(" text=\"" + srcText + "\""); return sb.toString();