annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java @ 4670:41034914e2ee

add MethodContents assumption to fix debbugging issue
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 22 Feb 2012 17:04:27 +0100
parents 6a44a26ed9e6
children 7167f487cc31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
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
19fb5eea48b9 Minor change.
Andreas Woess <andreas.woess@jku.at>
parents: 4413
diff changeset
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");
4598
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
62 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
63
4434
19fb5eea48b9 Minor change.
Andreas Woess <andreas.woess@jku.at>
parents: 4413
diff changeset
64 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
65 this.target = target;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 this.runtime = runtime;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 this.hints = hints;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 this.assumptions = assumptions;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 this.plan = plan;
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
70 this.weightComputationPolicy = createWeightComputationPolicy();
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
71 this.inliningPolicy = createInliningPolicy();
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 @SuppressWarnings("unchecked")
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 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
77 graph.createNodeMap();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 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
80 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
81 } else {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
82 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
83 scanInvokes(graph.getNodes(InvokeWithExceptionNode.class), 0, graph);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 InlineInfo info = inlineCandidates.remove();
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
88 if (inliningPolicy.isWorthInlining(graph, info)) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
89 Iterable<Node> newNodes = null;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
90 if (info.invoke.node().isAlive()) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
91 try {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
92 info.inline(graph, runtime, this);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
93 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
94 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
95 // 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
96 newNodes = graph.getNewNodes();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
97 if (GraalOptions.OptCanonicalizer) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
98 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
99 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
100 if (GraalOptions.Intrinsify) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
101 new IntrinsificationPhase(runtime).apply(graph);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
102 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
103 metricInliningPerformed.increment();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
104 } catch (CiBailout bailout) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
105 // 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
106 throw bailout;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
107 } catch (AssertionError e) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
108 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
109 } catch (RuntimeException e) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
110 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
111 } catch (GraalInternalError e) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
112 throw e.addContext(info.toString());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 }
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
115 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
116 scanInvokes(newNodes, info.level + 1, graph);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
117 }
3733
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 }
4598
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
120
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
121 if (GraalOptions.Debug && graph.getNodeCount() >= GraalOptions.MaximumDesiredSize) {
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
122 metricInliningStoppedByMaxDesiredSize.increment();
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
123 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
126 private void scanInvokes(Iterable<? extends Node> newNodes, int level, StructuredGraph graph) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 graph.mark();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 for (Node node : newNodes) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 if (node != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 if (node instanceof Invoke) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 Invoke invoke = (Invoke) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 scanInvoke(invoke, level);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4205
diff changeset
134 for (Node usage : node.usages().filterInterface(Invoke.class).snapshot()) {
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4205
diff changeset
135 scanInvoke((Invoke) usage, level);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 private void scanInvoke(Invoke invoke, int level) {
4564
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4531
diff changeset
142 InlineInfo info = InliningUtil.getInlineInfo(invoke, level >= 0 ? level : computeInliningLevel(invoke), runtime, assumptions, this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 if (info != null) {
4564
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4531
diff changeset
144 assert level == -1 || computeInliningLevel(invoke) == level : "outer FramesStates must match inlining level";
4348
d49c90e641cb Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4205
diff changeset
145 metricInliningConsidered.increment();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 inlineCandidates.add(info);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
150 public static final Map<RiMethod, Integer> parsedMethods = new HashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 public StructuredGraph buildGraph(RiResolvedMethod method) {
4203
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
154 StructuredGraph newGraph = new StructuredGraph(method);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 if (plan != null) {
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
157 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 if (GraalOptions.ProbabilityAnalysis) {
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
161 new DeadCodeEliminationPhase().apply(newGraph);
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
162 new ComputeProbabilityPhase().apply(newGraph);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 }
4589
c148bec9398a Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4579
diff changeset
164 if (GraalOptions.OptCanonicalizer) {
c148bec9398a Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4579
diff changeset
165 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
166 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
167 return newGraph;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 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
172 boolean preferred = hints != null && hints.contains(invoke);
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
173 return weightComputationPolicy.computeWeight(caller, method, invoke, preferred);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 public static int graphComplexity(StructuredGraph graph) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 int result = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 for (Node node : graph.getNodes()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 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
180 result += 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 } else if (node instanceof PhiNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 result += 5;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 } 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
184 result += 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 } else if (node instanceof ControlSplitNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 result += ((ControlSplitNode) node).blockSuccessorCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 result += 1;
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 return Math.max(1, result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 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
197 assumptions.recordConcreteMethod(method, context, impl);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199
4670
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4598
diff changeset
200 @Override
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4598
diff changeset
201 public void recordMethodContentsAssumption(RiResolvedMethod method) {
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4598
diff changeset
202 assumptions.recordMethodContents(method);
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4598
diff changeset
203 }
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4598
diff changeset
204
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
205 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
206 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
207 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
208 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
209 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
210 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
211 }
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4531
diff changeset
212 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
213 }
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4531
diff changeset
214
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 default:
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
223 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
224 return null;
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
225 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
226 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
227
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
228 private WeightComputationPolicy createWeightComputationPolicy() {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
229 switch(GraalOptions.WeightComputationPolicy) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
230 case 0: return new ExecutionCountBasedWeightComputationPolicy();
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
231 case 1: return new BytecodeSizeBasedWeightComputationPolicy();
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
232 case 2: return new ComplexityBasedWeightComputationPolicy();
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
233 default:
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
234 GraalInternalError.shouldNotReachHere();
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
235 return null;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
236 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
237 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
238
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
239 private interface InliningPolicy {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
240 boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
241 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
242
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
243 private static class WeightBasedInliningPolicy implements InliningPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
244 @Override
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
245 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
246 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
247 return false;
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
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
250 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
251 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
252 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
253 return false;
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 return true;
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 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
258
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
259 private static class C1StaticSizeBasedInliningPolicy implements InliningPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
260 @Override
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
261 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
262 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
263 return info.weight <= maxSize;
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 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
266
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
267 private static class MinimumCodeSizeBasedInliningPolicy implements InliningPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
268 @Override
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
269 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
270 assert GraalOptions.ProbabilityAnalysis;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
271 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
272 return false;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
273 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
274
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
275 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
276 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
277 maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize);
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
278 return info.weight <= maxSize;
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 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
281
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
282 private static class DynamicSizeBasedInliningPolicy implements InliningPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
283 @Override
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
284 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
285 assert GraalOptions.ProbabilityAnalysis;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
286 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
287 return false;
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
4598
6a44a26ed9e6 set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4594
diff changeset
290 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
291 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
292 maxSize = maxSize + maxSize * inlineBoost;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
293 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
294 return info.weight <= maxSize;
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 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
297
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
298 private static class GreedySizeBasedInliningPolicy implements InliningPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
299 @Override
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
300 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
301 assert GraalOptions.ProbabilityAnalysis;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
302 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
303 return false;
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
304 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
305
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
306 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
307 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
308 maxSize = Math.max(maxSize, GraalOptions.MaximumInlineSize);
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
309 return info.weight <= maxSize;
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 interface WeightComputationPolicy {
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
314 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
315 }
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
316
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
317 private class ExecutionCountBasedWeightComputationPolicy implements WeightComputationPolicy {
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
318 @Override
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
319 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
320 double ratio;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
321 if (preferredInvoke) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
322 ratio = 1000000;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
323 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
324 if (GraalOptions.ProbabilityAnalysis) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
325 ratio = invoke.node().probability();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
326 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
327 RiProfilingInfo profilingInfo = method.profilingInfo();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
328 int executionCount = profilingInfo.getExecutionCount(invoke.bci());
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
329 if (executionCount > 0) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
330 RiResolvedMethod parent = invoke.stateAfter().method();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
331 ratio = executionCount / (float) parent.invocationCount();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
332 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
333 ratio = 1;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
334 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
335 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
336 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
337
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
338 final double normalSize;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
339 // 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
340 if (ratio < 0.01) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
341 ratio = 0.01;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
342 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
343 if (ratio < 0.5) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
344 normalSize = 10 * ratio / 0.5;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
345 } else if (ratio < 2) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
346 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
347 } else if (ratio < 20) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
348 normalSize = 35;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
349 } else if (ratio < 40) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
350 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
351 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
352 normalSize = 350;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
353 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
354
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
355 int count;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
356 if (GraalOptions.ParseBeforeInlining) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
357 if (!parsedMethods.containsKey(method)) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
358 StructuredGraph newGraph = new StructuredGraph(method);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
359 if (plan != null) {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
360 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
361 }
4589
c148bec9398a Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4579
diff changeset
362 if (GraalOptions.OptCanonicalizer) {
c148bec9398a Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4579
diff changeset
363 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
364 }
4468
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
365 count = graphComplexity(newGraph);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
366 parsedMethods.put(method, count);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
367 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
368 count = parsedMethods.get(method);
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
369 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
370 } else {
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
371 count = method.codeSize();
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
372 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
373
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
374 return count / normalSize;
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
375 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
376 }
87a12a816e99 added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4461
diff changeset
377
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
378 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
379 @Override
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
380 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
381 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
382 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
383 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
384 }
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
385 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
386 }
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
387 }
333ce00358f4 added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
388
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
389 private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy {
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
390 @Override
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
391 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
392 double complexity = method.compilationComplexity();
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
393 if (preferredInvoke) {
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
394 complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis;
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
395 }
4594
eb6df44a1374 bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4591
diff changeset
396 return complexity;
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
397 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4469
diff changeset
398 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 }