use of org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType in project graal by oracle.
the class WriteBarrierAdditionPhase method addAtomicReadWriteNodeBarriers.
private void addAtomicReadWriteNodeBarriers(LoweredAtomicReadAndWriteNode 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(), null, true, node.getNullCheck(), 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);
}
}
use of org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType in project graal by oracle.
the class WriteBarrierAdditionPhase method addCASBarriers.
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);
}
}
use of org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerCommitAllocationNode.
@SuppressWarnings("try")
protected void lowerCommitAllocationNode(CommitAllocationNode commit, LoweringTool tool) {
StructuredGraph graph = commit.graph();
if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
List<AbstractNewObjectNode> recursiveLowerings = new ArrayList<>();
ValueNode[] allocations = new ValueNode[commit.getVirtualObjects().size()];
BitSet omittedValues = new BitSet();
int valuePos = 0;
for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
int entryCount = virtual.entryCount();
AbstractNewObjectNode newObject;
try (DebugCloseable nsp = virtual.withNodeSourcePosition()) {
if (virtual instanceof VirtualInstanceNode) {
newObject = graph.add(createNewInstanceFromVirtual(virtual));
} else {
newObject = graph.add(createNewArrayFromVirtual(virtual, ConstantNode.forInt(entryCount, graph)));
}
}
recursiveLowerings.add(newObject);
graph.addBeforeFixed(commit, newObject);
allocations[objIndex] = newObject;
for (int i = 0; i < entryCount; i++) {
ValueNode value = commit.getValues().get(valuePos);
if (value instanceof VirtualObjectNode) {
value = allocations[commit.getVirtualObjects().indexOf(value)];
}
if (value == null) {
omittedValues.set(valuePos);
} else if (!(value.isConstant() && value.asConstant().isDefaultForKind())) {
// Constant.illegal is always the defaultForKind, so it is skipped
JavaKind valueKind = value.getStackKind();
JavaKind entryKind = virtual.entryKind(i);
// Truffle requires some leniency in terms of what can be put where:
assert valueKind.getStackKind() == entryKind.getStackKind() || (valueKind == JavaKind.Long || valueKind == JavaKind.Double || (valueKind == JavaKind.Int && virtual instanceof VirtualArrayNode));
AddressNode address = null;
BarrierType barrierType = null;
if (virtual instanceof VirtualInstanceNode) {
ResolvedJavaField field = ((VirtualInstanceNode) virtual).field(i);
long offset = fieldOffset(field);
if (offset >= 0) {
address = createOffsetAddress(graph, newObject, offset);
barrierType = fieldInitializationBarrier(entryKind);
}
} else {
address = createOffsetAddress(graph, newObject, arrayBaseOffset(entryKind) + i * arrayScalingFactor(entryKind));
barrierType = arrayInitializationBarrier(entryKind);
}
if (address != null) {
WriteNode write = new WriteNode(address, LocationIdentity.init(), implicitStoreConvert(graph, entryKind, value), barrierType);
graph.addAfterFixed(newObject, graph.add(write));
}
}
valuePos++;
}
}
valuePos = 0;
for (int objIndex = 0; objIndex < commit.getVirtualObjects().size(); objIndex++) {
VirtualObjectNode virtual = commit.getVirtualObjects().get(objIndex);
int entryCount = virtual.entryCount();
ValueNode newObject = allocations[objIndex];
for (int i = 0; i < entryCount; i++) {
if (omittedValues.get(valuePos)) {
ValueNode value = commit.getValues().get(valuePos);
assert value instanceof VirtualObjectNode;
ValueNode allocValue = allocations[commit.getVirtualObjects().indexOf(value)];
if (!(allocValue.isConstant() && allocValue.asConstant().isDefaultForKind())) {
assert virtual.entryKind(i) == JavaKind.Object && allocValue.getStackKind() == JavaKind.Object;
AddressNode address;
BarrierType barrierType;
if (virtual instanceof VirtualInstanceNode) {
VirtualInstanceNode virtualInstance = (VirtualInstanceNode) virtual;
address = createFieldAddress(graph, newObject, virtualInstance.field(i));
barrierType = BarrierType.IMPRECISE;
} else {
address = createArrayAddress(graph, newObject, virtual.entryKind(i), ConstantNode.forInt(i, graph));
barrierType = BarrierType.PRECISE;
}
if (address != null) {
WriteNode write = new WriteNode(address, LocationIdentity.init(), implicitStoreConvert(graph, JavaKind.Object, allocValue), barrierType);
graph.addBeforeFixed(commit, graph.add(write));
}
}
}
valuePos++;
}
}
finishAllocatedObjects(tool, commit, allocations);
graph.removeFixed(commit);
for (AbstractNewObjectNode recursiveLowering : recursiveLowerings) {
recursiveLowering.lower(tool);
}
}
}
use of org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType in project graal by oracle.
the class DefaultHotSpotLoweringProvider method fieldLoadBarrierType.
@Override
protected BarrierType fieldLoadBarrierType(ResolvedJavaField f) {
HotSpotResolvedJavaField loadField = (HotSpotResolvedJavaField) f;
BarrierType barrierType = BarrierType.NONE;
if (runtime.getVMConfig().useG1GC && loadField.getJavaKind() == JavaKind.Object && metaAccess.lookupJavaType(Reference.class).equals(loadField.getDeclaringClass()) && loadField.getName().equals("referent")) {
barrierType = BarrierType.PRECISE;
}
return barrierType;
}
use of org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType in project graal by oracle.
the class WordOperationPlugin method writeOp.
protected void writeOp(GraphBuilderContext b, JavaKind writeKind, AddressNode address, LocationIdentity location, ValueNode value, Opcode op) {
assert op == Opcode.WRITE_POINTER || op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED || op == Opcode.INITIALIZE;
final BarrierType barrier = (op == Opcode.WRITE_BARRIERED ? BarrierType.PRECISE : BarrierType.NONE);
final boolean compressible = (op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED);
assert op != Opcode.INITIALIZE || location.isInit() : "must use init location for initializing";
b.add(new JavaWriteNode(writeKind, address, location, value, barrier, compressible));
}
Aggregations