Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java @ 9705:de7319e48e48
Temporary fixes for the merge.
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Mon, 13 May 2013 17:43:42 +0200 |
parents | f9a65a0e626b |
children | f44d7e24cebd |
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 */ |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
23 package com.oracle.graal.phases.common; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
7879
1474fe91323c
create debug scope for graph building during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
26 import java.util.concurrent.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
28 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
|
29 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
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
|
33 import com.oracle.graal.nodes.spi.*; |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
34 import com.oracle.graal.nodes.type.*; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
35 import com.oracle.graal.nodes.util.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
36 import com.oracle.graal.phases.*; |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
37 import com.oracle.graal.phases.PhasePlan.PhasePosition; |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7256
diff
changeset
|
38 import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
39 import com.oracle.graal.phases.common.InliningUtil.InlineInfo; |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
40 import com.oracle.graal.phases.common.InliningUtil.InlineableMacroNode; |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
41 import com.oracle.graal.phases.common.InliningUtil.InliningPolicy; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
42 import com.oracle.graal.phases.graph.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
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
|
44 public class InliningPhase extends Phase { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
46 private final PhasePlan plan; |
8608
056966f39a36
changed parameters of InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8385
diff
changeset
|
47 private final MetaAccessProvider runtime; |
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
|
48 private final Assumptions compilationAssumptions; |
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
|
49 private final Replacements replacements; |
5718
10341299528c
renamings: ExtendedRiRuntime -> GraalCodeCacheProvider, CiLoweringTool -> LoweringTool, RiGraphCache -> GraphCache
Doug Simon <doug.simon@oracle.com>
parents:
5674
diff
changeset
|
50 private final GraphCache cache; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
51 private final InliningPolicy inliningPolicy; |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
52 private final OptimisticOptimizations optimisticOpts; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7256
diff
changeset
|
54 private CustomCanonicalizer customCanonicalizer; |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
55 private int inliningCount; |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
56 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
|
57 |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
58 // Metrics |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
59 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
|
60 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
|
61 private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize"); |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
62 private static final DebugMetric metricInliningRuns = Debug.metric("Runs"); |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
63 |
8930 | 64 public InliningPhase(MetaAccessProvider runtime, Map<Invoke, Double> hints, Replacements replacements, Assumptions assumptions, GraphCache cache, PhasePlan plan, |
65 OptimisticOptimizations optimisticOpts) { | |
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
|
66 this(runtime, replacements, assumptions, cache, plan, optimisticOpts, hints); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
67 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
68 |
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
|
69 private InliningPhase(MetaAccessProvider runtime, Replacements replacements, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, |
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
|
70 Map<Invoke, Double> hints) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 this.runtime = runtime; |
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
|
72 this.replacements = replacements; |
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
|
73 this.compilationAssumptions = assumptions; |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
74 this.cache = cache; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 this.plan = plan; |
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
|
76 this.inliningPolicy = new GreedyInliningPolicy(replacements, hints); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
77 this.optimisticOpts = optimisticOpts; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
8618 | 79 |
8617 | 80 public void setCustomCanonicalizer(CustomCanonicalizer customCanonicalizer) { |
81 this.customCanonicalizer = customCanonicalizer; | |
82 } | |
8618 | 83 |
8617 | 84 public void setMaxMethodsPerInlining(int max) { |
85 maxMethodPerInlining = max; | |
86 } | |
8618 | 87 |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
88 public int getInliningCount() { |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
89 return inliningCount; |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
90 } |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8385
diff
changeset
|
91 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
92 public static void storeHighLevelStatistics(StructuredGraph graph) { |
9705
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
93 ResolvedJavaMethod method = graph.method(); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
94 if (method != null) { |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
95 CompiledMethodInfo info = compiledMethodInfo(method); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
96 double summedUpProbabilityOfRemainingInvokes = sumUpInvokeProbabilities(graph); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
97 info.setSummedUpProbabilityOfRemainingInvokes(summedUpProbabilityOfRemainingInvokes); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
98 info.setHighLevelNodeCount(graph.getNodeCount()); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
99 } |
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
|
100 } |
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 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
102 public static void storeMidLevelStatistics(StructuredGraph graph) { |
9705
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
103 ResolvedJavaMethod method = graph.method(); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
104 if (method != null) { |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
105 CompiledMethodInfo info = compiledMethodInfo(graph.method()); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
106 info.setMidLevelNodeCount(graph.getNodeCount()); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
107 } |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
108 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
109 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
110 public static void storeLowLevelStatistics(StructuredGraph graph) { |
9705
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
111 ResolvedJavaMethod method = graph.method(); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
112 if (method != null) { |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
113 CompiledMethodInfo info = compiledMethodInfo(graph.method()); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
114 info.setLowLevelNodeCount(graph.getNodeCount()); |
de7319e48e48
Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
115 } |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
116 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
117 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 @Override |
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
|
119 protected void run(final StructuredGraph graph) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
120 InliningData data = new InliningData(); |
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
|
121 data.pushGraph(graph, 1.0, 1.0); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
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
|
123 while (data.hasUnprocessedGraphs()) { |
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
|
124 GraphInfo graphInfo = data.currentGraph(); |
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
|
125 if (graphInfo.hasRemainingInvokes() && inliningPolicy.continueInlining(data)) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
126 processNextInvoke(data, graphInfo); |
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
|
127 } 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
|
128 data.popGraph(); |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
129 MethodInvocation currentInvocation = data.currentInvocation(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
130 if (currentInvocation != null) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
131 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
|
132 currentInvocation.incrementProcessedGraphs(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
133 if (currentInvocation.processedAllGraphs()) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
134 data.popInvocation(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
135 MethodInvocation parentInvoke = data.currentInvocation(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
136 tryToInline(data.currentGraph(), currentInvocation, parentInvoke); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
137 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
138 } |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
139 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
140 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
141 } |
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
|
142 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
143 /** |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
144 * 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
|
145 */ |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
146 private void processNextInvoke(InliningData data, GraphInfo graphInfo) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
147 Invoke invoke = graphInfo.popInvoke(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
148 MethodInvocation callerInvocation = data.currentInvocation(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
149 Assumptions parentAssumptions = callerInvocation == null ? compilationAssumptions : callerInvocation.assumptions(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
150 InlineInfo info = InliningUtil.getInlineInfo(data, invoke, maxMethodPerInlining, replacements, parentAssumptions, optimisticOpts); |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9147
diff
changeset
|
151 |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
152 double invokeProbability = graphInfo.invokeProbability(invoke); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
153 double invokeRelevance = graphInfo.invokeRelevance(invoke); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
154 if (info != null && inliningPolicy.isWorthInlining(info, invokeProbability, invokeRelevance, false)) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
155 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
|
156 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
157 for (int i = 0; i < info.numberOfMethods(); i++) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
158 InlineableElement elem = getInlineableElement(info.methodAt(i), info.invoke(), calleeInvocation.assumptions()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
159 info.setInlinableElement(i, elem); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
160 if (elem instanceof StructuredGraph) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
161 data.pushGraph((StructuredGraph) elem, invokeProbability * info.probabilityAt(i), invokeRelevance * info.relevanceAt(i)); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
162 } else { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
163 assert elem instanceof InlineableMacroNode; |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
164 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
|
165 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
170 private void tryToInline(GraphInfo callerGraphInfo, MethodInvocation calleeInfo, MethodInvocation parentInvocation) { |
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 InlineInfo callee = calleeInfo.callee(); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
172 Assumptions callerAssumptions = parentInvocation == null ? compilationAssumptions : 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
|
173 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
174 if (inliningPolicy.isWorthInlining(callee, calleeInfo.probability(), calleeInfo.relevance(), 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
|
175 doInline(callerGraphInfo, calleeInfo, callerAssumptions); |
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 } else if (optimisticOpts.devirtualizeInvokes()) { |
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
|
177 callee.tryToDevirtualizeInvoke(runtime, callerAssumptions); |
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 } |
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 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
|
180 } |
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
|
181 |
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
|
182 private void doInline(GraphInfo callerGraphInfo, MethodInvocation calleeInfo, Assumptions callerAssumptions) { |
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
|
183 StructuredGraph callerGraph = callerGraphInfo.graph(); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
184 int 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
|
185 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
|
186 try { |
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
|
187 List<Node> invokeUsages = callee.invoke().asNode().usages().snapshot(); |
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
|
188 callee.inline(runtime, callerAssumptions); |
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
|
189 callerAssumptions.record(calleeInfo.assumptions()); |
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 metricInliningRuns.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
|
191 Debug.dump(callerGraph, "after %s", 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
|
192 |
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
|
193 if (GraalOptions.OptCanonicalizer) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
194 int markBeforeCanonicalization = callerGraph.getMark(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
195 new CanonicalizerPhase.Instance(runtime, callerAssumptions, invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph); |
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
|
196 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
197 // process invokes that are possibly created during canonicalization |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
198 for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
199 if (newNode instanceof Invoke) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
200 callerGraphInfo.pushInvoke((Invoke) newNode); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
201 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
202 } |
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
|
203 } |
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 |
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 callerGraphInfo.computeProbabilities(); |
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 |
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 inliningCount++; |
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 metricInliningPerformed.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
|
209 } 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
|
210 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
|
211 } 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
|
212 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
|
213 } 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
|
214 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
|
215 } |
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
|
216 } |
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 |
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
|
218 private InlineableElement getInlineableElement(final ResolvedJavaMethod method, Invoke invoke, Assumptions assumptions) { |
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 Class<? extends FixedWithNextNode> macroNodeClass = InliningUtil.getMacroNodeClass(replacements, 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
|
220 if (macroNodeClass != null) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
221 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
|
222 } 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
|
223 return buildGraph(method, invoke, assumptions); |
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 } |
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 } |
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
|
226 |
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
|
227 private StructuredGraph buildGraph(final ResolvedJavaMethod method, final Invoke invoke, final Assumptions assumptions) { |
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
|
228 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
|
229 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
|
230 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
231 // 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
|
232 // any invokes |
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
|
233 StructuredGraph intrinsicGraph = InliningUtil.getIntrinsicGraph(replacements, 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
|
234 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
|
235 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
|
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 StructuredGraph cachedGraph = getCachedGraph(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 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
|
240 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
|
241 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
|
242 } 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
|
243 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
|
244 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
|
245 } |
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
|
246 } |
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 |
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
|
248 return Debug.scope("InlineGraph", newGraph, new Callable<StructuredGraph>() { |
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
|
249 |
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
|
250 @Override |
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
|
251 public StructuredGraph call() throws Exception { |
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
|
252 if (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
|
253 parseBytecodes(newGraph, assumptions); |
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
|
254 } |
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
|
255 |
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
|
256 if (GraalOptions.PropagateArgumentsDuringInlining) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
257 boolean callerHasMoreInformationAboutArguments = false; |
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
|
258 NodeInputList<ValueNode> args = invoke.callTarget().arguments(); |
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
|
259 for (LocalNode localNode : newGraph.getNodes(LocalNode.class).snapshot()) { |
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
|
260 ValueNode arg = args.get(localNode.index()); |
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 if (arg.isConstant()) { |
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
|
262 Constant constant = arg.asConstant(); |
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
|
263 newGraph.replaceFloating(localNode, ConstantNode.forConstant(constant, runtime, newGraph)); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
264 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
|
265 } else { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
266 Stamp joinedStamp = localNode.stamp().join(arg.stamp()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
267 if (!joinedStamp.equals(localNode.stamp())) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
268 localNode.setStamp(joinedStamp); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
269 callerHasMoreInformationAboutArguments = true; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
270 } |
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
|
271 } |
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
|
272 } |
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
|
273 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
274 if (!callerHasMoreInformationAboutArguments) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
275 // TODO (chaeubl): if args are not more concrete, inlining should be avoided |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
276 // in most cases or we could at least use the previous graph size + invoke |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
277 // probability to check the inlining |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
278 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
279 |
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
|
280 if (GraalOptions.OptCanonicalizer) { |
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
|
281 new CanonicalizerPhase.Instance(runtime, assumptions).apply(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
|
282 } |
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
|
283 } |
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
|
284 |
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
|
285 return 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
|
286 } |
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
|
287 }); |
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 } |
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 |
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
|
290 private StructuredGraph getCachedGraph(ResolvedJavaMethod method) { |
6353
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
291 if (GraalOptions.CacheGraphs && cache != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
292 StructuredGraph cachedGraph = cache.get(method); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
293 if (cachedGraph != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
294 return cachedGraph; |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
295 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
296 } |
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
|
297 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
|
298 } |
7879
1474fe91323c
create debug scope for graph building during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
7827
diff
changeset
|
299 |
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
|
300 private StructuredGraph parseBytecodes(StructuredGraph newGraph, Assumptions assumptions) { |
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
|
301 if (plan != 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
|
302 plan.runPhases(PhasePosition.AFTER_PARSING, 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
|
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 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
|
305 |
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
|
306 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
|
307 |
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
|
308 if (GraalOptions.OptCanonicalizer) { |
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
|
309 new CanonicalizerPhase.Instance(runtime, assumptions).apply(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
|
310 } |
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 |
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
|
312 if (GraalOptions.CullFrameStates) { |
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 new CullFrameStatesPhase().apply(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
|
314 } |
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
|
315 if (GraalOptions.CacheGraphs && cache != 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
|
316 cache.put(newGraph.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
|
317 } |
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
|
318 return newGraph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
321 private static synchronized CompiledMethodInfo compiledMethodInfo(ResolvedJavaMethod m) { |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
322 CompiledMethodInfo info = (CompiledMethodInfo) m.getCompilerStorage().get(CompiledMethodInfo.class); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
323 if (info == null) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
324 info = new CompiledMethodInfo(); |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
325 m.getCompilerStorage().put(CompiledMethodInfo.class, info); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
326 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
327 return info; |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
328 } |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
329 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
330 private static double sumUpInvokeProbabilities(StructuredGraph graph) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
331 NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
332 double summedUpProbabilityOfRemainingInvokes = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
333 for (Invoke invoke : graph.getInvokes()) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
334 summedUpProbabilityOfRemainingInvokes += nodeProbabilities.get(invoke.asNode()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
335 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
336 return summedUpProbabilityOfRemainingInvokes; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
337 } |
7686 | 338 |
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
|
339 private abstract static class AbstractInliningPolicy implements InliningPolicy { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
340 |
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
|
341 protected final Replacements replacements; |
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
|
342 protected final Map<Invoke, Double> hints; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
343 |
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
|
344 public AbstractInliningPolicy(Replacements replacements, Map<Invoke, Double> hints) { |
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
|
345 this.replacements = replacements; |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
346 this.hints = hints; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
347 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
348 |
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
|
349 protected double computeMaximumSize(double relevance, int configuredMaximum) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
350 double inlineRatio = Math.min(GraalOptions.RelevanceCapForInlining, relevance); |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
351 return configuredMaximum * inlineRatio; |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
352 } |
7065
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
353 |
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
|
354 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
|
355 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
|
356 return hints.get(info.invoke()); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
357 } |
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
|
358 return 1; |
7065
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
359 } |
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
360 |
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
|
361 protected boolean isIntrinsic(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
|
362 if (GraalOptions.AlwaysInlineIntrinsics) { |
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
|
363 return onlyIntrinsics(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
|
364 } 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
|
365 return onlyForcedIntrinsics(info); |
7388
599ea4fcdb6d
added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7256
diff
changeset
|
366 } |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
367 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
368 |
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
|
369 private boolean onlyIntrinsics(InlineInfo info) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
370 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
|
371 if (!InliningUtil.canIntrinsify(replacements, info.methodAt(i))) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
372 return false; |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
373 } |
7388
599ea4fcdb6d
added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7256
diff
changeset
|
374 } |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
375 return true; |
7065
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
376 } |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8618
diff
changeset
|
377 |
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
|
378 private boolean onlyForcedIntrinsics(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
|
379 for (int i = 0; i < info.numberOfMethods(); i++) { |
8930 | 380 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
|
381 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
|
382 } |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8618
diff
changeset
|
383 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
|
384 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
|
385 } |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8618
diff
changeset
|
386 } |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8618
diff
changeset
|
387 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
|
388 } |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
389 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
390 protected static int previousHighLevelGraphSize(InlineInfo info) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
391 int size = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
392 for (int i = 0; i < info.numberOfMethods(); i++) { |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
393 size += compiledMethodInfo(info.methodAt(i)).highLevelNodeCount(); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
394 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
395 return size; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
396 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
397 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
398 protected static int previousMidLevelGraphSize(InlineInfo info) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
399 int size = 0; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
400 for (int i = 0; i < info.numberOfMethods(); i++) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
401 size += compiledMethodInfo(info.methodAt(i)).midLevelNodeCount(); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
402 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
403 return size; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
404 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
405 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
406 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
|
407 int size = 0; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
408 for (int i = 0; i < info.numberOfMethods(); i++) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
409 size += compiledMethodInfo(info.methodAt(i)).lowLevelNodeCount(); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
410 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
411 return size; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
412 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
413 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
414 protected static int determineNodeCount(InlineInfo info) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
415 int nodes = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
416 for (int i = 0; i < info.numberOfMethods(); i++) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
417 InlineableElement elem = info.inlineableElementAt(i); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
418 if (elem != null) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
419 nodes += elem.getNodeCount(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
420 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
421 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
422 return nodes; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
423 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
424 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
425 protected static double determineInvokeProbability(InlineInfo info) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
426 double invokeProbability = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
427 for (int i = 0; i < info.numberOfMethods(); i++) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
428 InlineableElement callee = info.inlineableElementAt(i); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
429 Iterable<Invoke> invokes = callee.getInvokes(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
430 if (invokes.iterator().hasNext()) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
431 NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure((StructuredGraph) callee).apply(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
432 for (Invoke invoke : invokes) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
433 invokeProbability += nodeProbabilities.get(invoke.asNode()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
434 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
435 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
436 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
437 return invokeProbability; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
438 } |
7065
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
439 } |
cfacf5d5bade
fixed logging of inlining decisions
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7064
diff
changeset
|
440 |
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
|
441 private static class GreedyInliningPolicy extends AbstractInliningPolicy { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
442 |
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
|
443 public GreedyInliningPolicy(Replacements replacements, Map<Invoke, Double> hints) { |
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 super(replacements, hints); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
445 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
446 |
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
|
447 public boolean continueInlining(InliningData data) { |
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
|
448 if (data.currentGraph().graph().getNodeCount() >= GraalOptions.MaximumDesiredSize) { |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
449 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
|
450 metricInliningStoppedByMaxDesiredSize.increment(); |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
451 return false; |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
452 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
453 |
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
|
454 MethodInvocation currentInvocation = data.currentInvocation(); |
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
|
455 if (currentInvocation == 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
|
456 return 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
|
457 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
458 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
459 return isWorthInlining(currentInvocation.callee(), currentInvocation.probability(), currentInvocation.relevance(), false); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
460 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
461 |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9147
diff
changeset
|
462 @Override |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
463 public boolean isWorthInlining(InlineInfo info, double probability, double relevance, boolean fullyProcessed) { |
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
|
464 if (isIntrinsic(info)) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
465 return InliningUtil.logInlinedMethod(info, 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
|
466 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
467 |
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
|
468 double inliningBonus = getInliningBonus(info); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
469 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
470 int highLevelGraphSize = previousHighLevelGraphSize(info); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
471 if (GraalOptions.SmallCompiledHighLevelGraphSize > 0 && highLevelGraphSize > GraalOptions.SmallCompiledHighLevelGraphSize * inliningBonus) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
472 return InliningUtil.logNotInlinedMethod(info, "too large previous high-level graph: %d", highLevelGraphSize); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
473 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
474 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
475 int midLevelGraphSize = previousMidLevelGraphSize(info); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
476 if (GraalOptions.SmallCompiledMidLevelGraphSize > 0 && midLevelGraphSize > GraalOptions.SmallCompiledMidLevelGraphSize * inliningBonus) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
477 return InliningUtil.logNotInlinedMethod(info, "too large previous mid-level graph: %d", midLevelGraphSize); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
478 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
479 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
480 int lowLevelGraphSize = previousLowLevelGraphSize(info); |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
481 if (GraalOptions.SmallCompiledLowLevelGraphSize > 0 && lowLevelGraphSize > GraalOptions.SmallCompiledLowLevelGraphSize * inliningBonus) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
482 return InliningUtil.logNotInlinedMethod(info, "too large previous low-level graph: %d", lowLevelGraphSize); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
483 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
484 |
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
|
485 /* |
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
|
486 * 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
|
487 * 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
|
488 * 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
|
489 * 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
|
490 */ |
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
|
491 |
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
|
492 int nodes = determineNodeCount(info); |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
493 if (nodes < GraalOptions.TrivialInliningSize * inliningBonus) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
494 return InliningUtil.logInlinedMethod(info, fullyProcessed, "trivial (nodes=%d)", nodes); |
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
|
495 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
496 |
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
|
497 double invokes = determineInvokeProbability(info); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
498 if (GraalOptions.LimitInlinedInvokes > 0 && fullyProcessed && invokes > GraalOptions.LimitInlinedInvokes * inliningBonus) { |
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
|
499 return InliningUtil.logNotInlinedMethod(info, "invoke probability is too high (%f)", invokes); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
500 } |
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
|
501 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
502 double maximumNodes = computeMaximumSize(relevance, (int) (GraalOptions.MaximumInliningSize * inliningBonus)); |
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
|
503 if (nodes < maximumNodes) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
504 return InliningUtil.logInlinedMethod(info, fullyProcessed, "relevance-based (relevance=%f, nodes=%d)", relevance, nodes); |
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
|
505 } |
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
|
506 |
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
|
507 return InliningUtil.logNotInlinedMethod(info, "(relevance=%f, probability=%f, bonus=%f)", relevance, probability, inliningBonus); |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
508 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
509 } |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
510 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
511 private static class InliningIterator { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
512 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
513 private final FixedNode start; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
514 private final Deque<FixedNode> nodeQueue; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
515 private final NodeBitMap queuedNodes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
516 |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
517 public InliningIterator(FixedNode start, NodeBitMap visitedFixedNodes) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
518 this.start = start; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
519 this.nodeQueue = new ArrayDeque<>(); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
520 this.queuedNodes = visitedFixedNodes; |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
521 assert start.isAlive(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
522 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
523 |
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
|
524 public Stack<Invoke> apply() { |
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
|
525 Stack<Invoke> invokes = new Stack<>(); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
526 FixedNode current; |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
527 forcedQueue(start); |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
528 |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
529 while ((current = nextQueuedNode()) != null) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
530 assert current.isAlive(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
531 |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
532 if (current instanceof Invoke) { |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
533 if (current != start) { |
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
|
534 invokes.push((Invoke) current); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
535 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
536 queueSuccessors(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
537 } else if (current instanceof LoopBeginNode) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
538 queueSuccessors(current); |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
539 } else if (current instanceof LoopEndNode) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
540 // nothing todo |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
541 } else if (current instanceof MergeNode) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
542 queueSuccessors(current); |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
543 } else if (current instanceof FixedWithNextNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
544 queueSuccessors(current); |
9435
794370a64b71
Replace AbstractEndNode usages with EndNode usages wherever appropriate.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
545 } else if (current instanceof EndNode) { |
794370a64b71
Replace AbstractEndNode usages with EndNode usages wherever appropriate.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
546 queueMerge((EndNode) current); |
8385
85d4392b9e26
Introduce a ControlSinkNode base class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7879
diff
changeset
|
547 } else if (current instanceof ControlSinkNode) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
548 // nothing todo |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
549 } else if (current instanceof ControlSplitNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
550 queueSuccessors(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
551 } else { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
552 assert false : current; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
553 } |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
554 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
555 |
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
556 return invokes; |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
557 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
558 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
559 private void queueSuccessors(FixedNode x) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
560 for (Node node : x.successors()) { |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
561 queue(node); |
7063
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 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
564 |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
565 private void queue(Node node) { |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
566 if (node != null && !queuedNodes.isMarked(node)) { |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
567 forcedQueue(node); |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
568 } |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
569 } |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
570 |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
571 private void forcedQueue(Node node) { |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
572 queuedNodes.mark(node); |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
573 nodeQueue.addFirst((FixedNode) node); |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
574 } |
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
575 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
576 private FixedNode nextQueuedNode() { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
577 if (nodeQueue.isEmpty()) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
578 return null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
579 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
580 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
581 FixedNode result = nodeQueue.removeFirst(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
582 assert queuedNodes.isMarked(result); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
583 return result; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
584 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
585 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9389
diff
changeset
|
586 private void queueMerge(AbstractEndNode end) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
587 MergeNode merge = end.merge(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
588 if (!queuedNodes.isMarked(merge) && visitedAllEnds(merge)) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
589 queuedNodes.mark(merge); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
590 nodeQueue.add(merge); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
591 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
592 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
593 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
594 private boolean visitedAllEnds(MergeNode merge) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
595 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
|
596 if (!queuedNodes.isMarked(merge.forwardEndAt(i))) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
597 return false; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
598 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
599 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
600 return true; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
601 } |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7063
diff
changeset
|
602 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
603 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
604 /** |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
605 * 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
|
606 * invocation can have multiple graphs). |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
607 */ |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
608 static class InliningData { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
609 |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
610 private static final GraphInfo DummyGraphInfo = new GraphInfo(null, new Stack<Invoke>(), 1.0, 1.0); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
611 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
612 private final ArrayDeque<GraphInfo> graphQueue; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
613 private final ArrayDeque<MethodInvocation> invocationQueue; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
614 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
615 private int maxGraphs = 1; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
616 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
617 public InliningData() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
618 this.graphQueue = new ArrayDeque<>(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
619 this.invocationQueue = new ArrayDeque<>(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
620 } |
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 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
|
623 assert !contains(graph); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
624 NodeBitMap visitedFixedNodes = graph.createNodeBitMap(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
625 Stack<Invoke> invokes = new InliningIterator(graph.start(), visitedFixedNodes).apply(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
626 assert invokes.size() == count(graph.getInvokes()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
627 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
|
628 assert graphQueue.size() <= maxGraphs; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
629 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
630 |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
631 public void pushDummyGraph() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
632 graphQueue.push(DummyGraphInfo); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
633 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
634 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
635 public boolean hasUnprocessedGraphs() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
636 return !graphQueue.isEmpty(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
637 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
638 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
639 public GraphInfo currentGraph() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
640 return graphQueue.peek(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
641 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
642 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
643 public void popGraph() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
644 graphQueue.pop(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
645 assert graphQueue.size() <= maxGraphs; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
646 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
647 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
648 public MethodInvocation currentInvocation() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
649 return invocationQueue.peek(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
650 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
651 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
652 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
|
653 MethodInvocation methodInvocation = new MethodInvocation(info, new Assumptions(assumptions.useOptimisticAssumptions()), probability, relevance); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
654 invocationQueue.push(methodInvocation); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
655 maxGraphs += info.numberOfMethods(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
656 assert graphQueue.size() <= maxGraphs; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
657 return methodInvocation; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
658 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
659 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
660 public void popInvocation() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
661 maxGraphs -= invocationQueue.peek().callee.numberOfMethods(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
662 assert graphQueue.size() <= maxGraphs; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
663 invocationQueue.pop(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
664 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
665 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
666 public int countRecursiveInlining(ResolvedJavaMethod method) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
667 int count = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
668 for (GraphInfo graphInfo : graphQueue) { |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
669 if (method.equals(graphInfo.method())) { |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
670 count++; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
671 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
672 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
673 return count; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
674 } |
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 public int inliningDepth() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
677 return invocationQueue.size(); |
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 @Override |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
681 public String toString() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
682 StringBuilder result = new StringBuilder("Invocations: "); |
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 for (MethodInvocation invocation : invocationQueue) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
685 result.append(invocation.callee().numberOfMethods()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
686 result.append("x "); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
687 result.append(invocation.callee().invoke()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
688 result.append("; "); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
689 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
690 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
691 result.append("\nGraphs: "); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
692 for (GraphInfo graph : graphQueue) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
693 result.append(graph.graph()); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
694 result.append("; "); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
695 } |
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 return result.toString(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
698 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
699 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
700 private boolean contains(StructuredGraph graph) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
701 for (GraphInfo info : graphQueue) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
702 if (info.graph() == graph) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
703 return true; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
704 } |
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 return false; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
707 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
708 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
709 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
|
710 int count = 0; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
711 Iterator<Invoke> iterator = invokes.iterator(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
712 while (iterator.hasNext()) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
713 iterator.next(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
714 count++; |
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 return count; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
717 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
718 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
719 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
720 private static class MethodInvocation { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
721 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
722 private final InlineInfo callee; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
723 private final Assumptions assumptions; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
724 private final double probability; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
725 private final double relevance; |
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 int processedGraphs; |
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 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
|
730 this.callee = info; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
731 this.assumptions = assumptions; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
732 this.probability = probability; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
733 this.relevance = relevance; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
734 } |
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 void incrementProcessedGraphs() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
737 processedGraphs++; |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
738 assert processedGraphs <= callee.numberOfMethods(); |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
739 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
740 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
741 public boolean processedAllGraphs() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
742 assert processedGraphs <= callee.numberOfMethods(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
743 return processedGraphs == callee.numberOfMethods(); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
744 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
745 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
746 public InlineInfo callee() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
747 return callee; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
748 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
749 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
750 public Assumptions assumptions() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
751 return assumptions; |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
752 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
753 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
754 public double probability() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
755 return probability; |
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 |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
758 public double relevance() { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
759 return relevance; |
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 } |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
762 |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
763 private static class GraphInfo { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
764 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
765 private final StructuredGraph graph; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
766 private final Stack<Invoke> remainingInvokes; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
767 private final double probability; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
768 private final double relevance; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
769 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
770 private NodesToDoubles nodeProbabilities; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
771 private NodesToDoubles nodeRelevance; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
772 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
773 public GraphInfo(StructuredGraph graph, Stack<Invoke> invokes, double probability, double relevance) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
774 this.graph = graph; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
775 this.remainingInvokes = invokes; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
776 this.probability = probability; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
777 this.relevance = relevance; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
778 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
779 if (graph != null) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
780 computeProbabilities(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
781 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
782 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
783 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
784 public ResolvedJavaMethod method() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
785 return graph.method(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
786 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
787 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
788 public boolean hasRemainingInvokes() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
789 return !remainingInvokes.isEmpty(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
790 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
791 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
792 public StructuredGraph graph() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
793 return graph; |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
794 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
795 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
796 public Invoke popInvoke() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
797 return remainingInvokes.pop(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
798 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
799 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
800 public void pushInvoke(Invoke invoke) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
801 remainingInvokes.push(invoke); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
802 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
803 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
804 public void computeProbabilities() { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
805 nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
806 nodeRelevance = new ComputeInliningRelevanceClosure(graph, nodeProbabilities).apply(); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
807 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
808 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
809 public double invokeProbability(Invoke invoke) { |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
810 return probability * nodeProbabilities.get(invoke.asNode()); |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
811 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
812 |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
813 public double invokeRelevance(Invoke invoke) { |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
814 return Math.min(GraalOptions.CapInheritedRelevance, relevance) * nodeRelevance.get(invoke.asNode()); |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
815 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
816 } |
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
817 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
818 private static class CompiledMethodInfo { |
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
|
819 |
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
|
820 private int highLevelNodes; |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
821 private int midLevelNodes; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
822 private int lowLevelNodes; |
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
|
823 private double summedUpProbabilityOfRemainingInvokes; |
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
|
824 |
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
|
825 public CompiledMethodInfo() { |
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
|
826 } |
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
|
827 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
828 public int highLevelNodeCount() { |
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
|
829 return highLevelNodes; |
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
|
830 } |
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
|
831 |
9701
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
832 public void setHighLevelNodeCount(int highLevelNodes) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
833 this.highLevelNodes = highLevelNodes; |
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
|
834 } |
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
|
835 |
9703
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
836 public int midLevelNodeCount() { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
837 return midLevelNodes; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
838 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
839 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
840 public void setMidLevelNodeCount(int midLevelNodes) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
841 this.midLevelNodes = midLevelNodes; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
842 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
843 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
844 public int lowLevelNodeCount() { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
845 return lowLevelNodes; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
846 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
847 |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
848 public void setLowLevelNodeCount(int lowLevelNodes) { |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
849 this.lowLevelNodes = lowLevelNodes; |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
850 } |
57113d21ce36
Added some tunable parameters to the inlining phase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9702
diff
changeset
|
851 |
9702
907f1124b427
Removed memory leak and bugfixes for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9701
diff
changeset
|
852 public double summedUpProbabilityOfRemainingInvokes() { |
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
|
853 return summedUpProbabilityOfRemainingInvokes; |
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
|
854 } |
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
|
855 |
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
|
856 public void setSummedUpProbabilityOfRemainingInvokes(double summedUpProbabilityOfRemainingInvokes) { |
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
|
857 this.summedUpProbabilityOfRemainingInvokes = summedUpProbabilityOfRemainingInvokes; |
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
|
858 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
859 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 } |