use of org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode in project graal by oracle.
the class CompareAndSetVMThreadLocalNode method lower.
@Override
public void lower(LoweringTool tool) {
assert threadLocalInfo.offset >= 0;
ConstantNode offset = ConstantNode.forIntegerKind(FrameAccess.getWordKind(), threadLocalInfo.offset, holder.graph());
AddressNode address = graph().unique(new OffsetAddressNode(holder, offset));
LogicCompareAndSwapNode atomic = graph().add(new LogicCompareAndSwapNode(address, threadLocalInfo.locationIdentity, expect, update, barrierType));
atomic.setStateAfter(stateAfter());
graph().replaceFixedWithFixed(this, atomic);
}
use of org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerCompareAndSwapNode.
protected void lowerCompareAndSwapNode(UnsafeCompareAndSwapNode cas) {
StructuredGraph graph = cas.graph();
JavaKind valueKind = cas.getValueKind();
ValueNode expectedValue = implicitStoreConvert(graph, valueKind, cas.expected());
ValueNode newValue = implicitStoreConvert(graph, valueKind, cas.newValue());
AddressNode address = graph.unique(new OffsetAddressNode(cas.object(), cas.offset()));
LogicCompareAndSwapNode atomicNode = graph.add(new LogicCompareAndSwapNode(address, cas.getLocationIdentity(), expectedValue, newValue, compareAndSwapBarrierType(cas)));
atomicNode.setStateAfter(cas.stateAfter());
graph.replaceFixedWithFixed(cas, atomicNode);
}
use of org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode 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;
}
use of org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode in project graal by oracle.
the class AMD64NodeMatchRules 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());
AMD64AddressValue address = (AMD64AddressValue) operand(cas.getAddress());
Condition condition = successIsTrue ? Condition.EQ : Condition.NE;
getLIRGeneratorTool().emitCompareAndSwapBranch(kind, address, expectedValue, newValue, condition, trueLabel, falseLabel, trueLabelProbability);
return null;
};
}
return null;
}
use of org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode in project graal by oracle.
the class WordOperationPlugin method casOp.
protected AbstractCompareAndSwapNode casOp(JavaKind writeKind, JavaKind returnKind, AddressNode address, LocationIdentity location, ValueNode expectedValue, ValueNode newValue) {
boolean isLogic = returnKind == JavaKind.Boolean;
assert isLogic || writeKind == returnKind : writeKind + " != " + returnKind;
AbstractCompareAndSwapNode cas;
if (isLogic) {
cas = new LogicCompareAndSwapNode(address, expectedValue, newValue, location);
} else {
cas = new ValueCompareAndSwapNode(address, expectedValue, newValue, location);
}
return cas;
}
Aggregations