# HG changeset patch # User Thomas Wuerthinger # Date 1429540254 -7200 # Node ID 3fe33ec624ea9f4e291d25adf887bfcb0e1139eb # Parent 37b516b9080c700a1ea1610358bfae482785d765# Parent e4a8c886515f0b7d70022c2c2cacd08527b58436 Merge. diff -r 37b516b9080c -r 3fe33ec624ea graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Mon Apr 20 16:30:41 2015 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java Mon Apr 20 16:30:54 2015 +0200 @@ -64,7 +64,7 @@ @Override public int asInt() { - assert getKind().getStackKind() == Kind.Int; + assert getKind().getStackKind() == Kind.Int : getKind().getStackKind(); return (int) primitive; } diff -r 37b516b9080c -r 3fe33ec624ea graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java --- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java Mon Apr 20 16:30:41 2015 +0200 +++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java Mon Apr 20 16:30:54 2015 +0200 @@ -918,6 +918,10 @@ return isSimm(imm, 13); } + public static boolean isSimm13(JavaConstant constant) { + return constant.isNull() || isSimm13(constant.asLong()); + } + public static boolean isSimm13(long imm) { return NumUtil.isInt(imm) && isSimm(imm, 13); } diff -r 37b516b9080c -r 3fe33ec624ea graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Apr 20 16:30:41 2015 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Apr 20 16:30:54 2015 +0200 @@ -319,8 +319,7 @@ } Variable result = newVariable(trueValue.getLIRKind()); ConditionFlag finalCondition = ConditionFlag.fromCondtition(conditionFlags, mirrored ? cond.mirror() : cond, unorderedIsTrue); - Kind kind = result.getKind().getStackKind(); - append(new CondMoveOp(kind, result, conditionFlags, finalCondition, actualTrueValue, actualFalseValue)); + append(new CondMoveOp(result, conditionFlags, finalCondition, actualTrueValue, actualFalseValue)); return result; } @@ -396,7 +395,7 @@ throw GraalInternalError.shouldNotReachHere(); } ConditionFlag flag = ConditionFlag.fromCondtition(conditionCode, Condition.EQ, false); - append(new CondMoveOp(kind, result, conditionCode, flag, loadSimm11(trueValue), loadSimm11(falseValue))); + append(new CondMoveOp(result, conditionCode, flag, loadSimm11(trueValue), loadSimm11(falseValue))); return result; } diff -r 37b516b9080c -r 3fe33ec624ea graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Apr 20 16:30:41 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Mon Apr 20 16:30:54 2015 +0200 @@ -377,7 +377,8 @@ } } } catch (Throwable t) { - println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); + println("CompileTheWorld (%d) : Skipping %s %s", classFileCounter, className, t.toString()); + t.printStackTrace(); } } jarFile.close(); diff -r 37b516b9080c -r 3fe33ec624ea graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Mon Apr 20 16:30:41 2015 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Mon Apr 20 16:30:54 2015 +0200 @@ -91,7 +91,7 @@ private double trueDestinationProbability; // This describes the maximum offset between the first emitted (load constant in to scratch, // if does not fit into simm5 of cbcond) instruction and the final branch instruction - private static int maximumSelfOffsetInstructions = 4; + private static int maximumSelfOffsetInstructions = 2; public CompareBranchOp(SPARCCompare opcode, Value x, Value y, Condition condition, LabelRef trueDestination, LabelRef falseDestination, Kind kind, boolean unorderedIsTrue, double trueDestinationProbability) { @@ -218,19 +218,9 @@ actualY = tmpValue; actualConditionFlag = actualConditionFlag.mirror(); } - boolean isValidConstant = isConstant(actualY) && isSimm5(asConstant(actualY)); try (ScratchRegister scratch = masm.getScratchRegister()) { - if (isConstant(actualY) && !isValidConstant) { // Make sure, the y value is loaded - Value scratchValue = scratch.getRegister().asValue(actualY.getLIRKind()); - SPARCMove.move(crb, masm, scratchValue, actualY, SPARCDelayedControlTransfer.DUMMY); - actualY = scratchValue; - } - // Test if the previous instruction was cbcond, if so, put a nop inbetween (See - // SPARC Architecture 2011 manual) - if (masm.isCbcond(masm.getInt(masm.position() - 1))) { - masm.nop(); - } emitCBCond(masm, actualX, actualY, actualTrueTarget, actualConditionFlag); + masm.nop(); } if (needJump) { masm.jmp(actualFalseTarget); @@ -289,6 +279,12 @@ default: return false; } + // Do not use short branch, if the y value is a constant and does not fit into simm5 but + // fits into simm13; this means the code with CBcond would be longer as the code without + // CBcond. + if (isConstant(y) && !isSimm5(asConstant(y)) && isSimm13(asConstant(y))) { + return false; + } boolean hasShortJumpTarget = false; if (!crb.isSuccessorEdge(trueDestination)) { hasShortJumpTarget |= isShortBranch(asm, position, trueDestinationHint, trueDestination.label()); @@ -303,7 +299,6 @@ int disp = 0; if (label.isBound()) { disp = label.position() - position; - } else if (hint != null && hint.isValid()) { disp = hint.getTarget() - hint.getPosition(); } @@ -370,7 +365,6 @@ // We cannot make use of the delay slot when we jump in true-case and false-case return false; } - if (kind == Kind.Double || kind == Kind.Float) { masm.fbpcc(actualConditionFlag, NOT_ANNUL, actualTarget, CC.Fcc0, predictTaken); } else { @@ -524,8 +518,6 @@ public static final class CondMoveOp extends SPARCLIRInstruction { public static final LIRInstructionClass TYPE = LIRInstructionClass.create(CondMoveOp.class); - private final Kind kind; - @Def({REG, HINT}) protected Value result; @Use({REG, CONST}) protected Value trueValue; @Use({REG, CONST}) protected Value falseValue; @@ -533,9 +525,8 @@ private final ConditionFlag condition; private final CC cc; - public CondMoveOp(Kind kind, Variable result, CC cc, ConditionFlag condition, Value trueValue, Value falseValue) { + public CondMoveOp(Variable result, CC cc, ConditionFlag condition, Value trueValue, Value falseValue) { super(TYPE); - this.kind = kind; this.result = result; this.condition = condition; this.trueValue = trueValue; @@ -546,9 +537,9 @@ @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (result.equals(trueValue)) { // We have the true value in place, do he opposite - cmove(masm, cc, kind, result, condition.negate(), falseValue); + cmove(masm, cc, result, condition.negate(), falseValue); } else if (result.equals(falseValue)) { - cmove(masm, cc, kind, result, condition, trueValue); + cmove(masm, cc, result, condition, trueValue); } else { // We have to move one of the input values to the result ConditionFlag actualCondition = condition; Value actualTrueValue = trueValue; @@ -559,13 +550,13 @@ actualFalseValue = trueValue; } SPARCMove.move(crb, masm, result, actualFalseValue, SPARCDelayedControlTransfer.DUMMY); - cmove(masm, cc, kind, result, actualCondition, actualTrueValue); + cmove(masm, cc, result, actualCondition, actualTrueValue); } } } - private static void cmove(SPARCMacroAssembler masm, CC cc, Kind kind, Value result, ConditionFlag cond, Value other) { - switch (kind) { + private static void cmove(SPARCMacroAssembler masm, CC cc, Value result, ConditionFlag cond, Value other) { + switch (other.getKind()) { case Int: if (isConstant(other)) { int constant; diff -r 37b516b9080c -r 3fe33ec624ea src/cpu/sparc/vm/templateInterpreter_sparc.hpp --- a/src/cpu/sparc/vm/templateInterpreter_sparc.hpp Mon Apr 20 16:30:41 2015 +0200 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.hpp Mon Apr 20 16:30:54 2015 +0200 @@ -37,9 +37,9 @@ #ifdef _LP64 // The sethi() instruction generates lots more instructions when shell // stack limit is unlimited, so that's why this is much bigger. - const static int InterpreterCodeSize = 210 * K; + const static int InterpreterCodeSize = 260 * K; #else - const static int InterpreterCodeSize = 180 * K; + const static int InterpreterCodeSize = 230 * K; #endif #endif // CPU_SPARC_VM_TEMPLATEINTERPRETER_SPARC_HPP