Mercurial > hg > truffle
comparison graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java @ 5339:e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 02 May 2012 14:55:51 +0200 |
parents | 8ac40aed34bf |
children | 1fbc4a08d029 |
comparison
equal
deleted
inserted
replaced
5338:17a84768b1cd | 5339:e8f80481326d |
---|---|
24 | 24 |
25 import java.lang.reflect.*; | 25 import java.lang.reflect.*; |
26 import java.util.*; | 26 import java.util.*; |
27 import java.util.concurrent.*; | 27 import java.util.concurrent.*; |
28 | 28 |
29 import com.oracle.max.cri.ci.*; | |
30 import com.oracle.max.cri.ri.*; | |
31 import com.oracle.max.cri.ri.RiType.Representation; | |
32 import com.oracle.graal.compiler.*; | 29 import com.oracle.graal.compiler.*; |
33 import com.oracle.graal.compiler.phases.*; | 30 import com.oracle.graal.compiler.phases.*; |
34 import com.oracle.graal.cri.*; | 31 import com.oracle.graal.cri.*; |
35 import com.oracle.graal.debug.*; | 32 import com.oracle.graal.debug.*; |
36 import com.oracle.graal.graph.*; | 33 import com.oracle.graal.graph.*; |
38 import com.oracle.graal.nodes.PhiNode.PhiType; | 35 import com.oracle.graal.nodes.PhiNode.PhiType; |
39 import com.oracle.graal.nodes.calc.*; | 36 import com.oracle.graal.nodes.calc.*; |
40 import com.oracle.graal.nodes.extended.*; | 37 import com.oracle.graal.nodes.extended.*; |
41 import com.oracle.graal.nodes.java.*; | 38 import com.oracle.graal.nodes.java.*; |
42 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; | 39 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
40 import com.oracle.graal.nodes.type.*; | |
43 import com.oracle.graal.nodes.util.*; | 41 import com.oracle.graal.nodes.util.*; |
42 import com.oracle.max.cri.ci.*; | |
43 import com.oracle.max.cri.ri.*; | |
44 | 44 |
45 public class InliningUtil { | 45 public class InliningUtil { |
46 | 46 |
47 public interface InliningCallback { | 47 public interface InliningCallback { |
48 StructuredGraph buildGraph(RiResolvedMethod method); | 48 StructuredGraph buildGraph(RiResolvedMethod method); |
191 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClass, type)); | 191 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClass, type)); |
192 FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode, RiDeoptReason.TypeCheckedInliningViolated, RiDeoptAction.InvalidateReprofile, invoke.leafGraphId())); | 192 FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode, RiDeoptReason.TypeCheckedInliningViolated, RiDeoptAction.InvalidateReprofile, invoke.leafGraphId())); |
193 AnchorNode anchor = graph.add(new AnchorNode()); | 193 AnchorNode anchor = graph.add(new AnchorNode()); |
194 assert invoke.predecessor() != null; | 194 assert invoke.predecessor() != null; |
195 | 195 |
196 CheckCastNode checkCast = createAnchoredReceiver(graph, runtime, anchor, type, receiver); | 196 ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver); |
197 invoke.callTarget().replaceFirstInput(receiver, checkCast); | 197 invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
198 | 198 |
199 graph.addBeforeFixed(invoke.node(), objectClass); | 199 graph.addBeforeFixed(invoke.node(), objectClass); |
200 graph.addBeforeFixed(invoke.node(), guard); | 200 graph.addBeforeFixed(invoke.node(), guard); |
201 graph.addBeforeFixed(invoke.node(), anchor); | 201 graph.addBeforeFixed(invoke.node(), anchor); |
202 | 202 |
346 BeginNode node = calleeEntryNodes[i]; | 346 BeginNode node = calleeEntryNodes[i]; |
347 Invoke invokeForInlining = (Invoke) node.next(); | 347 Invoke invokeForInlining = (Invoke) node.next(); |
348 | 348 |
349 RiResolvedType commonType = getLeastCommonType(i); | 349 RiResolvedType commonType = getLeastCommonType(i); |
350 ValueNode receiver = invokeForInlining.callTarget().receiver(); | 350 ValueNode receiver = invokeForInlining.callTarget().receiver(); |
351 CheckCastNode checkCast = createAnchoredReceiver(graph, runtime, node, commonType, receiver); | 351 ValueNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver); |
352 invokeForInlining.callTarget().replaceFirstInput(receiver, checkCast); | 352 invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
353 | 353 |
354 RiResolvedMethod concrete = concretes.get(i); | 354 RiResolvedMethod concrete = concretes.get(i); |
355 StructuredGraph calleeGraph = getGraph(concrete, callback); | 355 StructuredGraph calleeGraph = getGraph(concrete, callback); |
356 callback.recordMethodContentsAssumption(concrete); | 356 callback.recordMethodContentsAssumption(concrete); |
357 assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime); | 357 assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime); |
691 Debug.log("not inlining %s because no type profile exists", methodName(targetMethod, invoke)); | 691 Debug.log("not inlining %s because no type profile exists", methodName(targetMethod, invoke)); |
692 return null; | 692 return null; |
693 } | 693 } |
694 } | 694 } |
695 | 695 |
696 private static CheckCastNode createAnchoredReceiver(StructuredGraph graph, GraalRuntime runtime, FixedNode anchor, RiResolvedType commonType, ValueNode receiver) { | 696 private static ValueNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, RiResolvedType commonType, ValueNode receiver) { |
697 // to avoid that floating reads on receiver fields float above the type check | 697 // to avoid that floating reads on receiver fields float above the type check |
698 ConstantNode typeConst = graph.unique(ConstantNode.forCiConstant(commonType.getEncoding(Representation.ObjectHub), runtime, graph)); | 698 return graph.unique(new PiNode(receiver, anchor, StampFactory.declaredNonNull(commonType))); |
699 CheckCastNode checkCast = graph.unique(new CheckCastNode(anchor, typeConst, commonType, receiver, false)); | |
700 return checkCast; | |
701 } | 699 } |
702 | 700 |
703 private static boolean checkInvokeConditions(Invoke invoke) { | 701 private static boolean checkInvokeConditions(Invoke invoke) { |
704 if (invoke.stateAfter() == null) { | 702 if (invoke.stateAfter() == null) { |
705 Debug.log("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); | 703 Debug.log("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); |