public class InliningData extends Object
The space of inlining decisions is explored depth-first with the help of a stack realized by
InliningData
. At any point in time, the topmost element of that stack consists of:
MethodInvocation
.CallsiteHolder
s, all of them associated to the callsite above. Why more than
one? Depending on the type-profile for the receiver more than one concrete method may be feasible
target.The bottom element in the stack consists of:
MethodInvocation
(the
root
one, ie the
unknown caller of the root graph)CallsiteHolder
(the root one, for the method on which inlining was called)moveForward()
Modifier and Type | Field and Description |
---|---|
private CanonicalizerPhase |
canonicalizer |
private HighTierContext |
context |
private ArrayDeque<CallsiteHolder> |
graphQueue
Call hierarchy from outer most call (i.e., compilation unit) to inner most callee.
|
private InliningPolicy |
inliningPolicy |
private ArrayDeque<MethodInvocation> |
invocationQueue |
private int |
maxGraphs |
private int |
maxMethodPerInlining |
private static DebugMetric |
metricInliningConsidered |
private static DebugMetric |
metricInliningPerformed |
private static DebugMetric |
metricInliningRuns |
private static Object[] |
NO_CONTEXT |
Constructor and Description |
---|
InliningData(StructuredGraph rootGraph,
HighTierContext context,
int maxMethodPerInlining,
CanonicalizerPhase canonicalizer,
InliningPolicy inliningPolicy) |
Modifier and Type | Method and Description |
---|---|
private boolean |
checkTargetConditions(Invoke invoke,
ResolvedJavaMethod method) |
private String |
checkTargetConditionsHelper(ResolvedJavaMethod method,
int invokeBci) |
private boolean |
contains(StructuredGraph graph) |
int |
countRecursiveInlining(ResolvedJavaMethod method) |
private CallsiteHolder |
currentGraph() |
private MethodInvocation |
currentInvocation() |
private void |
doInline(CallsiteHolderExplorable callerCallsiteHolder,
MethodInvocation calleeInvocation) |
static BitSet |
freshlyInstantiatedArguments(Invoke invoke,
Set<ParameterNode> fixedParams)
Gets the freshly instantiated arguments.
|
private InlineInfo |
getAssumptionInlineInfo(Invoke invoke,
ResolvedJavaMethod concrete,
Assumptions.AssumptionResult<?> takenAssumption) |
private InlineInfo |
getExactInlineInfo(Invoke invoke,
ResolvedJavaMethod targetMethod) |
private InlineInfo |
getInlineInfo(Invoke invoke)
Determines if inlining is possible at the given invoke node.
|
private InlineInfo |
getTypeCheckedInlineInfo(Invoke invoke,
ResolvedJavaMethod targetMethod) |
int |
graphCount() |
boolean |
hasUnprocessedGraphs() |
private Object[] |
inliningContext()
Gets the call hierarchy of this inlining from outer most call to inner most callee.
|
int |
inliningDepth() |
static boolean |
isFreshInstantiation(ValueNode arg) |
boolean |
moveForward()
The stack realized by
InliningData grows and shrinks as choices are made among the
alternatives below:
not worth inlining: pop stack top, which comprises:
pop any remaining graphs not yet delved into
pop the current invocation
delve into one of the callsites hosted in the current graph,
such callsite is explored next by moveForward()
try to inline : move past the current graph
(remove it from the topmost element). |
private static boolean |
paramsAndInvokeAreInSameGraph(Invoke invoke,
Set<ParameterNode> fixedParams) |
private void |
popGraph() |
private void |
popGraphs(int count) |
private void |
popInvocation() |
private void |
processNextInvoke()
This method picks one of the callsites belonging to the current
CallsiteHolderExplorable . |
private void |
pushInvocationAndGraphs(MethodInvocation methodInvocation) |
boolean |
repOK()
This method checks invariants for this class.
|
private boolean |
topGraphsForTopInvocation()
Checks an invariant that
moveForward() must maintain: "the top invocation records
how many concrete target methods (for it) remain on the graphQueue ; those targets
'belong' to the current invocation in question. |
String |
toString() |
private boolean |
tryToInline(MethodInvocation calleeInvocation,
int inliningDepth)
This method attempts:
to inline at the callsite given by
calleeInvocation , where that callsite belongs
to the CallsiteHolderExplorable at the top of the graphQueue maintained in
this class.
otherwise, to devirtualize the callsite in question.
|
private static final DebugMetric metricInliningPerformed
private static final DebugMetric metricInliningRuns
private static final DebugMetric metricInliningConsidered
private final ArrayDeque<CallsiteHolder> graphQueue
private final ArrayDeque<MethodInvocation> invocationQueue
private final HighTierContext context
private final int maxMethodPerInlining
private final CanonicalizerPhase canonicalizer
private final InliningPolicy inliningPolicy
private int maxGraphs
private static final Object[] NO_CONTEXT
public InliningData(StructuredGraph rootGraph, HighTierContext context, int maxMethodPerInlining, CanonicalizerPhase canonicalizer, InliningPolicy inliningPolicy)
public static boolean isFreshInstantiation(ValueNode arg)
private String checkTargetConditionsHelper(ResolvedJavaMethod method, int invokeBci)
private boolean checkTargetConditions(Invoke invoke, ResolvedJavaMethod method)
private InlineInfo getInlineInfo(Invoke invoke)
invoke
- the invoke that should be inlinedprivate InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod targetMethod)
private InlineInfo getAssumptionInlineInfo(Invoke invoke, ResolvedJavaMethod concrete, Assumptions.AssumptionResult<?> takenAssumption)
private InlineInfo getExactInlineInfo(Invoke invoke, ResolvedJavaMethod targetMethod)
private void doInline(CallsiteHolderExplorable callerCallsiteHolder, MethodInvocation calleeInvocation)
private boolean tryToInline(MethodInvocation calleeInvocation, int inliningDepth)
calleeInvocation
, where that callsite belongs
to the CallsiteHolderExplorable
at the top of the graphQueue
maintained in
this class.private void processNextInvoke()
CallsiteHolderExplorable
. Provided the callsite qualifies to be analyzed for
inlining, this method prepares a new stack top in InliningData
for such callsite,
which comprises:
InlineInfo
MethodInvocation
CallsiteHolder
for each feasible target
The thus prepared "stack top" is needed by moveForward()
to explore the space of
inlining decisions (each decision one of: backtracking, delving, inlining).
The InlineInfo
used to get things rolling is kept around in the
MethodInvocation
, it will be needed in case of inlining, see
InlineInfo.inline(Providers)
public static BitSet freshlyInstantiatedArguments(Invoke invoke, Set<ParameterNode> fixedParams)
A freshly instantiated argument is either:
isFreshInstantiation(com.oracle.graal.nodes.ValueNode)
ParameterNode
receiving a freshly instantiated argumentinvoke
, or null if no such positions exist.private static boolean paramsAndInvokeAreInSameGraph(Invoke invoke, Set<ParameterNode> fixedParams)
public int graphCount()
public boolean hasUnprocessedGraphs()
private CallsiteHolder currentGraph()
private void popGraph()
private void popGraphs(int count)
private Object[] inliningContext()
private MethodInvocation currentInvocation()
private void pushInvocationAndGraphs(MethodInvocation methodInvocation)
private void popInvocation()
public int countRecursiveInlining(ResolvedJavaMethod method)
public int inliningDepth()
private boolean contains(StructuredGraph graph)
public boolean moveForward()
The stack realized by InliningData
grows and shrinks as choices are made among the
alternatives below:
delve
into one of the callsites hosted in the current graph,
such callsite is explored next by moveForward()
try to inline
: move past the current graph
(remove it from the topmost element).
try to inline
the
callsite under consideration (ie, the "current invocation").InliningData
.Some facts about the alternatives above:
InliningPolicy.isWorthInlining(com.oracle.graal.nodes.spi.Replacements, com.oracle.graal.phases.common.inlining.walker.MethodInvocation, int, boolean)
and InliningPolicy.continueInlining(com.oracle.graal.nodes.StructuredGraph)
.private boolean topGraphsForTopInvocation()
moveForward()
must maintain: "the top invocation records
how many concrete target methods (for it) remain on the graphQueue
; those targets
'belong' to the current invocation in question.public boolean repOK()