Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java @ 14734:6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Tue, 25 Mar 2014 18:53:34 +0100 |
parents | da2431cc1506 |
children | fbae9be45c95 |
comparison
equal
deleted
inserted
replaced
14733:b10e42998d01 | 14734:6ae9af961b7c |
---|---|
130 } | 130 } |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 private void processNodeWithState(NodeWithState nodeWithState, final BlockT state, final GraphEffectList effects) { | 134 private void processNodeWithState(NodeWithState nodeWithState, final BlockT state, final GraphEffectList effects) { |
135 FrameState frameState = nodeWithState.getState(); | 135 for (Node input : nodeWithState.asNode().inputs()) { |
136 if (frameState != null) { | 136 if (input instanceof FrameState) { |
137 if (frameState.usages().count() > 1) { | 137 FrameState frameState = (FrameState) input; |
138 nodeWithState.asNode().replaceFirstInput(frameState, frameState.copyWithInputs()); | 138 if (frameState.usages().count() > 1) { |
139 frameState = nodeWithState.getState(); | 139 FrameState copy = (FrameState) frameState.copyWithInputs(); |
140 } | 140 nodeWithState.asNode().replaceFirstInput(frameState, copy); |
141 final Set<ObjectState> virtual = new ArraySet<>(); | 141 frameState = copy; |
142 frameState.applyToNonVirtual(new NodeClosure<ValueNode>() { | 142 } |
143 | 143 final Set<ObjectState> virtual = new ArraySet<>(); |
144 @Override | 144 frameState.applyToNonVirtual(new NodeClosure<ValueNode>() { |
145 public void apply(Node usage, ValueNode value) { | 145 |
146 ObjectState valueObj = getObjectState(state, value); | 146 @Override |
147 if (valueObj != null) { | 147 public void apply(Node usage, ValueNode value) { |
148 virtual.add(valueObj); | 148 ObjectState valueObj = getObjectState(state, value); |
149 effects.replaceFirstInput(usage, value, valueObj.virtual); | 149 if (valueObj != null) { |
150 } else if (value instanceof VirtualObjectNode) { | 150 virtual.add(valueObj); |
151 ObjectState virtualObj = null; | 151 effects.replaceFirstInput(usage, value, valueObj.virtual); |
152 for (ObjectState obj : state.getStates()) { | 152 } else if (value instanceof VirtualObjectNode) { |
153 if (value == obj.virtual) { | 153 ObjectState virtualObj = null; |
154 virtualObj = obj; | 154 for (ObjectState obj : state.getStates()) { |
155 break; | 155 if (value == obj.virtual) { |
156 virtualObj = obj; | |
157 break; | |
158 } | |
156 } | 159 } |
157 } | 160 if (virtualObj != null) { |
158 if (virtualObj != null) { | 161 virtual.add(virtualObj); |
159 virtual.add(virtualObj); | |
160 } | |
161 } | |
162 } | |
163 }); | |
164 for (ObjectState obj : state.getStates()) { | |
165 if (obj.isVirtual() && obj.hasLocks()) { | |
166 virtual.add(obj); | |
167 } | |
168 } | |
169 | |
170 ArrayDeque<ObjectState> queue = new ArrayDeque<>(virtual); | |
171 while (!queue.isEmpty()) { | |
172 ObjectState obj = queue.removeLast(); | |
173 if (obj.isVirtual()) { | |
174 for (ValueNode field : obj.getEntries()) { | |
175 if (field instanceof VirtualObjectNode) { | |
176 ObjectState fieldObj = state.getObjectState((VirtualObjectNode) field); | |
177 if (fieldObj.isVirtual() && !virtual.contains(fieldObj)) { | |
178 virtual.add(fieldObj); | |
179 queue.addLast(fieldObj); | |
180 } | 162 } |
181 } | 163 } |
182 } | 164 } |
183 } | 165 }); |
184 } | 166 for (ObjectState obj : state.getStates()) { |
185 for (ObjectState obj : virtual) { | 167 if (obj.isVirtual() && obj.hasLocks()) { |
186 EscapeObjectState v; | 168 virtual.add(obj); |
187 if (obj.isVirtual()) { | 169 } |
188 ValueNode[] fieldState = obj.getEntries().clone(); | 170 } |
189 for (int i = 0; i < fieldState.length; i++) { | 171 |
190 ObjectState valueObj = getObjectState(state, fieldState[i]); | 172 ArrayDeque<ObjectState> queue = new ArrayDeque<>(virtual); |
191 if (valueObj != null) { | 173 while (!queue.isEmpty()) { |
192 if (valueObj.isVirtual()) { | 174 ObjectState obj = queue.removeLast(); |
193 fieldState[i] = valueObj.virtual; | 175 if (obj.isVirtual()) { |
194 } else { | 176 for (ValueNode field : obj.getEntries()) { |
195 fieldState[i] = valueObj.getMaterializedValue(); | 177 if (field instanceof VirtualObjectNode) { |
178 ObjectState fieldObj = state.getObjectState((VirtualObjectNode) field); | |
179 if (fieldObj.isVirtual() && !virtual.contains(fieldObj)) { | |
180 virtual.add(fieldObj); | |
181 queue.addLast(fieldObj); | |
182 } | |
196 } | 183 } |
197 } | 184 } |
198 } | 185 } |
199 v = new VirtualObjectState(obj.virtual, fieldState); | 186 } |
200 } else { | 187 for (ObjectState obj : virtual) { |
201 v = new MaterializedObjectState(obj.virtual, obj.getMaterializedValue()); | 188 EscapeObjectState v; |
202 } | 189 if (obj.isVirtual()) { |
203 effects.addVirtualMapping(frameState, v); | 190 ValueNode[] fieldState = obj.getEntries().clone(); |
191 for (int i = 0; i < fieldState.length; i++) { | |
192 ObjectState valueObj = getObjectState(state, fieldState[i]); | |
193 if (valueObj != null) { | |
194 if (valueObj.isVirtual()) { | |
195 fieldState[i] = valueObj.virtual; | |
196 } else { | |
197 fieldState[i] = valueObj.getMaterializedValue(); | |
198 } | |
199 } | |
200 } | |
201 v = new VirtualObjectState(obj.virtual, fieldState); | |
202 } else { | |
203 v = new MaterializedObjectState(obj.virtual, obj.getMaterializedValue()); | |
204 } | |
205 effects.addVirtualMapping(frameState, v); | |
206 } | |
204 } | 207 } |
205 } | 208 } |
206 } | 209 } |
207 | 210 |
208 /** | 211 /** |