Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java @ 5040:4d6e5ddf70e5
added option to print the profiling information
better log output for the inlining decisions
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Wed, 07 Mar 2012 09:48:08 -0800 |
parents | a7c079d5dc87 |
children | 2f2c6347fce4 |
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 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.max.graal.compiler.phases; |
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.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
27 import com.oracle.max.cri.ci.*; |
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
28 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.max.graal.compiler.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.max.graal.compiler.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.max.graal.compiler.util.InliningUtil.InlineInfo; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.max.graal.compiler.util.InliningUtil.InliningCallback; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.max.graal.cri.*; |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
35 import com.oracle.max.graal.debug.*; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
36 import com.oracle.max.graal.debug.internal.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.max.graal.graph.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.max.graal.nodes.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 public class InliningPhase extends Phase implements InliningCallback { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * - Detect method which only call another method with some parameters set to constants: void foo(a) -> void foo(a, b) -> void foo(a, b, c) ... |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 * These should not be taken into account when determining inlining depth. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * - honor the result of overrideInliningDecision(0, caller, invoke.bci, method, true); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 private final CiTarget target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 private final GraalRuntime runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
4434 | 51 private final Collection<? extends Invoke> hints; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
53 private final PriorityQueue<InlineInfo> inlineCandidates = new PriorityQueue<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 private CiAssumptions assumptions; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 private final PhasePlan plan; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
57 private final WeightComputationPolicy weightComputationPolicy; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
58 private final InliningPolicy inliningPolicy; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
60 // Metrics |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
61 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
|
62 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
|
63 private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize"); |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
64 |
4434 | 65 public InliningPhase(CiTarget target, GraalRuntime runtime, Collection<? extends Invoke> hints, CiAssumptions assumptions, PhasePlan plan) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 this.target = target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 this.runtime = runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 this.hints = hints; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 this.assumptions = assumptions; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 this.plan = plan; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
71 this.weightComputationPolicy = createWeightComputationPolicy(); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
72 this.inliningPolicy = createInliningPolicy(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 @SuppressWarnings("unchecked") |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 protected void run(StructuredGraph graph) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
78 graph.createNodeMap(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 if (hints != null) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
81 scanInvokes((Iterable<? extends Node>) Util.uncheckedCast(this.hints), -1, graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 } else { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
83 scanInvokes(graph.getNodes(InvokeNode.class), 0, graph); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
84 scanInvokes(graph.getNodes(InvokeWithExceptionNode.class), 0, graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 InlineInfo info = inlineCandidates.remove(); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
89 if (info.invoke.node().isAlive() && inliningPolicy.isWorthInlining(graph, info)) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
90 Iterable<Node> newNodes = null; |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
91 try { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
92 info.inline(graph, runtime, this); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
93 Debug.dump(graph, "after %s", info); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
94 // get the new nodes here, the canonicalizer phase will reset the mark |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
95 newNodes = graph.getNewNodes(); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
96 if (GraalOptions.OptCanonicalizer) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
97 new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
98 } |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
99 if (GraalOptions.Intrinsify) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
100 new IntrinsificationPhase(runtime).apply(graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 } |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
102 metricInliningPerformed.increment(); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
103 } catch (CiBailout bailout) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
104 // TODO determine if we should really bail out of the whole compilation. |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
105 throw bailout; |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
106 } catch (AssertionError e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
107 throw new GraalInternalError(e).addContext(info.toString()); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
108 } catch (RuntimeException e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
109 throw new GraalInternalError(e).addContext(info.toString()); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
110 } catch (GraalInternalError e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
111 throw e.addContext(info.toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 } |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
113 |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
114 if (newNodes != null && info.level < GraalOptions.MaximumInlineLevel) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
115 scanInvokes(newNodes, info.level + 1, graph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
116 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 } |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
119 |
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
120 if (GraalOptions.Debug && graph.getNodeCount() >= GraalOptions.MaximumDesiredSize) { |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
121 Debug.log("inlining cut off by MaximumDesiredSize"); |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
122 metricInliningStoppedByMaxDesiredSize.increment(); |
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
123 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
126 private void scanInvokes(Iterable<? extends Node> newNodes, int level, StructuredGraph graph) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 graph.mark(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 for (Node node : newNodes) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 if (node != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 if (node instanceof Invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 Invoke invoke = (Invoke) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 scanInvoke(invoke, level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 } |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4205
diff
changeset
|
134 for (Node usage : node.usages().filterInterface(Invoke.class).snapshot()) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4205
diff
changeset
|
135 scanInvoke((Invoke) usage, level); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 private void scanInvoke(Invoke invoke, int level) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
142 InlineInfo info = InliningUtil.getInlineInfo(invoke, level >= 0 ? level : computeInliningLevel(invoke), runtime, assumptions, this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 if (info != null) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
144 assert level == -1 || computeInliningLevel(invoke) == level : "outer FramesStates must match inlining level"; |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
145 metricInliningConsidered.increment(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 inlineCandidates.add(info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
150 public static final Map<RiMethod, Integer> parsedMethods = new HashMap<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 public StructuredGraph buildGraph(RiResolvedMethod method) { |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4199
diff
changeset
|
154 StructuredGraph newGraph = new StructuredGraph(method); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 if (plan != null) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
157 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4699
diff
changeset
|
159 assert newGraph.start().next() != null : "graph needs to be populated during PhasePosition.AFTER_PARSING"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 if (GraalOptions.ProbabilityAnalysis) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
162 new DeadCodeEliminationPhase().apply(newGraph); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
163 new ComputeProbabilityPhase().apply(newGraph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
4589
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
165 if (GraalOptions.OptCanonicalizer) { |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
166 new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
167 } |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
168 return newGraph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 public double inliningWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
173 boolean preferred = hints != null && hints.contains(invoke); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
174 return weightComputationPolicy.computeWeight(caller, method, invoke, preferred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 public static int graphComplexity(StructuredGraph graph) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 int result = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 for (Node node : graph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 if (node instanceof ConstantNode || node instanceof LocalNode || node instanceof BeginNode || node instanceof ReturnNode || node instanceof UnwindNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 } else if (node instanceof PhiNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 result += 5; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } else if (node instanceof MergeNode || node instanceof Invoke || node instanceof LoopEndNode || node instanceof EndNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 } else if (node instanceof ControlSplitNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 result += ((ControlSplitNode) node).blockSuccessorCount(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 result += 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 return Math.max(1, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 public void recordConcreteMethodAssumption(RiResolvedMethod method, RiResolvedType context, RiResolvedMethod impl) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 assumptions.recordConcreteMethod(method, context, impl); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
201 @Override |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
202 public void recordMethodContentsAssumption(RiResolvedMethod method) { |
4672
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
203 if (assumptions != null) { |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
204 assumptions.recordMethodContents(method); |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
205 } |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
206 } |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
207 |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
208 private static int computeInliningLevel(Invoke invoke) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
209 int count = 0; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
210 FrameState curState = invoke.stateAfter(); |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
211 while (curState != null) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
212 count++; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
213 curState = curState.outerFrameState(); |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
214 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
215 return count - 1; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
216 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
217 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
218 private static InliningPolicy createInliningPolicy() { |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
219 switch(GraalOptions.InliningPolicy) { |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
220 case 0: return new WeightBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
221 case 1: return new C1StaticSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
222 case 2: return new MinimumCodeSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
223 case 3: return new DynamicSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
224 case 4: return new GreedySizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
225 default: |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
226 GraalInternalError.shouldNotReachHere(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
227 return null; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
228 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
229 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
230 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
231 private WeightComputationPolicy createWeightComputationPolicy() { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
232 switch(GraalOptions.WeightComputationPolicy) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
233 case 0: return new ExecutionCountBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
234 case 1: return new BytecodeSizeBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
235 case 2: return new ComplexityBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
236 default: |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
237 GraalInternalError.shouldNotReachHere(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
238 return null; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
239 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
240 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
241 |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
242 private interface InliningPolicy { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
243 boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
244 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
245 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
246 private static class WeightBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
247 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
248 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
249 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
250 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
251 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
252 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
253 double penalty = Math.pow(GraalOptions.InliningSizePenaltyExp, callerGraph.getNodeCount() / (double) GraalOptions.MaximumDesiredSize) / GraalOptions.InliningSizePenaltyExp; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
254 if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
255 Debug.log("not inlining (cut off by weight %e): %s", info.weight, info); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
256 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
257 } |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
258 |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
259 Debug.log("inlining (weight %f): %s", info.weight, info); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
260 return true; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
261 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
262 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
263 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
264 private static class C1StaticSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
265 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
266 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
267 double maxSize = Math.max(GraalOptions.MaximumTrivialSize, Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
268 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
269 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
270 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
271 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
272 private static class MinimumCodeSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
273 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
274 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
275 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
276 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
277 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
278 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
279 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
280 double inlineWeight = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
281 double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize * inlineWeight; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
282 maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
283 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
284 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
285 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
286 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
287 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
288 private static class DynamicSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
289 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
290 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
291 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
292 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
293 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
294 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
295 |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
296 double inlineBoost = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()) + Math.log10(Math.max(1, info.invoke.probability() - GraalOptions.ProbabilityCapForInlining + 1)); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
297 double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
298 maxSize = maxSize + maxSize * inlineBoost; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
299 maxSize = Math.min(GraalOptions.MaximumGreedyInlineSize, Math.max(GraalOptions.MaximumTrivialSize, maxSize)); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
300 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
301 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
302 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
303 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
304 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
305 private static class GreedySizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
306 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
307 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
308 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
309 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
310 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
311 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
312 |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
313 double maxSize = GraalOptions.MaximumGreedyInlineSize; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
314 if (GraalOptions.InliningBonusPerTransferredValue != 0) { |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
315 RiSignature signature = info.invoke.callTarget().targetMethod().signature(); |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
316 int transferredValues = signature.argumentCount(true); |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
317 if (signature.returnKind(false) != CiKind.Void) { |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
318 transferredValues++; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
319 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
320 maxSize += transferredValues * GraalOptions.InliningBonusPerTransferredValue; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
321 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
322 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
323 double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
324 maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * maxSize * inlineRatio; |
4699
83e7065e9c75
adjust inlining policy's maximum trivial size
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4672
diff
changeset
|
325 maxSize = Math.max(maxSize, GraalOptions.MaximumTrivialSize); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
326 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
327 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
328 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
329 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
330 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
331 private static boolean decideSizeBasedInlining(InlineInfo info, double maxSize) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
332 boolean success = info.weight <= maxSize; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
333 if (DebugScope.getInstance().isLogEnabled()) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
334 String formatterString = success ? "inlining invoke at %s@%d (size %f <= %f): %s" : "not inlining invoke at %s@%d (too large %f > %f): %s"; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
335 Debug.log(formatterString, CiUtil.format("%H.%n(%p):%r", info.invoke.stateAfter().method()), info.invoke.bci(), info.weight, maxSize, info); |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
336 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
337 return success; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
338 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
339 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
340 private static boolean checkCompiledCodeSize(InlineInfo info) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
341 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
342 Debug.log("not inlining invoke at %s@%d (CompiledCodeSize %d > %d): %s", CiUtil.format("%H.%n(%p):%r", info.invoke.stateAfter().method()), info.invoke.bci(), info.compiledCodeSize(), GraalOptions.SmallCompiledCodeSize, info); |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
343 return false; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
344 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
345 return true; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
346 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
347 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
348 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
349 private interface WeightComputationPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
350 double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
351 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
352 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
353 private class ExecutionCountBasedWeightComputationPolicy implements WeightComputationPolicy { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
354 @Override |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
355 public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
356 double ratio; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
357 if (preferredInvoke) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
358 ratio = 1000000; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
359 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
360 if (GraalOptions.ProbabilityAnalysis) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
361 ratio = invoke.node().probability(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
362 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
363 RiProfilingInfo profilingInfo = method.profilingInfo(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
364 int executionCount = profilingInfo.getExecutionCount(invoke.bci()); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
365 if (executionCount > 0) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
366 RiResolvedMethod parent = invoke.stateAfter().method(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
367 ratio = executionCount / (float) parent.invocationCount(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
368 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
369 ratio = 1; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
370 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
371 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
372 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
373 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
374 final double normalSize; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
375 // TODO(ls) get rid of this magic, it's here to emulate the old behavior for the time being |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
376 if (ratio < 0.01) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
377 ratio = 0.01; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
378 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
379 if (ratio < 0.5) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
380 normalSize = 10 * ratio / 0.5; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
381 } else if (ratio < 2) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
382 normalSize = 10 + (35 - 10) * (ratio - 0.5) / 1.5; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
383 } else if (ratio < 20) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
384 normalSize = 35; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
385 } else if (ratio < 40) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
386 normalSize = 35 + (350 - 35) * (ratio - 20) / 20; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
387 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
388 normalSize = 350; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
389 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
390 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
391 int count; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
392 if (GraalOptions.ParseBeforeInlining) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
393 if (!parsedMethods.containsKey(method)) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
394 StructuredGraph newGraph = new StructuredGraph(method); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
395 if (plan != null) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
396 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
397 } |
4589
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
398 if (GraalOptions.OptCanonicalizer) { |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
399 new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
400 } |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
401 count = graphComplexity(newGraph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
402 parsedMethods.put(method, count); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
403 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
404 count = parsedMethods.get(method); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
405 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
406 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
407 count = method.codeSize(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
408 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
409 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
410 return count / normalSize; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
411 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
412 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
413 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
414 private static class BytecodeSizeBasedWeightComputationPolicy implements WeightComputationPolicy { |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
415 @Override |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
416 public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
417 double codeSize = method.codeSize(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
418 if (preferredInvoke) { |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
419 codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
420 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
421 return codeSize; |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
422 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
423 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
424 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
425 private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
426 @Override |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
427 public double computeWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke, boolean preferredInvoke) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
428 double complexity = method.compilationComplexity(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
429 if (preferredInvoke) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
430 complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
431 } |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
432 return complexity; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
433 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
434 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 } |