Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java @ 7213:ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Mon, 03 Dec 2012 13:44:12 +0100 |
parents | e23980f4a890 |
children | 2ae3e26b7e9a |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
3733
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 */ |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
23 package com.oracle.graal.phases.common; |
3733
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.lang.reflect.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import java.util.*; |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
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:
5506
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
7071 | 31 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
32 import com.oracle.graal.api.meta.ResolvedJavaType.Representation; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
5720
46ad94a0574a
moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
40 import com.oracle.graal.nodes.spi.*; |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
41 import com.oracle.graal.nodes.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.nodes.util.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
43 import com.oracle.graal.phases.*; |
3733
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 public class InliningUtil { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
46 private static final DebugMetric metricInliningTailDuplication = Debug.metric("InliningTailDuplication"); |
7071 | 47 private static final String inliningDecisionsScopeString = "InliningDecisions"; |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
48 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 public interface InliningCallback { |
7071 | 50 StructuredGraph buildGraph(final ResolvedJavaMethod method); |
51 } | |
52 | |
53 public interface InliningPolicy { | |
54 void initialize(StructuredGraph graph); | |
55 boolean continueInlining(StructuredGraph graph); | |
56 InlineInfo next(); | |
57 void scanInvokes(Iterable<? extends Node> newNodes); | |
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
|
58 double inliningWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke); |
7071 | 59 boolean isWorthInlining(InlineInfo info); |
60 } | |
61 | |
62 public interface WeightComputationPolicy { | |
63 double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke); | |
64 } | |
65 | |
66 public static void logNotInlinedMethod(InlineInfo info, String msg, Object... args) { | |
67 logInliningDecision(info, false, msg, args); | |
68 } | |
69 | |
70 public static void logInliningDecision(InlineInfo info, boolean success, String msg, final Object... args) { | |
71 if (shouldLogInliningDecision()) { | |
72 logInliningDecision(methodName(info), success, msg, args); | |
73 } | |
74 } | |
75 | |
76 public static void logInliningDecision(final String msg, final Object... args) { | |
77 Debug.scope(inliningDecisionsScopeString, new Runnable() { | |
78 public void run() { | |
79 Debug.log(msg, args); | |
80 } | |
81 }); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 |
7071 | 84 private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, String msg) { |
85 if (shouldLogInliningDecision()) { | |
86 String methodString = invoke.callTarget() == null ? "callTarget=null" : invoke.callTarget().targetName(); | |
87 logInliningDecision(methodString, false, msg, new Object[0]); | |
88 } | |
89 return false; | |
90 } | |
91 | |
92 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, ResolvedJavaMethod method, String msg) { | |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
93 return logNotInlinedMethodAndReturnNull(invoke, method, msg, new Object[0]); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
94 } |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
95 |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
96 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, ResolvedJavaMethod method, String msg, Object... args) { |
7071 | 97 if (shouldLogInliningDecision()) { |
98 String methodString = methodName(method, invoke); | |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
99 logInliningDecision(methodString, false, msg, args); |
7071 | 100 } |
101 return null; | |
102 } | |
103 | |
104 private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, ResolvedJavaMethod method, String msg) { | |
105 if (shouldLogInliningDecision()) { | |
106 String methodString = methodName(method, invoke); | |
107 logInliningDecision(methodString, false, msg, new Object[0]); | |
108 } | |
109 return false; | |
110 } | |
111 | |
112 private static void logInliningDecision(final String methodString, final boolean success, final String msg, final Object... args) { | |
113 String inliningMsg = "inlining " + methodString + ": " + msg; | |
114 if (!success) { | |
115 inliningMsg = "not " + inliningMsg; | |
116 } | |
117 logInliningDecision(inliningMsg, args); | |
118 } | |
119 | |
120 private static boolean shouldLogInliningDecision() { | |
121 return Debug.scope(inliningDecisionsScopeString, new Callable<Boolean>() { | |
122 public Boolean call() { | |
123 return Debug.isLogEnabled(); | |
124 } | |
125 }); | |
126 } | |
127 | |
128 private static String methodName(ResolvedJavaMethod method, Invoke invoke) { | |
129 if (invoke != null && invoke.stateAfter() != null) { | |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
130 return methodName(invoke.stateAfter(), invoke.bci()) + ": " + MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 } else { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
132 return MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 |
7071 | 136 private static String methodName(InlineInfo info) { |
137 if (info == null) { | |
138 return "null"; | |
139 } else if (info.invoke() != null && info.invoke().stateAfter() != null) { | |
140 return methodName(info.invoke().stateAfter(), info.invoke().bci()) + ": " + info.toString(); | |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
141 } else { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
142 return info.toString(); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
143 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
144 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
145 |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
146 private static String methodName(FrameState frameState, int bci) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
147 StringBuilder sb = new StringBuilder(); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
148 if (frameState.outerFrameState() != null) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
149 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci)); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
150 sb.append("->"); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
151 } |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
152 sb.append(MetaUtil.format("%h.%n", frameState.method())); |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
153 sb.append("@").append(bci); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
154 return sb.toString(); |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
155 } |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
156 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 * Represents an opportunity for inlining at the given invoke, with the given weight and level. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 * The weight is the amortized weight of the additional code - so smaller is better. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 * The level is the number of nested inlinings that lead to this invoke. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 */ |
7071 | 162 public interface InlineInfo extends Comparable<InlineInfo> { |
163 Invoke invoke(); | |
164 double weight(); | |
165 int level(); | |
166 int compiledCodeSize(); | |
167 int compareTo(InlineInfo o); | |
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 * Performs the inlining described by this object and returns the node that represents the return value of the |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 * inlined method (or null for void methods and methods that have no non-exceptional exit). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 */ |
7071 | 173 void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions); |
174 } | |
175 | |
176 public abstract static class AbstractInlineInfo implements InlineInfo { | |
177 protected final Invoke invoke; | |
178 protected final double weight; | |
179 | |
180 public AbstractInlineInfo(Invoke invoke, double weight) { | |
181 this.invoke = invoke; | |
182 this.weight = weight; | |
183 } | |
184 | |
185 @Override | |
186 public int compareTo(InlineInfo o) { | |
187 return (weight < o.weight()) ? -1 : (weight > o.weight()) ? 1 : 0; | |
188 } | |
189 | |
190 public Invoke invoke() { | |
191 return invoke; | |
192 } | |
193 | |
194 public double weight() { | |
195 return weight; | |
196 } | |
197 | |
198 public int level() { | |
199 return computeInliningLevel(invoke); | |
200 } | |
201 | |
202 protected static StructuredGraph getGraph(final Invoke invoke, final ResolvedJavaMethod concrete, final GraalCodeCacheProvider runtime, final InliningCallback callback) { | |
203 return Debug.scope("GetInliningGraph", concrete, new Callable<StructuredGraph>() { | |
204 @Override | |
205 public StructuredGraph call() throws Exception { | |
206 StructuredGraph result = getIntrinsicGraph(invoke, concrete, runtime); | |
207 if (result == null) { | |
208 assert !Modifier.isNative(concrete.getModifiers()); | |
209 result = callback.buildGraph(concrete); | |
210 } | |
211 return result; | |
212 } | |
213 }); | |
214 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 * Represents an inlining opportunity where the compiler can statically determine a monomorphic target method and |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 * therefore is able to determine the called method exactly. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 */ |
7071 | 221 private static class ExactInlineInfo extends AbstractInlineInfo { |
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
|
222 public final ResolvedJavaMethod concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 |
7071 | 224 public ExactInlineInfo(Invoke invoke, double weight, ResolvedJavaMethod concrete) { |
225 super(invoke, weight); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 this.concrete = concrete; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 @Override |
7071 | 230 public void inline(StructuredGraph compilerGraph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { |
231 StructuredGraph graph = getGraph(invoke, concrete, runtime, callback); | |
232 assumptions.recordMethodContents(concrete); | |
4461 | 233 InliningUtil.inline(invoke, graph, true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
237 public int compiledCodeSize() { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
238 return concrete.getCompiledCodeSize(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
239 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
240 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
241 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 public String toString() { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
243 return "exact " + MetaUtil.format("%H.%n(%p):%r", concrete); |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 * Represents an inlining opportunity for which profiling information suggests a monomorphic receiver, but for which |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 * the receiver type cannot be proven. A type check guard will be generated if this inlining is performed. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 */ |
7071 | 251 private static class TypeGuardInlineInfo extends AbstractInlineInfo { |
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
|
252 public final ResolvedJavaMethod concrete; |
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 final ResolvedJavaType type; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 |
7071 | 255 public TypeGuardInlineInfo(Invoke invoke, double weight, ResolvedJavaMethod concrete, ResolvedJavaType type) { |
256 super(invoke, weight); | |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
257 this.concrete = concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
262 public int compiledCodeSize() { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
263 return concrete.getCompiledCodeSize(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
264 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
265 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
266 @Override |
7071 | 267 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
268 // receiver null check must be before the type check |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
269 InliningUtil.receiverNullCheck(invoke); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
270 ValueNode receiver = invoke.methodCallTarget().receiver(); |
6457
03a1a0c5ee84
removed IsTypeNode and replaced its usage with an ObjectEqualsNode
Doug Simon <doug.simon@oracle.com>
parents:
6456
diff
changeset
|
271 ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), runtime, graph); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
272 LoadHubNode receiverHub = graph.add(new LoadHubNode(receiver, typeHub.kind())); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
273 CompareNode typeCheck = CompareNode.createCompareNode(Condition.EQ, receiverHub, typeHub); |
6457
03a1a0c5ee84
removed IsTypeNode and replaced its usage with an ObjectEqualsNode
Doug Simon <doug.simon@oracle.com>
parents:
6456
diff
changeset
|
274 FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, invoke.leafGraphId())); |
5642
6c3a5ccec483
Merge AnchorNode and ValueAnchorNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
275 ValueAnchorNode anchor = graph.add(new ValueAnchorNode()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 assert invoke.predecessor() != null; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
277 |
6289
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
278 ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver, true); |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
279 invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
280 |
6463
41f0849e107b
reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents:
6460
diff
changeset
|
281 graph.addBeforeFixed(invoke.node(), receiverHub); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4249
diff
changeset
|
282 graph.addBeforeFixed(invoke.node(), guard); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
283 graph.addBeforeFixed(invoke.node(), anchor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 |
7071 | 285 StructuredGraph calleeGraph = getGraph(invoke, concrete, runtime, callback); |
286 assumptions.recordMethodContents(concrete); | |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
287 InliningUtil.inline(invoke, calleeGraph, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 public String toString() { |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
292 return "type-checked with type " + type.getName() + " and method " + MetaUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 /** |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
297 * Polymorphic inlining of m methods with n type checks (n >= m) in case that the profiling information suggests a reasonable |
4455 | 298 * amounts of different receiver types and different methods. If an unknown type is encountered a deoptimization is triggered. |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
299 */ |
7071 | 300 private static class MultiTypeGuardInlineInfo extends AbstractInlineInfo { |
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
|
301 public final List<ResolvedJavaMethod> concretes; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
302 public final ProfiledType[] ptypes; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
303 public final int[] typesToConcretes; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
304 public final double notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
305 |
7071 | 306 public MultiTypeGuardInlineInfo(Invoke invoke, double weight, List<ResolvedJavaMethod> concretes, ProfiledType[] ptypes, |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
307 int[] typesToConcretes, double notRecordedTypeProbability) { |
7071 | 308 super(invoke, weight); |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
309 assert concretes.size() > 0 && concretes.size() <= ptypes.length : "must have at least one method but no more than types methods"; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
310 assert ptypes.length == typesToConcretes.length : "array lengths must match"; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
311 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
312 this.concretes = concretes; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
313 this.ptypes = ptypes; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
314 this.typesToConcretes = typesToConcretes; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
315 this.notRecordedTypeProbability = notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
316 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
317 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
318 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
319 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
320 int result = 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
|
321 for (ResolvedJavaMethod m: concretes) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
322 result += m.getCompiledCodeSize(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
323 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
324 return result; |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
325 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
326 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
327 @Override |
7071 | 328 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
329 int numberOfMethods = concretes.size(); |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
330 boolean hasReturnValue = invoke.node().kind() != Kind.Void; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
331 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
332 // receiver null check must be the first node |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
333 InliningUtil.receiverNullCheck(invoke); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
334 if (numberOfMethods > 1 || shouldFallbackToInvoke()) { |
7071 | 335 inlineMultipleMethods(graph, runtime, callback, assumptions, numberOfMethods, hasReturnValue); |
4455 | 336 } else { |
7071 | 337 inlineSingleMethod(graph, runtime, callback, assumptions); |
4455 | 338 } |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
339 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
340 |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
341 private boolean shouldFallbackToInvoke() { |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
342 return notRecordedTypeProbability > 0; |
4455 | 343 } |
344 | |
7071 | 345 private void inlineMultipleMethods(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions, int numberOfMethods, boolean hasReturnValue) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
346 FixedNode continuation = invoke.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
347 |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
348 ValueNode originalReceiver = invoke.methodCallTarget().receiver(); |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
349 // setup merge and phi nodes for results and exceptions |
4455 | 350 MergeNode returnMerge = graph.add(new MergeNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
351 returnMerge.setProbability(invoke.probability()); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
352 returnMerge.setStateAfter(invoke.stateAfter().duplicate(invoke.stateAfter().bci)); |
4455 | 353 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
354 PhiNode returnValuePhi = null; |
4455 | 355 if (hasReturnValue) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
356 returnValuePhi = graph.unique(new PhiNode(invoke.node().kind(), returnMerge)); |
4455 | 357 } |
358 | |
359 MergeNode exceptionMerge = null; | |
360 PhiNode exceptionObjectPhi = null; | |
361 if (invoke instanceof InvokeWithExceptionNode) { | |
362 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; | |
5373
53cc37c27b04
used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents:
5365
diff
changeset
|
363 DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
4455 | 364 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
365 | |
366 exceptionMerge = graph.add(new MergeNode()); | |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
367 exceptionMerge.setProbability(exceptionEdge.probability()); |
4455 | 368 |
369 FixedNode exceptionSux = exceptionObject.next(); | |
370 graph.addBeforeFixed(exceptionSux, exceptionMerge); | |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
371 exceptionObjectPhi = graph.unique(new PhiNode(Kind.Object, exceptionMerge)); |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
372 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Void, exceptionObjectPhi)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
373 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
374 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
375 // create one separate block for each invoked method |
7071 | 376 BeginNode[] successors = new BeginNode[numberOfMethods + 1]; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
377 for (int i = 0; i < numberOfMethods; i++) { |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
378 double probability = 0; |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
379 for (int j = 0; j < typesToConcretes.length; j++) { |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
380 if (typesToConcretes[j] == i) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
381 probability += ptypes[j].getProbability(); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
382 } |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
383 } |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
384 |
7071 | 385 successors[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, invoke.probability() * probability, true); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
386 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
387 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
388 // create the successor for an unknown type |
7071 | 389 FixedNode unknownTypeSux; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
390 if (shouldFallbackToInvoke()) { |
7071 | 391 unknownTypeSux = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, notRecordedTypeProbability, false); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
392 } else { |
7071 | 393 unknownTypeSux = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId())); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
394 } |
7071 | 395 successors[successors.length - 1] = BeginNode.begin(unknownTypeSux); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
396 |
4455 | 397 // replace the invoke exception edge |
398 if (invoke instanceof InvokeWithExceptionNode) { | |
399 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke; | |
400 BeginNode exceptionEdge = invokeWithExceptionNode.exceptionEdge(); | |
401 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); | |
402 exceptionObject.replaceAtUsages(exceptionObjectPhi); | |
403 exceptionObject.setNext(null); | |
404 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge()); | |
405 } | |
406 | |
7071 | 407 // get all graphs and record assumptions |
408 assert invoke.node().isAlive(); | |
409 StructuredGraph[] calleeGraphs = new StructuredGraph[numberOfMethods]; | |
410 for (int i = 0; i < numberOfMethods; i++) { | |
411 ResolvedJavaMethod concrete = concretes.get(i); | |
412 calleeGraphs[i] = getGraph(invoke, concrete, runtime, callback); | |
413 assumptions.recordMethodContents(concrete); | |
414 } | |
415 | |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
416 // replace the invoke with a switch on the type of the actual receiver |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
417 Kind hubKind = invoke.methodCallTarget().targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind(); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
418 LoadHubNode receiverHub = graph.add(new LoadHubNode(invoke.methodCallTarget().receiver(), hubKind)); |
6463
41f0849e107b
reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents:
6460
diff
changeset
|
419 graph.addBeforeFixed(invoke.node(), receiverHub); |
7071 | 420 FixedNode dispatchOnType = createDispatchOnType(graph, receiverHub, successors); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
421 |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
422 assert invoke.next() == continuation; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
423 invoke.setNext(null); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
424 returnMerge.setNext(continuation); |
4455 | 425 invoke.node().replaceAtUsages(returnValuePhi); |
426 invoke.node().replaceAndDelete(dispatchOnType); | |
427 | |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
428 ArrayList<PiNode> replacements = new ArrayList<>(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
429 |
4455 | 430 // do the actual inlining for every invoke |
7071 | 431 for (int i = 0; i < numberOfMethods; i++) { |
432 BeginNode node = successors[i]; | |
4455 | 433 Invoke invokeForInlining = (Invoke) node.next(); |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
434 |
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
|
435 ResolvedJavaType commonType = getLeastCommonType(i); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
436 ValueNode receiver = invokeForInlining.methodCallTarget().receiver(); |
6289
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
437 boolean exact = getTypeCount(i) == 1; |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
438 PiNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver, exact); |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
439 invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
440 |
7071 | 441 StructuredGraph calleeGraph = calleeGraphs[i]; |
4455 | 442 InliningUtil.inline(invokeForInlining, calleeGraph, false); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
443 replacements.add(anchoredReceiver); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
444 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
445 if (shouldFallbackToInvoke()) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
446 replacements.add(null); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
447 } |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
448 if (GraalOptions.OptTailDuplication) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
449 /* |
5792
fa6ed51ac198
more aggressive tail duplication
Lukas Stadler <lukas.stadler@jku.at>
parents:
5791
diff
changeset
|
450 * We might want to perform tail duplication at the merge after a type switch, if there are invokes that would |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
451 * benefit from the improvement in type information. |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
452 */ |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
453 FixedNode current = returnMerge; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
454 int opportunities = 0; |
5791
506e76281145
(symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents:
5786
diff
changeset
|
455 do { |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
456 if (current instanceof InvokeNode && ((InvokeNode) current).methodCallTarget().receiver() == originalReceiver) { |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
457 opportunities++; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
458 } else if (current.inputs().contains(originalReceiver)) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
459 opportunities++; |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
460 } |
5791
506e76281145
(symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents:
5786
diff
changeset
|
461 current = ((FixedWithNextNode) current).next(); |
506e76281145
(symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents:
5786
diff
changeset
|
462 } while (current instanceof FixedWithNextNode); |
5786
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
463 if (opportunities > 0) { |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
464 metricInliningTailDuplication.increment(); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
465 Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
466 TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacements); |
f69a406355b2
new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5720
diff
changeset
|
467 } |
4455 | 468 } |
469 } | |
470 | |
6289
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
471 private int getTypeCount(int concreteMethodIndex) { |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
472 int count = 0; |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
473 for (int i = 0; i < typesToConcretes.length; i++) { |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
474 if (typesToConcretes[i] == concreteMethodIndex) { |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
475 count++; |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
476 } |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
477 } |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
478 return count; |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
479 } |
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
480 |
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
|
481 private ResolvedJavaType getLeastCommonType(int concreteMethodIndex) { |
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
|
482 ResolvedJavaType commonType = null; |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
483 for (int i = 0; i < typesToConcretes.length; i++) { |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
484 if (typesToConcretes[i] == concreteMethodIndex) { |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
485 if (commonType == null) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
486 commonType = ptypes[i].getType(); |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
487 } else { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
488 commonType = commonType.findLeastCommonAncestor(ptypes[i].getType()); |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
489 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
490 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
491 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
492 assert commonType != null; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
493 return commonType; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
494 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
495 |
7071 | 496 private void inlineSingleMethod(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
497 assert concretes.size() == 1 && ptypes.length > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0; |
4455 | 498 |
7071 | 499 BeginNode calleeEntryNode = graph.add(new BeginNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
500 calleeEntryNode.setProbability(invoke.probability()); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
501 Kind hubKind = invoke.methodCallTarget().targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind(); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6683
diff
changeset
|
502 LoadHubNode receiverHub = graph.add(new LoadHubNode(invoke.methodCallTarget().receiver(), hubKind)); |
6463
41f0849e107b
reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents:
6460
diff
changeset
|
503 graph.addBeforeFixed(invoke.node(), receiverHub); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
504 |
7071 | 505 BeginNode unknownTypeSux = BeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId()))); |
506 BeginNode[] successors = new BeginNode[] {calleeEntryNode, unknownTypeSux}; | |
507 FixedNode dispatchOnType = createDispatchOnType(graph, receiverHub, successors); | |
4455 | 508 |
509 FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor(); | |
510 pred.setNext(dispatchOnType); | |
511 calleeEntryNode.setNext(invoke.node()); | |
512 | |
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
|
513 ResolvedJavaMethod concrete = concretes.get(0); |
7071 | 514 StructuredGraph calleeGraph = getGraph(invoke, concrete, runtime, callback); |
515 assumptions.recordMethodContents(concrete); | |
4455 | 516 InliningUtil.inline(invoke, calleeGraph, false); |
517 } | |
518 | |
7071 | 519 private FixedNode createDispatchOnType(StructuredGraph graph, LoadHubNode hub, BeginNode[] successors) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
520 assert ptypes.length > 1; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
521 |
7071 | 522 ResolvedJavaType[] keys = new ResolvedJavaType[ptypes.length]; |
523 double[] keyProbabilities = new double[ptypes.length + 1]; | |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5693
diff
changeset
|
524 int[] keySuccessors = new int[ptypes.length + 1]; |
5662
13166af0809e
added TypeSwitchNode for polymorphic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5647
diff
changeset
|
525 for (int i = 0; i < ptypes.length; i++) { |
7071 | 526 keys[i] = ptypes[i].getType(); |
527 keyProbabilities[i] = ptypes[i].getProbability(); | |
528 keySuccessors[i] = typesToConcretes[i]; | |
529 assert keySuccessors[i] < successors.length - 1 : "last successor is the unknownTypeSux"; | |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
530 } |
7071 | 531 keyProbabilities[keyProbabilities.length - 1] = notRecordedTypeProbability; |
532 keySuccessors[keySuccessors.length - 1] = successors.length - 1; | |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
533 |
7071 | 534 double[] successorProbabilities = SwitchNode.successorProbabilites(successors.length, keySuccessors, keyProbabilities); |
535 TypeSwitchNode typeSwitch = graph.add(new TypeSwitchNode(hub, successors, successorProbabilities, keys, keyProbabilities, keySuccessors)); | |
5662
13166af0809e
added TypeSwitchNode for polymorphic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5647
diff
changeset
|
536 |
13166af0809e
added TypeSwitchNode for polymorphic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5647
diff
changeset
|
537 return typeSwitch; |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
538 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
539 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
540 private static BeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi, |
7071 | 541 MergeNode exceptionMerge, PhiNode exceptionObjectPhi, double probability, boolean useForInlining) { |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
542 Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining, probability); |
7071 | 543 BeginNode calleeEntryNode = graph.add(new BeginNode()); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
544 calleeEntryNode.setNext(duplicatedInvoke.node()); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
545 calleeEntryNode.setProbability(probability); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
546 |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
547 EndNode endNode = graph.add(new EndNode()); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
548 endNode.setProbability(probability); |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
549 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
550 duplicatedInvoke.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
551 returnMerge.addForwardEnd(endNode); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
552 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
553 if (returnValuePhi != null) { |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
554 returnValuePhi.addInput(duplicatedInvoke.node()); |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
555 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
556 return calleeEntryNode; |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
557 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
558 |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
559 private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, MergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining, double probability) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
560 Invoke result = (Invoke) invoke.node().copyWithInputs(); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
561 Node callTarget = result.callTarget().copyWithInputs(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
562 result.node().replaceFirstInput(result.callTarget(), callTarget); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
563 result.setUseForInlining(useForInlining); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
564 result.setProbability(probability); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
565 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
566 Kind kind = invoke.node().kind(); |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
567 if (kind != Kind.Void) { |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
568 FrameState stateAfter = invoke.stateAfter(); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
569 stateAfter = stateAfter.duplicate(stateAfter.bci); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
570 stateAfter.replaceFirstInput(invoke.node(), result.node()); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
571 result.setStateAfter(stateAfter); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
572 } |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
573 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
574 if (invoke instanceof InvokeWithExceptionNode) { |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
575 assert exceptionMerge != null && exceptionObjectPhi != null; |
4455 | 576 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
577 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
578 BeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
579 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
580 FrameState stateAfterException = exceptionObject.stateAfter(); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
581 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
582 BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
583 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs(); |
4529
fc78ad20ec38
fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4528
diff
changeset
|
584 // set new state (pop old exception object, push new one) |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
585 newExceptionObject.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionObject)); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
586 newExceptionEdge.setNext(newExceptionObject); |
4455 | 587 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
588 EndNode endNode = graph.add(new EndNode()); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
589 newExceptionObject.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
590 exceptionMerge.addForwardEnd(endNode); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
591 exceptionObjectPhi.addInput(newExceptionObject); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
592 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
593 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
594 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
595 return result; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
596 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
597 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
598 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
599 public String toString() { |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
600 StringBuilder builder = new StringBuilder(shouldFallbackToInvoke() ? "megamorphic" : "polymorphic"); |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
601 builder.append(", "); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
602 builder.append(concretes.size()); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
603 builder.append(" methods [ "); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
604 for (int i = 0; i < concretes.size(); i++) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
605 builder.append(MetaUtil.format(" %H.%n(%p):%r", concretes.get(i))); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
606 } |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
607 builder.append(" ], "); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
608 builder.append(ptypes.length); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
609 builder.append(" type checks [ "); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
610 for (int i = 0; i < ptypes.length; i++) { |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
611 builder.append(" "); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
612 builder.append(ptypes[i].getType().getName()); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
613 builder.append(ptypes[i].getProbability()); |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
614 } |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
615 builder.append(" ]"); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
616 return builder.toString(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
617 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
618 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
619 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
620 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
621 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
622 * Represents an inlining opportunity where the current class hierarchy leads to a monomorphic target method, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 * but for which an assumption has to be registered because of non-final classes. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
624 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 private static class AssumptionInlineInfo extends ExactInlineInfo { |
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
|
626 public final ResolvedJavaType context; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 |
7071 | 628 public AssumptionInlineInfo(Invoke invoke, double weight, ResolvedJavaType context, ResolvedJavaMethod concrete) { |
629 super(invoke, weight, concrete); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 this.context = context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 @Override |
7071 | 634 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
635 if (Debug.isLogEnabled()) { |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
636 String targetName = MetaUtil.format("%H.%n(%p):%r", invoke.methodCallTarget().targetMethod()); |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
637 String concreteName = MetaUtil.format("%H.%n(%p):%r", concrete); |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
638 Debug.log("recording concrete method assumption: %s on receiver type %s -> %s", targetName, context, concreteName); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 } |
7071 | 640 assumptions.recordConcreteMethod(invoke.methodCallTarget().targetMethod(), context, concrete); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
641 |
7071 | 642 super.inline(graph, runtime, callback, assumptions); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
645 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 public String toString() { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
647 return "assumption " + MetaUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
649 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
651 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
652 * Determines if inlining is possible at the given invoke node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 * @param invoke the invoke that should be inlined |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
654 * @param runtime a GraalRuntime instance used to determine of the invoke can be inlined and/or should be intrinsified |
7071 | 655 * @param inliningPolicy used to determine the weight of a specific inlining |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 * @return an instance of InlineInfo, or null if no inlining is possible at the given invoke |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 */ |
7071 | 658 public static InlineInfo getInlineInfo(Invoke invoke, GraalCodeCacheProvider runtime, Assumptions assumptions, InliningPolicy inliningPolicy, OptimisticOptimizations optimisticOpts) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
659 if (!checkInvokeConditions(invoke)) { |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
660 return null; |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
661 } |
7071 | 662 ResolvedJavaMethod caller = getCaller(invoke); |
663 MethodCallTargetNode callTarget = invoke.methodCallTarget(); | |
664 ResolvedJavaMethod targetMethod = callTarget.targetMethod(); | |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
665 |
4571 | 666 if (callTarget.invokeKind() == InvokeKind.Special || targetMethod.canBeStaticallyBound()) { |
7071 | 667 if (!checkTargetConditions(invoke, targetMethod, optimisticOpts, runtime)) { |
668 return null; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
669 } |
7071 | 670 double weight = inliningPolicy.inliningWeight(caller, targetMethod, invoke); |
671 return new ExactInlineInfo(invoke, weight, targetMethod); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
673 ObjectStamp receiverStamp = callTarget.receiver().objectStamp(); |
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
|
674 ResolvedJavaType receiverType = receiverStamp.type(); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
675 if (receiverStamp.isExactType()) { |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7079
diff
changeset
|
676 assert targetMethod.getDeclaringClass().isAssignableFrom(receiverType) : receiverType + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
677 ResolvedJavaMethod resolved = receiverType.resolveMethod(targetMethod); |
7071 | 678 if (!checkTargetConditions(invoke, resolved, optimisticOpts, runtime)) { |
679 return null; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 } |
7071 | 681 double weight = inliningPolicy.inliningWeight(caller, resolved, invoke); |
682 return new ExactInlineInfo(invoke, weight, resolved); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
683 } |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
684 ResolvedJavaType holder = targetMethod.getDeclaringClass(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
686 if (receiverStamp.type() != null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...) |
5056
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5020
diff
changeset
|
688 // TODO (lstadler) fix this |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7079
diff
changeset
|
689 if (receiverType != null && holder.isAssignableFrom(receiverType)) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
690 holder = receiverType; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 } |
5056
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5020
diff
changeset
|
693 // TODO (thomaswue) fix this |
7071 | 694 if (assumptions.useOptimisticAssumptions()) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
695 ResolvedJavaMethod concrete = holder.findUniqueConcreteMethod(targetMethod); |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
696 if (concrete != null) { |
7071 | 697 if (!checkTargetConditions(invoke, concrete, optimisticOpts, runtime)) { |
698 return null; | |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
699 } |
7071 | 700 double weight = inliningPolicy.inliningWeight(caller, concrete, invoke); |
701 return new AssumptionInlineInfo(invoke, weight, holder, concrete); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 } |
4440
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
704 |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
705 // type check based inlining |
7071 | 706 return getTypeCheckedInlineInfo(invoke, inliningPolicy, caller, targetMethod, optimisticOpts, runtime); |
5109
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
707 } |
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
708 |
7071 | 709 private static InlineInfo getTypeCheckedInlineInfo(Invoke invoke, InliningPolicy inliningPolicy, ResolvedJavaMethod caller, |
710 ResolvedJavaMethod targetMethod, OptimisticOptimizations optimisticOpts, GraalCodeCacheProvider runtime) { | |
711 ProfilingInfo profilingInfo = caller.getProfilingInfo(); | |
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
|
712 JavaTypeProfile typeProfile = profilingInfo.getTypeProfile(invoke.bci()); |
7071 | 713 if (typeProfile == null) { |
714 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "no type profile exists"); | |
715 } | |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
716 |
7071 | 717 ProfiledType[] ptypes = typeProfile.getTypes(); |
718 if (ptypes == null || ptypes.length <= 0) { | |
719 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "no types/probabilities were recorded"); | |
720 } | |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
721 |
7071 | 722 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability(); |
723 if (ptypes.length == 1 && notRecordedTypeProbability == 0) { | |
724 if (!optimisticOpts.inlineMonomorphicCalls()) { | |
725 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining monomorphic calls is disabled"); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
727 |
7071 | 728 ResolvedJavaType type = ptypes[0].getType(); |
729 ResolvedJavaMethod concrete = type.resolveMethod(targetMethod); | |
730 if (!checkTargetConditions(invoke, concrete, optimisticOpts, runtime)) { | |
731 return null; | |
732 } | |
733 double weight = inliningPolicy.inliningWeight(caller, concrete, invoke); | |
734 return new TypeGuardInlineInfo(invoke, weight, concrete, type); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 } else { |
7071 | 736 invoke.setPolymorphic(true); |
737 | |
738 if (!optimisticOpts.inlinePolymorphicCalls() && notRecordedTypeProbability == 0) { | |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
739 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining polymorphic calls is disabled (%d types)", ptypes.length); |
7071 | 740 } |
741 if (!optimisticOpts.inlineMegamorphicCalls() && notRecordedTypeProbability > 0) { | |
7213
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
742 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining megamorphic calls is disabled (%d types, %f %% not recorded types)", ptypes.length, notRecordedTypeProbability * 100); |
7071 | 743 } |
744 | |
745 // TODO (chaeubl) inlining of multiple methods should work differently | |
746 // 1. check which methods can be inlined | |
747 // 2. for those methods, use weight and probability to compute which of them should be inlined | |
748 // 3. do the inlining | |
749 // a) all seen methods can be inlined -> do so and guard with deopt | |
750 // b) some methods can be inlined -> inline them and fall back to invocation if violated | |
751 | |
752 // determine concrete methods and map type to specific method | |
753 ArrayList<ResolvedJavaMethod> concreteMethods = new ArrayList<>(); | |
754 int[] typesToConcretes = new int[ptypes.length]; | |
755 for (int i = 0; i < ptypes.length; i++) { | |
756 ResolvedJavaMethod concrete = ptypes[i].getType().resolveMethod(targetMethod); | |
757 | |
758 int index = concreteMethods.indexOf(concrete); | |
759 if (index < 0) { | |
760 index = concreteMethods.size(); | |
761 concreteMethods.add(concrete); | |
762 } | |
763 typesToConcretes[i] = index; | |
764 } | |
765 | |
766 double totalWeight = 0; | |
767 for (ResolvedJavaMethod concrete: concreteMethods) { | |
768 if (!checkTargetConditions(invoke, concrete, optimisticOpts, runtime)) { | |
769 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "it is a polymorphic method call and at least one invoked method cannot be inlined"); | |
770 } | |
771 totalWeight += inliningPolicy.inliningWeight(caller, concrete, invoke); | |
772 } | |
773 return new MultiTypeGuardInlineInfo(invoke, totalWeight, concreteMethods, ptypes, typesToConcretes, notRecordedTypeProbability); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 |
7071 | 777 |
778 private static ResolvedJavaMethod getCaller(Invoke invoke) { | |
779 return invoke.stateAfter().method(); | |
780 } | |
781 | |
6289
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
782 private static PiNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) { |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
783 // to avoid that floating reads on receiver fields float above the type check |
6289
72eb3a1a20c4
create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5792
diff
changeset
|
784 return graph.unique(new PiNode(receiver, anchor, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType))); |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
785 } |
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
786 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 private static boolean checkInvokeConditions(Invoke invoke) { |
7071 | 788 if (!(invoke.callTarget() instanceof MethodCallTargetNode)) { |
789 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke has already been lowered, or has been created as a low-level node"); | |
790 } else if (invoke.methodCallTarget().targetMethod() == null) { | |
791 return logNotInlinedMethodAndReturnFalse(invoke, "target method is null"); | |
792 } else if (invoke.stateAfter() == null) { | |
793 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke has no after state"); | |
794 } else if (invoke.predecessor() == null || !invoke.node().isAlive()) { | |
795 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke is dead code"); | |
796 } else if (!invoke.useForInlining()) { | |
797 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke is marked to be not used for inlining"); | |
798 } else { | |
799 return true; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
801 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 |
7071 | 803 private static boolean checkTargetConditions(Invoke invoke, ResolvedJavaMethod method, OptimisticOptimizations optimisticOpts, GraalCodeCacheProvider runtime) { |
4530 | 804 if (method == null) { |
7071 | 805 return logNotInlinedMethodAndReturnFalse(invoke, method, "the method is not resolved"); |
806 } else if (Modifier.isNative(method.getModifiers()) && (!GraalOptions.Intrinsify || !InliningUtil.canIntrinsify(invoke, method, runtime))) { | |
807 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is a non-intrinsic native method"); | |
808 } else if (Modifier.isAbstract(method.getModifiers())) { | |
809 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is an abstract method"); | |
810 } else if (!method.getDeclaringClass().isInitialized()) { | |
811 return logNotInlinedMethodAndReturnFalse(invoke, method, "the method's class is not initialized"); | |
812 } else if (!method.canBeInlined()) { | |
813 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is marked non-inlinable"); | |
814 } else if (computeInliningLevel(invoke) > GraalOptions.MaximumInlineLevel) { | |
815 return logNotInlinedMethodAndReturnFalse(invoke, method, "it exceeds the maximum inlining depth"); | |
816 } else if (computeRecursiveInliningLevel(invoke.stateAfter(), method) > GraalOptions.MaximumRecursiveInlining) { | |
817 return logNotInlinedMethodAndReturnFalse(invoke, method, "it exceeds the maximum recursive inlining depth"); | |
818 } else if (new OptimisticOptimizations(method).lessOptimisticThan(optimisticOpts)) { | |
819 return logNotInlinedMethodAndReturnFalse(invoke, method, "the callee uses less optimistic optimizations than caller"); | |
820 } else { | |
821 return true; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 } |
7071 | 823 } |
824 | |
825 private static int computeInliningLevel(Invoke invoke) { | |
826 int count = -1; | |
827 FrameState curState = invoke.stateAfter(); | |
828 while (curState != null) { | |
829 count++; | |
830 curState = curState.outerFrameState(); | |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
831 } |
7071 | 832 return count; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
834 |
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
|
835 private static int computeRecursiveInliningLevel(FrameState state, ResolvedJavaMethod method) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
836 assert state != null; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
837 |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
838 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:
4539
diff
changeset
|
839 FrameState curState = state; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
840 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:
4539
diff
changeset
|
841 if (curState.method() == method) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
842 count++; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
843 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
844 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:
4539
diff
changeset
|
845 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
846 return count; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
847 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
848 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph. |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
5341
diff
changeset
|
851 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 * @param invoke the invoke that will be replaced |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
853 * @param inlineGraph the graph that the invoke will be replaced with |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
854 * @param receiverNullCheck true if a null check needs to be generated for non-static inlinings, false if no such check is required |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
855 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
856 public static void inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 NodeInputList<ValueNode> parameters = invoke.callTarget().arguments(); |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
858 StructuredGraph graph = (StructuredGraph) invoke.node().graph(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 FrameState stateAfter = invoke.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 assert stateAfter.isAlive(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
862 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
863 IdentityHashMap<Node, Node> replacements = new IdentityHashMap<>(); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
864 ArrayList<Node> nodes = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
865 ReturnNode returnNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 UnwindNode unwindNode = null; |
5373
53cc37c27b04
used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents:
5365
diff
changeset
|
867 StartNode entryPointNode = inlineGraph.start(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 FixedNode firstCFGNode = entryPointNode.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
869 for (Node node : inlineGraph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
870 if (node == entryPointNode || node == entryPointNode.stateAfter()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
871 // Do nothing. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
872 } else if (node instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
873 replacements.put(node, parameters.get(((LocalNode) node).index())); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
874 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
875 nodes.add(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
876 if (node instanceof ReturnNode) { |
5693
0356d95f01ba
While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5662
diff
changeset
|
877 assert returnNode == null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
878 returnNode = (ReturnNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
879 } else if (node instanceof UnwindNode) { |
5693
0356d95f01ba
While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5662
diff
changeset
|
880 assert unwindNode == null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
881 unwindNode = (UnwindNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
882 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
884 } |
5693
0356d95f01ba
While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5662
diff
changeset
|
885 replacements.put(entryPointNode, BeginNode.prevBegin(invoke.node())); // ensure proper anchoring of things that where anchored to the StartNode |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
886 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
887 assert invoke.node().successors().first() != null : invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
888 assert invoke.node().predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
889 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 Map<Node, Node> duplicates = graph.addDuplicates(nodes, replacements); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
892 if (receiverNullCheck) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
893 receiverNullCheck(invoke); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
894 } |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5444
diff
changeset
|
895 invoke.node().replaceAtPredecessor(firstCFGNodeDuplicate); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
896 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
897 FrameState stateAtExceptionEdge = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
898 if (invoke instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
900 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
901 assert unwindNode.predecessor() != null; |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4312
diff
changeset
|
902 assert invokeWithException.exceptionEdge().successors().count() == 1; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
903 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
904 stateAtExceptionEdge = obj.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
905 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
4455 | 906 obj.replaceAtUsages(unwindDuplicate.exception()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
907 unwindDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
908 Node n = obj.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
909 obj.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
910 unwindDuplicate.replaceAndDelete(n); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
911 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
912 invokeWithException.killExceptionEdge(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
913 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
914 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
915 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
916 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
917 DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler, invoke.leafGraphId()); |
4339
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
918 unwindDuplicate.replaceAndDelete(graph.add(deoptimizeNode)); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
919 // move the deopt upwards if there is a monitor exit that tries to use the "after exception" frame state |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
920 // (because there is no "after exception" frame state!) |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
921 if (deoptimizeNode.predecessor() instanceof MonitorExitNode) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
922 MonitorExitNode monitorExit = (MonitorExitNode) deoptimizeNode.predecessor(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
923 if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == FrameState.AFTER_EXCEPTION_BCI) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
924 FrameState monitorFrameState = monitorExit.stateAfter(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
925 graph.removeFixed(monitorExit); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
926 monitorFrameState.safeDelete(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
927 } |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
928 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
929 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
931 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
932 FrameState outerFrameState = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
933 double invokeProbability = invoke.node().probability(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
934 for (Node node : duplicates.values()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
935 if (GraalOptions.ProbabilityAnalysis) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
936 if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
937 FixedNode fixed = (FixedNode) node; |
4605
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
938 double newProbability = fixed.probability() * invokeProbability; |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
939 if (GraalOptions.LimitInlinedProbability) { |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
940 newProbability = Math.min(newProbability, invokeProbability); |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
941 } |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
942 fixed.setProbability(newProbability); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
943 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
944 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
945 if (node instanceof FrameState) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
946 FrameState frameState = (FrameState) node; |
4687
bacc18e07f7b
Removed dead code from the inlining util. STATE_BEFORE is only used in BlockBegin, which in turn is not added to the caller graph during inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4678
diff
changeset
|
947 assert frameState.bci != FrameState.BEFORE_BCI; |
bacc18e07f7b
Removed dead code from the inlining util. STATE_BEFORE is only used in BlockBegin, which in turn is not added to the caller graph during inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4678
diff
changeset
|
948 if (frameState.bci == FrameState.AFTER_BCI) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
949 frameState.replaceAndDelete(stateAfter); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
950 } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) { |
4339
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
951 if (frameState.isAlive()) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
952 assert stateAtExceptionEdge != null; |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
953 frameState.replaceAndDelete(stateAtExceptionEdge); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
954 } else { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
955 assert stateAtExceptionEdge == null; |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
956 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
957 } else { |
6435
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
958 // only handle the outermost frame states |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
959 if (frameState.outerFrameState() == null) { |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
960 assert frameState.method() == inlineGraph.method(); |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
961 if (outerFrameState == null) { |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
962 outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invoke.node().kind()); |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
963 outerFrameState.setDuringCall(true); |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
964 } |
9ce24a27f035
fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
965 frameState.setOuterFrameState(outerFrameState); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
966 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
967 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
968 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
969 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
970 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
971 Node returnValue = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
972 if (returnNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
973 if (returnNode.result() instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
974 returnValue = replacements.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
975 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
976 returnValue = duplicates.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
977 } |
4455 | 978 invoke.node().replaceAtUsages(returnValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
979 Node returnDuplicate = duplicates.get(returnNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
980 returnDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
981 Node n = invoke.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
982 invoke.setNext(null); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
983 returnDuplicate.replaceAndDelete(n); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
984 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
985 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
986 invoke.node().replaceAtUsages(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
987 GraphUtil.killCFG(invoke.node()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
988 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
989 |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
990 public static void receiverNullCheck(Invoke invoke) { |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6383
diff
changeset
|
991 MethodCallTargetNode callTarget = invoke.methodCallTarget(); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
992 StructuredGraph graph = (StructuredGraph) invoke.graph(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
993 NodeInputList<ValueNode> parameters = callTarget.arguments(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
994 ValueNode firstParam = parameters.size() <= 0 ? null : parameters.get(0); |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
995 if (!callTarget.isStatic() && firstParam.kind() == Kind.Object && !firstParam.objectStamp().nonNull()) { |
6683
45872267325e
Fix Inlining : null check guard should use reason NullCheckException
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6673
diff
changeset
|
996 graph.addBeforeFixed(invoke.node(), graph.add(new FixedGuardNode(graph.unique(new IsNullNode(firstParam)), DeoptimizationReason.NullCheckException, DeoptimizationAction.InvalidateReprofile, true, invoke.leafGraphId()))); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
997 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
998 } |
7071 | 999 |
1000 public static boolean canIntrinsify(Invoke invoke, ResolvedJavaMethod target, GraalCodeCacheProvider runtime) { | |
1001 return getIntrinsicGraph(invoke, target, runtime) != null; | |
1002 } | |
1003 | |
1004 private static StructuredGraph getIntrinsicGraph(Invoke invoke, ResolvedJavaMethod target, GraalCodeCacheProvider runtime) { | |
1005 assert invoke.node().isAlive(); | |
1006 | |
1007 StructuredGraph intrinsicGraph = (StructuredGraph) target.getCompilerStorage().get(Graph.class); | |
7079
57d96c2a5950
re-applied changeset d9930fec7553
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7077
diff
changeset
|
1008 if (intrinsicGraph == null && runtime != null) { |
7071 | 1009 // TODO remove once all intrinsics are available via compilerStorage |
1010 intrinsicGraph = runtime.intrinsicGraph(invoke.stateAfter().method(), invoke.bci(), target, invoke.callTarget().arguments()); | |
1011 } | |
1012 return intrinsicGraph; | |
1013 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1014 } |