Mercurial > hg > graal-jvmci-8
changeset 18328:58b7133cd0e1
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 10 Nov 2014 20:16:12 +0100 |
parents | 13273385abb5 (diff) 0459da9d94c0 (current diff) |
children | 75e72d395820 |
files | |
diffstat | 35 files changed, 268 insertions(+), 191 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Mon Nov 10 20:16:12 2014 +0100 @@ -31,7 +31,7 @@ * The information stored in the {@link VirtualObject} is used during deoptimization to recreate the * object. */ -public final class VirtualObject extends Value implements JavaValue { +public final class VirtualObject extends AbstractValue implements JavaValue { private static final long serialVersionUID = -2907197776426346021L;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractValue.java Mon Nov 10 20:16:12 2014 +0100 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.meta; + +import java.io.*; + +/** + * Abstract base class for values. + */ +public abstract class AbstractValue implements Serializable, Value, KindProvider { + + private static final long serialVersionUID = -6909397188697766469L; + + public static final AllocatableValue ILLEGAL = Value.ILLEGAL; + + private final Kind kind; + private final LIRKind lirKind; + + /** + * Initializes a new value of the specified kind. + * + * @param lirKind the kind + */ + protected AbstractValue(LIRKind lirKind) { + this.lirKind = lirKind; + if (getPlatformKind() instanceof Kind) { + this.kind = (Kind) getPlatformKind(); + } else { + this.kind = Kind.Illegal; + } + } + + /** + * Returns a String representation of the kind, which should be the end of all + * {@link #toString()} implementation of subclasses. + */ + protected final String getKindSuffix() { + return "|" + getKind().getTypeChar(); + } + + /** + * Returns the kind of this value. + */ + public final Kind getKind() { + return kind; + } + + public final LIRKind getLIRKind() { + return lirKind; + } + + /** + * Returns the platform specific kind used to store this value. + */ + public final PlatformKind getPlatformKind() { + return lirKind.getPlatformKind(); + } + + @Override + public int hashCode() { + return 41 + lirKind.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof AbstractValue) { + AbstractValue that = (AbstractValue) obj; + return kind.equals(that.kind) && lirKind.equals(that.lirKind); + } + return false; + } + + /** + * Checks if this value is identical to {@code other}. + * + * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and + * should be used. + */ + @ExcludeFromIdentityComparisonVerification + public final boolean identityEquals(AbstractValue other) { + return this == other; + } +}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Mon Nov 10 20:16:12 2014 +0100 @@ -26,7 +26,7 @@ * Common base class for values that are stored in some location that's managed by the register * allocator (e.g. register, stack slot). */ -public abstract class AllocatableValue extends Value implements JavaValue { +public abstract class AllocatableValue extends AbstractValue implements JavaValue, KindProvider { private static final long serialVersionUID = 153019506717492133L;
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaConstant.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaConstant.java Mon Nov 10 20:16:12 2014 +0100 @@ -28,40 +28,34 @@ * {@code JavaConstant} instances that represent frequently used constant values, such as * {@link #NULL_OBJECT}. */ -public abstract class JavaConstant extends Value implements Constant, JavaValue { - - private static final long serialVersionUID = -6355452536852663986L; +public interface JavaConstant extends Constant, JavaValue, Value { /* * Using a larger cache for integers leads to only a slight increase in cache hit ratio which is * not enough to justify the impact on startup time. */ - public static final JavaConstant NULL_OBJECT = new NullConstant(); - public static final JavaConstant INT_MINUS_1 = new PrimitiveConstant(Kind.Int, -1); - public static final JavaConstant INT_0 = new PrimitiveConstant(Kind.Int, 0); - public static final JavaConstant INT_1 = new PrimitiveConstant(Kind.Int, 1); - public static final JavaConstant INT_2 = new PrimitiveConstant(Kind.Int, 2); - public static final JavaConstant LONG_0 = new PrimitiveConstant(Kind.Long, 0L); - public static final JavaConstant LONG_1 = new PrimitiveConstant(Kind.Long, 1L); - public static final JavaConstant FLOAT_0 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(0.0F)); - public static final JavaConstant FLOAT_1 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(1.0F)); - public static final JavaConstant DOUBLE_0 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(0.0D)); - public static final JavaConstant DOUBLE_1 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(1.0D)); - public static final JavaConstant TRUE = new PrimitiveConstant(Kind.Boolean, 1L); - public static final JavaConstant FALSE = new PrimitiveConstant(Kind.Boolean, 0L); - - protected JavaConstant(LIRKind kind) { - super(kind); - } + JavaConstant NULL_OBJECT = new NullConstant(); + PrimitiveConstant INT_MINUS_1 = new PrimitiveConstant(Kind.Int, -1); + PrimitiveConstant INT_0 = new PrimitiveConstant(Kind.Int, 0); + PrimitiveConstant INT_1 = new PrimitiveConstant(Kind.Int, 1); + PrimitiveConstant INT_2 = new PrimitiveConstant(Kind.Int, 2); + PrimitiveConstant LONG_0 = new PrimitiveConstant(Kind.Long, 0L); + PrimitiveConstant LONG_1 = new PrimitiveConstant(Kind.Long, 1L); + PrimitiveConstant FLOAT_0 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(0.0F)); + PrimitiveConstant FLOAT_1 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(1.0F)); + PrimitiveConstant DOUBLE_0 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(0.0D)); + PrimitiveConstant DOUBLE_1 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(1.0D)); + PrimitiveConstant TRUE = new PrimitiveConstant(Kind.Boolean, 1L); + PrimitiveConstant FALSE = new PrimitiveConstant(Kind.Boolean, 0L); /** * Checks whether this constant is null. * * @return {@code true} if this constant is the null constant */ - public abstract boolean isNull(); + boolean isNull(); - public static boolean isNull(Constant c) { + static boolean isNull(Constant c) { if (c instanceof JavaConstant) { return ((JavaConstant) c).isNull(); } else { @@ -74,7 +68,7 @@ * * @return {@code true} if this constant is a primitive, or an object constant that is not null */ - public final boolean isNonNull() { + default boolean isNonNull() { return !isNull(); } @@ -83,14 +77,14 @@ * * @return {@code true} if this constant is the default value for its kind */ - public abstract boolean isDefaultForKind(); + boolean isDefaultForKind(); /** * Returns the value of this constant as a boxed Java value. * * @return the value of this constant */ - public abstract Object asBoxedPrimitive(); + Object asBoxedPrimitive(); /** * Returns the primitive int value this constant represents. The constant must have a @@ -98,7 +92,7 @@ * * @return the constant value */ - public abstract int asInt(); + int asInt(); /** * Returns the primitive boolean value this constant represents. The constant must have kind @@ -106,7 +100,7 @@ * * @return the constant value */ - public abstract boolean asBoolean(); + boolean asBoolean(); /** * Returns the primitive long value this constant represents. The constant must have kind @@ -114,7 +108,7 @@ * * @return the constant value */ - public abstract long asLong(); + long asLong(); /** * Returns the primitive float value this constant represents. The constant must have kind @@ -122,7 +116,7 @@ * * @return the constant value */ - public abstract float asFloat(); + float asFloat(); /** * Returns the primitive double value this constant represents. The constant must have kind @@ -130,9 +124,9 @@ * * @return the constant value */ - public abstract double asDouble(); + double asDouble(); - public String toValueString() { + default String toValueString() { if (getKind() == Kind.Illegal) { return "illegal"; } else { @@ -140,14 +134,14 @@ } } - @Override - public String toString() { - if (getKind() == Kind.Illegal) { - return "illegal"; - } else { - return getKind().getJavaName() + "[" + toValueString() + "]"; - } - } +// @Override +// public String toString() { +// if (getKind() == Kind.Illegal) { +// return "illegal"; +// } else { +// return getKind().getJavaName() + "[" + toValueString() + "]"; +// } +// } /** * Creates a boxed double constant. @@ -155,7 +149,7 @@ * @param d the double value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forDouble(double d) { + static PrimitiveConstant forDouble(double d) { if (Double.compare(0.0D, d) == 0) { return DOUBLE_0; } @@ -171,7 +165,7 @@ * @param f the float value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forFloat(float f) { + static PrimitiveConstant forFloat(float f) { if (Float.compare(f, 0.0F) == 0) { return FLOAT_0; } @@ -187,7 +181,7 @@ * @param i the long value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forLong(long i) { + static PrimitiveConstant forLong(long i) { if (i == 0) { return LONG_0; } else if (i == 1) { @@ -203,7 +197,7 @@ * @param i the integer value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forInt(int i) { + static PrimitiveConstant forInt(int i) { switch (i) { case -1: return INT_MINUS_1; @@ -224,7 +218,7 @@ * @param i the byte value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forByte(byte i) { + static PrimitiveConstant forByte(byte i) { return new PrimitiveConstant(Kind.Byte, i); } @@ -234,7 +228,7 @@ * @param i the boolean value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forBoolean(boolean i) { + static PrimitiveConstant forBoolean(boolean i) { return i ? TRUE : FALSE; } @@ -244,7 +238,7 @@ * @param i the char value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forChar(char i) { + static PrimitiveConstant forChar(char i) { return new PrimitiveConstant(Kind.Char, i); } @@ -254,14 +248,14 @@ * @param i the short value to box * @return a boxed copy of {@code value} */ - public static JavaConstant forShort(short i) { + static PrimitiveConstant forShort(short i) { return new PrimitiveConstant(Kind.Short, i); } /** * Creates a {@link JavaConstant} from a primitive integer of a certain kind. */ - public static JavaConstant forIntegerKind(Kind kind, long i) { + static PrimitiveConstant forIntegerKind(Kind kind, long i) { switch (kind) { case Byte: return new PrimitiveConstant(kind, (byte) i); @@ -281,7 +275,7 @@ /** * Creates a {@link JavaConstant} from a primitive integer of a certain width. */ - public static JavaConstant forPrimitiveInt(int bits, long i) { + static PrimitiveConstant forPrimitiveInt(int bits, long i) { assert bits <= 64; switch (bits) { case 1: @@ -305,7 +299,7 @@ * @param value the Java boxed value * @return the primitive constant holding the {@code value} */ - public static JavaConstant forBoxedPrimitive(Object value) { + static PrimitiveConstant forBoxedPrimitive(Object value) { if (value instanceof Boolean) { return forBoolean((Boolean) value); } else if (value instanceof Byte) { @@ -327,14 +321,14 @@ } } - public static JavaConstant forIllegal() { + static PrimitiveConstant forIllegal() { return new PrimitiveConstant(Kind.Illegal, 0); } /** * Returns a constant with the default value for the given kind. */ - public static JavaConstant defaultForKind(Kind kind) { + static JavaConstant defaultForKind(Kind kind) { switch (kind) { case Boolean: return FALSE; @@ -362,7 +356,7 @@ /** * Returns the zero value for a given numeric kind. */ - public static JavaConstant zero(Kind kind) { + static JavaConstant zero(Kind kind) { switch (kind) { case Boolean: return FALSE; @@ -388,7 +382,7 @@ /** * Returns the one value for a given numeric kind. */ - public static JavaConstant one(Kind kind) { + static JavaConstant one(Kind kind) { switch (kind) { case Boolean: return TRUE; @@ -414,7 +408,7 @@ /** * Adds two numeric constants. */ - public static JavaConstant add(JavaConstant x, JavaConstant y) { + static JavaConstant add(JavaConstant x, JavaConstant y) { assert x.getKind() == y.getKind(); switch (x.getKind()) { case Byte: @@ -439,7 +433,7 @@ /** * Multiplies two numeric constants. */ - public static JavaConstant mul(JavaConstant x, JavaConstant y) { + static PrimitiveConstant mul(JavaConstant x, JavaConstant y) { assert x.getKind() == y.getKind(); switch (x.getKind()) { case Byte:
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java Mon Nov 10 20:16:12 2014 +0100 @@ -25,7 +25,7 @@ /** * The implementation type of the {@link JavaConstant#NULL_OBJECT null constant}. */ -final class NullConstant extends JavaConstant { +final class NullConstant extends AbstractValue implements JavaConstant { private static final long serialVersionUID = 8906209595800783961L; @@ -85,7 +85,6 @@ @Override public boolean equals(Object o) { - assert o == this || !(o instanceof NullConstant) : "null constant is a singleton"; - return o == this; + return o instanceof NullConstant; } }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Mon Nov 10 20:16:12 2014 +0100 @@ -26,7 +26,7 @@ * Represents a primitive constant value, such as an integer or floating point number, within the * compiler and across the compiler/runtime interface. */ -public class PrimitiveConstant extends JavaConstant { +public class PrimitiveConstant extends AbstractValue implements JavaConstant { private static final long serialVersionUID = 8787949721295655376L;
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java Mon Nov 10 20:16:12 2014 +0100 @@ -22,19 +22,9 @@ */ package com.oracle.graal.api.meta; -import java.lang.annotation.*; - /** * Marker interface for classes whose values are proxied during replay compilation capture or remote * compilation. */ public interface Remote { - - /** - * Denotes a method whose return value is determined solely by its parameter values. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface PureFunction { - } }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Mon Nov 10 20:16:12 2014 +0100 @@ -22,17 +22,13 @@ */ package com.oracle.graal.api.meta; -import java.io.*; - /** - * Abstract base class for values manipulated by the compiler. All values have a {@linkplain Kind - * kind} and are immutable. + * Interface for values manipulated by the compiler. All values have a {@linkplain Kind kind} and + * are immutable. */ -public abstract class Value implements Serializable, KindProvider { +public interface Value extends KindProvider { - private static final long serialVersionUID = -6909397188697766469L; - - @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) { + @SuppressWarnings("serial") AllocatableValue ILLEGAL = new AllocatableValue(LIRKind.Illegal) { @Override public String toString() { @@ -40,62 +36,12 @@ } }; - private final Kind kind; - private final LIRKind lirKind; - - /** - * Initializes a new value of the specified kind. - * - * @param lirKind the kind - */ - protected Value(LIRKind lirKind) { - this.lirKind = lirKind; - if (getPlatformKind() instanceof Kind) { - this.kind = (Kind) getPlatformKind(); - } else { - this.kind = Kind.Illegal; - } - } - - /** - * Returns a String representation of the kind, which should be the end of all - * {@link #toString()} implementation of subclasses. - */ - protected final String getKindSuffix() { - return "|" + getKind().getTypeChar(); - } - - /** - * Returns the kind of this value. - */ - public final Kind getKind() { - return kind; - } - - public final LIRKind getLIRKind() { - return lirKind; - } + LIRKind getLIRKind(); /** * Returns the platform specific kind used to store this value. */ - public final PlatformKind getPlatformKind() { - return lirKind.getPlatformKind(); - } - - @Override - public int hashCode() { - return 41 + lirKind.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Value) { - Value that = (Value) obj; - return kind.equals(that.kind) && lirKind.equals(that.lirKind); - } - return false; - } + PlatformKind getPlatformKind(); /** * Checks if this value is identical to {@code other}. @@ -104,7 +50,7 @@ * should be used. */ @ExcludeFromIdentityComparisonVerification - public final boolean identityEquals(Value other) { + default boolean identityEquals(Value other) { return this == other; } }
--- a/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java Mon Nov 10 20:16:12 2014 +0100 @@ -68,7 +68,7 @@ public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) { AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig); Register ret = registerConfig.getReturnRegister(Kind.Double); - Data data = new Data(8, 8, DataBuilder.primitive((PrimitiveConstant) JavaConstant.forDouble(84.72))); + Data data = new Data(8, 8, DataBuilder.primitive(JavaConstant.forDouble(84.72))); DataSectionReference ref = compResult.getDataSection().insertData(data); compResult.recordDataPatch(asm.position(), ref); asm.movdbl(ret, asm.getPlaceholder());
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java Mon Nov 10 20:16:12 2014 +0100 @@ -25,16 +25,12 @@ import java.lang.reflect.*; import java.util.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.Remote.PureFunction; - -@SuppressWarnings("unused") public class Handler<T> implements InvocationHandler { private final T delegate; private final Context context; - Map<Invocation, Object> constantDataInvocations = new HashMap<>(); + Map<Invocation, Object> cachedInvocations = new HashMap<>(); public Handler(T delegate, Context context) { this.delegate = delegate; @@ -63,15 +59,23 @@ return res; } + /** + * @param method + */ + private static boolean isCacheable(Method method) { + // TODO: use annotations for finer control of what should be cached + return true; + } + @Override public Object invoke(Object proxy, Method method, Object[] a) throws Throwable { Object[] args = unproxify(a); - boolean isConstantData = method.getAnnotation(PureFunction.class) != null; + boolean isCacheable = isCacheable(method); Invocation invocation = new Invocation(method, delegate, args); - if (isConstantData) { - if (constantDataInvocations.containsKey(invocation)) { - Object result = constantDataInvocations.get(invocation); - assert Objects.deepEquals(result, invocation.invoke()); + if (isCacheable) { + assert method.getReturnType() != Void.TYPE : method; + if (cachedInvocations.containsKey(invocation)) { + Object result = cachedInvocations.get(invocation); // System.out.println(invocation + ": " + result); return result; } @@ -81,8 +85,8 @@ Object result = invocation.invoke(); result = context.get(result); - if (isConstantData) { - constantDataInvocations.put(invocation, result); + if (isCacheable) { + cachedInvocations.put(invocation, result); } return result; }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java Mon Nov 10 20:16:12 2014 +0100 @@ -90,8 +90,11 @@ @Override public Stamp constant(Constant c, MetaAccessProvider meta) { - long value = ((PrimitiveConstant) c).asLong(); - return StampFactory.forInteger(getBits(), value, value); + if (c instanceof PrimitiveConstant) { + long value = ((PrimitiveConstant) c).asLong(); + return StampFactory.forInteger(getBits(), value, value); + } + return this; } @Override @@ -375,7 +378,7 @@ @Override public Constant foldConstant(Constant value) { PrimitiveConstant c = (PrimitiveConstant) value; - return PrimitiveConstant.forIntegerKind(c.getKind(), -c.asLong()); + return JavaConstant.forIntegerKind(c.getKind(), -c.asLong()); } @Override @@ -683,7 +686,7 @@ @Override public Constant foldConstant(Constant value) { PrimitiveConstant c = (PrimitiveConstant) value; - return PrimitiveConstant.forIntegerKind(c.getKind(), Math.abs(c.asLong())); + return JavaConstant.forIntegerKind(c.getKind(), Math.abs(c.asLong())); } @Override
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Nov 10 20:16:12 2014 +0100 @@ -689,13 +689,17 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graphToCompile.method(), false); try (Context c = new Context(); Debug.Scope s = Debug.scope("ReplayCompiling", new DebugDumpScope("REPLAY", true))) { - Request<CompilationResult> request = new GraalCompiler.Request<>(graphToCompile, null, cc, installedCodeOwner, getProviders(), getBackend(), getCodeCache().getTarget(), null, - getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), new CompilationResult(), - CompilationResultBuilderFactory.Default); + try { + Request<CompilationResult> request = new GraalCompiler.Request<>(graphToCompile, null, cc, installedCodeOwner, getProviders(), getBackend(), getCodeCache().getTarget(), null, + getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), new CompilationResult(), + CompilationResultBuilderFactory.Default); - request = c.get(request); - - return GraalCompiler.compile(request); + request = c.get(request); + return GraalCompiler.compile(request); + } catch (Throwable e) { + e.printStackTrace(); + throw e; + } } catch (Throwable e) { throw Debug.handle(e); }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/ComplexMatchValue.java Mon Nov 10 20:16:12 2014 +0100 @@ -30,14 +30,14 @@ * closure because Value is serializable which is a hassle for the little inner classes which * usually occur here. */ -public class ComplexMatchValue extends Value { +public class ComplexMatchValue extends AbstractValue { private static final long serialVersionUID = -4734670273590368770L; /** * This is the Value of a node which was matched as part of a complex match. The value isn't * actually useable but this marks it as having been evaluated. */ - @SuppressWarnings("serial") public static final Value INTERIOR_MATCH = new Value(LIRKind.Illegal) { + @SuppressWarnings("serial") public static final Value INTERIOR_MATCH = new AbstractValue(LIRKind.Illegal) { @Override public String toString() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java Mon Nov 10 20:16:12 2014 +0100 @@ -27,7 +27,7 @@ /** * The compressed representation of the {@link JavaConstant#NULL_OBJECT null constant}. */ -public final class HotSpotCompressedNullConstant extends JavaConstant implements HotSpotConstant { +public final class HotSpotCompressedNullConstant extends AbstractValue implements JavaConstant, HotSpotConstant { private static final long serialVersionUID = 8906209595800783961L;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMonitorValue.java Mon Nov 10 20:16:12 2014 +0100 @@ -28,7 +28,7 @@ /** * Represents lock information in the debug information. */ -public final class HotSpotMonitorValue extends Value implements JavaValue { +public final class HotSpotMonitorValue extends AbstractValue implements JavaValue { private static final long serialVersionUID = 8241681800464483691L;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Mon Nov 10 20:16:12 2014 +0100 @@ -33,7 +33,7 @@ * Represents a constant non-{@code null} object reference, within the compiler and across the * compiler/runtime interface. */ -public interface HotSpotObjectConstant extends JavaValue, HotSpotConstant, VMConstant, Remote { +public interface HotSpotObjectConstant extends JavaConstant, HotSpotConstant, VMConstant, Remote { JavaConstant compress(); @@ -47,14 +47,12 @@ * * @return {@code null} if this constant does not represent a {@link Class} object */ - @PureFunction JavaConstant getClassLoader(); /** * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object * represented by this constant. */ - @PureFunction int getIdentityHashCode(); /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Mon Nov 10 20:16:12 2014 +0100 @@ -35,7 +35,7 @@ * Represents a constant non-{@code null} object reference, within the compiler and across the * compiler/runtime interface. */ -public final class HotSpotObjectConstantImpl extends JavaConstant implements HotSpotObjectConstant { +public final class HotSpotObjectConstantImpl extends AbstractValue implements HotSpotObjectConstant { private static final long serialVersionUID = 3592151693708093496L;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Mon Nov 10 20:16:12 2014 +0100 @@ -39,7 +39,7 @@ */ boolean isCallerSensitive(); - HotSpotResolvedObjectTypeImpl getDeclaringClass(); + HotSpotResolvedObjectType getDeclaringClass(); /** * Returns true if this method has a {@code ForceInline} annotation. @@ -70,7 +70,7 @@ boolean hasBalancedMonitors(); - ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectTypeImpl receiver); + ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver); /** * Returns whether this method has compiled code.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java Mon Nov 10 20:16:12 2014 +0100 @@ -350,7 +350,7 @@ return runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, bci); } - public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectTypeImpl receiver) { + public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { if (receiver.isInterface()) { // Cannot trust interfaces. Because of: // interface I { void foo(); } @@ -362,7 +362,8 @@ // seeing A.foo(). return null; } - final long uniqueConcreteMethod = runtime().getCompilerToVM().findUniqueConcreteMethod(receiver.getMetaspaceKlass(), metaspaceMethod); + long metaspaceKlass = ((HotSpotResolvedObjectTypeImpl) receiver).getMetaspaceKlass(); + final long uniqueConcreteMethod = runtime().getCompilerToVM().findUniqueConcreteMethod(metaspaceKlass, metaspaceMethod); if (uniqueConcreteMethod == 0) { return null; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java Mon Nov 10 20:16:12 2014 +0100 @@ -503,7 +503,7 @@ @Override public ResolvedJavaMethod findUniqueConcreteMethod(ResolvedJavaMethod method) { HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; - HotSpotResolvedObjectTypeImpl declaredHolder = hmethod.getDeclaringClass(); + HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); /* * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared * holder, usually because of phis, so make sure that the type is related to the declared
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest1.java Mon Nov 10 20:16:12 2014 +0100 @@ -50,7 +50,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = -645435039553382737L; private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest2.java Mon Nov 10 20:16:12 2014 +0100 @@ -51,7 +51,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = -645435039553382737L; private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest3.java Mon Nov 10 20:16:12 2014 +0100 @@ -51,7 +51,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = -645435039553382737L; private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/CompositeValueReplacementTest4.java Mon Nov 10 20:16:12 2014 +0100 @@ -51,7 +51,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = -645435039553382737L; private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest1.java Mon Nov 10 20:16:12 2014 +0100 @@ -48,7 +48,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = -645435039553382737L; private final int id;
--- a/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir.test/src/com/oracle/graal/lir/test/ValuePositionTest2.java Mon Nov 10 20:16:12 2014 +0100 @@ -50,7 +50,7 @@ } - private static class DummyValue extends Value { + private static class DummyValue extends AbstractValue { private static final long serialVersionUID = 3620305384660607012L; private final int id;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java Mon Nov 10 20:16:12 2014 +0100 @@ -33,7 +33,7 @@ /** * Base class to represent values that need to be stored in more than one register. */ -public abstract class CompositeValue extends Value implements Cloneable { +public abstract class CompositeValue extends AbstractValue implements Cloneable { private static final long serialVersionUID = -169180052684126180L;
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Mon Nov 10 20:16:12 2014 +0100 @@ -30,6 +30,8 @@ import org.junit.internal.*; import org.junit.runner.*; import org.junit.runner.notification.*; +import org.junit.runners.*; +import org.junit.runners.model.*; public class GraalJUnitCore { @@ -52,6 +54,7 @@ List<Failure> missingClasses = new ArrayList<>(); boolean verbose = false; boolean enableTiming = false; + boolean failFast = false; boolean color = false; boolean eagerStackTrace = false; boolean gcAfterTest = false; @@ -63,6 +66,8 @@ // command line arguments if (each.contentEquals("-JUnitVerbose")) { verbose = true; + } else if (each.contentEquals("-JUnitFailFast")) { + failFast = true; } else if (each.contentEquals("-JUnitEnableTiming")) { enableTiming = true; } else if (each.contentEquals("-JUnitColor")) { @@ -107,12 +112,13 @@ } } } - GraalJUnitRunListener graalListener; + final GraalTextListener textListener; if (!verbose) { - graalListener = new GraalTextListener(system); + textListener = new GraalTextListener(system); } else { - graalListener = new GraalVerboseTextListener(system); + textListener = new GraalVerboseTextListener(system); } + GraalJUnitRunListener graalListener = textListener; if (enableTiming) { graalListener = new TimingDecorator(graalListener); } @@ -132,6 +138,24 @@ } else { request = Request.method(classes.get(0), methodName); } + if (failFast) { + Runner runner = request.getRunner(); + if (runner instanceof ParentRunner) { + ParentRunner<?> parentRunner = (ParentRunner<?>) runner; + parentRunner.setScheduler(new RunnerScheduler() { + public void schedule(Runnable childStatement) { + if (textListener.getLastFailure() == null) { + childStatement.run(); + } + } + + public void finished() { + } + }); + } else { + system.out().println("Unexpected Runner subclass " + runner.getClass().getName() + " - fail fast not supported"); + } + } Result result = junitCore.run(request); for (Failure each : missingClasses) { result.getFailures().add(each);
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTextListener.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTextListener.java Mon Nov 10 20:16:12 2014 +0100 @@ -31,6 +31,7 @@ public class GraalTextListener implements GraalJUnitRunListener { private final PrintStream fWriter; + protected Failure lastFailure; public GraalTextListener(JUnitSystem system) { this(system.out()); @@ -45,6 +46,10 @@ return fWriter; } + public Failure getLastFailure() { + return lastFailure; + } + @Override public void testRunStarted(Description description) { } @@ -77,6 +82,7 @@ @Override public void testFailed(Failure failure) { getWriter().print('E'); + lastFailure = failure; } @Override
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalVerboseTextListener.java Mon Nov 10 18:32:32 2014 +0100 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalVerboseTextListener.java Mon Nov 10 20:16:12 2014 +0100 @@ -71,6 +71,7 @@ @Override public void testFailed(Failure failure) { getWriter().print("FAILED"); + lastFailure = failure; } @Override
--- a/mx/mx_graal.py Mon Nov 10 18:32:32 2014 +0100 +++ b/mx/mx_graal.py Mon Nov 10 20:16:12 2014 +0100 @@ -1141,7 +1141,7 @@ f_testfile.close() harness(projectsCp, vmArgs) -def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False): +def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False): testfile = os.environ.get('MX_TESTFILE', None) if testfile is None: (_, testfile) = tempfile.mkstemp(".testclasses", "graal") @@ -1151,6 +1151,8 @@ coreArgs = [] if verbose: coreArgs.append('-JUnitVerbose') + if fail_fast: + coreArgs.append('-JUnitFailFast') if enable_timing: coreArgs.append('-JUnitEnableTiming') if color: @@ -1206,6 +1208,7 @@ --whitelist <file> run only testcases which are included in the given whitelist --verbose enable verbose JUnit output + --fail-fast stop after first JUnit test class that has a failure --enable-timing enable JUnit test timing --regex <regex> run only testcases matching a regular expression --color enable colors output @@ -1250,6 +1253,7 @@ parser.add_argument('--blacklist', help='run all testcases not specified in the blacklist', metavar='<path>') parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='<path>') parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true') + parser.add_argument('--fail-fast', help='stop after first JUnit test class that has a failure', action='store_true') parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true') parser.add_argument('--regex', help='run only testcases matching a regular expression', metavar='<regex>') parser.add_argument('--color', help='enable color output', action='store_true')
--- a/src/share/vm/classfile/systemDictionary.hpp Mon Nov 10 18:32:32 2014 +0100 +++ b/src/share/vm/classfile/systemDictionary.hpp Mon Nov 10 20:16:12 2014 +0100 @@ -242,7 +242,7 @@ GRAAL_ONLY(do_klass(LIRKind_klass, com_oracle_graal_api_meta_LIRKind, Graal)) \ GRAAL_ONLY(do_klass(JavaMethod_klass, com_oracle_graal_api_meta_JavaMethod, Graal)) \ GRAAL_ONLY(do_klass(JavaType_klass, com_oracle_graal_api_meta_JavaType, Graal)) \ - GRAAL_ONLY(do_klass(Value_klass, com_oracle_graal_api_meta_Value, Graal)) \ + GRAAL_ONLY(do_klass(AbstractValue_klass, com_oracle_graal_api_meta_AbstractValue, Graal)) \ /*end*/ @@ -263,7 +263,7 @@ #ifdef GRAAL FIRST_GRAAL_WKID = WK_KLASS_ENUM_NAME(CompilerThread_klass), - LAST_GRAAL_WKID = WK_KLASS_ENUM_NAME(Value_klass), + LAST_GRAAL_WKID = WK_KLASS_ENUM_NAME(AbstractValue_klass), #endif FIRST_WKID = NO_WKID + 1
--- a/src/share/vm/classfile/vmSymbols.hpp Mon Nov 10 18:32:32 2014 +0100 +++ b/src/share/vm/classfile/vmSymbols.hpp Mon Nov 10 20:16:12 2014 +0100 @@ -321,7 +321,7 @@ GRAAL_ONLY(template(com_oracle_graal_api_meta_JavaType, "com/oracle/graal/api/meta/JavaType")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_Kind, "com/oracle/graal/api/meta/Kind")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_LIRKind, "com/oracle/graal/api/meta/LIRKind")) \ - GRAAL_ONLY(template(com_oracle_graal_api_meta_Value, "com/oracle/graal/api/meta/Value")) \ + GRAAL_ONLY(template(com_oracle_graal_api_meta_AbstractValue, "com/oracle/graal/api/meta/AbstractValue")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions, "com/oracle/graal/api/code/Assumptions")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions_MethodContents, "com/oracle/graal/api/code/Assumptions$MethodContents")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_Assumptions_ConcreteSubtype, "com/oracle/graal/api/code/Assumptions$ConcreteSubtype")) \
--- a/src/share/vm/graal/graalCodeInstaller.cpp Mon Nov 10 18:32:32 2014 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Mon Nov 10 20:16:12 2014 +0100 @@ -191,7 +191,7 @@ if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant); - assert(Kind::typeChar(Value::kind(constant)) == 'j', "must have word kind"); + assert(Kind::typeChar(AbstractValue::kind(constant)) == 'j', "must have word kind"); assert(obj != NULL, "must have an object"); assert(prim != 0, "must have a primitive value"); @@ -205,11 +205,11 @@ ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) { second = NULL; - if (value == Value::ILLEGAL()) { + if (value == AbstractValue::ILLEGAL()) { return _illegal_value; } - oop lirKind = Value::lirKind(value); + oop lirKind = AbstractValue::lirKind(value); oop platformKind = LIRKind::platformKind(lirKind); jint referenceMask = LIRKind::referenceMask(lirKind); assert(referenceMask == 0 || referenceMask == 1, "unexpected referenceMask"); @@ -803,7 +803,7 @@ if (second != NULL) { i++; assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); - assert(values->obj_at(i) == Value::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); + assert(values->obj_at(i) == AbstractValue::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); } }
--- a/src/share/vm/graal/graalJavaAccess.hpp Mon Nov 10 18:32:32 2014 +0100 +++ b/src/share/vm/graal/graalJavaAccess.hpp Mon Nov 10 20:16:12 2014 +0100 @@ -224,10 +224,10 @@ oop_field(LIRKind, platformKind, "Lcom/oracle/graal/api/meta/PlatformKind;") \ int_field(LIRKind, referenceMask) \ end_class \ - start_class(Value) \ - oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;") \ - oop_field(Value, lirKind, "Lcom/oracle/graal/api/meta/LIRKind;") \ - static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ + start_class(AbstractValue) \ + oop_field(AbstractValue, kind, "Lcom/oracle/graal/api/meta/Kind;") \ + oop_field(AbstractValue, lirKind, "Lcom/oracle/graal/api/meta/LIRKind;") \ + static_oop_field(AbstractValue, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ end_class \ start_class(RegisterValue) \ oop_field(RegisterValue, reg, "Lcom/oracle/graal/api/code/Register;") \