use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class GraphEffectList method addCounterAfter.
public void addCounterAfter(String group, String name, int increment, boolean addContext, FixedWithNextNode position) {
FixedNode nextPosition = position.next();
add("add counter after", graph -> DynamicCounterNode.addCounterBefore(group, name, increment, addContext, nextPosition));
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class PartialEscapeBlockState method materializeBefore.
/**
* Materializes the given virtual object and produces the necessary effects in the effects list.
* This transitively also materializes all other virtual objects that are reachable from the
* entries.
*/
public void materializeBefore(FixedNode fixed, VirtualObjectNode virtual, GraphEffectList materializeEffects) {
PartialEscapeClosure.COUNTER_MATERIALIZATIONS.increment(fixed.getDebug());
List<AllocatedObjectNode> objects = new ArrayList<>(2);
List<ValueNode> values = new ArrayList<>(8);
List<List<MonitorIdNode>> locks = new ArrayList<>();
List<ValueNode> otherAllocations = new ArrayList<>(2);
List<Boolean> ensureVirtual = new ArrayList<>(2);
materializeWithCommit(fixed, virtual, objects, locks, values, ensureVirtual, otherAllocations);
materializeEffects.addVirtualizationDelta(-(objects.size() + otherAllocations.size()));
materializeEffects.add("materializeBefore", new Effect() {
@Override
public void apply(StructuredGraph graph, ArrayList<Node> obsoleteNodes) {
for (ValueNode alloc : otherAllocations) {
ValueNode otherAllocation = graph.addOrUniqueWithInputs(alloc);
if (otherAllocation instanceof FixedWithNextNode) {
graph.addBeforeFixed(fixed, (FixedWithNextNode) otherAllocation);
} else {
assert otherAllocation instanceof FloatingNode;
}
}
if (!objects.isEmpty()) {
CommitAllocationNode commit;
if (fixed.predecessor() instanceof CommitAllocationNode) {
commit = (CommitAllocationNode) fixed.predecessor();
} else {
commit = graph.add(new CommitAllocationNode());
graph.addBeforeFixed(fixed, commit);
}
for (AllocatedObjectNode obj : objects) {
graph.addWithoutUnique(obj);
commit.getVirtualObjects().add(obj.getVirtualObject());
obj.setCommit(commit);
}
for (ValueNode value : values) {
commit.getValues().add(graph.addOrUniqueWithInputs(value));
}
for (List<MonitorIdNode> monitorIds : locks) {
commit.addLocks(monitorIds);
}
commit.getEnsureVirtual().addAll(ensureVirtual);
assert commit.usages().filter(AllocatedObjectNode.class).count() == commit.getUsageCount();
List<AllocatedObjectNode> materializedValues = commit.usages().filter(AllocatedObjectNode.class).snapshot();
for (int i = 0; i < commit.getValues().size(); i++) {
if (materializedValues.contains(commit.getValues().get(i))) {
commit.getValues().set(i, ((AllocatedObjectNode) commit.getValues().get(i)).getVirtualObject());
}
}
}
}
});
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class PartialEscapeClosure method processNodeInternal.
private boolean processNodeInternal(Node node, BlockT state, GraphEffectList effects, FixedWithNextNode lastFixedNode) {
FixedNode nextFixedNode = lastFixedNode == null ? null : lastFixedNode.next();
VirtualUtil.trace(node.getOptions(), debug, "%s", node);
if (requiresProcessing(node)) {
if (processVirtualizable((ValueNode) node, nextFixedNode, state, effects) == false) {
return false;
}
if (tool.isDeleted()) {
VirtualUtil.trace(node.getOptions(), debug, "deleted virtualizable allocation %s", node);
return true;
}
}
if (hasVirtualInputs.isMarked(node) && node instanceof ValueNode) {
if (node instanceof Virtualizable) {
if (processVirtualizable((ValueNode) node, nextFixedNode, state, effects) == false) {
return false;
}
if (tool.isDeleted()) {
VirtualUtil.trace(node.getOptions(), debug, "deleted virtualizable node %s", node);
return true;
}
}
processNodeInputs((ValueNode) node, nextFixedNode, state, effects);
}
if (hasScalarReplacedInputs(node) && node instanceof ValueNode) {
if (processNodeWithScalarReplacedInputs((ValueNode) node, nextFixedNode, state, effects)) {
return true;
}
}
return false;
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class VirtualUtil method assertNonReachable.
public static boolean assertNonReachable(StructuredGraph graph, List<Node> obsoleteNodes) {
// Helper code that determines the paths that keep obsolete nodes alive.
// Nodes with support for GVN can be kept alive by GVN and are therefore not part of the
// assertion.
DebugContext debug = graph.getDebug();
NodeFlood flood = graph.createNodeFlood();
EconomicMap<Node, Node> path = EconomicMap.create(Equivalence.IDENTITY);
flood.add(graph.start());
for (Node current : flood) {
if (current instanceof AbstractEndNode) {
AbstractEndNode end = (AbstractEndNode) current;
flood.add(end.merge());
if (!path.containsKey(end.merge())) {
path.put(end.merge(), end);
}
} else {
for (Node successor : current.successors()) {
flood.add(successor);
if (!path.containsKey(successor)) {
path.put(successor, current);
}
}
}
}
for (Node node : obsoleteNodes) {
if (node instanceof FixedNode && !node.isDeleted()) {
assert !flood.isMarked(node) : node;
}
}
for (Node node : graph.getNodes()) {
if (flood.isMarked(node)) {
for (Node input : node.inputs()) {
flood.add(input);
if (!path.containsKey(input)) {
path.put(input, node);
}
}
}
}
for (Node current : flood) {
for (Node input : current.inputs()) {
flood.add(input);
if (!path.containsKey(input)) {
path.put(input, current);
}
}
}
boolean success = true;
for (Node node : obsoleteNodes) {
if (!node.isDeleted() && flood.isMarked(node) && !node.getNodeClass().valueNumberable()) {
TTY.println("offending node path:");
Node current = node;
TTY.print(current.toString());
while (true) {
current = path.get(current);
if (current != null) {
TTY.print(" -> " + current.toString());
if (current instanceof FixedNode && !obsoleteNodes.contains(current)) {
break;
}
}
}
success = false;
}
}
if (!success) {
TTY.println();
debug.forceDump(graph, "assertNonReachable");
}
return success;
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class PartialEscapeClosure method processNodeInputs.
/**
* This replaces all inputs that point to virtual or materialized values with the actual value,
* materializing if necessary. Also takes care of frame states, adding the necessary
* {@link VirtualObjectState}.
*/
private void processNodeInputs(ValueNode node, FixedNode insertBefore, BlockT state, GraphEffectList effects) {
VirtualUtil.trace(node.getOptions(), debug, "processing nodewithstate: %s", node);
for (Node input : node.inputs()) {
if (input instanceof ValueNode) {
ValueNode alias = getAlias((ValueNode) input);
if (alias instanceof VirtualObjectNode) {
int id = ((VirtualObjectNode) alias).getObjectId();
ensureMaterialized(state, id, insertBefore, effects, COUNTER_MATERIALIZATIONS_UNHANDLED);
effects.replaceFirstInput(node, input, state.getObjectState(id).getMaterializedValue());
VirtualUtil.trace(node.getOptions(), debug, "replacing input %s at %s", input, node);
}
}
}
if (node instanceof NodeWithState) {
processNodeWithState((NodeWithState) node, state, effects);
}
}
Aggregations