private void addCASBarriers(AbstractCompareAndSwapNode node, StructuredGraph graph) {
BarrierType barrierType = node.getBarrierType();
switch (barrierType) {
case NONE:
break;
case IMPRECISE:
case PRECISE:
boolean precise = barrierType == BarrierType.PRECISE;
if (config.useG1GC) {
addG1PreWriteBarrier(node, node.getAddress(), node.getExpectedValue(), false, false, graph);
addG1PostWriteBarrier(node, node.getAddress(), node.getNewValue(), precise, graph);
} else {
addSerialPostWriteBarrier(node, node.getAddress(), node.getNewValue(), precise, graph);
}
break;
default:
throw new GraalError("unexpected barrier type: " + barrierType);
}
}