Mercurial > hg > truffle
comparison graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java @ 8382:496db8bf756d
Killing cfg path to deoptimization.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 19 Mar 2013 18:05:35 +0100 |
parents | 0269ef50021f |
children | 0edb2a515cb1 |
comparison
equal
deleted
inserted
replaced
8363:25691fcb505a | 8382:496db8bf756d |
---|---|
26 | 26 |
27 import com.oracle.graal.debug.*; | 27 import com.oracle.graal.debug.*; |
28 import com.oracle.graal.graph.*; | 28 import com.oracle.graal.graph.*; |
29 import com.oracle.graal.nodes.*; | 29 import com.oracle.graal.nodes.*; |
30 import com.oracle.graal.nodes.java.*; | 30 import com.oracle.graal.nodes.java.*; |
31 import com.oracle.graal.nodes.util.*; | |
31 import com.oracle.graal.phases.*; | 32 import com.oracle.graal.phases.*; |
32 | 33 |
33 public class ConvertDeoptimizeToGuardPhase extends Phase { | 34 public class ConvertDeoptimizeToGuardPhase extends Phase { |
34 | 35 |
35 private static BeginNode findBeginNode(Node startNode) { | 36 private static BeginNode findBeginNode(Node startNode) { |
73 if (!deopt.isDeleted()) { | 74 if (!deopt.isDeleted()) { |
74 Debug.log("Merge deleted, deopt moved to %s", findBeginNode(deopt)); | 75 Debug.log("Merge deleted, deopt moved to %s", findBeginNode(deopt)); |
75 visitDeoptBegin(findBeginNode(deopt), deopt, graph); | 76 visitDeoptBegin(findBeginNode(deopt), deopt, graph); |
76 } | 77 } |
77 } | 78 } |
79 return; | |
78 } else if (deoptBegin.predecessor() instanceof IfNode) { | 80 } else if (deoptBegin.predecessor() instanceof IfNode) { |
79 IfNode ifNode = (IfNode) deoptBegin.predecessor(); | 81 IfNode ifNode = (IfNode) deoptBegin.predecessor(); |
80 BeginNode otherBegin = ifNode.trueSuccessor(); | 82 BeginNode otherBegin = ifNode.trueSuccessor(); |
81 LogicNode conditionNode = ifNode.condition(); | 83 LogicNode conditionNode = ifNode.condition(); |
82 if (conditionNode instanceof InstanceOfNode || conditionNode instanceof InstanceOfDynamicNode) { | 84 if (!(conditionNode instanceof InstanceOfNode) && !(conditionNode instanceof InstanceOfDynamicNode)) { |
83 // TODO The lowering currently does not support a FixedGuard as the usage of an | 85 // TODO The lowering currently does not support a FixedGuard as the usage of an |
84 // InstanceOfNode. Relax this restriction. | 86 // InstanceOfNode. Relax this restriction. |
87 FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deopt.reason(), deopt.action(), deoptBegin == ifNode.trueSuccessor())); | |
88 FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor(); | |
89 if (deoptBegin == ifNode.trueSuccessor()) { | |
90 graph.removeSplitPropagate(ifNode, ifNode.falseSuccessor()); | |
91 } else { | |
92 graph.removeSplitPropagate(ifNode, ifNode.trueSuccessor()); | |
93 } | |
94 Debug.log("Converting %s on %-5s branch of %s to guard for remaining branch %s.", deopt, deoptBegin == ifNode.trueSuccessor() ? "true" : "false", ifNode, otherBegin); | |
95 FixedNode next = pred.next(); | |
96 pred.setNext(guard); | |
97 guard.setNext(next); | |
85 return; | 98 return; |
86 } | 99 } |
87 FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deopt.reason(), deopt.action(), deoptBegin == ifNode.trueSuccessor())); | 100 } |
88 FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor(); | 101 |
89 if (deoptBegin == ifNode.trueSuccessor()) { | 102 // We could not convert the control split - at least cut off control flow after the split. |
90 graph.removeSplitPropagate(ifNode, ifNode.falseSuccessor()); | 103 FixedNode next = deoptBegin.next(); |
91 } else { | 104 if (next != deopt) { |
92 graph.removeSplitPropagate(ifNode, ifNode.trueSuccessor()); | 105 FixedWithNextNode pred = (FixedWithNextNode) deopt.predecessor(); |
93 } | 106 pred.setNext(null); |
94 Debug.log("Converting %s on %-5s branch of %s to guard for remaining branch %s.", deopt, deoptBegin == ifNode.trueSuccessor() ? "true" : "false", ifNode, otherBegin); | 107 deoptBegin.setNext(deopt); |
95 FixedNode next = pred.next(); | 108 GraphUtil.killCFG(next); |
96 pred.setNext(guard); | |
97 guard.setNext(next); | |
98 Debug.dump(graph, "After introducing fixed guard %s", guard); | |
99 } | 109 } |
100 } | 110 } |
101 } | 111 } |