comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 19707:d57ca11a6883

Use FixedGuard in tryCheckcastSingleImplementor
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 05 Mar 2015 17:57:36 -0800
parents 8fc336a04d77
children 3362ba500371
comparison
equal deleted inserted replaced
19706:ef30b2318658 19707:d57ca11a6883
188 private void tryCheckCastSingleImplementor(ValueNode receiver, ResolvedJavaType declaredReceiverType) { 188 private void tryCheckCastSingleImplementor(ValueNode receiver, ResolvedJavaType declaredReceiverType) {
189 ResolvedJavaType singleImplementor = declaredReceiverType.getSingleImplementor(); 189 ResolvedJavaType singleImplementor = declaredReceiverType.getSingleImplementor();
190 if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) { 190 if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) {
191 ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType(), true); 191 ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType(), true);
192 if (singleImplementorMethod != null) { 192 if (singleImplementorMethod != null) {
193 assert graph().getGuardsStage().allowsFloatingGuards() : "Graph already fixed!";
194 /** 193 /**
195 * We have an invoke on an interface with a single implementor. We can replace this 194 * We have an invoke on an interface with a single implementor. We can replace this
196 * with an invoke virtual. 195 * with an invoke virtual.
197 * 196 *
198 * To do so we need to ensure two properties: 1) the receiver must implement the 197 * To do so we need to ensure two properties: 1) the receiver must implement the
201 * this interface, i.e. that we are calling the right method. We could do this with 200 * this interface, i.e. that we are calling the right method. We could do this with
202 * an assumption but as we need an instanceof check anyway we can verify both 201 * an assumption but as we need an instanceof check anyway we can verify both
203 * properties by checking of the receiver is an instance of the single implementor. 202 * properties by checking of the receiver is an instance of the single implementor.
204 */ 203 */
205 LogicNode condition = graph().unique(new InstanceOfNode(singleImplementor, receiver, getProfile())); 204 LogicNode condition = graph().unique(new InstanceOfNode(singleImplementor, receiver, getProfile()));
206 GuardNode guard = graph().unique( 205 FixedGuardNode guard = graph().add(new FixedGuardNode(condition, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, false));
207 new GuardNode(condition, AbstractBeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, 206 graph().addBeforeFixed(invoke().asNode(), guard);
208 false, JavaConstant.NULL_POINTER));
209 PiNode piNode = graph().unique(new PiNode(receiver, StampFactory.declaredNonNull(singleImplementor), guard)); 207 PiNode piNode = graph().unique(new PiNode(receiver, StampFactory.declaredNonNull(singleImplementor), guard));
210 arguments().set(0, piNode); 208 arguments().set(0, piNode);
211 setInvokeKind(InvokeKind.Virtual); 209 setInvokeKind(InvokeKind.Virtual);
212 setTargetMethod(singleImplementorMethod); 210 setTargetMethod(singleImplementorMethod);
213 } 211 }