use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class CollectingObjectReferenceVisitor method verifyValue.
private void verifyValue(CompilationResult compilation, JavaValue expectedValue, ValueInfo actualValue, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
if (ValueUtil.isIllegalJavaValue(expectedValue)) {
assert actualValue.getType() == ValueType.Illegal;
} else if (ValueUtil.isConstantJavaValue(expectedValue)) {
assert actualValue.getType() == ValueType.Constant || actualValue.getType() == ValueType.DefaultConstant;
JavaConstant expectedConstant = ValueUtil.asConstantJavaValue(expectedValue);
JavaConstant actualConstant = actualValue.getValue();
FrameInfoVerifier.verifyConstant(expectedConstant, actualConstant);
} else if (expectedValue instanceof StackSlot) {
assert actualValue.getType() == ValueType.StackSlot;
int expectedOffset = ((StackSlot) expectedValue).getOffset(compilation.getTotalFrameSize());
long actualOffset = actualValue.getData();
assert expectedOffset == actualOffset;
} else if (ValueUtil.isVirtualObject(expectedValue)) {
assert actualValue.getType() == ValueType.VirtualObject;
int expectedId = ValueUtil.asVirtualObject(expectedValue).getId();
long actualId = actualValue.getData();
assert expectedId == actualId;
verifyVirtualObject(compilation, ValueUtil.asVirtualObject(expectedValue), actualFrame.getVirtualObjects()[expectedId], actualFrame, visitedVirtualObjects);
} else {
throw shouldNotReachHere();
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SPARCAddressLowering method lower.
@Override
public AddressNode lower(ValueNode base, ValueNode offset) {
JavaConstant immBase = asImmediate(base);
if (immBase != null && SPARCAssembler.isSimm13(immBase)) {
return lower(offset, immBase.asLong());
}
JavaConstant immOffset = asImmediate(offset);
if (immOffset != null && SPARCAssembler.isSimm13(immOffset)) {
return lower(base, immOffset.asLong());
}
return base.graph().unique(new SPARCIndexedAddressNode(base, offset));
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitStore.
@Override
public void emitStore(ValueKind<?> kind, Value address, Value inputVal, LIRFrameState state) {
SPARCAddressValue storeAddress = getLIRGen().asAddressValue(address);
if (isJavaConstant(inputVal)) {
JavaConstant c = asJavaConstant(inputVal);
if (c.isDefaultForKind()) {
getLIRGen().append(new StoreConstantOp(kind.getPlatformKind(), storeAddress, c, state));
return;
}
}
Variable input = getLIRGen().load(inputVal);
getLIRGen().append(new StoreOp(kind.getPlatformKind(), storeAddress, input, state));
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitSignExtend.
@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
assert fromBits <= toBits && toBits <= XWORD.getSizeInBits();
LIRKind shiftKind = LIRKind.value(WORD);
LIRKind resultKind = LIRKind.combine(inputVal).changeType(toBits > 32 ? XWORD : WORD);
int shiftCount = XWORD.getSizeInBits() - fromBits;
if (fromBits == toBits) {
return inputVal;
} else if (isJavaConstant(inputVal)) {
JavaConstant javaConstant = asJavaConstant(inputVal);
long constant;
if (javaConstant.isNull()) {
constant = 0;
} else {
constant = javaConstant.asLong();
}
return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
} else {
AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputVal);
Variable result = getLIRGen().newVariable(resultKind);
if (fromBits == WORD.getSizeInBits() && toBits == XWORD.getSizeInBits()) {
getLIRGen().append(new SPARCOP3Op(Sra, inputAllocatable, g0.asValue(LIRKind.value(WORD)), result));
} else {
Variable tmp = getLIRGen().newVariable(resultKind.changeType(XWORD));
getLIRGen().append(new SPARCOP3Op(Sllx, inputAllocatable, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), tmp));
getLIRGen().append(new SPARCOP3Op(Srax, tmp, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), result));
}
return result;
}
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class SPARCNodeMatchRules method ifCompareLogicCas.
@MatchRule("(If (ObjectEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (PointerEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (FloatEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (IntegerEquals=compare value LogicCompareAndSwap=cas))")
public ComplexMatchResult ifCompareLogicCas(IfNode root, CompareNode compare, ValueNode value, LogicCompareAndSwapNode cas) {
JavaConstant constant = value.asJavaConstant();
assert compare.condition() == CanonicalCondition.EQ;
if (constant != null && cas.usages().count() == 1) {
long constantValue = constant.asLong();
boolean successIsTrue;
if (constantValue == 0) {
successIsTrue = false;
} else if (constantValue == 1) {
successIsTrue = true;
} else {
return null;
}
return builder -> {
LIRKind kind = getLirKind(cas);
LabelRef trueLabel = getLIRBlock(root.trueSuccessor());
LabelRef falseLabel = getLIRBlock(root.falseSuccessor());
double trueLabelProbability = root.probability(root.trueSuccessor());
Value expectedValue = operand(cas.getExpectedValue());
Value newValue = operand(cas.getNewValue());
SPARCAddressValue address = (SPARCAddressValue) operand(cas.getAddress());
Condition condition = successIsTrue ? Condition.EQ : Condition.NE;
Value result = getLIRGeneratorTool().emitValueCompareAndSwap(address, expectedValue, newValue);
getLIRGeneratorTool().emitCompareBranch(kind.getPlatformKind(), result, expectedValue, condition, false, trueLabel, falseLabel, trueLabelProbability);
return null;
};
}
return null;
}
Aggregations