annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java @ 5541:b4c406861c33

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