Mercurial > hg > graal-jvmci-8
changeset 21138:7a62f41ed610
Merge
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Tue, 28 Apr 2015 18:35:16 +0200 |
parents | fb2b27418347 (diff) a5faa9aafc80 (current diff) |
children | 0b221b4ad707 |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SyntaxTagged.java |
diffstat | 5 files changed, 143 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Tue Apr 28 13:08:22 2015 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Tue Apr 28 18:35:16 2015 +0200 @@ -90,6 +90,10 @@ @Override public boolean canInlineConstant(JavaConstant c) { switch (c.getKind()) { + case Boolean: + case Byte: + case Char: + case Short: case Int: return SPARCAssembler.isSimm13(c.asInt()) && !getCodeCache().needsDataPatch(c); case Long: @@ -217,7 +221,7 @@ @Override public void emitCompareBranch(PlatformKind cmpKind, Value x, Value y, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) { - Variable left; + Value left; Value right; Condition actualCondition; if (isConstant(x)) { @@ -230,8 +234,20 @@ actualCondition = cond; } SPARCCompare opcode; - Kind kind = left.getKind().getStackKind(); - switch (kind) { + Kind actualCmpKind = (Kind) cmpKind; + switch (actualCmpKind) { + case Byte: + left = emitSignExtend(left, 8, 32); + right = emitSignExtend(right, 8, 32); + actualCmpKind = Kind.Int; + opcode = ICMP; + break; + case Short: + left = emitSignExtend(left, 16, 32); + right = emitSignExtend(right, 16, 32); + actualCmpKind = Kind.Int; + opcode = ICMP; + break; case Object: opcode = ACMP; break; @@ -239,9 +255,6 @@ opcode = LCMP; break; case Int: - case Short: - case Char: - case Byte: opcode = ICMP; break; case Float: @@ -251,9 +264,9 @@ opcode = DCMP; break; default: - throw GraalInternalError.shouldNotReachHere(kind.toString()); + throw GraalInternalError.shouldNotReachHere(actualCmpKind.toString()); } - append(new SPARCControlFlow.CompareBranchOp(opcode, left, right, actualCondition, trueDestination, falseDestination, kind, unorderedIsTrue, trueDestinationProbability)); + append(new SPARCControlFlow.CompareBranchOp(opcode, left, right, actualCondition, trueDestination, falseDestination, actualCmpKind, unorderedIsTrue, trueDestinationProbability)); } @Override
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq.java Tue Apr 28 13:08:22 2015 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq.java Tue Apr 28 18:35:16 2015 +0200 @@ -55,4 +55,101 @@ runTest("test", 1); } + @Test + public void run3() { + runTest("testb", 0xff); + } + + /** + * Tests if the if does work properly on byte stamp. + */ + public static int testb(int b) { + byte x = (byte) b; + int y = x & 0xff; + if (y == 0xff) { + // Just do anything else to force jump instead of conditional move + y = (int) (System.currentTimeMillis() >> 32); + } + return y; + } + + @Test + public void run4() { + runTest("tests", 0xffff); + } + + /** + * Tests if the if does work properly on short stamp. + */ + public static int tests(int b) { + short x = (short) b; + int y = x & 0xffff; + if (y == 0xffff) { + // Just do anything else to force jump instead of conditional move + y = (int) (System.currentTimeMillis() >> 32); + } + return y; + } + + @Test + public void run5() { + runTest("testc", 0xffff); + } + + /** + * Tests if the if does work properly on char stamp (boils down to short, just to cover all the + * java types). + */ + public static int testc(int b) { + char x = (char) b; + int y = x & 0xffff; + if (y == 0xffff) { + // Just do anything else to force jump instead of conditional move + y = (int) (System.currentTimeMillis() >> 32); + } + return y; + } + + // the same with conditional move + @Test + public void run6() { + runTest("testCondb", 0xff); + } + + /** + * Tests if the if does work properly on byte stamp. + */ + public static boolean testCondb(int b) { + byte x = (byte) b; + int y = x & 0xff; + return y == 0xff; + } + + @Test + public void run7() { + runTest("testConds", 0xffff); + } + + /** + * Tests if the if does work properly on short stamp. + */ + public static boolean testConds(int b) { + short x = (short) b; + int y = x & 0xffff; + return y == 0xffff; + } + + @Test + public void run8() { + runTest("testCondc", 0xffff); + } + + /** + * Tests if the if does work properly on char type. + */ + public static boolean testCondc(int b) { + char x = (char) b; + int y = x & 0xffff; + return y == 0xffff; + } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Apr 28 13:08:22 2015 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Apr 28 18:35:16 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; +import com.oracle.graal.lir.sparc.SPARCControlFlow.CompareBranchOp; public enum SPARCCompare { ICMP, @@ -63,11 +64,11 @@ @Override public void verify() { super.verify(); + assert CompareBranchOp.SUPPORTED_KINDS.contains(x.getKind()) : x.getKind(); + assert x.getKind().equals(y.getKind()) : x + " " + y; // @formatter:off - assert (name().startsWith("I") && - (!(x.getKind() == Kind.Int) || y.getKind().getStackKind() == Kind.Int) && - (!(x.getKind() == Kind.Short) || y.getKind().getStackKind() == Kind.Int) && - (!(x.getKind() == Kind.Byte) || y.getKind().getStackKind() == Kind.Int)) || + assert + (name().startsWith("I") && x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (name().startsWith("L") && x.getKind() == Kind.Long && y.getKind() == Kind.Long) || (name().startsWith("A") && x.getKind() == Kind.Object && y.getKind() == Kind.Object) || (name().startsWith("F") && x.getKind() == Kind.Float && y.getKind() == Kind.Float) ||
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Apr 28 13:08:22 2015 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Apr 28 18:35:16 2015 +0200 @@ -31,6 +31,8 @@ import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static com.oracle.graal.sparc.SPARC.*; +import java.util.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; @@ -75,6 +77,7 @@ public static final class CompareBranchOp extends SPARCLIRInstruction implements BlockEndOp, SPARCDelayedControlTransfer { public static final LIRInstructionClass<CompareBranchOp> TYPE = LIRInstructionClass.create(CompareBranchOp.class); + static final EnumSet<Kind> SUPPORTED_KINDS = EnumSet.of(Kind.Long, Kind.Int, Kind.Object, Kind.Float, Kind.Double); private final SPARCCompare opcode; @Use({REG}) protected Value x; @@ -231,9 +234,6 @@ private static void emitCBCond(SPARCMacroAssembler masm, Value actualX, Value actualY, Label actualTrueTarget, ConditionFlag conditionFlag) { switch ((Kind) actualX.getLIRKind().getPlatformKind()) { - case Byte: - case Char: - case Short: case Int: if (isConstant(actualY)) { int constantY = asConstant(actualY).asInt(); @@ -269,9 +269,6 @@ return false; } switch ((Kind) x.getPlatformKind()) { - case Byte: - case Char: - case Short: case Int: case Long: case Object: @@ -319,6 +316,13 @@ emitted = false; delaySlotPosition = -1; } + + @Override + public void verify() { + super.verify(); + assert SUPPORTED_KINDS.contains(kind) : kind; + assert x.getKind().equals(kind) && y.getKind().equals(kind) : x + " " + y; + } } public static final class BranchOp extends SPARCLIRInstruction implements StandardOp.BranchOp { @@ -342,6 +346,11 @@ public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { emitBranch(crb, masm, kind, conditionFlag, trueDestination, falseDestination, true, trueDestinationProbability); } + + @Override + public void verify() { + assert CompareBranchOp.SUPPORTED_KINDS.contains(kind); + } } private static boolean emitBranch(CompilationResultBuilder crb, SPARCMacroAssembler masm, Kind kind, ConditionFlag conditionFlag, LabelRef trueDestination, LabelRef falseDestination,
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Apr 28 13:08:22 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Apr 28 18:35:16 2015 +0200 @@ -52,6 +52,8 @@ import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.options.*; +import com.oracle.graal.options.OptionValue.OverrideScope; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; @@ -446,7 +448,9 @@ * @param frameStateProcessing controls how {@link FrameState FrameStates} should be handled. */ public StructuredGraph makeGraph(ResolvedJavaMethod method, Object[] args, ResolvedJavaMethod original, FrameStateProcessing frameStateProcessing) { - return createGraphMaker(method, original, frameStateProcessing).makeGraph(args); + try (OverrideScope s = OptionValue.override(DeoptALot, false)) { + return createGraphMaker(method, original, frameStateProcessing).makeGraph(args); + } } /**