private void addCASBarriers(AbstractCompareAndSwapNode node, StructuredGraph graph) { BarrierType barrierType = node.getBarrierType(); switch (barrierType) { case NONE: // nothing to do 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); } }
@Override public void setStateAfter(FrameState x) { assert x == null || x.isAlive() : "frame state must be in a graph"; updateUsages(stateAfter, x); stateAfter = x; }
/** * AbstractCompareAndSwapNode has * <ul> * <li>The object to which the write is done, in node.object(),</li> * <li>the value to be written, in node.getNewValue(),</li> * <li>the location within the object for the write, in node.location(),</li> * <li>whether a precise or imprecise barrier is needed, in node.getBarrierType(),</li>. * </ul> */ protected void rewriteWithBarriers(StructuredGraph graph, AbstractCompareAndSwapNode node) { if (node.getBarrierType() == BarrierType.NONE) { // No barrier requested. return; } final ValueNode value = node.getNewValue(); if (!value.getStackKind().isObject()) { // Storing something other than an Object does not require a barrier. return; } if (StampTool.isPointerAlwaysNull(value)) { // Storing a null does not require a barrier. return; } // TODO: What about initializing writes, which I can check in node.isInitialization()? addPostWriteBarrier(graph, node, node.getAddress()); }