use of org.graalvm.compiler.nodes.ProxyNode in project graal by oracle.
the class LoopFragmentInside method nodes.
@Override
public NodeBitMap nodes() {
if (nodes == null) {
LoopFragmentWhole whole = loop().whole();
// init nodes bitmap in whole
whole.nodes();
nodes = whole.nodes.copy();
// remove the phis
LoopBeginNode loopBegin = loop().loopBegin();
for (PhiNode phi : loopBegin.phis()) {
nodes.clear(phi);
}
clearStateNodes(loopBegin);
for (LoopExitNode exit : exits()) {
clearStateNodes(exit);
for (ProxyNode proxy : exit.proxies()) {
nodes.clear(proxy);
}
}
}
return nodes;
}
use of org.graalvm.compiler.nodes.ProxyNode in project graal by oracle.
the class GraphUtil method checkRedundantProxy.
public static void checkRedundantProxy(ProxyNode vpn) {
if (vpn.isDeleted()) {
return;
}
AbstractBeginNode proxyPoint = vpn.proxyPoint();
if (proxyPoint instanceof LoopExitNode) {
LoopExitNode exit = (LoopExitNode) proxyPoint;
LoopBeginNode loopBegin = exit.loopBegin();
Node vpnValue = vpn.value();
for (ValueNode v : loopBegin.stateAfter().values()) {
ValueNode v2 = v;
if (loopBegin.isPhiAtMerge(v2)) {
v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd());
}
if (vpnValue == v2) {
Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot();
Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot();
vpn.replaceAtUsagesAndDelete(vpnValue);
for (PhiNode phi : phiUsages) {
checkRedundantPhi(phi);
}
for (ProxyNode proxy : proxyUsages) {
checkRedundantProxy(proxy);
}
return;
}
}
}
}
use of org.graalvm.compiler.nodes.ProxyNode in project graal by oracle.
the class GraalCompilerTest method getCanonicalGraphString.
protected static String getCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants) {
SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.EARLIEST);
schedule.apply(graph);
ScheduleResult scheduleResult = graph.getLastSchedule();
NodeMap<Integer> canonicalId = graph.createNodeMap();
int nextId = 0;
List<String> constantsLines = new ArrayList<>();
StringBuilder result = new StringBuilder();
for (Block block : scheduleResult.getCFG().getBlocks()) {
result.append("Block ").append(block).append(' ');
if (block == scheduleResult.getCFG().getStartBlock()) {
result.append("* ");
}
result.append("-> ");
for (Block succ : block.getSuccessors()) {
result.append(succ).append(' ');
}
result.append('\n');
for (Node node : scheduleResult.getBlockToNodesMap().get(block)) {
if (node instanceof ValueNode && node.isAlive()) {
if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode || node instanceof FullInfopointNode || node instanceof ParameterNode)) {
if (node instanceof ConstantNode) {
String name = checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
if (excludeVirtual) {
constantsLines.add(name);
} else {
constantsLines.add(name + " (" + filteredUsageCount(node) + ")");
}
} else {
int id;
if (canonicalId.get(node) != null) {
id = canonicalId.get(node);
} else {
id = nextId++;
canonicalId.set(node, id);
}
String name = node.getClass().getSimpleName();
result.append(" ").append(id).append('|').append(name);
if (node instanceof AccessFieldNode) {
result.append('#');
result.append(((AccessFieldNode) node).field());
}
if (!excludeVirtual) {
result.append(" (");
result.append(filteredUsageCount(node));
result.append(')');
}
result.append('\n');
}
}
}
}
}
StringBuilder constantsLinesResult = new StringBuilder();
constantsLinesResult.append(constantsLines.size()).append(" constants:\n");
Collections.sort(constantsLines);
for (String s : constantsLines) {
constantsLinesResult.append(s);
constantsLinesResult.append('\n');
}
return constantsLinesResult.toString() + result.toString();
}
Aggregations