Mercurial > hg > graal-compiler
changeset 22540:3285aa5a60f8
Update jvmci: Remove JavaConstant from Value hierarchy.
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/ConstantStackMoveTest.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/ConstantStackMoveTest.java Mon Aug 31 15:21:36 2015 +0200 @@ -51,9 +51,9 @@ FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); // create slots PrimitiveConstant constantValue = JavaConstant.forBoxedPrimitive(primitive); - StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(constantValue.getLIRKind()); + StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(gen.target().getLIRKind(constantValue.getKind())); // move stuff around - gen.emitMove(s1, constantValue); + gen.emitMoveConstant(s1, constantValue); gen.emitBlackhole(s1); setResult(gen.emitMove(s1)); }
--- a/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/StackStoreTest.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/StackStoreTest.java Mon Aug 31 15:21:36 2015 +0200 @@ -48,7 +48,7 @@ StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); // move stuff around gen.emitMove(s1, a); - gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); + gen.emitMoveConstant(s2, JavaConstant.forShort(Short.MIN_VALUE)); setResult(gen.emitMove(s1)); gen.emitBlackhole(s1); gen.emitBlackhole(s2); @@ -64,7 +64,7 @@ StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); // move stuff around gen.emitMove(s1, a); - Value v = gen.emitMove(JavaConstant.forShort(Short.MIN_VALUE)); + Value v = gen.emitLoadConstant(LIRKind.value(Kind.Short), JavaConstant.forShort(Short.MIN_VALUE)); gen.emitMove(s2, v); setResult(gen.emitMove(s1)); gen.emitBlackhole(s1); @@ -80,7 +80,7 @@ StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); // move stuff around - gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); + gen.emitMoveConstant(s2, JavaConstant.forShort(Short.MIN_VALUE)); gen.emitMove(s1, a); setResult(gen.emitMove(s2)); gen.emitBlackhole(s1);
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Mon Aug 31 15:21:36 2015 +0200 @@ -28,6 +28,7 @@ import static com.oracle.graal.asm.amd64.AMD64Assembler.AMD64RMOp.*; import static com.oracle.graal.asm.amd64.AMD64Assembler.AMD64Shift.*; import static com.oracle.graal.asm.amd64.AMD64Assembler.OperandSize.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*; import static com.oracle.graal.lir.amd64.AMD64MathIntrinsicOp.IntrinsicOpcode.*; import static jdk.internal.jvmci.code.ValueUtil.*; @@ -109,6 +110,10 @@ return AMD64LIRGenerator.this.createStackMove(result, input); } + @Override + protected LIRInstruction createLoadIntern(AllocatableValue result, Constant input) { + return AMD64LIRGenerator.this.createMoveConstant(result, input); + } } public AMD64LIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { @@ -159,8 +164,8 @@ protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { if (src instanceof AMD64AddressValue) { return new LeaOp(dst, (AMD64AddressValue) src); - } else if (isConstant(src)) { - return new MoveFromConstOp(dst, asConstant(src)); + } else if (isJavaConstant(src)) { + return createMoveConstant(dst, asJavaConstant(src)); } else if (isRegister(src) || isStackSlotValue(dst)) { return new MoveFromRegOp(dst.getKind(), dst, (AllocatableValue) src); } else { @@ -168,6 +173,10 @@ } } + protected AMD64LIRInstruction createMoveConstant(AllocatableValue dst, Constant src) { + return new MoveFromConstOp(dst, (JavaConstant) src); + } + protected LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) { Kind kind = result.getKind(); OperandSize size; @@ -219,7 +228,16 @@ @Override public void emitMove(AllocatableValue dst, Value src) { - append(createMove(dst, src)); + if (src instanceof ConstantValue) { + emitMoveConstant(dst, ((ConstantValue) src).getConstant()); + } else { + append(createMove(dst, src)); + } + } + + @Override + public void emitMoveConstant(AllocatableValue dst, Constant src) { + append(createMoveConstant(dst, src)); } public void emitData(AllocatableValue dst, byte[] data) { @@ -292,8 +310,9 @@ return result; } - protected void emitStoreConst(Kind kind, AMD64AddressValue address, JavaConstant value, LIRFrameState state) { - if (value.isNull()) { + protected void emitStoreConst(Kind kind, AMD64AddressValue address, ConstantValue value, LIRFrameState state) { + JavaConstant c = (JavaConstant) value.getConstant(); + if (c.isNull()) { assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object; OperandSize size = kind == Kind.Int ? DWORD : QWORD; append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, size, address, 0, state)); @@ -307,28 +326,28 @@ case Byte: op = AMD64MIOp.MOVB; size = BYTE; - imm = value.asInt(); + imm = c.asInt(); break; case Char: case Short: size = WORD; - imm = value.asInt(); + imm = c.asInt(); break; case Int: size = DWORD; - imm = value.asInt(); + imm = c.asInt(); break; case Long: size = QWORD; - imm = value.asLong(); + imm = c.asLong(); break; case Float: size = DWORD; - imm = Float.floatToRawIntBits(value.asFloat()); + imm = Float.floatToRawIntBits(c.asFloat()); break; case Double: size = QWORD; - imm = Double.doubleToRawLongBits(value.asDouble()); + imm = Double.doubleToRawLongBits(c.asDouble()); break; default: throw JVMCIError.shouldNotReachHere("unexpected kind " + kind); @@ -374,8 +393,8 @@ public void emitStore(LIRKind lirKind, Value address, Value input, LIRFrameState state) { AMD64AddressValue storeAddress = asAddressValue(address); Kind kind = (Kind) lirKind.getPlatformKind(); - if (isConstant(input)) { - emitStoreConst(kind, storeAddress, asConstant(input), state); + if (isJavaConstant(input)) { + emitStoreConst(kind, storeAddress, asConstantValue(input), state); } else { emitStore(kind, storeAddress, asAllocatable(input), state); } @@ -488,10 +507,10 @@ private void emitIntegerTest(Value a, Value b) { assert a.getKind().isNumericInteger(); OperandSize size = a.getKind() == Kind.Long ? QWORD : DWORD; - if (isConstant(b) && NumUtil.is32bit(asConstant(b).asLong())) { - append(new AMD64BinaryConsumer.ConstOp(AMD64MIOp.TEST, size, asAllocatable(a), (int) asConstant(b).asLong())); - } else if (isConstant(a) && NumUtil.is32bit(asConstant(a).asLong())) { - append(new AMD64BinaryConsumer.ConstOp(AMD64MIOp.TEST, size, asAllocatable(b), (int) asConstant(a).asLong())); + if (isJavaConstant(b) && NumUtil.is32bit(asJavaConstant(b).asLong())) { + append(new AMD64BinaryConsumer.ConstOp(AMD64MIOp.TEST, size, asAllocatable(a), (int) asJavaConstant(b).asLong())); + } else if (isJavaConstant(a) && NumUtil.is32bit(asJavaConstant(a).asLong())) { + append(new AMD64BinaryConsumer.ConstOp(AMD64MIOp.TEST, size, asAllocatable(b), (int) asJavaConstant(a).asLong())); } else if (isAllocatableValue(b)) { append(new AMD64BinaryConsumer.Op(AMD64RMOp.TEST, size, asAllocatable(b), asAllocatable(a))); } else { @@ -527,8 +546,8 @@ throw JVMCIError.shouldNotReachHere("unexpected kind: " + cmpKind); } - if (isConstant(right)) { - JavaConstant c = asConstant(right); + if (isJavaConstant(right)) { + JavaConstant c = asJavaConstant(right); if (c.isDefaultForKind()) { AMD64RMOp op = size == BYTE ? TESTB : TEST; append(new AMD64BinaryConsumer.Op(op, size, left, left)); @@ -578,25 +597,26 @@ throw JVMCIError.shouldNotReachHere("unexpected kind: " + cmpKind); } - if (isConstant(a)) { - return emitCompareMemoryConOp(size, asConstant(a), b, state); + if (isJavaConstant(a)) { + return emitCompareMemoryConOp(size, asConstantValue(a), b, state); } else { - return emitCompareRegMemoryOp(size, a, b, state); + return emitCompareRegMemoryOp(size, asAllocatable(a), b, state); } } - protected boolean emitCompareMemoryConOp(OperandSize size, JavaConstant a, AMD64AddressValue b, LIRFrameState state) { - if (NumUtil.is32bit(a.asLong())) { - append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, (int) a.asLong(), state)); + protected boolean emitCompareMemoryConOp(OperandSize size, ConstantValue a, AMD64AddressValue b, LIRFrameState state) { + long value = a.getJavaConstant().asLong(); + if (NumUtil.is32bit(value)) { + append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, (int) value, state)); return true; } else { - return emitCompareRegMemoryOp(size, a, b, state); + return emitCompareRegMemoryOp(size, asAllocatable(a), b, state); } } - private boolean emitCompareRegMemoryOp(OperandSize size, Value a, AMD64AddressValue b, LIRFrameState state) { + private boolean emitCompareRegMemoryOp(OperandSize size, AllocatableValue a, AMD64AddressValue b, LIRFrameState state) { AMD64RMOp op = CMP.getRMOpcode(size); - append(new AMD64BinaryConsumer.MemoryRMOp(op, size, asAllocatable(a), b, state)); + append(new AMD64BinaryConsumer.MemoryRMOp(op, size, a, b, state)); return false; } @@ -666,29 +686,30 @@ } private Variable emitBinary(LIRKind resultKind, AMD64BinaryArithmetic op, OperandSize size, boolean commutative, Value a, Value b, boolean setFlags) { - if (isConstant(b)) { - return emitBinaryConst(resultKind, op, size, commutative, asAllocatable(a), asConstant(b), setFlags); - } else if (commutative && isConstant(a)) { - return emitBinaryConst(resultKind, op, size, commutative, asAllocatable(b), asConstant(a), setFlags); + if (isJavaConstant(b)) { + return emitBinaryConst(resultKind, op, size, commutative, asAllocatable(a), asConstantValue(b), setFlags); + } else if (commutative && isJavaConstant(a)) { + return emitBinaryConst(resultKind, op, size, commutative, asAllocatable(b), asConstantValue(a), setFlags); } else { return emitBinaryVar(resultKind, op.getRMOpcode(size), size, commutative, asAllocatable(a), asAllocatable(b)); } } private Variable emitBinary(LIRKind resultKind, AMD64RMOp op, OperandSize size, boolean commutative, Value a, Value b) { - if (isConstant(b)) { - return emitBinaryConst(resultKind, op, size, asAllocatable(a), asConstant(b)); - } else if (commutative && isConstant(a)) { - return emitBinaryConst(resultKind, op, size, asAllocatable(b), asConstant(a)); + if (isJavaConstant(b)) { + return emitBinaryConst(resultKind, op, size, asAllocatable(a), asJavaConstant(b)); + } else if (commutative && isJavaConstant(a)) { + return emitBinaryConst(resultKind, op, size, asAllocatable(b), asJavaConstant(a)); } else { return emitBinaryVar(resultKind, op, size, commutative, asAllocatable(a), asAllocatable(b)); } } - private Variable emitBinaryConst(LIRKind resultKind, AMD64BinaryArithmetic op, OperandSize size, boolean commutative, AllocatableValue a, JavaConstant b, boolean setFlags) { - if (NumUtil.isInt(b.asLong())) { + private Variable emitBinaryConst(LIRKind resultKind, AMD64BinaryArithmetic op, OperandSize size, boolean commutative, AllocatableValue a, ConstantValue b, boolean setFlags) { + long value = b.getJavaConstant().asLong(); + if (NumUtil.isInt(value)) { Variable result = newVariable(resultKind); - int constant = (int) b.asLong(); + int constant = (int) value; if (!setFlags) { AMD64MOp mop = getMOp(op, constant); @@ -772,9 +793,10 @@ } } - private Variable emitIMULConst(OperandSize size, AllocatableValue a, JavaConstant b) { - if (NumUtil.isInt(b.asLong())) { - int imm = (int) b.asLong(); + private Variable emitIMULConst(OperandSize size, AllocatableValue a, ConstantValue b) { + long value = b.getJavaConstant().asLong(); + if (NumUtil.isInt(value)) { + int imm = (int) value; AMD64RMIOp op; if (NumUtil.isByte(imm)) { op = AMD64RMIOp.IMUL_SX; @@ -791,10 +813,10 @@ } private Variable emitIMUL(OperandSize size, Value a, Value b) { - if (isConstant(b)) { - return emitIMULConst(size, asAllocatable(a), asConstant(b)); - } else if (isConstant(a)) { - return emitIMULConst(size, asAllocatable(b), asConstant(a)); + if (isJavaConstant(b)) { + return emitIMULConst(size, asAllocatable(a), asConstantValue(b)); + } else if (isJavaConstant(a)) { + return emitIMULConst(size, asAllocatable(b), asConstantValue(a)); } else { return emitBinaryVar(LIRKind.combine(a, b), AMD64RMOp.IMUL, size, true, asAllocatable(a), asAllocatable(b)); } @@ -1047,8 +1069,8 @@ private Variable emitShift(AMD64Shift op, OperandSize size, Value a, Value b) { Variable result = newVariable(LIRKind.combine(a, b).changeType(a.getPlatformKind())); AllocatableValue input = asAllocatable(a); - if (isConstant(b)) { - JavaConstant c = asConstant(b); + if (isJavaConstant(b)) { + JavaConstant c = asJavaConstant(b); if (c.asLong() == 1) { append(new AMD64Unary.MOp(op.m1Op, size, result, input)); } else {
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java Mon Aug 31 15:21:36 2015 +0200 @@ -181,7 +181,7 @@ double trueLabelProbability = ifNode.probability(ifNode.trueSuccessor()); Value other; if (value.isConstant()) { - other = value.asJavaConstant(); + other = gen.emitJavaConstant(value.asJavaConstant()); } else { other = operand(value); }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java Mon Aug 31 15:21:36 2015 +0200 @@ -44,7 +44,7 @@ @Override public LIRKind getLIRKind(LIRKindTool tool) { - throw JVMCIError.shouldNotReachHere("illegal stamp should not reach backend"); + return LIRKind.Illegal; } @Override
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Aug 31 15:21:36 2015 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.compiler.sparc; +import static com.oracle.graal.lir.LIRValueUtil.*; import static com.oracle.graal.lir.sparc.SPARCArithmetic.*; import static com.oracle.graal.lir.sparc.SPARCBitManipulationOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.sparc.SPARCCompare.*; @@ -86,6 +87,11 @@ protected LIRInstruction createStackMoveIntern(AllocatableValue result, AllocatableValue input) { return SPARCLIRGenerator.this.createStackMove(result, input); } + + @Override + protected LIRInstruction createLoadIntern(AllocatableValue result, Constant input) { + return SPARCLIRGenerator.this.createMoveConstant(result, input); + } } public SPARCLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { @@ -120,15 +126,10 @@ protected LIRInstruction createMove(AllocatableValue dst, Value src) { boolean srcIsSlot = isStackSlotValue(src); boolean dstIsSlot = isStackSlotValue(dst); - if (src instanceof SPARCAddressValue) { + if (src instanceof ConstantValue) { + return createMoveConstant(dst, ((ConstantValue) src).getConstant()); + } else if (src instanceof SPARCAddressValue) { return new LoadAddressOp(dst, (SPARCAddressValue) src); - } else if (src instanceof JavaConstant) { - JavaConstant javaConstant = (JavaConstant) src; - if (canInlineConstant(javaConstant)) { - return new SPARCMove.LoadInlineConstant(javaConstant, dst); - } else { - return new SPARCMove.LoadConstantFromTable(javaConstant, getConstantTableBase(), dst); - } } else { assert src instanceof AllocatableValue; if (srcIsSlot && dstIsSlot) { @@ -139,6 +140,19 @@ } } + protected LIRInstruction createMoveConstant(AllocatableValue dst, Constant src) { + if (src instanceof JavaConstant) { + JavaConstant javaConstant = (JavaConstant) src; + if (canInlineConstant(javaConstant)) { + return new SPARCMove.LoadInlineConstant(javaConstant, dst); + } else { + return new SPARCMove.LoadConstantFromTable(javaConstant, getConstantTableBase(), dst); + } + } else { + throw JVMCIError.shouldNotReachHere(src.getClass().toString()); + } + } + protected LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) { return new SPARCMove.Move(result, input); } @@ -149,6 +163,11 @@ } @Override + public void emitMoveConstant(AllocatableValue dst, Constant src) { + append(createMoveConstant(dst, src)); + } + + @Override public void emitData(AllocatableValue dst, byte[] data) { append(new LoadDataAddressOp(dst, data)); } @@ -196,7 +215,7 @@ Value left; Value right; Condition actualCondition; - if (isConstant(x)) { + if (isJavaConstant(x)) { left = load(y); right = loadNonConst(x); actualCondition = cond.mirror(); @@ -263,8 +282,8 @@ } private Value loadSimm11(Value value) { - if (isConstant(value)) { - JavaConstant c = asConstant(value); + if (isJavaConstant(value)) { + JavaConstant c = asJavaConstant(value); if (c.isNull() || SPARCAssembler.isSimm11(c)) { return value; } @@ -514,16 +533,16 @@ } private Variable emitBinary(LIRKind resultKind, SPARCArithmetic op, boolean commutative, Value a, Value b, LIRFrameState state) { - if (isConstant(b) && canInlineConstant(asConstant(b))) { - return emitBinaryConst(resultKind, op, load(a), asConstant(b), state); - } else if (commutative && isConstant(a) && canInlineConstant(asConstant(a))) { - return emitBinaryConst(resultKind, op, load(b), asConstant(a), state); + if (isJavaConstant(b) && canInlineConstant(asJavaConstant(b))) { + return emitBinaryConst(resultKind, op, load(a), asConstantValue(b), state); + } else if (commutative && isJavaConstant(a) && canInlineConstant(asJavaConstant(a))) { + return emitBinaryConst(resultKind, op, load(b), asConstantValue(a), state); } else { return emitBinaryVar(resultKind, op, load(a), load(b), state); } } - private Variable emitBinaryConst(LIRKind resultKind, SPARCArithmetic op, AllocatableValue a, JavaConstant b, LIRFrameState state) { + private Variable emitBinaryConst(LIRKind resultKind, SPARCArithmetic op, AllocatableValue a, ConstantValue b, LIRFrameState state) { switch (op) { case IADD: case LADD: @@ -537,9 +556,9 @@ case LXOR: case IMUL: case LMUL: - if (canInlineConstant(b)) { + if (canInlineConstant(b.getJavaConstant())) { Variable result = newVariable(resultKind); - append(new BinaryRegConst(op, result, a, b, state)); + append(new BinaryRegConst(op, result, a, b.getJavaConstant(), state)); return result; } break; @@ -777,8 +796,8 @@ private Variable emitShift(SPARCArithmetic op, Value a, Value b) { Variable result = newVariable(LIRKind.combine(a, b).changeType(a.getPlatformKind())); - if (isConstant(b) && canInlineConstant((JavaConstant) b)) { - append(new BinaryRegConst(op, result, load(a), asConstant(b), null)); + if (isJavaConstant(b) && canInlineConstant((JavaConstant) b)) { + append(new BinaryRegConst(op, result, load(a), asJavaConstant(b), null)); } else { append(new BinaryRegReg(op, result, load(a), load(b))); } @@ -985,7 +1004,7 @@ append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), constant, null)); } else { Variable maskVar = newVariable(LIRKind.combine(inputVal).changeType(Kind.Int)); - emitMove(maskVar, constant); + emitMoveConstant(maskVar, constant); append(new BinaryRegReg(IAND, result, maskVar, asAllocatable(inputVal))); } if (toBits > 32) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Mon Aug 31 15:21:36 2015 +0200 @@ -202,14 +202,17 @@ ArrayList<LIRKind> values = new ArrayList<>(phi.valueCount()); for (int i = 0; i < phi.valueCount(); i++) { ValueNode node = phi.valueAt(i); - Value value = node instanceof ConstantNode ? ((ConstantNode) node).asJavaConstant() : getOperand(node); - if (value != null) { - values.add(value.getLIRKind()); + if (node instanceof ConstantNode) { + values.add(gen.getLIRKind(node.stamp())); } else { - assert node instanceof ConstantNode || isPhiInputFromBackedge(phi, i) : String.format("Input %s to phi node %s is not yet available although it is not coming from a loop back edge", - node, phi); - // non-java constant -> get Kind from stamp. - values.add(getLIRGeneratorTool().getLIRKind(node.stamp())); + Value value = getOperand(node); + if (value != null) { + values.add(value.getLIRKind()); + } else { + assert isPhiInputFromBackedge(phi, i) : String.format("Input %s to phi node %s is not yet available although it is not coming from a loop back edge", node, phi); + // non-java constant -> get Kind from stamp. + values.add(getLIRGeneratorTool().getLIRKind(node.stamp())); + } } } LIRKind derivedKind = LIRKind.merge(values); @@ -496,8 +499,9 @@ } private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { - PlatformKind kind = gen.getLIRKind(node.getValue().stamp()).getPlatformKind(); - gen.emitCompareBranch(kind, operand(node.getValue()), kind.getDefaultValue(), Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability); + LIRKind kind = gen.getLIRKind(node.getValue().stamp()); + Value nullValue = gen.emitConstant(kind, JavaConstant.NULL_POINTER); + gen.emitCompareBranch(kind.getPlatformKind(), operand(node.getValue()), nullValue, Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability); } public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) { @@ -524,8 +528,9 @@ public Variable emitConditional(LogicNode node, Value trueValue, Value falseValue) { if (node instanceof IsNullNode) { IsNullNode isNullNode = (IsNullNode) node; - PlatformKind kind = gen.getLIRKind(isNullNode.getValue().stamp()).getPlatformKind(); - return gen.emitConditionalMove(kind, operand(isNullNode.getValue()), kind.getDefaultValue(), Condition.EQ, false, trueValue, falseValue); + LIRKind kind = gen.getLIRKind(isNullNode.getValue().stamp()); + Value nullValue = gen.emitConstant(kind, JavaConstant.NULL_POINTER); + return gen.emitConditionalMove(kind.getPlatformKind(), operand(isNullNode.getValue()), nullValue, Condition.EQ, false, trueValue, falseValue); } else if (node instanceof CompareNode) { CompareNode compare = (CompareNode) node; PlatformKind kind = gen.getLIRKind(compare.getX().stamp()).getPlatformKind(); @@ -615,8 +620,9 @@ if (keyCount == 1) { assert defaultTarget != null; double probability = x.probability(x.keySuccessor(0)); - PlatformKind kind = gen.getLIRKind(x.value().stamp()).getPlatformKind(); - gen.emitCompareBranch(kind, gen.load(operand(x.value())), x.keyAt(0), Condition.EQ, false, getLIRBlock(x.keySuccessor(0)), defaultTarget, probability); + LIRKind kind = gen.getLIRKind(x.value().stamp()); + Value key = gen.emitConstant(kind, x.keyAt(0)); + gen.emitCompareBranch(kind.getPlatformKind(), gen.load(operand(x.value())), key, Condition.EQ, false, getLIRBlock(x.keySuccessor(0)), defaultTarget, probability); } else { LabelRef[] keyTargets = new LabelRef[keyCount]; JavaConstant[] keyConstants = new JavaConstant[keyCount];
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,12 +22,13 @@ */ package com.oracle.graal.hotspot.amd64; +import static com.oracle.graal.lir.LIRValueUtil.*; +import static jdk.internal.jvmci.amd64.AMD64.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.common.JVMCIError.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; -import static jdk.internal.jvmci.amd64.AMD64.*; -import static jdk.internal.jvmci.code.ValueUtil.*; -import static jdk.internal.jvmci.common.JVMCIError.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; @@ -102,8 +103,8 @@ // address for counter value AMD64Address counterAddr = new AMD64Address(countersArrayReg, displacement); // increment counter (in memory) - if (isConstant(incrementValue)) { - int increment = asInt(asConstant(incrementValue)); + if (isJavaConstant(incrementValue)) { + int increment = asInt(asJavaConstant(incrementValue)); masm.incrementq(counterAddr, increment); } else { masm.addq(counterAddr, asRegister(incrementValue));
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Aug 31 15:21:36 2015 +0200 @@ -26,6 +26,7 @@ import static com.oracle.graal.asm.amd64.AMD64Assembler.AMD64RMOp.*; import static com.oracle.graal.asm.amd64.AMD64Assembler.OperandSize.*; import static com.oracle.graal.hotspot.HotSpotBackend.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.amd64.AMD64.*; import java.util.*; @@ -33,9 +34,8 @@ import jdk.internal.jvmci.amd64.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import com.oracle.graal.debug.*; import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.hotspot.HotSpotVMConfig.*; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; import jdk.internal.jvmci.meta.*; import com.oracle.graal.asm.amd64.AMD64Address.Scale; @@ -44,6 +44,7 @@ import com.oracle.graal.compiler.amd64.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.spi.*; +import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.StoreRbpOp; import com.oracle.graal.hotspot.debug.*; @@ -431,15 +432,15 @@ // TODO(mg): in case a native function uses floating point varargs, the ABI requires that // RAX contains the length of the varargs PrimitiveConstant intConst = JavaConstant.forInt(numberOfFloatingPointArguments); - AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue(intConst.getLIRKind()); - emitMove(numberOfFloatingPointArgumentsRegister, intConst); + AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue(LIRKind.value(Kind.Int)); + emitMoveConstant(numberOfFloatingPointArgumentsRegister, intConst); for (int i = 0; i < args.length; i++) { Value arg = args[i]; AllocatableValue loc = nativeCallingConvention.getArgument(i); emitMove(loc, arg); argLocations[i] = loc; } - Value ptr = emitMove(JavaConstant.forLong(address)); + Value ptr = emitLoadConstant(LIRKind.value(Kind.Long), JavaConstant.forLong(address)); append(new AMD64CCall(nativeCallingConvention.getReturn(), ptr, numberOfFloatingPointArgumentsRegister, argLocations)); } @@ -473,7 +474,9 @@ @Override public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) { - moveDeoptValuesToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0), JavaConstant.NULL_POINTER); + Value actionAndReason = emitJavaConstant(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0)); + Value nullValue = emitConstant(LIRKind.reference(Kind.Object), JavaConstant.NULL_POINTER); + moveDeoptValuesToThread(actionAndReason, nullValue); append(new AMD64HotSpotDeoptimizeCallerOp(saveRbp.getRbpRescueSlot())); } @@ -506,15 +509,16 @@ } @Override - protected void emitStoreConst(Kind kind, AMD64AddressValue address, JavaConstant value, LIRFrameState state) { - if (value instanceof HotSpotConstant && value.isNonNull()) { - HotSpotConstant c = (HotSpotConstant) value; - if (c.isCompressed()) { + protected void emitStoreConst(Kind kind, AMD64AddressValue address, ConstantValue value, LIRFrameState state) { + Constant c = value.getConstant(); + if (c instanceof HotSpotConstant && !JavaConstant.isNull(c)) { + HotSpotConstant hc = (HotSpotConstant) c; + if (hc.isCompressed()) { assert kind == Kind.Int; - if (!target().inlineObjects && c instanceof HotSpotObjectConstant) { + if (!target().inlineObjects && hc instanceof HotSpotObjectConstant) { emitStore(kind, address, asAllocatable(value), state); } else { - append(new AMD64HotSpotBinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, address, c, state)); + append(new AMD64HotSpotBinaryConsumer.MemoryConstOp(AMD64MIOp.MOV, address, hc, state)); } } else { emitStore(kind, address, asAllocatable(value), state); @@ -538,7 +542,7 @@ Variable result = newVariable(LIRKind.value(Kind.Int)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { - base = emitMove(JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(Kind.Long), JavaConstant.forLong(encoding.base)); } append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); return result; @@ -559,7 +563,7 @@ Variable result = newVariable(LIRKind.value(Kind.Long)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { - base = emitMove(JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(Kind.Long), JavaConstant.forLong(encoding.base)); } append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); return result; @@ -567,19 +571,16 @@ } @Override - protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { - if (src instanceof JavaConstant) { - if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(src)) { - return super.createMove(dst, JavaConstant.INT_0); - } - if (src instanceof HotSpotObjectConstant) { - return new AMD64HotSpotMove.HotSpotLoadObjectConstantOp(dst, (HotSpotObjectConstant) src); - } - if (src instanceof HotSpotMetaspaceConstant) { - return new AMD64HotSpotMove.HotSpotLoadMetaspaceConstantOp(dst, (HotSpotMetaspaceConstant) src); - } + protected AMD64LIRInstruction createMoveConstant(AllocatableValue dst, Constant src) { + if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(src)) { + return super.createMoveConstant(dst, JavaConstant.INT_0); + } else if (src instanceof HotSpotObjectConstant) { + return new AMD64HotSpotMove.HotSpotLoadObjectConstantOp(dst, (HotSpotObjectConstant) src); + } else if (src instanceof HotSpotMetaspaceConstant) { + return new AMD64HotSpotMove.HotSpotLoadMetaspaceConstantOp(dst, (HotSpotMetaspaceConstant) src); + } else { + return super.createMoveConstant(dst, src); } - return super.createMove(dst, src); } @Override @@ -601,32 +602,38 @@ @Override protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) { - if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(right)) { - append(new AMD64BinaryConsumer.Op(TEST, DWORD, left, left)); - } else if (right instanceof HotSpotConstant) { - HotSpotConstant c = (HotSpotConstant) right; + if (isConstantValue(right)) { + Constant c = asConstant(right); + if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { + append(new AMD64BinaryConsumer.Op(TEST, DWORD, left, left)); + return; + } else if (c instanceof HotSpotConstant) { + HotSpotConstant hsc = (HotSpotConstant) c; - boolean isImmutable = GraalOptions.ImmutableCode.getValue(); - boolean generatePIC = GraalOptions.GeneratePIC.getValue(); - if (c.isCompressed() && !(isImmutable && generatePIC)) { - append(new AMD64HotSpotBinaryConsumer.ConstOp(CMP.getMIOpcode(DWORD, false), left, c)); - } else { - OperandSize size = c.isCompressed() ? DWORD : QWORD; - append(new AMD64BinaryConsumer.DataOp(CMP.getRMOpcode(size), size, left, c)); + boolean isImmutable = GraalOptions.ImmutableCode.getValue(); + boolean generatePIC = GraalOptions.GeneratePIC.getValue(); + if (hsc.isCompressed() && !(isImmutable && generatePIC)) { + append(new AMD64HotSpotBinaryConsumer.ConstOp(CMP.getMIOpcode(DWORD, false), left, hsc)); + } else { + OperandSize size = hsc.isCompressed() ? DWORD : QWORD; + append(new AMD64BinaryConsumer.DataOp(CMP.getRMOpcode(size), size, left, hsc)); + } + return; } - } else { - super.emitCompareOp(cmpKind, left, right); } + + super.emitCompareOp(cmpKind, left, right); } @Override - protected boolean emitCompareMemoryConOp(OperandSize size, JavaConstant a, AMD64AddressValue b, LIRFrameState state) { - if (a.isNull()) { + protected boolean emitCompareMemoryConOp(OperandSize size, ConstantValue a, AMD64AddressValue b, LIRFrameState state) { + if (JavaConstant.isNull(a.getConstant())) { append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, 0, state)); return true; - } else if (a instanceof HotSpotConstant && size == DWORD) { - assert ((HotSpotConstant) a).isCompressed(); - append(new AMD64HotSpotBinaryConsumer.MemoryConstOp(CMP.getMIOpcode(size, false), b, (HotSpotConstant) a, state)); + } else if (a.getConstant() instanceof HotSpotConstant && size == DWORD) { + HotSpotConstant hc = (HotSpotConstant) a.getConstant(); + assert hc.isCompressed(); + append(new AMD64HotSpotBinaryConsumer.MemoryConstOp(CMP.getMIOpcode(size, false), b, hc, state)); return true; } else { return super.emitCompareMemoryConOp(size, a, b, state);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,15 +22,17 @@ */ package com.oracle.graal.hotspot.sparc; +import static com.oracle.graal.asm.sparc.SPARCAssembler.*; +import static com.oracle.graal.lir.LIRValueUtil.*; +import static jdk.internal.jvmci.code.ValueUtil.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.asm.sparc.SPARCAssembler.*; -import static jdk.internal.jvmci.code.ValueUtil.*; import com.oracle.graal.asm.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*; +import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister; +import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; @@ -76,8 +78,8 @@ masm.ldx(counterAddr, counterReg); counterPatchOffsets[counterIndex] = masm.position(); // increment counter - if (isConstant(increment)) { - masm.add(counterReg, asInt(asConstant(increment)), counterReg); + if (isJavaConstant(increment)) { + masm.add(counterReg, asInt(asJavaConstant(increment)), counterReg); } else { masm.add(counterReg, asRegister(increment), counterReg); }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Mon Aug 31 15:21:36 2015 +0200 @@ -24,7 +24,7 @@ import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static jdk.internal.jvmci.code.ValueUtil.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.hotspot.HotSpotCompressedNullConstant.*; import static jdk.internal.jvmci.sparc.SPARC.*; @@ -198,7 +198,9 @@ @Override public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) { - moveDeoptValuesToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0), JavaConstant.NULL_POINTER); + Value actionAndReason = emitJavaConstant(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0)); + Value nullValue = emitJavaConstant(JavaConstant.NULL_POINTER); + moveDeoptValuesToThread(actionAndReason, nullValue); append(new SPARCHotSpotDeoptimizeCallerOp()); } @@ -224,8 +226,8 @@ @Override public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { SPARCAddressValue storeAddress = asAddressValue(address); - if (isConstant(inputVal)) { - JavaConstant c = asConstant(inputVal); + if (isJavaConstant(inputVal)) { + JavaConstant c = asJavaConstant(inputVal); if (c.isDefaultForKind()) { append(new StoreConstantOp(kind.getPlatformKind(), storeAddress, c, state)); return; @@ -254,14 +256,14 @@ } @Override - protected LIRInstruction createMove(AllocatableValue dst, Value src) { - Value usedSource; + protected LIRInstruction createMoveConstant(AllocatableValue dst, Constant src) { + Constant usedSource; if (COMPRESSED_NULL.equals(src)) { usedSource = INT_0; } else { usedSource = src; } - return super.createMove(dst, usedSource); + return super.createMoveConstant(dst, usedSource); } @Override @@ -282,15 +284,21 @@ protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b) { Value localA = a; Value localB = b; - if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(localA)) { - localA = SPARC.g0.asValue(LIRKind.value(Kind.Int)); - } else if (localA instanceof HotSpotObjectConstant) { - localA = load(localA); + if (isConstantValue(a)) { + Constant c = asConstant(a); + if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { + localA = SPARC.g0.asValue(LIRKind.value(Kind.Int)); + } else if (c instanceof HotSpotObjectConstant) { + localA = load(localA); + } } - if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(localB)) { - localB = SPARC.g0.asValue(LIRKind.value(Kind.Int)); - } else if (localB instanceof HotSpotObjectConstant) { - localB = load(localB); + if (isConstantValue(b)) { + Constant c = asConstant(b); + if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { + localB = SPARC.g0.asValue(LIRKind.value(Kind.Int)); + } else if (c instanceof HotSpotObjectConstant) { + localB = load(localB); + } } return super.emitCompare(cmpKind, localA, localB); } @@ -309,7 +317,7 @@ Variable result = newVariable(LIRKind.value(Kind.Int)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { - base = emitMove(JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(Kind.Long), JavaConstant.forLong(encoding.base)); } append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); return result; @@ -330,7 +338,7 @@ Variable result = newVariable(LIRKind.value(Kind.Long)); AllocatableValue base = Value.ILLEGAL; if (encoding.base != 0) { - base = emitMove(JavaConstant.forLong(encoding.base)); + base = emitLoadConstant(LIRKind.value(Kind.Long), JavaConstant.forLong(encoding.base)); } append(new SPARCHotSpotMove.UncompressPointer(result, asAllocatable(pointer), base, encoding, nonNull)); return result;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; @@ -111,9 +112,9 @@ } protected int getIndex(String name, String group, Value increment) { - if (isConstant(increment)) { + if (isJavaConstant(increment)) { // get index for the counter - return BenchmarkCounters.getIndexConstantIncrement(name, group, config, asLong(asConstant(increment))); + return BenchmarkCounters.getIndexConstantIncrement(name, group, config, asLong(asJavaConstant(increment))); } assert isRegister(increment) : "Unexpected Value: " + increment; // get index for the counter
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotInstructionProfiling.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotInstructionProfiling.java Mon Aug 31 15:21:36 2015 +0200 @@ -48,16 +48,18 @@ @Override protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, BenchmarkCounterFactory counterFactory) { - new Analyzer(lirGenRes.getCompilationUnitName(), lirGenRes.getLIR(), counterFactory).run(); + new Analyzer(target, lirGenRes.getCompilationUnitName(), lirGenRes.getLIR(), counterFactory).run(); } private class Analyzer { + private final TargetDescription target; private final LIR lir; private final BenchmarkCounterFactory counterFactory; private final LIRInsertionBuffer buffer; private final String compilationUnitName; - public Analyzer(String compilationUnitName, LIR lir, BenchmarkCounterFactory counterFactory) { + public Analyzer(TargetDescription target, String compilationUnitName, LIR lir, BenchmarkCounterFactory counterFactory) { + this.target = target; this.lir = lir; this.compilationUnitName = compilationUnitName; this.counterFactory = counterFactory; @@ -83,7 +85,7 @@ for (int i = 0; i < instructionsToProfile.length; i++) { names[i] = compilationUnitName; groups[i] = COUNTER_GROUP + " " + instructionsToProfile[i]; - increments[i] = JavaConstant.INT_0; + increments[i] = new ConstantValue(target.getLIRKind(Kind.Int), JavaConstant.INT_0); } HotSpotCounterOp op = (HotSpotCounterOp) counterFactory.createMultiBenchmarkCounter(names, groups, increments); LIRInstruction inst = new InstructionCounterOp(op, instructionsToProfile);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMapBuilder.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMapBuilder.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,18 +22,19 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.framemap.*; - import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.hotspot.*; import jdk.internal.jvmci.meta.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.framemap.*; + public final class HotSpotReferenceMapBuilder extends ReferenceMapBuilder { private int maxRegisterSize; @@ -54,7 +55,7 @@ @Override public void addLiveValue(Value v) { - if (isConstant(v)) { + if (isJavaConstant(v)) { return; } LIRKind lirKind = v.getLIRKind();
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, 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 @@ -127,7 +127,7 @@ public static final class StrategySwitchOp extends AMD64BlockEndOp { public static final LIRInstructionClass<StrategySwitchOp> TYPE = LIRInstructionClass.create(StrategySwitchOp.class); - @Use({CONST}) protected JavaConstant[] keyConstants; + protected final JavaConstant[] keyConstants; private final LabelRef[] keyTargets; private LabelRef defaultTarget; @Alive({REG}) protected Value key; @@ -168,7 +168,7 @@ break; case Object: assert condition == Condition.EQ || condition == Condition.NE; - AMD64Move.move(crb, masm, scratch, keyConstants[index]); + AMD64Move.const2reg(crb, masm, scratch, keyConstants[index]); masm.cmpptr(keyRegister, asObjectReg(scratch)); break; default:
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Mon Aug 31 15:21:36 2015 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.lir.amd64; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static java.lang.Double.*; import static java.lang.Float.*; import static jdk.internal.jvmci.code.ValueUtil.*; @@ -491,11 +492,11 @@ } else { throw JVMCIError.shouldNotReachHere(); } - } else if (isConstant(input)) { + } else if (isJavaConstant(input)) { if (isRegister(result)) { - const2reg(crb, masm, result, (JavaConstant) input); + const2reg(crb, masm, result, asJavaConstant(input)); } else if (isStackSlot(result)) { - const2stack(crb, masm, result, (JavaConstant) input); + const2stack(crb, masm, result, asJavaConstant(input)); } else { throw JVMCIError.shouldNotReachHere(); } @@ -595,7 +596,7 @@ } } - private static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, JavaConstant input) { + public static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, JavaConstant input) { /* * Note: we use the kind of the input operand (and not the kind of the result operand) * because they don't match in all cases. For example, an object constant can be loaded to a @@ -672,7 +673,7 @@ } } - private static void const2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, JavaConstant input) { + public static void const2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, JavaConstant input) { assert !crb.codeCache.needsDataPatch(input); AMD64Address dest = (AMD64Address) crb.asAddress(result); final long imm;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.lir.amd64; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static com.oracle.graal.lir.amd64.AMD64SaveRegistersOp.*; import java.util.*; @@ -51,7 +50,7 @@ /** * The garbage values that are written to the registers. */ - @Use({CONST}) protected JavaConstant[] zapValues; + protected final JavaConstant[] zapValues; public AMD64ZapRegistersOp(Register[] zappedRegisters, JavaConstant[] zapValues) { super(TYPE); @@ -62,9 +61,11 @@ @Override public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < zappedRegisters.length; i++) { - if (zappedRegisters[i] != null) { - RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getLIRKind()); - AMD64Move.move(crb, masm, registerValue, zapValues[i]); + Register reg = zappedRegisters[i]; + if (reg != null) { + PlatformKind kind = crb.target.arch.getLargestStorableKind(reg.getRegisterCategory()); + RegisterValue registerValue = reg.asValue(LIRKind.value(kind)); + AMD64Move.const2reg(crb, masm, registerValue, zapValues[i]); } } }
--- a/graal/com.oracle.graal.lir.jtt/src/com/oracle/graal/lir/jtt/ConstantStackCastTest.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.jtt/src/com/oracle/graal/lir/jtt/ConstantStackCastTest.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,13 +22,14 @@ */ package com.oracle.graal.lir.jtt; -import static jdk.internal.jvmci.code.ValueUtil.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; import org.junit.*; +import com.oracle.graal.lir.*; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; @@ -52,17 +53,23 @@ // create slots StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(dstKind); // move stuff around - Value srcValue = isConstant(value) ? getConstant(srcKind, value) : value; + Value srcValue; + if (isJavaConstant(value)) { + srcValue = getConstant(srcKind, asJavaConstant(value)); + } else { + srcValue = value; + } gen.emitMove(s1, srcValue); gen.emitBlackhole(s1); setResult(gen.emitMove(s1)); } - private static PrimitiveConstant getConstant(LIRKind srcKind, Value value) { + private static ConstantValue getConstant(LIRKind srcKind, JavaConstant c) { switch ((Kind) srcKind.getPlatformKind()) { case Byte: - return JavaConstant.forByte((byte) asConstant(value).asInt()); + JavaConstant byteConst = JavaConstant.forByte((byte) c.asInt()); + return new ConstantValue(srcKind, byteConst); default: throw JVMCIError.shouldNotReachHere("Kind not supported: " + srcKind); }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Mon Aug 31 15:21:36 2015 +0200 @@ -29,6 +29,7 @@ import static com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag.*; import static com.oracle.graal.asm.sparc.SPARCAssembler.Opfs.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.code.*; @@ -134,7 +135,7 @@ @Override public void verify() { super.verify(); - verifyKind(opcode, result, x, y); + verifyKind(opcode, result.getKind(), x.getKind(), y.getKind()); } @Override @@ -185,7 +186,7 @@ @Override public void verify() { super.verify(); - verifyKind(opcode, result, x, y); + verifyKind(opcode, result.getKind(), x.getKind(), y.getKind()); } } @@ -223,7 +224,7 @@ @Override public void verify() { super.verify(); - verifyKind(opcode, result, x, y); + verifyKind(opcode, result.getKind(), x.getKind(), y.getKind()); } } @@ -276,8 +277,8 @@ private static void emitRegConstant(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, JavaConstant src2, LIRFrameState info, SPARCDelayedControlTransfer delaySlotLir) { - assert isSimm13(crb.asIntConst(src2)) : src2; - int constant = crb.asIntConst(src2); + assert isSimm13(src2.asLong()) : src2; + int constant = (int) src2.asLong(); int exceptionOffset = -1; delaySlotLir.emitControlTransfer(crb, masm); switch (opcode) { @@ -384,8 +385,8 @@ public static void emitRegReg(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info, SPARCDelayedControlTransfer delaySlotLir) { int exceptionOffset = -1; - assert !isConstant(src1) : src1; - assert !isConstant(src2) : src2; + assert !isJavaConstant(src1) : src1; + assert !isJavaConstant(src2) : src2; switch (opcode) { case IADD: delaySlotLir.emitControlTransfer(crb, masm); @@ -573,7 +574,7 @@ public static void emitRem(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, Value scratch1, Value scratch2, LIRFrameState info, SPARCDelayedControlTransfer delaySlotLir) { int exceptionOffset = -1; - if (!isConstant(src1) && isConstant(src2)) { + if (!isJavaConstant(src1) && isJavaConstant(src2)) { assert isSimm13(crb.asIntConst(src2)); assert !src1.equals(scratch1); assert !src1.equals(scratch2); @@ -611,7 +612,7 @@ Value srcLeft = src1; switch (opcode) { case LREM: - if (isConstant(src1)) { + if (isJavaConstant(src1)) { new Setx(crb.asLongConst(src1), asLongReg(scratch2), false).emit(masm); srcLeft = scratch2; } @@ -625,7 +626,7 @@ masm.sub(asLongReg(srcLeft), asLongReg(scratch1), asLongReg(dst)); break; case LUREM: - if (isConstant(src1)) { + if (isJavaConstant(src1)) { new Setx(crb.asLongConst(src1), asLongReg(scratch2), false).emit(masm); srcLeft = scratch2; } @@ -638,7 +639,7 @@ masm.sub(asLongReg(srcLeft), asLongReg(scratch1), asLongReg(dst)); break; case IREM: - if (isConstant(src1)) { + if (isJavaConstant(src1)) { new Setx(crb.asIntConst(src1), asIntReg(scratch2), false).emit(masm); srcLeft = scratch2; } @@ -796,7 +797,7 @@ } } - private static void verifyKind(SPARCArithmetic opcode, Value result, Value x, Value y) { + private static void verifyKind(SPARCArithmetic opcode, Kind result, Kind x, Kind y) { Kind rk; Kind xk; Kind yk; @@ -820,9 +821,9 @@ case IUSHR: case IUDIV: case IUREM: - rk = result.getKind().getStackKind(); - xsk = x.getKind().getStackKind(); - ysk = y.getKind().getStackKind(); + rk = result.getStackKind(); + xsk = x.getStackKind(); + ysk = y.getStackKind(); boolean valid = false; for (Kind k : new Kind[]{Kind.Int, Kind.Short, Kind.Byte, Kind.Char}) { valid |= rk == k && xsk == k && ysk == k; @@ -842,17 +843,17 @@ case LXOR: case LUDIV: case LUREM: - rk = result.getKind(); - xk = x.getKind(); - yk = y.getKind(); + rk = result; + xk = x; + yk = y; assert rk == Kind.Long && xk == Kind.Long && yk == Kind.Long; break; case LSHL: case LSHR: case LUSHR: - rk = result.getKind(); - xk = x.getKind(); - yk = y.getKind(); + rk = result; + xk = x; + yk = y; assert rk == Kind.Long && xk == Kind.Long && (yk == Kind.Int || yk == Kind.Long); break; case FADD: @@ -860,9 +861,9 @@ case FMUL: case FDIV: case FREM: - rk = result.getKind(); - xk = x.getKind(); - yk = y.getKind(); + rk = result; + xk = x; + yk = y; assert (rk == Kind.Float || rk == Kind.Double) && xk == Kind.Float && yk == Kind.Float; break; case DAND: @@ -871,9 +872,9 @@ case DMUL: case DDIV: case DREM: - rk = result.getKind(); - xk = x.getKind(); - yk = y.getKind(); + rk = result; + xk = x; + yk = y; assert rk == Kind.Double && xk == Kind.Double && yk == Kind.Double : "opcode=" + opcode + ", result kind=" + rk + ", x kind=" + xk + ", y kind=" + yk; break; default:
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,13 +22,14 @@ */ package com.oracle.graal.lir.sparc; +import static com.oracle.graal.asm.sparc.SPARCAssembler.*; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.asm.sparc.SPARCAssembler.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static jdk.internal.jvmci.code.ValueUtil.*; -import static jdk.internal.jvmci.sparc.SPARC.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.lir.*; @@ -139,7 +140,7 @@ throw JVMCIError.shouldNotReachHere(); } - } else if (isConstant(input) && isSimm13(crb.asIntConst(input))) { + } else if (isJavaConstant(input) && isSimm13(crb.asIntConst(input))) { switch (opcode) { case IPOPCNT: masm.popc(crb.asIntConst(input), dst);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -22,13 +22,14 @@ */ package com.oracle.graal.lir.sparc; -import jdk.internal.jvmci.common.*; -import jdk.internal.jvmci.meta.*; import static com.oracle.graal.asm.sparc.SPARCAssembler.*; import static com.oracle.graal.asm.sparc.SPARCAssembler.CC.*; import static com.oracle.graal.asm.sparc.SPARCAssembler.Opfs.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; +import jdk.internal.jvmci.common.*; +import jdk.internal.jvmci.meta.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.lir.*; @@ -101,7 +102,7 @@ throw JVMCIError.shouldNotReachHere(); } } else { - assert isConstant(y); + assert isJavaConstant(y); switch (opcode) { case LCMP: assert isSimm13(crb.asLongConst(y));
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Mon Aug 31 15:21:36 2015 +0200 @@ -28,6 +28,7 @@ import static com.oracle.graal.asm.sparc.SPARCAssembler.CC.*; import static com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static com.oracle.graal.lir.sparc.SPARCMove.*; import static jdk.internal.jvmci.code.ValueUtil.*; import static jdk.internal.jvmci.sparc.SPARC.*; @@ -219,7 +220,7 @@ } } // Keep the constant on the right - if (isConstant(actualX)) { + if (isJavaConstant(actualX)) { tmpValue = actualX; actualX = actualY; actualY = tmpValue; @@ -238,25 +239,25 @@ private static void emitCBCond(SPARCMacroAssembler masm, Value actualX, Value actualY, Label actualTrueTarget, ConditionFlag conditionFlag) { switch ((Kind) actualX.getLIRKind().getPlatformKind()) { case Int: - if (isConstant(actualY)) { - int constantY = asConstant(actualY).asInt(); + if (isJavaConstant(actualY)) { + int constantY = asJavaConstant(actualY).asInt(); CBCOND.emit(masm, conditionFlag, false, asIntReg(actualX), constantY, actualTrueTarget); } else { CBCOND.emit(masm, conditionFlag, false, asIntReg(actualX), asIntReg(actualY), actualTrueTarget); } break; case Long: - if (isConstant(actualY)) { - int constantY = (int) asConstant(actualY).asLong(); + if (isJavaConstant(actualY)) { + int constantY = (int) asJavaConstant(actualY).asLong(); CBCOND.emit(masm, conditionFlag, true, asLongReg(actualX), constantY, actualTrueTarget); } else { CBCOND.emit(masm, conditionFlag, true, asLongReg(actualX), asLongReg(actualY), actualTrueTarget); } break; case Object: - if (isConstant(actualY)) { + if (isJavaConstant(actualY)) { // Object constant valid can only be null - assert asConstant(actualY).isNull(); + assert asJavaConstant(actualY).isNull(); CBCOND.emit(masm, conditionFlag, true, asObjectReg(actualX), 0, actualTrueTarget); } else { // this is already loaded CBCOND.emit(masm, conditionFlag, true, asObjectReg(actualX), asObjectReg(actualY), actualTrueTarget); @@ -282,7 +283,7 @@ // 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))) { + if (isJavaConstant(y) && !isSimm5(asJavaConstant(y)) && isSimm13(asJavaConstant(y))) { return false; } boolean hasShortJumpTarget = false; @@ -398,7 +399,7 @@ public static final class StrategySwitchOp extends SPARCBlockEndOp { public static final LIRInstructionClass<StrategySwitchOp> TYPE = LIRInstructionClass.create(StrategySwitchOp.class); - @Use({CONST}) protected JavaConstant[] keyConstants; + protected JavaConstant[] keyConstants; private final LabelRef[] keyTargets; private LabelRef defaultTarget; @Alive({REG}) protected Value key; @@ -636,7 +637,7 @@ ConditionFlag actualCondition = condition; Value actualTrueValue = trueValue; Value actualFalseValue = falseValue; - if (isConstant(falseValue) && isSimm11(asConstant(falseValue))) { + if (isJavaConstant(falseValue) && isSimm11(asJavaConstant(falseValue))) { actualCondition = condition.negate(); actualTrueValue = falseValue; actualFalseValue = trueValue; @@ -649,10 +650,10 @@ @Override public SizeEstimate estimateSize() { int constantSize = 0; - if (isConstant(trueValue) && !SPARCAssembler.isSimm13(asConstant(trueValue))) { + if (isJavaConstant(trueValue) && !SPARCAssembler.isSimm13(asJavaConstant(trueValue))) { constantSize += trueValue.getKind().getByteCount(); } - if (isConstant(falseValue) && !SPARCAssembler.isSimm13(asConstant(falseValue))) { + if (isJavaConstant(falseValue) && !SPARCAssembler.isSimm13(asJavaConstant(falseValue))) { constantSize += trueValue.getKind().getByteCount(); } return SizeEstimate.create(3, constantSize); @@ -666,12 +667,12 @@ case Short: case Char: case Int: - if (isConstant(other)) { + if (isJavaConstant(other)) { int constant; - if (asConstant(other).isNull()) { + if (asJavaConstant(other).isNull()) { constant = 0; } else { - constant = asConstant(other).asInt(); + constant = asJavaConstant(other).asInt(); } masm.movcc(cond, cc, constant, asRegister(result)); } else { @@ -680,12 +681,12 @@ break; case Long: case Object: - if (isConstant(other)) { + if (isJavaConstant(other)) { long constant; - if (asConstant(other).isNull()) { + if (asJavaConstant(other).isNull()) { constant = 0; } else { - constant = asConstant(other).asLong(); + constant = asJavaConstant(other).asLong(); } masm.movcc(cond, cc, (int) constant, asRegister(result)); } else {
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Mon Aug 31 15:21:36 2015 +0200 @@ -24,6 +24,7 @@ import static com.oracle.graal.asm.sparc.SPARCAssembler.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.MemoryBarriers.*; import static jdk.internal.jvmci.code.ValueUtil.*; import static jdk.internal.jvmci.meta.Kind.*; @@ -68,7 +69,7 @@ const2reg(crb, masm, result, g0, constant, getDelayedControlTransfer()); } else if (isStackSlot(result)) { StackSlot slot = asStackSlot(result); - const2stack(crb, masm, slot, g0, constant, getDelayedControlTransfer(), constant); + const2stack(crb, masm, slot, g0, getDelayedControlTransfer(), constant); } } @@ -514,12 +515,12 @@ } else { throw JVMCIError.shouldNotReachHere("Result is a: " + result); } - } else if (isConstant(input)) { - JavaConstant constant = asConstant(input); + } else if (isJavaConstant(input)) { + JavaConstant constant = asJavaConstant(input); if (isRegister(result)) { const2reg(crb, masm, result, constantTableBase, constant, delaySlotLir); } else if (isStackSlot(result)) { - const2stack(crb, masm, result, constantTableBase, input, delaySlotLir, constant); + const2stack(crb, masm, result, constantTableBase, delaySlotLir, constant); } else { throw JVMCIError.shouldNotReachHere("Result is a: " + result); } @@ -528,14 +529,13 @@ } } - public static void const2stack(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Register constantTableBase, Value input, SPARCDelayedControlTransfer delaySlotLir, - JavaConstant constant) { + public static void const2stack(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Register constantTableBase, SPARCDelayedControlTransfer delaySlotLir, JavaConstant constant) { if (constant.isDefaultForKind() || constant.isNull()) { SPARCAddress resultAddress = (SPARCAddress) crb.asAddress(result); - emitStore(g0.asValue(LIRKind.combine(input)), resultAddress, result.getPlatformKind(), delaySlotLir, null, crb, masm); + emitStore(g0.asValue(LIRKind.combine(result)), resultAddress, result.getPlatformKind(), delaySlotLir, null, crb, masm); } else { try (ScratchRegister sc = masm.getScratchRegister()) { - Value scratchRegisterValue = sc.getRegister().asValue(LIRKind.combine(constant)); + Value scratchRegisterValue = sc.getRegister().asValue(LIRKind.combine(result)); const2reg(crb, masm, scratchRegisterValue, constantTableBase, constant, SPARCDelayedControlTransfer.DUMMY); SPARCAddress resultAddress = (SPARCAddress) crb.asAddress(result); emitStore(scratchRegisterValue, resultAddress, result.getPlatformKind(), delaySlotLir, null, crb, masm);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,11 +22,12 @@ */ package com.oracle.graal.lir.sparc; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static com.oracle.graal.lir.LIRValueUtil.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static jdk.internal.jvmci.code.ValueUtil.*; -import static jdk.internal.jvmci.sparc.SPARC.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.lir.*; @@ -62,7 +63,7 @@ default: throw JVMCIError.shouldNotReachHere(); } - } else if (isConstant(y)) { + } else if (isJavaConstant(y)) { switch (x.getKind()) { case Short: case Byte:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ConstantValue.java Mon Aug 31 15:21:36 2015 +0200 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2015, 2015, 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.lir; + +import jdk.internal.jvmci.meta.*; + +/** + * Represents an inlined {@link Constant} value. + */ +public class ConstantValue extends AbstractValue { + + private final Constant constant; + + public ConstantValue(LIRKind lirKind, Constant constant) { + super(lirKind); + this.constant = constant; + } + + public Constant getConstant() { + return constant; + } + + public boolean isJavaConstant() { + return constant instanceof JavaConstant; + } + + public JavaConstant getJavaConstant() { + return (JavaConstant) constant; + } + + @Override + public String toString() { + return constant.toString(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof ConstantValue) { + ConstantValue other = (ConstantValue) obj; + return super.equals(other) && this.constant.equals(other.constant); + } + return false; + } + + @Override + public int hashCode() { + return constant.hashCode() + super.hashCode(); + } +}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -39,7 +39,7 @@ abstract class LIRIntrospection<T> extends FieldIntrospection<T> { private static final Class<Value> VALUE_CLASS = Value.class; - private static final Class<JavaConstant> CONSTANT_CLASS = JavaConstant.class; + private static final Class<ConstantValue> CONSTANT_VALUE_CLASS = ConstantValue.class; private static final Class<Variable> VARIABLE_CLASS = Variable.class; private static final Class<RegisterValue> REGISTER_VALUE_CLASS = RegisterValue.class; private static final Class<StackSlot> STACK_SLOT_CLASS = StackSlot.class; @@ -166,7 +166,7 @@ @Override protected void scanField(Field field, long offset) { Class<?> type = field.getType(); - if (VALUE_CLASS.isAssignableFrom(type) && !CONSTANT_CLASS.isAssignableFrom(type)) { + if (VALUE_CLASS.isAssignableFrom(type) && !CONSTANT_VALUE_CLASS.isAssignableFrom(type)) { assert !Modifier.isFinal(field.getModifiers()) : "Value field must not be declared final because it is modified by register allocator: " + field; OperandModeAnnotation annotation = getOperandModeAnnotation(field); assert annotation != null : "Field must have operand mode annotation: " + field; @@ -195,7 +195,7 @@ assert type.isAssignableFrom(STACK_SLOT_CLASS) : "Cannot assign StackSlot to field with STACK flag:" + field; } if (flags.contains(CONST)) { - assert type.isAssignableFrom(CONSTANT_CLASS) : "Cannot assign Constant to field with CONST flag:" + field; + assert type.isAssignableFrom(CONSTANT_VALUE_CLASS) : "Cannot assign Constant to field with CONST flag:" + field; } return true; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRValueUtil.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRValueUtil.java Mon Aug 31 15:21:36 2015 +0200 @@ -35,4 +35,26 @@ assert value != null; return (Variable) value; } + + public static boolean isConstantValue(Value value) { + assert value != null; + return value instanceof ConstantValue; + } + + public static ConstantValue asConstantValue(Value value) { + assert value != null; + return (ConstantValue) value; + } + + public static Constant asConstant(Value value) { + return asConstantValue(value).getConstant(); + } + + public static boolean isJavaConstant(Value value) { + return isConstantValue(value) && asConstantValue(value).isJavaConstant(); + } + + public static JavaConstant asJavaConstant(Value value) { + return asConstantValue(value).getJavaConstant(); + } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -233,7 +233,7 @@ if ((isVariable(value) && flags.contains(OperandFlag.REG)) || (isRegister(value) && flags.contains(OperandFlag.REG)) || (isStackSlotValue(value) && flags.contains(OperandFlag.STACK)) || - (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || + (isJavaConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL))) { return; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanAssignLocationsPhase.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanAssignLocationsPhase.java Mon Aug 31 15:21:36 2015 +0200 @@ -102,7 +102,7 @@ if (isIllegal(interval.location()) && interval.canMaterialize()) { assert mode != OperandMode.DEF; - return interval.getMaterializedValue(); + return new ConstantValue(interval.kind(), interval.getMaterializedValue()); } return interval.location(); } @@ -127,7 +127,7 @@ * is a branch, spill moves are inserted before this branch and so the wrong operand * would be returned (spill moves at block boundaries are not considered in the live * ranges of intervals). - * + * * Solution: use the first opId of the branch target block instead. */ final LIRInstruction instr = allocator.getLIR().getLIRforBlock(block).get(allocator.getLIR().getLIRforBlock(block).size() - 1); @@ -145,7 +145,7 @@ * cause an assert on failure. */ Value result = colorLirOperand(op, (Variable) operand, mode); - assert !allocator.hasCall(tempOpId) || isStackSlotValue(result) || isConstant(result) || !allocator.isCallerSave(result) : "cannot have caller-save register operands at calls"; + assert !allocator.hasCall(tempOpId) || isStackSlotValue(result) || isJavaConstant(result) || !allocator.isCallerSave(result) : "cannot have caller-save register operands at calls"; return result; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -22,16 +22,15 @@ */ package com.oracle.graal.lir.alloc.lsra; -import static java.lang.String.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; -import com.oracle.graal.debug.*; import jdk.internal.jvmci.meta.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; /** @@ -44,7 +43,7 @@ private LIRInsertionBuffer insertionBuffer; // buffer where moves are inserted private final List<Interval> mappingFrom; - private final List<Value> mappingFromOpr; + private final List<Constant> mappingFromOpr; private final List<Interval> mappingTo; private boolean multipleReadsAllowed; private final int[] registerBlocked; @@ -177,7 +176,7 @@ } } - private static boolean checkIntervalLocation(Interval from, Interval to, Value fromOpr) { + private static boolean checkIntervalLocation(Interval from, Interval to, Constant fromOpr) { if (from == null) { return fromOpr != null; } else { @@ -275,12 +274,11 @@ return getAllocator().getSpillMoveFactory().createMove(toOpr, fromOpr); } - private void insertMove(Value fromOpr, Interval toInterval) { - assert LIRKind.verifyMoveKinds(toInterval.kind(), fromOpr.getLIRKind()) : format("move between different types %s %s", fromOpr.getLIRKind(), toInterval.kind()); + private void insertMove(Constant fromOpr, Interval toInterval) { assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand; - LIRInstruction move = getAllocator().getSpillMoveFactory().createMove(toOpr, fromOpr); + LIRInstruction move = getAllocator().getSpillMoveFactory().createLoad(toOpr, fromOpr); insertionBuffer.append(insertIdx, move); if (Debug.isLogEnabled()) { @@ -393,12 +391,12 @@ for (int i = mappingFrom.size() - 1; i >= 0; i--) { Interval fromInterval = mappingFrom.get(i); Interval toInterval = mappingTo.get(i); - Value from; + String from; Value to = toInterval.location(); if (fromInterval == null) { - from = mappingFromOpr.get(i); + from = mappingFromOpr.get(i).toString(); } else { - from = fromInterval.location(); + from = fromInterval.location().toString(); } Debug.log("move %s <- %s", from, to); } @@ -438,7 +436,7 @@ } if (isIllegal(fromInterval.location()) && fromInterval.canMaterialize()) { // Instead of a reload, re-materialize the value - Value rematValue = fromInterval.getMaterializedValue(); + JavaConstant rematValue = fromInterval.getMaterializedValue(); addMapping(rematValue, toInterval); return; } @@ -450,17 +448,15 @@ assert LIRKind.verifyMoveKinds(toInterval.kind(), fromInterval.kind()) : String.format("Kind mismatch: %s vs. %s, from=%s, to=%s", fromInterval.kind(), toInterval.kind(), fromInterval, toInterval); mappingFrom.add(fromInterval); - mappingFromOpr.add(Value.ILLEGAL); + mappingFromOpr.add(null); mappingTo.add(toInterval); } - public void addMapping(Value fromOpr, Interval toInterval) { + public void addMapping(Constant fromOpr, Interval toInterval) { if (Debug.isLogEnabled()) { Debug.log("add move mapping from %s to %s", fromOpr, toInterval); } - assert isConstant(fromOpr) : "only for constants"; - mappingFrom.add(null); mappingFromOpr.add(fromOpr); mappingTo.add(toInterval);
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssa/SSALinarScanResolveDataFlowPhase.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssa/SSALinarScanResolveDataFlowPhase.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,15 +22,15 @@ */ package com.oracle.graal.lir.alloc.lsra.ssa; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; -import com.oracle.graal.debug.*; - import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.alloc.lsra.*; import com.oracle.graal.lir.ssa.*; @@ -65,9 +65,9 @@ assert !isRegister(phiOut) : "phiOut is a register: " + phiOut; assert !isRegister(phiIn) : "phiIn is a register: " + phiIn; Interval toInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiIn), toBlockFirstInstructionId, LIRInstruction.OperandMode.DEF); - if (isConstant(phiOut)) { + if (isConstantValue(phiOut)) { numPhiResolutionMoves.increment(); - moveResolver.addMapping(phiOut, toInterval); + moveResolver.addMapping(asConstant(phiOut), toInterval); } else { Interval fromInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiOut), phiOutId, LIRInstruction.OperandMode.DEF); if (fromInterval != toInterval && !fromInterval.location().equals(toInterval.location())) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanResolveDataFlowPhase.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/ssi/SSILinearScanResolveDataFlowPhase.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.lir.alloc.lsra.ssi; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; @@ -72,7 +73,7 @@ MyPhiValueVisitor visitor = new MyPhiValueVisitor(moveResolver, toBlock, fromBlock); SSIUtil.forEachValuePair(allocator.getLIR(), toBlock, midBlock, (to, from) -> { - Value phiOut = isConstant(from) ? from : map.get(from); + Value phiOut = isJavaConstant(from) ? from : map.get(from); assert phiOut != null : "No entry for " + from; visitor.visit(to, phiOut); }); @@ -107,9 +108,9 @@ return; } Interval toInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiIn), toId, LIRInstruction.OperandMode.DEF); - if (isConstant(phiOut)) { + if (isConstantValue(phiOut)) { numSSIResolutionMoves.increment(); - moveResolver.addMapping(phiOut, toInterval); + moveResolver.addMapping(asConstant(phiOut), toInterval); } else { Interval fromInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiOut), fromId, LIRInstruction.OperandMode.DEF); if (fromInterval != toInterval) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanResolveDataFlowPhase.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanResolveDataFlowPhase.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.lir.alloc.trace; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; @@ -87,9 +88,9 @@ return; } Interval toInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiIn), toId, LIRInstruction.OperandMode.DEF); - if (isConstant(phiOut)) { + if (isConstantValue(phiOut)) { numSSIResolutionMoves.increment(); - moveResolver.addMapping(phiOut, toInterval); + moveResolver.addMapping(asConstant(phiOut), toInterval); } else { Interval fromInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiOut), fromId, LIRInstruction.OperandMode.DEF); if (fromInterval != toInterval) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,24 +22,25 @@ */ package com.oracle.graal.lir.asm; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; import java.util.function.*; import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.code.CompilationResult.*; -import jdk.internal.jvmci.code.DataSection.*; +import jdk.internal.jvmci.code.CompilationResult.ConstantReference; +import jdk.internal.jvmci.code.CompilationResult.DataSectionReference; +import jdk.internal.jvmci.code.DataSection.Data; +import jdk.internal.jvmci.code.DataSection.DataBuilder; import jdk.internal.jvmci.common.*; - -import com.oracle.graal.debug.*; - import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.common.spi.*; +import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.framemap.*; @@ -215,8 +216,8 @@ * including long constants that fit into the 32-bit range. */ public int asIntConst(Value value) { - assert (value.getKind().isNumericInteger()) && isConstant(value); - JavaConstant constant = (JavaConstant) value; + assert (value.getKind().isNumericInteger()) && isJavaConstant(value); + JavaConstant constant = asJavaConstant(value); assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; long c = constant.asLong(); if (!NumUtil.isInt(c)) { @@ -229,8 +230,8 @@ * Returns the float value of any constant that can be represented by a 32-bit float value. */ public float asFloatConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Float && isConstant(value)); - JavaConstant constant = (JavaConstant) value; + assert (value.getKind().getStackKind() == Kind.Float && isJavaConstant(value)); + JavaConstant constant = asJavaConstant(value); assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; return constant.asFloat(); } @@ -239,8 +240,8 @@ * Returns the long value of any constant that can be represented by a 64-bit long value. */ public long asLongConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Long && isConstant(value)); - JavaConstant constant = (JavaConstant) value; + assert (value.getKind().getStackKind() == Kind.Long && isJavaConstant(value)); + JavaConstant constant = asJavaConstant(value); assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; return constant.asLong(); } @@ -249,8 +250,8 @@ * Returns the double value of any constant that can be represented by a 64-bit float value. */ public double asDoubleConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Double && isConstant(value)); - JavaConstant constant = (JavaConstant) value; + assert (value.getKind().getStackKind() == Kind.Double && isJavaConstant(value)); + JavaConstant constant = asJavaConstant(value); assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; return constant.asDouble(); } @@ -258,41 +259,41 @@ /** * Returns the address of a float constant that is embedded as a data reference into the code. */ - public AbstractAddress asFloatConstRef(Value value) { + public AbstractAddress asFloatConstRef(JavaConstant value) { return asFloatConstRef(value, 4); } - public AbstractAddress asFloatConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Float && isConstant(value); - return recordDataReferenceInCode((JavaConstant) value, alignment); + public AbstractAddress asFloatConstRef(JavaConstant value, int alignment) { + assert value.getKind() == Kind.Float; + return recordDataReferenceInCode(value, alignment); } /** * Returns the address of a double constant that is embedded as a data reference into the code. */ - public AbstractAddress asDoubleConstRef(Value value) { + public AbstractAddress asDoubleConstRef(JavaConstant value) { return asDoubleConstRef(value, 8); } - public AbstractAddress asDoubleConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Double && isConstant(value); - return recordDataReferenceInCode((JavaConstant) value, alignment); + public AbstractAddress asDoubleConstRef(JavaConstant value, int alignment) { + assert value.getKind() == Kind.Double; + return recordDataReferenceInCode(value, alignment); } /** * Returns the address of a long constant that is embedded as a data reference into the code. */ - public AbstractAddress asLongConstRef(Value value) { - assert value.getKind() == Kind.Long && isConstant(value); - return recordDataReferenceInCode((JavaConstant) value, 8); + public AbstractAddress asLongConstRef(JavaConstant value) { + assert value.getKind() == Kind.Long; + return recordDataReferenceInCode(value, 8); } /** * Returns the address of an object constant that is embedded as a data reference into the code. */ - public AbstractAddress asObjectConstRef(Value value) { - assert value.getKind() == Kind.Object && isConstant(value); - return recordDataReferenceInCode((JavaConstant) value, 8); + public AbstractAddress asObjectConstRef(JavaConstant value) { + assert value.getKind() == Kind.Object; + return recordDataReferenceInCode(value, 8); } public AbstractAddress asByteAddr(Value value) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Aug 31 15:21:36 2015 +0200 @@ -291,7 +291,7 @@ // create variable Variable variable = lirGen.newVariable(kind); // create move - LIRInstruction move = lirGen.getSpillMoveFactory().createMove(variable, (JavaConstant) constant); + LIRInstruction move = lirGen.getSpillMoveFactory().createLoad(variable, constant); // insert instruction getInsertionBuffer(block).append(1, move); Debug.log("new move (%s) and inserted in block %s", move, block);
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java Mon Aug 31 15:21:36 2015 +0200 @@ -119,18 +119,31 @@ } @Override - public Value emitLoadConstant(LIRKind kind, Constant constant) { - JavaConstant javaConstant = (JavaConstant) constant; - if (canInlineConstant(javaConstant)) { - return javaConstant; + public Value emitConstant(LIRKind kind, Constant constant) { + if (constant instanceof JavaConstant && canInlineConstant((JavaConstant) constant)) { + return new ConstantValue(kind, constant); } else { - return emitMove(javaConstant); + return emitLoadConstant(kind, constant); } } + @Override + public Value emitJavaConstant(JavaConstant constant) { + return emitConstant(target().getLIRKind(constant.getKind()), constant); + } + + @Override + public AllocatableValue emitLoadConstant(LIRKind kind, Constant constant) { + Variable result = newVariable(kind); + emitMoveConstant(result, constant); + return result; + } + public AllocatableValue asAllocatable(Value value) { if (isAllocatableValue(value)) { return asAllocatableValue(value); + } else if (isConstantValue(value)) { + return emitLoadConstant(value.getLIRKind(), asConstant(value)); } else { return emitMove(value); } @@ -154,7 +167,7 @@ protected abstract boolean canInlineConstant(JavaConstant c); public Value loadNonConst(Value value) { - if (isConstant(value) && !canInlineConstant((JavaConstant) value)) { + if (isJavaConstant(value) && !canInlineConstant(asJavaConstant(value))) { return emitMove(value); } return value;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java Mon Aug 31 15:21:36 2015 +0200 @@ -44,6 +44,8 @@ LIRInstruction createMove(AllocatableValue result, Value input); LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input); + + LIRInstruction createLoad(AllocatableValue result, Constant input); } public abstract class BlockScope implements AutoCloseable { @@ -74,7 +76,11 @@ BlockScope getBlockScope(AbstractBlockBase<?> block); - Value emitLoadConstant(LIRKind kind, Constant constant); + Value emitConstant(LIRKind kind, Constant constant); + + Value emitJavaConstant(JavaConstant constant); + + AllocatableValue emitLoadConstant(LIRKind kind, Constant constant); Variable emitLoad(LIRKind kind, Value address, LIRFrameState state); @@ -124,6 +130,8 @@ void emitMove(AllocatableValue dst, Value src); + void emitMoveConstant(AllocatableValue dst, Constant src); + /** * Emits an op that loads the address of some raw data. *
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/SpillMoveFactoryBase.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/SpillMoveFactoryBase.java Mon Aug 31 15:21:36 2015 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.lir.gen; import static com.oracle.graal.lir.LIRValueUtil.*; -import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; @@ -32,6 +31,7 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; +import com.oracle.graal.lir.StandardOp.LoadConstantOp; import com.oracle.graal.lir.StandardOp.StackMove; import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; @@ -53,8 +53,16 @@ return inst; } + public LIRInstruction createLoad(AllocatableValue result, Constant input) { + LIRInstruction inst = createLoadIntern(result, input); + assert inst instanceof LoadConstantOp && checkResult(inst, result, null); + return inst; + } + protected abstract LIRInstruction createMoveIntern(AllocatableValue result, Value input); + protected abstract LIRInstruction createLoadIntern(AllocatableValue result, Constant input); + protected LIRInstruction createStackMoveIntern(AllocatableValue result, AllocatableValue input) { return new StackMove(result, input); } @@ -93,7 +101,7 @@ } void inputProc(LIRInstruction op, Value value, OperandMode mode, EnumSet<OperandFlag> flags) { - assert value.equals(input) || isConstant(value) : String.format("SpillMoveFactory: Instruction %s can only have %s as input, got %s", op, input, value); + assert value.equals(input) || isJavaConstant(value) : String.format("SpillMoveFactory: Instruction %s can only have %s as input, got %s", op, input, value); inputCount++; }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/profiling/MoveProfiling.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/profiling/MoveProfiling.java Mon Aug 31 15:21:36 2015 +0200 @@ -45,7 +45,7 @@ @Override protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, BenchmarkCounterFactory counterFactory) { - new Analyzer(lirGenRes.getLIR(), counterFactory).run(); + new Analyzer(target, lirGenRes.getLIR(), counterFactory).run(); } private static enum MoveType { @@ -97,12 +97,14 @@ } private static class Analyzer { + private final TargetDescription target; private final LIR lir; private final BenchmarkCounterFactory counterFactory; private final LIRInsertionBuffer buffer; private final int[] cnt; - public Analyzer(LIR lir, BenchmarkCounterFactory counterFactory) { + public Analyzer(TargetDescription target, LIR lir, BenchmarkCounterFactory counterFactory) { + this.target = target; this.lir = lir; this.counterFactory = counterFactory; this.buffer = new LIRInsertionBuffer(); @@ -139,7 +141,7 @@ int i = cnt[type.ordinal()]; if (i > 0) { names.add(type.toString()); - increments.add(JavaConstant.forInt(i)); + increments.add(new ConstantValue(target.getLIRKind(Kind.Int), JavaConstant.forInt(i))); } } String[] groups = new String[names.size()];
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssa/SSAVerifier.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssa/SSAVerifier.java Mon Aug 31 15:21:36 2015 +0200 @@ -23,15 +23,16 @@ package com.oracle.graal.lir.ssa; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.*; import jdk.internal.jvmci.meta.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; import com.oracle.graal.lir.LIRInstruction.OperandMode; @@ -126,7 +127,7 @@ } private static boolean shouldProcess(Value value) { - return !value.equals(Value.ILLEGAL) && !isConstant(value) && !isRegister(value) && !isStackSlotValue(value); + return !value.equals(Value.ILLEGAL) && !isJavaConstant(value) && !isRegister(value) && !isStackSlotValue(value); } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIVerifier.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ssi/SSIVerifier.java Mon Aug 31 15:21:36 2015 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.lir.ssi; +import static com.oracle.graal.lir.LIRValueUtil.*; import static jdk.internal.jvmci.code.ValueUtil.*; import java.util.*; @@ -141,7 +142,7 @@ } private static boolean checkUsage(Value value) { - if (value instanceof Constant) { + if (isConstantValue(value)) { // Constants do not need to be defined return false; }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -31,6 +31,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; +import com.oracle.graal.lir.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; @@ -99,11 +100,11 @@ @Override public void generate(NodeLIRBuilderTool gen) { + LIRKind kind = gen.getLIRGeneratorTool().getLIRKind(stamp()); if (onlyUsedInVirtualState()) { - gen.setResult(this, (JavaConstant) value); + gen.setResult(this, new ConstantValue(kind, value)); } else { - LIRKind kind = gen.getLIRGeneratorTool().getLIRKind(stamp()); - gen.setResult(this, gen.getLIRGeneratorTool().emitLoadConstant(kind, value)); + gen.setResult(this, gen.getLIRGeneratorTool().emitConstant(kind, value)); } }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Mon Aug 31 15:21:36 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -26,6 +26,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; +import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.spi.*; @@ -82,7 +83,10 @@ @Override public void generate(NodeLIRBuilderTool gen) { - gen.getLIRGeneratorTool().emitDeoptimize(gen.getLIRGeneratorTool().getMetaAccess().encodeDeoptActionAndReason(action, reason, getDebugId()), speculation, gen.state(this)); + LIRGeneratorTool tool = gen.getLIRGeneratorTool(); + Value actionAndReason = tool.emitJavaConstant(tool.getMetaAccess().encodeDeoptActionAndReason(action, reason, getDebugId())); + Value speculationValue = tool.emitJavaConstant(speculation); + gen.getLIRGeneratorTool().emitDeoptimize(actionAndReason, speculationValue, gen.state(this)); } @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java Sun Aug 30 20:51:12 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java Mon Aug 31 15:21:36 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; +import com.oracle.graal.lir.gen.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.memory.*; @@ -79,7 +80,13 @@ @Override public void generate(NodeLIRBuilderTool gen) { assert getNewValue().stamp().isCompatible(getExpectedValue().stamp()); - Value result = gen.getLIRGeneratorTool().emitCompareAndSwap(gen.operand(getAddress()), gen.operand(getExpectedValue()), gen.operand(getNewValue()), JavaConstant.INT_1, JavaConstant.INT_0); + LIRGeneratorTool tool = gen.getLIRGeneratorTool(); + + LIRKind resultKind = tool.getLIRKind(stamp()); + Value trueResult = tool.emitConstant(resultKind, JavaConstant.TRUE); + Value falseResult = tool.emitConstant(resultKind, JavaConstant.FALSE); + Value result = tool.emitCompareAndSwap(gen.operand(getAddress()), gen.operand(getExpectedValue()), gen.operand(getNewValue()), trueResult, falseResult); + gen.setResult(this, result); } }
--- a/mx.graal/suite.py Sun Aug 30 20:51:12 2015 -0700 +++ b/mx.graal/suite.py Mon Aug 31 15:21:36 2015 +0200 @@ -6,7 +6,7 @@ "suites": [ { "name" : "jvmci", - "version" : "b5ebb80da4f1986232b143dcd67d0ac6da580614", + "version" : "24b4e5e1431c91de7083b319067c50f970974368", "urls" : [ {"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-jvmci-8", "kind" : "hg"}, {"url" : "http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots", "kind" : "binary"},