annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java @ 15470:c55f44b3c5e5

remove NodesToDoubles, refactoring of node probability and inlining relevance computation
author Lukas Stadler <lukas.stadler@oracle.com>
date Fri, 02 May 2014 12:02:27 +0200
parents graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java@be2434ceaffa
children 7903324bc739
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
23 package com.oracle.graal.phases.common.inlining;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
25 import static com.oracle.graal.compiler.common.GraalOptions.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
26 import static com.oracle.graal.phases.common.inlining.InliningPhase.Options.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
27
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
29 import java.util.function.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
31 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5503
diff changeset
32 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 14543
diff changeset
33 import com.oracle.graal.compiler.common.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
34 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
36 import com.oracle.graal.debug.Debug.Scope;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
37 import com.oracle.graal.graph.Graph.Mark;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.nodes.*;
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
40 import com.oracle.graal.nodes.java.*;
5720
46ad94a0574a moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
41 import com.oracle.graal.nodes.spi.*;
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9786
diff changeset
42 import com.oracle.graal.options.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
43 import com.oracle.graal.phases.common.*;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
44 import com.oracle.graal.phases.common.inlining.InliningUtil.InlineInfo;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
45 import com.oracle.graal.phases.common.inlining.InliningUtil.Inlineable;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
46 import com.oracle.graal.phases.common.inlining.InliningUtil.InlineableGraph;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
47 import com.oracle.graal.phases.common.inlining.InliningUtil.InlineableMacroNode;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
48 import com.oracle.graal.phases.common.inlining.InliningUtil.InliningPolicy;
9238
8f01fe16e473 refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9234
diff changeset
49 import com.oracle.graal.phases.graph.*;
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
50 import com.oracle.graal.phases.tiers.*;
13137
438ed35bed29 Change PhaseContext so that it does not subclass Providers, to avoid leaking low-level provider objects such as the CodeCacheProvdier to high-level optimization phases
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12686
diff changeset
51 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52
10935
2da7f2efe6e2 Move inlining phases to HighTier.
Roland Schatz <roland.schatz@oracle.com>
parents: 10934
diff changeset
53 public class InliningPhase extends AbstractInliningPhase {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54
9987
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
55 static class Options {
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
56
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
57 // @formatter:off
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
58 @Option(help = "Unconditionally inline intrinsics")
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
59 public static final OptionValue<Boolean> AlwaysInlineIntrinsics = new OptionValue<>(false);
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
60 // @formatter:on
b270f0856a39 fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents: 9961
diff changeset
61 }
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9786
diff changeset
62
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
63 private final InliningPolicy inliningPolicy;
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
64 private final CanonicalizerPhase canonicalizer;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
8548
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
66 private int inliningCount;
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
67 private int maxMethodPerInlining = Integer.MAX_VALUE;
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
68
4348
d49c90e641cb Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4205
diff changeset
69 // Metrics
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
70 private static final DebugMetric metricInliningPerformed = Debug.metric("InliningPerformed");
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
71 private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered");
4598
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
72 private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize");
11600
60f4c505993e remove global phase metric, replaced with per-phase metrics
Doug Simon <doug.simon@oracle.com>
parents: 11567
diff changeset
73 private static final DebugMetric metricInliningRuns = Debug.metric("InliningRuns");
4348
d49c90e641cb Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4205
diff changeset
74
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
75 public InliningPhase(CanonicalizerPhase canonicalizer) {
10934
e2333d8c72b1 Make InliningPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 10933
diff changeset
76 this(new GreedyInliningPolicy(null), canonicalizer);
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
77 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
78
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
79 public InliningPhase(Map<Invoke, Double> hints, CanonicalizerPhase canonicalizer) {
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
80 this(new GreedyInliningPolicy(hints), canonicalizer);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 }
8618
832b9a115a2d style fixes
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8617
diff changeset
82
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
83 public InliningPhase(InliningPolicy policy, CanonicalizerPhase canonicalizer) {
10934
e2333d8c72b1 Make InliningPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 10933
diff changeset
84 this.inliningPolicy = policy;
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
85 this.canonicalizer = canonicalizer;
8617
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8608 8552
diff changeset
86 }
8618
832b9a115a2d style fixes
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8617
diff changeset
87
8617
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8608 8552
diff changeset
88 public void setMaxMethodsPerInlining(int max) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8608 8552
diff changeset
89 maxMethodPerInlining = max;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8608 8552
diff changeset
90 }
8618
832b9a115a2d style fixes
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8617
diff changeset
91
8548
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
92 public int getInliningCount() {
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
93 return inliningCount;
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
94 }
51d5999900e2 simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents: 8385
diff changeset
95
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 @Override
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
97 protected void run(final StructuredGraph graph, final HighTierContext context) {
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
98 final InliningData data = new InliningData(graph, context.getAssumptions());
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
99 ToDoubleFunction<FixedNode> probabilities = new FixedNodeProbabilityCache();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
101 while (data.hasUnprocessedGraphs()) {
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
102 final MethodInvocation currentInvocation = data.currentInvocation();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
103 GraphInfo graphInfo = data.currentGraph();
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
104 if (!currentInvocation.isRoot() &&
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
105 !inliningPolicy.isWorthInlining(probabilities, context.getReplacements(), currentInvocation.callee(), data.inliningDepth(), currentInvocation.probability(),
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
106 currentInvocation.relevance(), false)) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
107 int remainingGraphs = currentInvocation.totalGraphs() - currentInvocation.processedGraphs();
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
108 assert remainingGraphs > 0;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
109 data.popGraphs(remainingGraphs);
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
110 data.popInvocation();
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
111 } else if (graphInfo.hasRemainingInvokes() && inliningPolicy.continueInlining(graphInfo.graph())) {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
112 processNextInvoke(data, graphInfo, context);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
113 } else {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
114 data.popGraph();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
115 if (!currentInvocation.isRoot()) {
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
116 assert currentInvocation.callee().invoke().asNode().isAlive();
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
117 currentInvocation.incrementProcessedGraphs();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
118 if (currentInvocation.processedGraphs() == currentInvocation.totalGraphs()) {
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
119 data.popInvocation();
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
120 final MethodInvocation parentInvoke = data.currentInvocation();
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
121 try (Scope s = Debug.scope("Inlining", data.inliningContext())) {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
122 tryToInline(probabilities, data.currentGraph(), currentInvocation, parentInvoke, data.inliningDepth() + 1, context);
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
123 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
124 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
125 }
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
126 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
127 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
128 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
129 }
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
130
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
131 assert data.inliningDepth() == 0;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
132 assert data.graphCount() == 0;
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
133 }
5316
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5299
diff changeset
134
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
135 /**
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
136 * Process the next invoke and enqueue all its graphs for processing.
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
137 */
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
138 private void processNextInvoke(InliningData data, GraphInfo graphInfo, HighTierContext context) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
139 Invoke invoke = graphInfo.popInvoke();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
140 MethodInvocation callerInvocation = data.currentInvocation();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
141 Assumptions parentAssumptions = callerInvocation.assumptions();
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
142 InlineInfo info = InliningUtil.getInlineInfo(data, invoke, maxMethodPerInlining, context.getReplacements(), parentAssumptions, context.getOptimisticOptimizations());
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
143
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
144 if (info != null) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
145 double invokeProbability = graphInfo.invokeProbability(invoke);
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
146 double invokeRelevance = graphInfo.invokeRelevance(invoke);
9961
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
147 MethodInvocation calleeInvocation = data.pushInvocation(info, parentAssumptions, invokeProbability, invokeRelevance);
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
148
9961
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
149 for (int i = 0; i < info.numberOfMethods(); i++) {
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
150 Inlineable elem = getInlineableElement(info.methodAt(i), info.invoke(), context.replaceAssumptions(calleeInvocation.assumptions()));
9961
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
151 info.setInlinableElement(i, elem);
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
152 if (elem instanceof InlineableGraph) {
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
153 data.pushGraph(((InlineableGraph) elem).getGraph(), invokeProbability * info.probabilityAt(i), invokeRelevance * info.relevanceAt(i));
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
154 } else {
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
155 assert elem instanceof InlineableMacroNode;
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9930
diff changeset
156 data.pushDummyGraph();
5316
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5299
diff changeset
157 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
162 private void tryToInline(ToDoubleFunction<FixedNode> probabilities, GraphInfo callerGraphInfo, MethodInvocation calleeInfo, MethodInvocation parentInvocation, int inliningDepth,
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
163 HighTierContext context) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
164 InlineInfo callee = calleeInfo.callee();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
165 Assumptions callerAssumptions = parentInvocation.assumptions();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
166
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
167 if (inliningPolicy.isWorthInlining(probabilities, context.getReplacements(), callee, inliningDepth, calleeInfo.probability(), calleeInfo.relevance(), true)) {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
168 doInline(callerGraphInfo, calleeInfo, callerAssumptions, context);
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
169 } else if (context.getOptimisticOptimizations().devirtualizeInvokes()) {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11753
diff changeset
170 callee.tryToDevirtualizeInvoke(context.getMetaAccess(), callerAssumptions);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
171 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
172 metricInliningConsidered.increment();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
173 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
174
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
175 private void doInline(GraphInfo callerGraphInfo, MethodInvocation calleeInfo, Assumptions callerAssumptions, HighTierContext context) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
176 StructuredGraph callerGraph = callerGraphInfo.graph();
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
177 Mark markBeforeInlining = callerGraph.getMark();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
178 InlineInfo callee = calleeInfo.callee();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
179 try {
15289
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
180 try (Scope scope = Debug.scope("doInline", callerGraph)) {
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
181 List<Node> invokeUsages = callee.invoke().asNode().usages().snapshot();
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
182 callee.inline(new Providers(context), callerAssumptions);
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
183 callerAssumptions.record(calleeInfo.assumptions());
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
184 metricInliningRuns.increment();
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
185 Debug.dump(callerGraph, "after %s", callee);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
186
15289
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
187 if (OptCanonicalizer.getValue()) {
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
188 Mark markBeforeCanonicalization = callerGraph.getMark();
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
189 canonicalizer.applyIncremental(callerGraph, context, invokeUsages, markBeforeInlining);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
190
15289
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
191 // process invokes that are possibly created during canonicalization
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
192 for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) {
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
193 if (newNode instanceof Invoke) {
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
194 callerGraphInfo.pushInvoke((Invoke) newNode);
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
195 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
196 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
197 }
15289
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
198
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
199 callerGraphInfo.computeProbabilities();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
200
15289
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
201 inliningCount++;
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
202 metricInliningPerformed.increment();
be2434ceaffa additional scope in inlining to get caller graph upon exceptions
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
203 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
204 } catch (BailoutException bailout) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
205 throw bailout;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
206 } catch (AssertionError | RuntimeException e) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
207 throw new GraalInternalError(e).addContext(callee.toString());
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
208 } catch (GraalInternalError e) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
209 throw e.addContext(callee.toString());
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
210 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
211 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
212
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
213 private Inlineable getInlineableElement(final ResolvedJavaMethod method, Invoke invoke, HighTierContext context) {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
214 Class<? extends FixedWithNextNode> macroNodeClass = InliningUtil.getMacroNodeClass(context.getReplacements(), method);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
215 if (macroNodeClass != null) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
216 return new InlineableMacroNode(macroNodeClass);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
217 } else {
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
218 return new InlineableGraph(buildGraph(method, invoke, context));
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
219 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
220 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
221
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
222 private StructuredGraph buildGraph(final ResolvedJavaMethod method, final Invoke invoke, final HighTierContext context) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
223 final StructuredGraph newGraph;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
224 final boolean parseBytecodes;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
225
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
226 // TODO (chaeubl): copying the graph is only necessary if it is modified or if it contains
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
227 // any invokes
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
228 StructuredGraph intrinsicGraph = InliningUtil.getIntrinsicGraph(context.getReplacements(), method);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
229 if (intrinsicGraph != null) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
230 newGraph = intrinsicGraph.copy();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
231 parseBytecodes = false;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
232 } else {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
233 StructuredGraph cachedGraph = getCachedGraph(method, context);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
234 if (cachedGraph != null) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
235 newGraph = cachedGraph.copy();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
236 parseBytecodes = false;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
237 } else {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
238 newGraph = new StructuredGraph(method);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
239 parseBytecodes = true;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
240 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
241 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
242
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
243 try (Scope s = Debug.scope("InlineGraph", newGraph)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
244 if (parseBytecodes) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
245 parseBytecodes(newGraph, context);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
246 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
247
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
248 boolean callerHasMoreInformationAboutArguments = false;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
249 NodeInputList<ValueNode> args = invoke.callTarget().arguments();
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
250 for (ParameterNode param : newGraph.getNodes(ParameterNode.class).snapshot()) {
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
251 ValueNode arg = args.get(param.index());
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
252 if (arg.isConstant()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
253 Constant constant = arg.asConstant();
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
254 newGraph.replaceFloating(param, ConstantNode.forConstant(constant, context.getMetaAccess(), newGraph));
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
255 callerHasMoreInformationAboutArguments = true;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
256 } else {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
257 Stamp joinedStamp = param.stamp().join(arg.stamp());
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
258 if (joinedStamp != null && !joinedStamp.equals(param.stamp())) {
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
259 param.setStamp(joinedStamp);
9706
f44d7e24cebd Fixes for the merge and inlining cleanups.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9705
diff changeset
260 callerHasMoreInformationAboutArguments = true;
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
261 }
9706
f44d7e24cebd Fixes for the merge and inlining cleanups.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9705
diff changeset
262 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
263 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
264
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
265 if (!callerHasMoreInformationAboutArguments) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
266 // TODO (chaeubl): if args are not more concrete, inlining should be avoided
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
267 // in most cases or we could at least use the previous graph size + invoke
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
268 // probability to check the inlining
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
269 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
270
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
271 if (OptCanonicalizer.getValue()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
272 canonicalizer.apply(newGraph, context);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
273 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
274
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
275 return newGraph;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
276 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
277 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13137
diff changeset
278 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
279 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
280
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
281 private static StructuredGraph getCachedGraph(ResolvedJavaMethod method, HighTierContext context) {
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 13953
diff changeset
282 if (context.getGraphCache() != null) {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
283 StructuredGraph cachedGraph = context.getGraphCache().get(method);
6353
2590d9cc3b6d remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5788
diff changeset
284 if (cachedGraph != null) {
2590d9cc3b6d remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5788
diff changeset
285 return cachedGraph;
2590d9cc3b6d remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5788
diff changeset
286 }
2590d9cc3b6d remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5788
diff changeset
287 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
288 return null;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
289 }
7879
1474fe91323c create debug scope for graph building during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 7827
diff changeset
290
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
291 private StructuredGraph parseBytecodes(StructuredGraph newGraph, HighTierContext context) {
9928
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9927
diff changeset
292 boolean hasMatureProfilingInfo = newGraph.method().getProfilingInfo().isMature();
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9927
diff changeset
293
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13197
diff changeset
294 if (context.getGraphBuilderSuite() != null) {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13197
diff changeset
295 context.getGraphBuilderSuite().apply(newGraph, context);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
296 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
297 assert newGraph.start().next() != null : "graph needs to be populated during PhasePosition.AFTER_PARSING";
5177
a26b6248d398 added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5114
diff changeset
298
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
299 new DeadCodeEliminationPhase().apply(newGraph);
9238
8f01fe16e473 refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9234
diff changeset
300
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
301 if (OptCanonicalizer.getValue()) {
11567
c69df2e602f4 Use CanonicalizerPhase.applyIncremental in InliningPhase.
Roland Schatz <roland.schatz@oracle.com>
parents: 11536
diff changeset
302 canonicalizer.apply(newGraph, context);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
303 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
304
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 13953
diff changeset
305 if (hasMatureProfilingInfo && context.getGraphCache() != null) {
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 13953
diff changeset
306 context.getGraphCache().put(newGraph.method(), newGraph.copy());
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
307 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
308 return newGraph;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
311 private abstract static class AbstractInliningPolicy implements InliningPolicy {
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
312
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
313 protected final Map<Invoke, Double> hints;
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
314
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
315 public AbstractInliningPolicy(Map<Invoke, Double> hints) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
316 this.hints = hints;
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
317 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7392
diff changeset
318
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
319 protected double computeMaximumSize(double relevance, int configuredMaximum) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
320 double inlineRatio = Math.min(RelevanceCapForInlining.getValue(), relevance);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
321 return configuredMaximum * inlineRatio;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
322 }
7065
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
323
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
324 protected double getInliningBonus(InlineInfo info) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
325 if (hints != null && hints.containsKey(info.invoke())) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
326 return hints.get(info.invoke());
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
327 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
328 return 1;
7065
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
329 }
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
330
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
331 protected boolean isIntrinsic(Replacements replacements, InlineInfo info) {
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9786
diff changeset
332 if (AlwaysInlineIntrinsics.getValue()) {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
333 return onlyIntrinsics(replacements, info);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
334 } else {
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
335 return onlyForcedIntrinsics(replacements, info);
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7256
diff changeset
336 }
4569
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
337 }
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
338
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
339 private static boolean onlyIntrinsics(Replacements replacements, InlineInfo info) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
340 for (int i = 0; i < info.numberOfMethods(); i++) {
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8618
diff changeset
341 if (!InliningUtil.canIntrinsify(replacements, info.methodAt(i))) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
342 return false;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
343 }
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7256
diff changeset
344 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
345 return true;
7065
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
346 }
8915
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
347
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
348 private static boolean onlyForcedIntrinsics(Replacements replacements, InlineInfo info) {
8915
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
349 for (int i = 0; i < info.numberOfMethods(); i++) {
8930
Lukas Stadler <lukas.stadler@jku.at>
parents: 8915 8637
diff changeset
350 if (!InliningUtil.canIntrinsify(replacements, info.methodAt(i))) {
8915
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
351 return false;
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
352 }
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
353 if (!replacements.isForcedSubstitution(info.methodAt(i))) {
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
354 return false;
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
355 }
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
356 }
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
357 return true;
880619fd6a67 allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 8618
diff changeset
358 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
359
9703
57113d21ce36 Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9702
diff changeset
360 protected static int previousLowLevelGraphSize(InlineInfo info) {
57113d21ce36 Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9702
diff changeset
361 int size = 0;
57113d21ce36 Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9702
diff changeset
362 for (int i = 0; i < info.numberOfMethods(); i++) {
14543
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
363 ResolvedJavaMethod m = info.methodAt(i);
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
364 ProfilingInfo profile = m.getProfilingInfo();
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
365 int compiledGraphSize = profile.getCompilerIRSize(StructuredGraph.class);
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
366 if (compiledGraphSize > 0) {
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
367 size += compiledGraphSize;
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
368 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
369 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
370 return size;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
371 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
372
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
373 protected static int determineNodeCount(InlineInfo info) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
374 int nodes = 0;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
375 for (int i = 0; i < info.numberOfMethods(); i++) {
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
376 Inlineable elem = info.inlineableElementAt(i);
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
377 if (elem != null) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
378 nodes += elem.getNodeCount();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
379 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
380 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
381 return nodes;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
382 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
383
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
384 protected static double determineInvokeProbability(ToDoubleFunction<FixedNode> probabilities, InlineInfo info) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
385 double invokeProbability = 0;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
386 for (int i = 0; i < info.numberOfMethods(); i++) {
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
387 Inlineable callee = info.inlineableElementAt(i);
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
388 Iterable<Invoke> invokes = callee.getInvokes();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
389 if (invokes.iterator().hasNext()) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
390 for (Invoke invoke : invokes) {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
391 invokeProbability += probabilities.applyAsDouble(invoke.asNode());
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
392 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
393 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
394 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
395 return invokeProbability;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
396 }
7065
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
397 }
cfacf5d5bade fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7064
diff changeset
398
11689
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11600
diff changeset
399 public static class GreedyInliningPolicy extends AbstractInliningPolicy {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7392
diff changeset
400
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
401 public GreedyInliningPolicy(Map<Invoke, Double> hints) {
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
402 super(hints);
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
403 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
404
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
405 public boolean continueInlining(StructuredGraph currentGraph) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
406 if (currentGraph.getNodeCount() >= MaximumDesiredSize.getValue()) {
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
407 InliningUtil.logInliningDecision("inlining is cut off by MaximumDesiredSize");
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
408 metricInliningStoppedByMaxDesiredSize.increment();
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
409 return false;
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
410 }
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
411 return true;
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
412 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
413
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
414 @Override
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
415 public boolean isWorthInlining(ToDoubleFunction<FixedNode> probabilities, Replacements replacements, InlineInfo info, int inliningDepth, double probability, double relevance,
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
416 boolean fullyProcessed) {
10769
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10629
diff changeset
417 if (InlineEverything.getValue()) {
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10629
diff changeset
418 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10629
diff changeset
419 }
395d34c10e26 HSAIL backend changes
Doug Simon <doug.simon@oracle.com>
parents: 10629
diff changeset
420
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10909
diff changeset
421 if (isIntrinsic(replacements, info)) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
422 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
423 }
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
424
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13742
diff changeset
425 if (info.shouldInline()) {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13742
diff changeset
426 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "forced inlining");
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13742
diff changeset
427 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13742
diff changeset
428
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
429 double inliningBonus = getInliningBonus(info);
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
430 int nodes = determineNodeCount(info);
9703
57113d21ce36 Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9702
diff changeset
431 int lowLevelGraphSize = previousLowLevelGraphSize(info);
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
432
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
433 if (SmallCompiledLowLevelGraphSize.getValue() > 0 && lowLevelGraphSize > SmallCompiledLowLevelGraphSize.getValue() * inliningBonus) {
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
434 return InliningUtil.logNotInlinedMethod(info, inliningDepth, "too large previous low-level graph (low-level-nodes: %d, relevance=%f, probability=%f, bonus=%f, nodes=%d)",
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
435 lowLevelGraphSize, relevance, probability, inliningBonus, nodes);
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
436 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
437
9915
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
438 if (nodes < TrivialInliningSize.getValue() * inliningBonus) {
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
439 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "trivial (relevance=%f, probability=%f, bonus=%f, nodes=%d)", relevance, probability, inliningBonus, nodes);
9915
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
440 }
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
441
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
442 /*
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
443 * TODO (chaeubl): invoked methods that are on important paths but not yet compiled ->
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
444 * will be compiled anyways and it is likely that we are the only caller... might be
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
445 * useful to inline those methods but increases bootstrap time (maybe those methods are
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
446 * also getting queued in the compilation queue concurrently)
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
447 */
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
448 double invokes = determineInvokeProbability(probabilities, info);
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
449 if (LimitInlinedInvokes.getValue() > 0 && fullyProcessed && invokes > LimitInlinedInvokes.getValue() * inliningBonus) {
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
450 return InliningUtil.logNotInlinedMethod(info, inliningDepth, "callee invoke probability is too high (invokeP=%f, relevance=%f, probability=%f, bonus=%f, nodes=%d)", invokes,
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
451 relevance, probability, inliningBonus, nodes);
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
452 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
453
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
454 double maximumNodes = computeMaximumSize(relevance, (int) (MaximumInliningSize.getValue() * inliningBonus));
9915
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
455 if (nodes <= maximumNodes) {
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
456 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d <= %f)", relevance, probability,
9915
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
457 inliningBonus, nodes, maximumNodes);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
458 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9238
diff changeset
459
9930
5a4fbe932ab3 Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9928
diff changeset
460 return InliningUtil.logNotInlinedMethod(info, inliningDepth, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d > %f)", relevance, probability, inliningBonus, nodes,
9915
d8a8d794f631 More precise inlining decision messages.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9914
diff changeset
461 maximumNodes);
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
462 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
463 }
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
464
10626
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
465 public static final class InlineEverythingPolicy implements InliningPolicy {
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
466
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
467 public boolean continueInlining(StructuredGraph graph) {
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
468 if (graph.getNodeCount() >= MaximumDesiredSize.getValue()) {
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
469 throw new BailoutException("Inline all calls failed. The resulting graph is too large.");
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
470 }
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
471 return true;
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
472 }
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
473
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
474 public boolean isWorthInlining(ToDoubleFunction<FixedNode> probabilities, Replacements replacements, InlineInfo info, int inliningDepth, double probability, double relevance,
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
475 boolean fullyProcessed) {
10626
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
476 return true;
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
477 }
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
478 }
b02b3c6a59b6 Added an inlining policy that tries to inline all calls.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10051
diff changeset
479
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
480 private static class InliningIterator {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7392
diff changeset
481
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
482 private final FixedNode start;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
483 private final Deque<FixedNode> nodeQueue;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
484 private final NodeBitMap queuedNodes;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
485
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
486 public InliningIterator(FixedNode start, NodeBitMap visitedFixedNodes) {
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
487 this.start = start;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
488 this.nodeQueue = new ArrayDeque<>();
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
489 this.queuedNodes = visitedFixedNodes;
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
490 assert start.isAlive();
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
491 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
492
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
493 public LinkedList<Invoke> apply() {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
494 LinkedList<Invoke> invokes = new LinkedList<>();
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
495 FixedNode current;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
496 forcedQueue(start);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
497
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
498 while ((current = nextQueuedNode()) != null) {
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
499 assert current.isAlive();
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
500
11536
9021f7761457 Inlining only needs to consider invokes of Java methods, i.e., calls with a MethodCallTargetNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10935
diff changeset
501 if (current instanceof Invoke && ((Invoke) current).callTarget() instanceof MethodCallTargetNode) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
502 if (current != start) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
503 invokes.addLast((Invoke) current);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
504 }
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
505 queueSuccessors(current);
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
506 } else if (current instanceof LoopBeginNode) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
507 queueSuccessors(current);
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
508 } else if (current instanceof LoopEndNode) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
509 // nothing todo
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
510 } else if (current instanceof MergeNode) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
511 queueSuccessors(current);
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
512 } else if (current instanceof FixedWithNextNode) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
513 queueSuccessors(current);
9435
794370a64b71 Replace AbstractEndNode usages with EndNode usages wherever appropriate.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
514 } else if (current instanceof EndNode) {
794370a64b71 Replace AbstractEndNode usages with EndNode usages wherever appropriate.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
515 queueMerge((EndNode) current);
8385
85d4392b9e26 Introduce a ControlSinkNode base class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7879
diff changeset
516 } else if (current instanceof ControlSinkNode) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
517 // nothing todo
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
518 } else if (current instanceof ControlSplitNode) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
519 queueSuccessors(current);
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
520 } else {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
521 assert false : current;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
522 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
523 }
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
524
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
525 return invokes;
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
526 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
527
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
528 private void queueSuccessors(FixedNode x) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
529 for (Node node : x.successors()) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
530 queue(node);
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
531 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
532 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
533
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
534 private void queue(Node node) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
535 if (node != null && !queuedNodes.isMarked(node)) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
536 forcedQueue(node);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
537 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
538 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
539
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
540 private void forcedQueue(Node node) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
541 queuedNodes.mark(node);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
542 nodeQueue.addFirst((FixedNode) node);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
543 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
544
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
545 private FixedNode nextQueuedNode() {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
546 if (nodeQueue.isEmpty()) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
547 return null;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
548 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
549
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
550 FixedNode result = nodeQueue.removeFirst();
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
551 assert queuedNodes.isMarked(result);
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
552 return result;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
553 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
554
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
555 private void queueMerge(AbstractEndNode end) {
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
556 MergeNode merge = end.merge();
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
557 if (!queuedNodes.isMarked(merge) && visitedAllEnds(merge)) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
558 queuedNodes.mark(merge);
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
559 nodeQueue.add(merge);
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
560 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
561 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
562
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
563 private boolean visitedAllEnds(MergeNode merge) {
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
564 for (int i = 0; i < merge.forwardEndCount(); i++) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
565 if (!queuedNodes.isMarked(merge.forwardEndAt(i))) {
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
566 return false;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
567 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
568 }
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
569 return true;
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
570 }
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
571 }
7063
0d7dfa5b79e8 merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6539
diff changeset
572
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
573 /**
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
574 * Holds the data for building the callee graphs recursively: graphs and invocations (each
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
575 * invocation can have multiple graphs).
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
576 */
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
577 static class InliningData {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
578
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
579 private static final GraphInfo DummyGraphInfo = new GraphInfo(null, new LinkedList<Invoke>(), 1.0, 1.0);
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
580
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
581 /**
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
582 * Call hierarchy from outer most call (i.e., compilation unit) to inner most callee.
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
583 */
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
584 private final ArrayDeque<GraphInfo> graphQueue;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
585 private final ArrayDeque<MethodInvocation> invocationQueue;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
586
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
587 private int maxGraphs;
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
588
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
589 public InliningData(StructuredGraph rootGraph, Assumptions rootAssumptions) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
590 this.graphQueue = new ArrayDeque<>();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
591 this.invocationQueue = new ArrayDeque<>();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
592 this.maxGraphs = 1;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
593
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
594 invocationQueue.push(new MethodInvocation(null, rootAssumptions, 1.0, 1.0));
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
595 pushGraph(rootGraph, 1.0, 1.0);
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
596 }
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
597
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
598 public int graphCount() {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
599 return graphQueue.size();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
600 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
601
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
602 public void pushGraph(StructuredGraph graph, double probability, double relevance) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
603 assert !contains(graph);
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
604 NodeBitMap visitedFixedNodes = graph.createNodeBitMap();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
605 LinkedList<Invoke> invokes = new InliningIterator(graph.start(), visitedFixedNodes).apply();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
606 assert invokes.size() == count(graph.getInvokes());
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
607 graphQueue.push(new GraphInfo(graph, invokes, probability, relevance));
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
608 assert graphQueue.size() <= maxGraphs;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
609 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
610
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
611 public void pushDummyGraph() {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
612 graphQueue.push(DummyGraphInfo);
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
613 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
614
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
615 public boolean hasUnprocessedGraphs() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
616 return !graphQueue.isEmpty();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
617 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
618
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
619 public GraphInfo currentGraph() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
620 return graphQueue.peek();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
621 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
622
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
623 public void popGraph() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
624 graphQueue.pop();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
625 assert graphQueue.size() <= maxGraphs;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
626 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
627
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
628 public void popGraphs(int count) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
629 assert count >= 0;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
630 for (int i = 0; i < count; i++) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
631 graphQueue.pop();
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
632 }
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
633 }
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
634
11753
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
635 private static final Object[] NO_CONTEXT = {};
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
636
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
637 /**
11753
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
638 * Gets the call hierarchy of this inlining from outer most call to inner most callee.
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
639 */
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
640 public Object[] inliningContext() {
11753
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
641 if (!Debug.isDumpEnabled()) {
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
642 return NO_CONTEXT;
095325ccbf9a removed dumping overhead during inlining when dumping is not active
Doug Simon <doug.simon@oracle.com>
parents: 11689
diff changeset
643 }
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
644 Object[] result = new Object[graphQueue.size()];
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
645 int i = 0;
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
646 for (GraphInfo g : graphQueue) {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
647 result[i++] = g.graph.method();
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
648 }
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
649 return result;
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
650 }
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
651
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
652 public MethodInvocation currentInvocation() {
10909
2151775dfd98 Changed inlining order to bottom-up.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10769
diff changeset
653 return invocationQueue.peekFirst();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
654 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
655
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
656 public MethodInvocation pushInvocation(InlineInfo info, Assumptions assumptions, double probability, double relevance) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
657 MethodInvocation methodInvocation = new MethodInvocation(info, new Assumptions(assumptions.useOptimisticAssumptions()), probability, relevance);
10909
2151775dfd98 Changed inlining order to bottom-up.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10769
diff changeset
658 invocationQueue.addFirst(methodInvocation);
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
659 maxGraphs += info.numberOfMethods();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
660 assert graphQueue.size() <= maxGraphs;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
661 return methodInvocation;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
662 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
663
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
664 public void popInvocation() {
10909
2151775dfd98 Changed inlining order to bottom-up.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10769
diff changeset
665 maxGraphs -= invocationQueue.peekFirst().callee.numberOfMethods();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
666 assert graphQueue.size() <= maxGraphs;
10909
2151775dfd98 Changed inlining order to bottom-up.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10769
diff changeset
667 invocationQueue.removeFirst();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
668 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
669
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
670 public int countRecursiveInlining(ResolvedJavaMethod method) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
671 int count = 0;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
672 for (GraphInfo graphInfo : graphQueue) {
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
673 if (method.equals(graphInfo.method())) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
674 count++;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
675 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
676 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
677 return count;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
678 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
679
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
680 public int inliningDepth() {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
681 assert invocationQueue.size() > 0;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
682 return invocationQueue.size() - 1;
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
683 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
684
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
685 @Override
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
686 public String toString() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
687 StringBuilder result = new StringBuilder("Invocations: ");
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
688
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
689 for (MethodInvocation invocation : invocationQueue) {
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
690 if (invocation.callee() != null) {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
691 result.append(invocation.callee().numberOfMethods());
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
692 result.append("x ");
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
693 result.append(invocation.callee().invoke());
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
694 result.append("; ");
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
695 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
696 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
697
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
698 result.append("\nGraphs: ");
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
699 for (GraphInfo graph : graphQueue) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
700 result.append(graph.graph());
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
701 result.append("; ");
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
702 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
703
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
704 return result.toString();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
705 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
706
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
707 private boolean contains(StructuredGraph graph) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
708 for (GraphInfo info : graphQueue) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
709 if (info.graph() == graph) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
710 return true;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
711 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
712 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
713 return false;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
714 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
715
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
716 private static int count(Iterable<Invoke> invokes) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
717 int count = 0;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
718 Iterator<Invoke> iterator = invokes.iterator();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
719 while (iterator.hasNext()) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
720 iterator.next();
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
721 count++;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
722 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
723 return count;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
724 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
725 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
726
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
727 private static class MethodInvocation {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
728
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
729 private final InlineInfo callee;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
730 private final Assumptions assumptions;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
731 private final double probability;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
732 private final double relevance;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
733
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
734 private int processedGraphs;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
735
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
736 public MethodInvocation(InlineInfo info, Assumptions assumptions, double probability, double relevance) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
737 this.callee = info;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
738 this.assumptions = assumptions;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
739 this.probability = probability;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
740 this.relevance = relevance;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
741 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
742
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
743 public void incrementProcessedGraphs() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
744 processedGraphs++;
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
745 assert processedGraphs <= callee.numberOfMethods();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
746 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
747
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
748 public int processedGraphs() {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
749 assert processedGraphs <= callee.numberOfMethods();
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
750 return processedGraphs;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
751 }
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
752
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
753 public int totalGraphs() {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
754 return callee.numberOfMethods();
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
755 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
756
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
757 public InlineInfo callee() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
758 return callee;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
759 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
760
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
761 public Assumptions assumptions() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
762 return assumptions;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
763 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
764
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
765 public double probability() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
766 return probability;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
767 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
768
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
769 public double relevance() {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
770 return relevance;
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
771 }
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
772
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
773 public boolean isRoot() {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
774 return callee == null;
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
775 }
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
776
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
777 @Override
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
778 public String toString() {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
779 if (isRoot()) {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
780 return "<root>";
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
781 }
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
782 CallTargetNode callTarget = callee.invoke().callTarget();
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
783 if (callTarget instanceof MethodCallTargetNode) {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
784 ResolvedJavaMethod calleeMethod = ((MethodCallTargetNode) callTarget).targetMethod();
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
785 return MetaUtil.format("Invoke#%H.%n(%p)", calleeMethod);
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
786 } else {
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
787 return "Invoke#" + callTarget.targetName();
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
788 }
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
789 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
790 }
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
791
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
792 /**
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
793 * Information about a graph that will potentially be inlined. This includes tracking the
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
794 * invocations in graph that will subject to inlining themselves.
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
795 */
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
796 private static class GraphInfo {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
797
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
798 private final StructuredGraph graph;
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
799 private final LinkedList<Invoke> remainingInvokes;
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
800 private final double probability;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
801 private final double relevance;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
802
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
803 private final ToDoubleFunction<FixedNode> probabilities;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
804 private final ComputeInliningRelevance computeInliningRelevance;
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
805
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
806 public GraphInfo(StructuredGraph graph, LinkedList<Invoke> invokes, double probability, double relevance) {
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
807 this.graph = graph;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
808 this.remainingInvokes = invokes;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
809 this.probability = probability;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
810 this.relevance = relevance;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
811
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
812 if (graph != null && (graph.hasNode(InvokeNode.class) || graph.hasNode(InvokeWithExceptionNode.class))) {
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
813 probabilities = new FixedNodeProbabilityCache();
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
814 computeInliningRelevance = new ComputeInliningRelevance(graph, probabilities);
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
815 computeProbabilities();
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
816 } else {
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
817 probabilities = null;
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
818 computeInliningRelevance = null;
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
819 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
820 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
821
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
822 /**
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
823 * Gets the method associated with the {@linkplain #graph() graph} represented by this
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
824 * object.
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
825 */
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
826 public ResolvedJavaMethod method() {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
827 return graph.method();
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
828 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
829
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
830 public boolean hasRemainingInvokes() {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
831 return !remainingInvokes.isEmpty();
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
832 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
833
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
834 /**
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
835 * The graph about which this object contains inlining information.
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
836 */
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
837 public StructuredGraph graph() {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
838 return graph;
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
839 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
840
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
841 public Invoke popInvoke() {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9708
diff changeset
842 return remainingInvokes.removeFirst();
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
843 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
844
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
845 public void pushInvoke(Invoke invoke) {
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
846 remainingInvokes.push(invoke);
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
847 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
848
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
849 public void computeProbabilities() {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
850 computeInliningRelevance.compute();
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
851 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
852
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
853 public double invokeProbability(Invoke invoke) {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
854 return probability * probabilities.applyAsDouble(invoke.asNode());
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
855 }
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
856
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
857 public double invokeRelevance(Invoke invoke) {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15289
diff changeset
858 return Math.min(CapInheritedRelevance.getValue(), relevance) * computeInliningRelevance.getRelevance(invoke);
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
859 }
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
860
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
861 @Override
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
862 public String toString() {
13742
0991dc195637 Handle null in printing
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13614
diff changeset
863 return (graph != null ? MetaUtil.format("%H.%n(%p)", method()) : "<null method>") + remainingInvokes;
10607
dd5a042811f6 enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
Doug Simon <doug.simon@oracle.com>
parents: 10051
diff changeset
864 }
9702
907f1124b427 Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701
diff changeset
865 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 }