Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java @ 4594:eb6df44a1374
bugfixes, added bytecode complexity estimation
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Tue, 14 Feb 2012 13:53:25 -0800 |
parents | 33f181ad79d5 |
children | 6a44a26ed9e6 |
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.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.max.graal.graph.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.max.graal.nodes.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
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 public class InliningPhase extends Phase implements InliningCallback { |
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 * - 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
|
43 * 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
|
44 * - 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
|
45 */ |
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 private final CiTarget target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 private final GraalRuntime runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
4434 | 50 private final Collection<? extends Invoke> hints; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
52 private final PriorityQueue<InlineInfo> inlineCandidates = new PriorityQueue<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 private CiAssumptions assumptions; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private final PhasePlan plan; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
56 private final WeightComputationPolicy weightComputationPolicy; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
57 private final InliningPolicy inliningPolicy; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
59 // Metrics |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
60 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
|
61 private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered"); |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
62 |
4434 | 63 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
|
64 this.target = target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 this.runtime = runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 this.hints = hints; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 this.assumptions = assumptions; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 this.plan = plan; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
69 this.weightComputationPolicy = createWeightComputationPolicy(); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
70 this.inliningPolicy = createInliningPolicy(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 @SuppressWarnings("unchecked") |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 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
|
76 graph.createNodeMap(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 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
|
79 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
|
80 } else { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
81 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
|
82 scanInvokes(graph.getNodes(InvokeWithExceptionNode.class), 0, graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 InlineInfo info = inlineCandidates.remove(); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
87 if (inliningPolicy.isWorthInlining(graph, info)) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
88 Iterable<Node> newNodes = null; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
89 if (info.invoke.node().isAlive()) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
90 try { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
91 info.inline(graph, runtime, this); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
92 Debug.log("inlining %f: %s", info.weight, info); |
4579
854145ec9866
Fix boxing elimination for boxed constants.
Andreas Woess <andreas.woess@jku.at>
parents:
4569
diff
changeset
|
93 Debug.dump(graph, "after %s", info); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
94 // get the new nodes here, the canonicalizer phase will reset the mark |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
95 newNodes = graph.getNewNodes(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
96 if (GraalOptions.OptCanonicalizer) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
97 new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
98 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
99 if (GraalOptions.Intrinsify) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
100 new IntrinsificationPhase(runtime).apply(graph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
101 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
102 metricInliningPerformed.increment(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
103 } catch (CiBailout bailout) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
104 // TODO determine if we should really bail out of the whole compilation. |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
105 throw bailout; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
106 } catch (AssertionError e) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
107 throw new GraalInternalError(e).addContext(info.toString()); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
108 } catch (RuntimeException e) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
109 throw new GraalInternalError(e).addContext(info.toString()); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
110 } catch (GraalInternalError e) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
121 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
|
122 graph.mark(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 for (Node node : newNodes) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 if (node != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 if (node instanceof Invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 Invoke invoke = (Invoke) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 scanInvoke(invoke, level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4205
diff
changeset
|
129 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
|
130 scanInvoke((Invoke) usage, level); |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 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
|
140 metricInliningConsidered.increment(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 inlineCandidates.add(info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
145 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
|
146 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 public StructuredGraph buildGraph(RiResolvedMethod method) { |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4199
diff
changeset
|
149 StructuredGraph newGraph = new StructuredGraph(method); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 if (plan != null) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
152 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 if (GraalOptions.ProbabilityAnalysis) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
156 new DeadCodeEliminationPhase().apply(newGraph); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
157 new ComputeProbabilityPhase().apply(newGraph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
4589
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
159 if (GraalOptions.OptCanonicalizer) { |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
160 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
|
161 } |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
162 return newGraph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 } |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 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
|
167 boolean preferred = hints != null && hints.contains(invoke); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
168 return weightComputationPolicy.computeWeight(caller, method, invoke, preferred); |
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 public static int graphComplexity(StructuredGraph graph) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 int result = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 for (Node node : graph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 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
|
175 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 } else if (node instanceof PhiNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 result += 5; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 } 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
|
179 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 } else if (node instanceof ControlSplitNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 result += ((ControlSplitNode) node).blockSuccessorCount(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 result += 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 return Math.max(1, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 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
|
192 assumptions.recordConcreteMethod(method, context, impl); |
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 |
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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 } |
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
|
202 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
|
203 } |
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
|
204 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 default: |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
213 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
|
214 return null; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
215 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
216 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
217 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
218 private WeightComputationPolicy createWeightComputationPolicy() { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
219 switch(GraalOptions.WeightComputationPolicy) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
220 case 0: return new ExecutionCountBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
221 case 1: return new BytecodeSizeBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
222 case 2: return new ComplexityBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
223 default: |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
224 GraalInternalError.shouldNotReachHere(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
225 return null; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
226 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
227 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
228 |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
229 private interface InliningPolicy { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
230 boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
231 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
232 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
233 private static class WeightBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
234 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
235 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
236 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
237 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
238 } |
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 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
|
241 if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
242 Debug.log("not inlining (cut off by weight): %e", info.weight); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
243 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
244 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
245 return true; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
246 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
247 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
248 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
249 private static class C1StaticSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
250 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
251 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
252 double maxSize = Math.max(GraalOptions.MaximumTrivialSize, Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
253 return info.weight <= maxSize; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
254 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
255 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
256 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
257 private static class MinimumCodeSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
258 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
259 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
260 assert GraalOptions.ProbabilityAnalysis; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
261 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
262 return false; |
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 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
265 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
|
266 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
|
267 maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
268 return info.weight <= maxSize; |
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 DynamicSizeBasedInliningPolicy 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; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
276 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
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 inlineBoost = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()) + Math.log(Math.max(1, info.invoke.probability() - GraalOptions.ProbabilityCapForInlining + 1)); |
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; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
282 maxSize = maxSize + maxSize * inlineBoost; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
283 maxSize = Math.min(GraalOptions.MaximumGreedyInlineSize, Math.max(GraalOptions.MaximumTrivialSize, maxSize)); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
284 return info.weight <= maxSize; |
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 GreedySizeBasedInliningPolicy 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; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
292 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
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 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
296 double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); |
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.MaximumGreedyInlineSize * inlineRatio; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
298 maxSize = Math.max(maxSize, GraalOptions.MaximumInlineSize); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
299 return info.weight <= maxSize; |
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 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
303 private interface WeightComputationPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
304 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
|
305 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
306 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
307 private class ExecutionCountBasedWeightComputationPolicy implements WeightComputationPolicy { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
308 @Override |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
309 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
|
310 double ratio; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
311 if (preferredInvoke) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
312 ratio = 1000000; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
313 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
314 if (GraalOptions.ProbabilityAnalysis) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
315 ratio = invoke.node().probability(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
316 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
317 RiProfilingInfo profilingInfo = method.profilingInfo(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
318 int executionCount = profilingInfo.getExecutionCount(invoke.bci()); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
319 if (executionCount > 0) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
320 RiResolvedMethod parent = invoke.stateAfter().method(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
321 ratio = executionCount / (float) parent.invocationCount(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
322 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
323 ratio = 1; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
324 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
325 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
326 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
327 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
328 final double normalSize; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
329 // 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
|
330 if (ratio < 0.01) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
331 ratio = 0.01; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
332 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
333 if (ratio < 0.5) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
334 normalSize = 10 * ratio / 0.5; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
335 } else if (ratio < 2) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
336 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
|
337 } else if (ratio < 20) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
338 normalSize = 35; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
339 } else if (ratio < 40) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
340 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
|
341 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
342 normalSize = 350; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
343 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
344 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
345 int count; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
346 if (GraalOptions.ParseBeforeInlining) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
347 if (!parsedMethods.containsKey(method)) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
348 StructuredGraph newGraph = new StructuredGraph(method); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
349 if (plan != null) { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
350 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
351 } |
4589
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
352 if (GraalOptions.OptCanonicalizer) { |
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4579
diff
changeset
|
353 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
|
354 } |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
355 count = graphComplexity(newGraph); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
356 parsedMethods.put(method, count); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
357 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
358 count = parsedMethods.get(method); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
359 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
360 } else { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
361 count = method.codeSize(); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
362 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
363 |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
364 return count / normalSize; |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
365 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
366 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
367 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
368 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
|
369 @Override |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
370 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
|
371 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
|
372 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
|
373 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
|
374 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
375 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
|
376 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
377 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
378 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
379 private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
380 @Override |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
381 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
|
382 double complexity = method.compilationComplexity(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
383 if (preferredInvoke) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
384 complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
385 } |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
386 return complexity; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
387 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
388 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |