Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java @ 5316:8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Fri, 27 Apr 2012 12:04:28 -0700 |
parents | 0ebd9cfdc11f |
children | a250ca83684e |
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 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.compiler.phases; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
25 import java.lang.reflect.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import java.util.*; |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
27 import java.util.concurrent.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.compiler.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.compiler.util.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.compiler.util.InliningUtil.InlineInfo; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.compiler.util.InliningUtil.InliningCallback; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.cri.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.debug.internal.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.nodes.*; |
5299
0ebd9cfdc11f
removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents:
5290
diff
changeset
|
39 import com.oracle.max.cri.ci.*; |
0ebd9cfdc11f
removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents:
5290
diff
changeset
|
40 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
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 public class InliningPhase extends Phase implements InliningCallback { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * - 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
|
46 * 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
|
47 * - 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
|
48 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 private final CiTarget target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 private final GraalRuntime runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
4434 | 53 private final Collection<? extends Invoke> hints; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
55 private final PriorityQueue<InlineInfo> inlineCandidates = new PriorityQueue<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 private CiAssumptions assumptions; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 private final PhasePlan plan; |
5290
82e606f9ba69
add RiGraphCache interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
59 private final RiGraphCache cache; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
60 private final WeightComputationPolicy weightComputationPolicy; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
61 private final InliningPolicy inliningPolicy; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
62 private final OptimisticOptimizations optimisticOpts; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
64 // Metrics |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 |
5290
82e606f9ba69
add RiGraphCache interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
69 public InliningPhase(CiTarget target, GraalRuntime runtime, Collection<? extends Invoke> hints, CiAssumptions assumptions, RiGraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 this.target = target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 this.runtime = runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 this.hints = hints; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 this.assumptions = 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; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
76 this.optimisticOpts = optimisticOpts; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
77 this.weightComputationPolicy = createWeightComputationPolicy(); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
78 this.inliningPolicy = createInliningPolicy(); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 @SuppressWarnings("unchecked") |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 @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
|
83 protected void run(final StructuredGraph graph) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
84 graph.createNodeMap(); |
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 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
|
87 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
|
88 } else { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
89 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
|
90 scanInvokes(graph.getNodes(InvokeWithExceptionNode.class), 0, graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { |
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
|
94 final InlineInfo info = inlineCandidates.remove(); |
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
|
95 |
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
|
96 boolean inline = Debug.scope("InliningDecisions", new Callable<Boolean>() { |
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
|
97 @Override |
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
|
98 public Boolean call() throws Exception { |
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
|
99 return info.invoke.node().isAlive() && inliningPolicy.isWorthInlining(graph, info); |
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
|
100 } |
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
|
101 }); |
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
|
102 |
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
|
103 if (inline) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
104 Iterable<Node> newNodes = null; |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
105 try { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
106 info.inline(graph, runtime, this); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
107 Debug.dump(graph, "after %s", info); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
108 // 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
|
109 newNodes = graph.getNewNodes(); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
110 if (GraalOptions.OptCanonicalizer) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
111 new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
112 } |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
113 // if (GraalOptions.Intrinsify) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
114 // new IntrinsificationPhase(runtime).apply(graph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
115 // } |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
116 metricInliningPerformed.increment(); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
117 } catch (CiBailout bailout) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
118 // 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
|
119 throw bailout; |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
120 } catch (AssertionError e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
121 throw new GraalInternalError(e).addContext(info.toString()); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
122 } catch (RuntimeException e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
123 throw new GraalInternalError(e).addContext(info.toString()); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
124 } catch (GraalInternalError e) { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
125 throw e.addContext(info.toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
127 |
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
|
128 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
|
129 scanInvokes(newNodes, info.level + 1, graph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
130 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 } |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
133 |
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
134 if (GraalOptions.Debug && graph.getNodeCount() >= GraalOptions.MaximumDesiredSize) { |
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
|
135 Debug.scope("InliningDecisions", new Runnable() { |
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
|
136 public void run() { |
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
|
137 for (InlineInfo info : inlineCandidates) { |
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
|
138 Debug.log("not inlining %s because inlining cut off by MaximumDesiredSize", InliningUtil.methodName(info)); |
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
|
139 } |
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
|
140 } |
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
|
141 }); |
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 |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
143 metricInliningStoppedByMaxDesiredSize.increment(); |
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
144 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 |
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
|
147 private void scanInvokes(final Iterable<? extends Node> newNodes, final int level, final StructuredGraph graph) { |
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
|
148 Debug.scope("InliningDecisions", new Runnable() { |
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
|
149 public void run() { |
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
|
150 graph.mark(); |
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
|
151 for (Node node : newNodes) { |
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
|
152 if (node != null) { |
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
|
153 if (node instanceof Invoke) { |
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
|
154 Invoke invoke = (Invoke) node; |
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
|
155 scanInvoke(invoke, level); |
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
|
156 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
157 for (Node usage : node.usages().filterInterface(Invoke.class).snapshot()) { |
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
|
158 scanInvoke((Invoke) usage, level); |
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
|
159 } |
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
|
160 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 } |
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
|
163 }); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 private void scanInvoke(Invoke invoke, int level) { |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
167 InlineInfo info = InliningUtil.getInlineInfo(invoke, level >= 0 ? level : computeInliningLevel(invoke), runtime, assumptions, this, optimisticOpts); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 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
|
169 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
|
170 metricInliningConsidered.increment(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 inlineCandidates.add(info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
175 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
|
176 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
177 |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
178 |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
179 private static final DebugMetric metricInliningRuns = Debug.metric("Runs"); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
180 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 @Override |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
182 public StructuredGraph buildGraph(final RiResolvedMethod method) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
183 final StructuredGraph newGraph = new StructuredGraph(method); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
184 |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
185 return Debug.scope("buildInlineGraph", this, new Callable<StructuredGraph>() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
187 public StructuredGraph call() { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
188 metricInliningRuns.increment(); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
189 if (GraalOptions.CacheGraphs && cache != null) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
190 StructuredGraph cachedGraph = cache.get(method); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
191 if (cachedGraph != null) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
192 return cachedGraph; |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
193 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
194 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
195 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
197 if (plan != null) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
198 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
199 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
200 assert newGraph.start().next() != null : "graph needs to be populated during PhasePosition.AFTER_PARSING"; |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
201 |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
202 if (GraalOptions.ProbabilityAnalysis) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
203 new DeadCodeEliminationPhase().apply(newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
204 new ComputeProbabilityPhase().apply(newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
205 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
206 if (GraalOptions.OptCanonicalizer) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
207 new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
208 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
209 if (GraalOptions.Intrinsify) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
210 new IntrinsificationPhase(runtime).apply(newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
211 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
212 if (GraalOptions.CacheGraphs && cache != null) { |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
213 cache.put(newGraph); |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
214 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
215 return newGraph; |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
216 } |
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
217 }); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 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
|
222 boolean preferred = hints != null && hints.contains(invoke); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
223 return weightComputationPolicy.computeWeight(caller, method, invoke, preferred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 public static int graphComplexity(StructuredGraph graph) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 int result = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 for (Node node : graph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 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
|
230 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 } else if (node instanceof PhiNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 result += 5; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 } 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
|
234 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 } else if (node instanceof ControlSplitNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 result += ((ControlSplitNode) node).blockSuccessorCount(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 result += 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 return Math.max(1, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 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
|
247 assumptions.recordConcreteMethod(method, context, impl); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
250 @Override |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
251 public void recordMethodContentsAssumption(RiResolvedMethod method) { |
4672
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
252 if (assumptions != null) { |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
253 assumptions.recordMethodContents(method); |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
254 } |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
255 } |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
256 |
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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 } |
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
|
264 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
|
265 } |
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
|
266 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 default: |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
275 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
|
276 return null; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
277 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
278 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
279 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
280 private static WeightComputationPolicy createWeightComputationPolicy() { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
281 switch(GraalOptions.WeightComputationPolicy) { |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
282 case 0: throw new GraalInternalError("removed because of invokation counter changes"); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
283 case 1: return new BytecodeSizeBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
284 case 2: return new ComplexityBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
285 default: |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
286 GraalInternalError.shouldNotReachHere(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
287 return null; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
288 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
289 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
290 |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
291 private interface InliningPolicy { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
292 boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
293 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
294 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
295 private static class WeightBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
296 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
297 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
|
298 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
299 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
300 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
301 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
302 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
|
303 if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { |
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
|
304 Debug.log("not inlining %s (cut off by weight %e)", InliningUtil.methodName(info), info.weight); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
305 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
306 } |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
307 |
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
|
308 Debug.log("inlining %s (weight %f): %s", InliningUtil.methodName(info), info.weight); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
309 return true; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
310 } |
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 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
313 private static class C1StaticSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
314 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
315 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
316 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
|
317 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
318 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
319 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
320 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
321 private static class MinimumCodeSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
322 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
323 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
324 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
325 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
326 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
327 } |
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 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
|
330 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
|
331 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
|
332 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
333 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
334 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
335 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
336 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
337 private static class DynamicSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
338 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
339 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
340 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
341 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
342 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
343 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
344 |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
345 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
|
346 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
|
347 maxSize = maxSize + maxSize * inlineBoost; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
348 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
|
349 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
350 return decideSizeBasedInlining(info, maxSize); |
4594
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 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
354 private static class GreedySizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
355 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
356 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
357 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
358 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
359 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
360 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
361 |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
362 double maxSize = GraalOptions.MaximumGreedyInlineSize; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
363 if (GraalOptions.InliningBonusPerTransferredValue != 0) { |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
364 RiSignature signature = info.invoke.callTarget().targetMethod().signature(); |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
365 int transferredValues = signature.argumentCount(!Modifier.isStatic(info.invoke.callTarget().targetMethod().accessFlags())); |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
366 if (signature.returnKind(false) != CiKind.Void) { |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
367 transferredValues++; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
368 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
369 maxSize += transferredValues * GraalOptions.InliningBonusPerTransferredValue; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
370 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
371 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
376 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
377 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
378 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
379 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
380 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
|
381 boolean success = info.weight <= maxSize; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
382 if (DebugScope.getInstance().isLogEnabled()) { |
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
|
383 String formatterString = success ? "inlining %s (size %f <= %f)" : "not inlining %s (too large %f > %f)"; |
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
|
384 Debug.log(formatterString, InliningUtil.methodName(info), info.weight, maxSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
385 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
386 return success; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
387 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
388 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
389 private static boolean checkCompiledCodeSize(InlineInfo info) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
390 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
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
|
391 Debug.log("not inlining %s (CompiledCodeSize %d > %d)", InliningUtil.methodName(info), info.compiledCodeSize(), GraalOptions.SmallCompiledCodeSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
392 return false; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
393 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
394 return true; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
395 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
396 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
397 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
398 private interface WeightComputationPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
399 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
|
400 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
401 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
402 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
|
403 @Override |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 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
|
408 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
409 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
|
410 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
411 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
412 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
413 private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
414 @Override |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
415 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
|
416 double complexity = method.compilationComplexity(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
417 if (preferredInvoke) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
418 complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
419 } |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
420 return complexity; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
421 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
422 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 } |