# HG changeset patch # User Tom Rodriguez # Date 1398705276 25200 # Node ID bd2d8a93cfbedadcf604189a28f40a29ef875699 # Parent 421a5d2beefe637401fcc4740d1b33bb53e423b9 fix bug with compressed comparision using wrong version of constant diff -r 421a5d2beefe -r bd2d8a93cfbe graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Apr 28 16:07:18 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Apr 28 10:14:36 2014 -0700 @@ -548,6 +548,14 @@ return result; } + public static Register asNarrowReg(Value value) { + if (value.getPlatformKind() != NarrowOopStamp.NarrowOop) { + throw new InternalError("needed NarrowOop got: " + value.getKind()); + } else { + return asRegister(value); + } + } + public Value emitAtomicReadAndWrite(Value address, Value newValue) { PlatformKind kind = newValue.getPlatformKind(); Kind memKind = getMemoryKind(kind); @@ -570,6 +578,11 @@ } @Override + protected void verify() { + assert y instanceof Constant || y.getPlatformKind() == NarrowOopStamp.NarrowOop; + } + + @Override public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (state != null) { crb.recordImplicitException(masm.position(), state); @@ -589,7 +602,7 @@ masm.cmpl(x.toAddress(), 0xdeaddead); } } else { - masm.cmpl(asRegister(y), x.toAddress()); + masm.cmpl(asNarrowReg(y), x.toAddress()); } } } diff -r 421a5d2beefe -r bd2d8a93cfbe graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Mon Apr 28 16:07:18 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Mon Apr 28 10:14:36 2014 -0700 @@ -65,26 +65,33 @@ return result; } - private void emitCompareCompressedMemory(IfNode ifNode, ValueNode value, Access access, CompareNode compare) { + private void emitCompareCompressedMemory(IfNode ifNode, ValueNode valueNode, Access access, CompareNode compare) { + Value value; + // This works by embedding the compressed form for constants, so force a constant instead of + // respecting what operand() would return. + if (valueNode.isConstant()) { + value = valueNode.asConstant(); + } else { + value = gen.load(operand(valueNode)); + } + AMD64AddressValue address = makeAddress(access); + Condition cond = compare.condition(); - LabelRef trueLabel = getLIRBlock(ifNode.trueSuccessor()); - LabelRef falseLabel = getLIRBlock(ifNode.falseSuccessor()); - double trueLabelProbability = ifNode.probability(ifNode.trueSuccessor()); Value left; Value right; if (access == filterCompression(compare.x())) { - if (value.isConstant()) { - left = value.asConstant(); - } else { - left = gen.loadNonConst(operand(value)); - } - right = makeAddress(access); + left = value; + right = address; } else { assert access == filterCompression(compare.y()); - left = makeAddress(access); - right = gen.loadNonConst(operand(value)); + left = address; + right = value; cond = cond.mirror(); } + + LabelRef trueLabel = getLIRBlock(ifNode.trueSuccessor()); + LabelRef falseLabel = getLIRBlock(ifNode.falseSuccessor()); + double trueLabelProbability = ifNode.probability(ifNode.trueSuccessor()); getGen().emitCompareBranchMemoryCompressed(left, right, cond, trueLabel, falseLabel, trueLabelProbability, getState(access)); }