Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java @ 4624:3b632ae14d47
Make assert in getInlineInfo output more information
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 16 Feb 2012 19:29:32 +0100 |
parents | 00e01f401c03 |
children | ee91624e54e6 |
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 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.max.graal.compiler.util; |
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 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4195
diff
changeset
|
29 import com.oracle.max.cri.ci.*; |
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4195
diff
changeset
|
30 import com.oracle.max.cri.ri.*; |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
31 import com.oracle.max.cri.ri.RiType.Representation; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.max.graal.compiler.*; |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
33 import com.oracle.max.graal.compiler.phases.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.max.graal.cri.*; |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
35 import com.oracle.max.graal.debug.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.max.graal.graph.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.max.graal.nodes.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
39 import com.oracle.max.graal.nodes.PhiNode.PhiType; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.max.graal.nodes.calc.*; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
41 import com.oracle.max.graal.nodes.extended.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 import com.oracle.max.graal.nodes.java.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 import com.oracle.max.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 import com.oracle.max.graal.nodes.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 public class InliningUtil { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 public interface InliningCallback { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 StructuredGraph buildGraph(RiResolvedMethod method); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 double inliningWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 void recordConcreteMethodAssumption(RiResolvedMethod method, RiResolvedType context, RiResolvedMethod impl); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 public static String methodName(RiResolvedMethod method) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
55 return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 private static String methodName(RiResolvedMethod method, Invoke invoke) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
59 if (Debug.isLogEnabled()) { |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
60 if (invoke != null && invoke.stateAfter() != null) { |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
61 RiMethod parent = invoke.stateAfter().method(); |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
62 return parent.name() + "@" + invoke.bci() + ": " + CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
63 } else { |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
64 return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; |
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
65 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 } else { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
67 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 * 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
|
73 * 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
|
74 * 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
|
75 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 public abstract static class InlineInfo implements Comparable<InlineInfo> { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 public final Invoke invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 public final double weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 public final int level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 public InlineInfo(Invoke invoke, double weight, int level) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 this.invoke = invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 this.weight = weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 this.level = level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
87 public abstract int compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
88 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 public int compareTo(InlineInfo o) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 return (weight < o.weight) ? -1 : (weight > o.weight) ? 1 : 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
94 protected static StructuredGraph getGraph(final RiResolvedMethod concrete, final InliningCallback callback) { |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
95 return Debug.scope("Inlining", concrete, new Callable<StructuredGraph>() { |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
96 @Override |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
97 public StructuredGraph call() throws Exception { |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
98 return callback.buildGraph(concrete); |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
99 } |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
100 }); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
101 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
102 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 public abstract boolean canDeopt(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 * 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
|
107 * 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
|
108 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 * @param graph |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 * @param runtime |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 * @param callback |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
113 public abstract void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 * 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
|
118 * 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
|
119 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 private static class ExactInlineInfo extends InlineInfo { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 public final RiResolvedMethod concrete; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 public ExactInlineInfo(Invoke invoke, double weight, int level, RiResolvedMethod concrete) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 super(invoke, weight, level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 this.concrete = concrete; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 @Override |
4461 | 129 public void inline(StructuredGraph compilerGraph, GraalRuntime runtime, final InliningCallback callback) { |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
130 StructuredGraph graph = getGraph(concrete, callback); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
131 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4461 | 132 InliningUtil.inline(invoke, graph, true); |
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 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
136 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
137 return concrete.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
138 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
139 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
140 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
142 return "exact inlining " + CiUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 * 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
|
153 * 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
|
154 */ |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
155 private static class TypeGuardInlineInfo extends InlineInfo { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
156 public final RiResolvedMethod concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 public final RiResolvedType type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
159 public TypeGuardInlineInfo(Invoke invoke, double weight, int level, RiResolvedMethod concrete, RiResolvedType type) { |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
160 super(invoke, weight, level); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
161 this.concrete = concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
166 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
167 return concrete.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
168 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
169 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
170 @Override |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
171 public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
172 // 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
|
173 InliningUtil.receiverNullCheck(invoke); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
174 ValueNode receiver = invoke.callTarget().receiver(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
175 ReadHubNode objectClass = graph.add(new ReadHubNode(receiver)); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
176 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClass, type)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
177 FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode)); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
178 AnchorNode anchor = graph.add(new AnchorNode()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 assert invoke.predecessor() != null; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
180 |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
181 ConstantNode typeConst = graph.unique(ConstantNode.forCiConstant(type.getEncoding(Representation.ObjectHub), runtime, graph)); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
182 CheckCastNode checkCast = graph.unique(new CheckCastNode(anchor, typeConst, type, receiver)); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
183 invoke.callTarget().replaceFirstInput(receiver, checkCast); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
184 |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
185 graph.addBeforeFixed(invoke.node(), objectClass); |
4305
0768bf0a4898
move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4249
diff
changeset
|
186 graph.addBeforeFixed(invoke.node(), guard); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
187 graph.addBeforeFixed(invoke.node(), anchor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
189 Debug.log("inlining 1 method using 1 type check"); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
190 |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
191 StructuredGraph calleeGraph = getGraph(concrete, callback); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
192 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
193 InliningUtil.inline(invoke, calleeGraph, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
198 return "type-checked inlining " + CiUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 /** |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
208 * Polymorphic inlining of m methods with n type checks (n >= m) in case that the profiling information suggests a reasonable |
4455 | 209 * 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
|
210 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
211 private static class MultiTypeGuardInlineInfo extends InlineInfo { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
212 public final List<RiResolvedMethod> concretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
213 public final RiResolvedType[] types; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
214 public final int[] typesToConcretes; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
215 public final double[] branchProbabilities; |
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
|
216 public final double notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
217 |
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
|
218 public MultiTypeGuardInlineInfo(Invoke invoke, double weight, int level, List<RiResolvedMethod> concretes, RiResolvedType[] types, |
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
|
219 int[] typesToConcretes, double[] branchProbabilities, double notRecordedTypeProbability) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
220 super(invoke, weight, level); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
221 assert concretes.size() > 0 && concretes.size() <= types.length : "must have at least one method but no more than types methods"; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
222 assert types.length == typesToConcretes.length && types.length == branchProbabilities.length : "array length must match"; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
223 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
224 this.concretes = concretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
225 this.types = types; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
226 this.typesToConcretes = typesToConcretes; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
227 this.branchProbabilities = branchProbabilities; |
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
|
228 this.notRecordedTypeProbability = notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
229 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
230 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
231 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
232 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
233 int result = 0; |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
234 for (RiResolvedMethod m: concretes) { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
235 result += m.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
236 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
237 return result; |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
238 } |
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 @Override |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
241 public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
242 int numberOfMethods = concretes.size(); |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
243 boolean hasReturnValue = invoke.node().kind() != CiKind.Void; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
244 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
245 // 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
|
246 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
|
247 if (numberOfMethods > 1 || shouldFallbackToInvoke()) { |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
248 inlineMultipleMethods(graph, runtime, callback, numberOfMethods, hasReturnValue); |
4455 | 249 } else { |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
250 inlineSingleMethod(graph, runtime, callback); |
4455 | 251 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
252 |
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
|
253 Debug.log("inlining %d methods with %d type checks and falling back to %s if violated", numberOfMethods, types.length, shouldFallbackToInvoke() ? "invocation" : "deoptimization"); |
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
|
254 } |
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
|
255 |
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
|
256 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
|
257 return notRecordedTypeProbability > 0; |
4455 | 258 } |
259 | |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
260 private void inlineMultipleMethods(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback, int numberOfMethods, boolean hasReturnValue) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
261 FixedNode continuation = invoke.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
262 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
263 // setup merge and phi nodes for results and exceptions |
4455 | 264 MergeNode returnMerge = graph.add(new MergeNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
265 returnMerge.setProbability(invoke.probability()); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
266 returnMerge.setStateAfter(invoke.stateAfter().duplicate(invoke.stateAfter().bci)); |
4455 | 267 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
268 PhiNode returnValuePhi = null; |
4455 | 269 if (hasReturnValue) { |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
270 returnValuePhi = graph.unique(new PhiNode(invoke.node().kind(), returnMerge, PhiType.Value)); |
4455 | 271 } |
272 | |
273 MergeNode exceptionMerge = null; | |
274 PhiNode exceptionObjectPhi = null; | |
275 if (invoke instanceof InvokeWithExceptionNode) { | |
276 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; | |
277 BeginNode exceptionEdge = invokeWithException.exceptionEdge(); | |
278 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); | |
279 | |
280 exceptionMerge = graph.add(new MergeNode()); | |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
281 exceptionMerge.setProbability(exceptionEdge.probability()); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
282 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicate(invoke.stateAfter().bci)); |
4455 | 283 |
284 FixedNode exceptionSux = exceptionObject.next(); | |
285 graph.addBeforeFixed(exceptionSux, exceptionMerge); | |
286 exceptionObjectPhi = graph.unique(new PhiNode(CiKind.Object, exceptionMerge, PhiType.Value)); | |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
287 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
288 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
289 // create one separate block for each invoked method |
4455 | 290 BeginNode[] calleeEntryNodes = new BeginNode[numberOfMethods]; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
291 for (int i = 0; i < numberOfMethods; i++) { |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
292 int predecessors = getPredecessorCount(i); |
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
|
293 calleeEntryNodes[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, predecessors, true); |
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
|
294 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
295 |
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
|
296 // create the successor for an unknown type |
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
|
297 FixedNode unknownTypeNode; |
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
|
298 if (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
|
299 unknownTypeNode = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, 1, false); |
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
|
300 } else { |
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
|
301 unknownTypeNode = graph.add(new DeoptimizeNode(DeoptAction.InvalidateReprofile)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
302 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
303 |
4455 | 304 // replace the invoke exception edge |
305 if (invoke instanceof InvokeWithExceptionNode) { | |
306 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke; | |
307 BeginNode exceptionEdge = invokeWithExceptionNode.exceptionEdge(); | |
308 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); | |
309 exceptionObject.replaceAtUsages(exceptionObjectPhi); | |
310 exceptionObject.setNext(null); | |
311 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge()); | |
312 } | |
313 | |
314 // replace the invoke with a cascade of if nodes | |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
315 ReadHubNode objectClassNode = graph.add(new ReadHubNode(invoke.callTarget().receiver())); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
316 graph.addBeforeFixed(invoke.node(), objectClassNode); |
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
|
317 FixedNode dispatchOnType = createDispatchOnType(graph, objectClassNode, calleeEntryNodes, unknownTypeNode); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
318 |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
319 assert invoke.next() == continuation; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
320 invoke.setNext(null); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
321 returnMerge.setNext(continuation); |
4455 | 322 invoke.node().replaceAtUsages(returnValuePhi); |
323 invoke.node().replaceAndDelete(dispatchOnType); | |
324 | |
325 // do the actual inlining for every invoke | |
326 for (int i = 0; i < calleeEntryNodes.length; i++) { | |
327 BeginNode node = calleeEntryNodes[i]; | |
328 Invoke invokeForInlining = (Invoke) node.next(); | |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
329 |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
330 ValueNode receiver = invokeForInlining.callTarget().receiver(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
331 ConstantNode typeConst = graph.unique(ConstantNode.forCiConstant(types[i].getEncoding(Representation.ObjectHub), runtime, graph)); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
332 CheckCastNode checkCast = graph.unique(new CheckCastNode(node, typeConst, types[i], receiver)); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
333 invokeForInlining.callTarget().replaceFirstInput(receiver, checkCast); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
334 |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
335 RiResolvedMethod concrete = concretes.get(i); |
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
336 StructuredGraph calleeGraph = getGraph(concrete, callback); |
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
337 assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime); |
4455 | 338 InliningUtil.inline(invokeForInlining, calleeGraph, false); |
339 } | |
340 } | |
341 | |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
342 private void inlineSingleMethod(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { |
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
|
343 assert concretes.size() == 1 && types.length > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0; |
4455 | 344 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
345 MergeNode calleeEntryNode = graph.add(new MergeNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
346 calleeEntryNode.setProbability(invoke.probability()); |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
347 ReadHubNode objectClassNode = graph.add(new ReadHubNode(invoke.callTarget().receiver())); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
348 graph.addBeforeFixed(invoke.node(), objectClassNode); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
349 |
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
|
350 FixedNode unknownTypeNode = graph.add(new DeoptimizeNode(DeoptAction.InvalidateReprofile)); |
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
|
351 FixedNode dispatchOnType = createDispatchOnType(graph, objectClassNode, new BeginNode[] {calleeEntryNode}, unknownTypeNode); |
4455 | 352 |
353 FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor(); | |
354 pred.setNext(dispatchOnType); | |
355 calleeEntryNode.setNext(invoke.node()); | |
356 | |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
357 RiResolvedMethod concrete = concretes.get(0); |
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
358 StructuredGraph calleeGraph = getGraph(concrete, callback); |
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
359 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4455 | 360 InliningUtil.inline(invoke, calleeGraph, false); |
361 } | |
362 | |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
363 private FixedNode createDispatchOnType(StructuredGraph graph, ReadHubNode objectClassNode, BeginNode[] calleeEntryNodes, FixedNode unknownTypeSux) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
364 assert types.length > 1; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
365 |
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
|
366 // TODO (ch) set probabilities for all created fixed nodes... |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
367 int lastIndex = types.length - 1; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
368 FixedNode nextNode = createTypeCheck(graph, objectClassNode, types[lastIndex], calleeEntryNodes[typesToConcretes[lastIndex]], unknownTypeSux, branchProbabilities[lastIndex]); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
369 for (int i = lastIndex - 1; i >= 0; i--) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
370 nextNode = createTypeCheck(graph, objectClassNode, types[i], calleeEntryNodes[typesToConcretes[i]], nextNode, branchProbabilities[i]); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
371 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
372 |
4455 | 373 return nextNode; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
374 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
375 |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
376 private static FixedNode createTypeCheck(StructuredGraph graph, ReadHubNode objectClassNode, RiResolvedType type, BeginNode tsux, FixedNode nextNode, double tsuxProbability) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
377 IfNode result; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
378 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClassNode, type)); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
379 if (tsux instanceof MergeNode) { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
380 EndNode endNode = graph.add(new EndNode()); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
381 result = graph.add(new IfNode(isTypeNode, endNode, nextNode, tsuxProbability)); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
382 ((MergeNode) tsux).addForwardEnd(endNode); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
383 } else { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
384 result = graph.add(new IfNode(isTypeNode, tsux, nextNode, tsuxProbability)); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
385 } |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
386 return result; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
387 } |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
388 |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
389 private int getPredecessorCount(int concreteMethodIndex) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
390 if (concretes.size() == types.length) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
391 return 1; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
392 } else { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
393 int count = 0; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
394 for (int i = 0; i < typesToConcretes.length; i++) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
395 if (typesToConcretes[i] == concreteMethodIndex) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
396 count++; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
397 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
398 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
399 return count; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
400 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
401 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
402 |
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
|
403 private static BeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi, |
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
|
404 MergeNode exceptionMerge, PhiNode exceptionObjectPhi, int predecessors, boolean useForInlining) { |
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
|
405 Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining); |
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
|
406 // TODO (ch) set probabilities |
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
|
407 BeginNode calleeEntryNode = graph.add(predecessors > 1 ? new MergeNode() : new BeginNode()); |
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
|
408 calleeEntryNode.setNext(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
|
409 |
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
|
410 EndNode endNode = graph.add(new EndNode()); |
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
|
411 // TODO (ch) set probability |
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
|
412 duplicatedInvoke.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
413 returnMerge.addForwardEnd(endNode); |
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
|
414 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
|
415 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
|
416 } |
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
|
417 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
|
418 } |
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
|
419 |
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
|
420 private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, MergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
421 Invoke result = (Invoke) invoke.node().copyWithInputs(); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
422 Node callTarget = result.callTarget().copyWithInputs(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
423 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
|
424 result.setUseForInlining(useForInlining); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
425 |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
426 CiKind kind = invoke.node().kind(); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
427 if (!kind.isVoid()) { |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
428 FrameState stateAfter = invoke.stateAfter(); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
429 stateAfter = stateAfter.duplicate(stateAfter.bci); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
430 stateAfter.replaceFirstInput(invoke.node(), result.node()); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
431 result.setStateAfter(stateAfter); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
432 } |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
433 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
434 if (invoke instanceof InvokeWithExceptionNode) { |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
435 assert exceptionMerge != null && exceptionObjectPhi != null; |
4455 | 436 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
437 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
438 BeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
439 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
440 FrameState stateAfterException = exceptionObject.stateAfter(); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
441 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
442 BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
443 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs(); |
4529
fc78ad20ec38
fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4528
diff
changeset
|
444 // set new state (pop old exception object, push new one) |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
445 newExceptionObject.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), CiKind.Object, newExceptionObject)); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
446 newExceptionEdge.setNext(newExceptionObject); |
4455 | 447 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
448 EndNode endNode = graph.add(new EndNode()); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
449 newExceptionObject.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
450 exceptionMerge.addForwardEnd(endNode); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
451 exceptionObjectPhi.addInput(newExceptionObject); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
452 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
453 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
454 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
455 return result; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
456 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
457 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
458 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
459 public String toString() { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
460 StringBuilder builder = new StringBuilder(String.format("inlining %d methods with %d type checks: ", concretes.size(), types.length)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
461 for (int i = 0; i < concretes.size(); i++) { |
4464
f304ba0d4e24
inlining seems stable but deoptimizes too frequently
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4462
diff
changeset
|
462 builder.append(CiUtil.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
|
463 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
464 return builder.toString(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
465 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
466 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
467 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
468 public boolean canDeopt() { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
469 return true; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
470 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
471 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
472 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
473 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
474 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
475 * 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
|
476 * 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
|
477 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 private static class AssumptionInlineInfo extends ExactInlineInfo { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
479 public final RiResolvedType context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 public AssumptionInlineInfo(Invoke invoke, double weight, int level, RiResolvedType context, RiResolvedMethod concrete) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 super(invoke, weight, level, concrete); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 this.context = context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 @Override |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
487 public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
488 if (Debug.isLogEnabled()) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
489 String targetName = CiUtil.format("%H.%n(%p):%r", invoke.callTarget().targetMethod()); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
490 String concreteName = CiUtil.format("%H.%n(%p):%r", concrete); |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
491 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
|
492 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 callback.recordConcreteMethodAssumption(invoke.callTarget().targetMethod(), context, concrete); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
494 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
495 super.inline(graph, runtime, callback); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
500 return "inlining with assumption " + CiUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 * 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
|
511 * @param invoke the invoke that should be inlined |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 * @param level the number of nested inlinings that lead to this invoke, or 0 if the invoke was part of the initial graph |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 * @param runtime a GraalRuntime instance used to determine of the invoke can be inlined and/or should be intrinsified |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 * @param callback a callback that is used to determine the weight of a specific inlining |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 * @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
|
516 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 public static InlineInfo getInlineInfo(Invoke invoke, int level, GraalRuntime runtime, CiAssumptions assumptions, InliningCallback callback) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 if (!checkInvokeConditions(invoke)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 RiResolvedMethod parent = invoke.stateAfter().method(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 MethodCallTargetNode callTarget = invoke.callTarget(); |
4571 | 523 RiResolvedMethod targetMethod = callTarget.targetMethod(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 |
4571 | 525 if (targetMethod == null) { |
526 return null; | |
527 } | |
528 if (callTarget.invokeKind() == InvokeKind.Special || targetMethod.canBeStaticallyBound()) { | |
529 if (checkTargetConditions(invoke, targetMethod)) { | |
530 double weight = callback == null ? 0 : callback.inliningWeight(parent, targetMethod, invoke); | |
531 return new ExactInlineInfo(invoke, weight, level, targetMethod); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 if (callTarget.receiver().exactType() != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 RiResolvedType exact = callTarget.receiver().exactType(); |
4624
3b632ae14d47
Make assert in getInlineInfo output more information
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4622
diff
changeset
|
537 assert exact.isSubtypeOf(targetMethod.holder()) : exact + " subtype of " + targetMethod.holder() + " for " + targetMethod; |
4571 | 538 RiResolvedMethod resolved = exact.resolveMethodImpl(targetMethod); |
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
|
539 if (checkTargetConditions(invoke, resolved)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 double weight = callback == null ? 0 : callback.inliningWeight(parent, resolved, invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 return new ExactInlineInfo(invoke, weight, level, resolved); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 } |
4571 | 545 RiResolvedType holder = targetMethod.holder(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 if (callTarget.receiver().declaredType() != null) { |
4249
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
548 RiResolvedType declared = callTarget.receiver().declaredType(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 // TODO (ls) fix this |
4249
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
551 if (declared != null && declared.isSubtypeOf(holder)) { |
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
552 holder = declared; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 // TODO (tw) fix this |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
556 if (assumptions != null) { |
4571 | 557 RiResolvedMethod concrete = holder.uniqueConcreteMethod(targetMethod); |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
558 if (concrete != null) { |
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
|
559 if (checkTargetConditions(invoke, concrete)) { |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
560 double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
561 return new AssumptionInlineInfo(invoke, weight, level, holder, concrete); |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
562 } |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
563 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
564 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 } |
4440
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
566 |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
567 // type check based inlining |
4440
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
568 RiProfilingInfo profilingInfo = parent.profilingInfo(); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
569 RiTypeProfile typeProfile = profilingInfo.getTypeProfile(invoke.bci()); |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
570 if (typeProfile != null) { |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
571 RiResolvedType[] types = typeProfile.getTypes(); |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
572 double[] probabilities = typeProfile.getProbabilities(); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
573 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
574 if (types != null && probabilities != null && types.length > 0) { |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
575 assert types.length == probabilities.length : "length must match"; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
576 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability(); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
577 if (types.length == 1 && notRecordedTypeProbability == 0) { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
578 if (GraalOptions.InlineMonomorphicCalls) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
579 RiResolvedType type = types[0]; |
4571 | 580 RiResolvedMethod concrete = type.resolveMethodImpl(targetMethod); |
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
|
581 if (checkTargetConditions(invoke, concrete)) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
582 double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
583 return new TypeGuardInlineInfo(invoke, weight, level, concrete, type); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
584 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
585 |
4571 | 586 Debug.log("not inlining %s because method can't be inlined", methodName(targetMethod, invoke)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
587 return null; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
588 } else { |
4571 | 589 Debug.log("not inlining %s because GraalOptions.InlinePolymorphicCalls == false", methodName(targetMethod, invoke)); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
590 return null; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
591 } |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
592 } else { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
593 if (GraalOptions.InlinePolymorphicCalls && notRecordedTypeProbability == 0 || GraalOptions.InlineMegamorphicCalls && notRecordedTypeProbability > 0) { |
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
|
594 // TODO (ch) inlining of multiple methods should work differently |
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
|
595 // 1. check which methods can be inlined |
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
|
596 // 2. for those methods, use weight and probability to compute which of them should be inlined |
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
|
597 // 3. do the inlining |
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
|
598 // a) all seen methods can be inlined -> do so and guard with deopt |
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
|
599 // b) some methods can be inlined -> inline them and fall back to invocation if violated |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
600 // TODO (ch) sort types by probability |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
601 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
602 // determine concrete methods and map type to specific method |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
603 ArrayList<RiResolvedMethod> concreteMethods = new ArrayList<>(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
604 int[] typesToConcretes = new int[types.length]; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
605 for (int i = 0; i < types.length; i++) { |
4571 | 606 RiResolvedMethod concrete = types[i].resolveMethodImpl(targetMethod); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
607 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
608 int index = concreteMethods.indexOf(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
609 if (index < 0) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
610 index = concreteMethods.size(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
611 concreteMethods.add(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
612 } |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
613 typesToConcretes[i] = index; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
614 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
615 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
616 double totalWeight = 0; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
617 boolean canInline = true; |
4464
f304ba0d4e24
inlining seems stable but deoptimizes too frequently
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4462
diff
changeset
|
618 for (RiResolvedMethod concrete: concreteMethods) { |
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
|
619 if (!checkTargetConditions(invoke, concrete)) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
620 canInline = false; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
621 break; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
622 } |
4464
f304ba0d4e24
inlining seems stable but deoptimizes too frequently
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4462
diff
changeset
|
623 totalWeight += callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
624 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
625 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
626 if (canInline) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
627 convertTypeToBranchProbabilities(probabilities, notRecordedTypeProbability); |
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
|
628 return new MultiTypeGuardInlineInfo(invoke, totalWeight, level, concreteMethods, types, typesToConcretes, probabilities, notRecordedTypeProbability); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
629 } else { |
4571 | 630 Debug.log("not inlining %s because it is a polymorphic method call and at least one invoked method cannot be inlined", methodName(targetMethod, invoke)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
631 return null; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
632 } |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
633 } else { |
4571 | 634 Debug.log("not inlining %s because GraalOptions.InlineMonomorphicCalls == false", methodName(targetMethod, invoke)); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
635 return null; |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
636 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
637 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
639 |
4571 | 640 Debug.log("not inlining %s because no types/probabilities were recorded", methodName(targetMethod, invoke)); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
641 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
642 } else { |
4571 | 643 Debug.log("not inlining %s because no type profile exists", methodName(targetMethod, invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
645 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
648 private static void convertTypeToBranchProbabilities(double[] typeProbabilities, double notRecordedTypeProbability) { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
649 // avoid branches with 0.0/1.0 probability |
4460 | 650 double total = Math.max(1E-10, notRecordedTypeProbability); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
651 |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
652 for (int i = typeProbabilities.length - 1; i >= 0; i--) { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
653 total += typeProbabilities[i]; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
654 typeProbabilities[i] = typeProbabilities[i] / total; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
656 assert total > 0.99 && total < 1.01; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
659 private static boolean checkInvokeConditions(Invoke invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
660 if (invoke.stateAfter() == null) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
661 Debug.log("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
663 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 if (invoke.predecessor() == null) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
665 Debug.log("not inlining %s because the invoke is dead code", methodName(invoke.callTarget().targetMethod(), invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 } |
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
|
668 if (!invoke.useForInlining()) { |
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
|
669 Debug.log("not inlining %s because invoke is marked to be not used for inlining", methodName(invoke.callTarget().targetMethod(), invoke)); |
4473 | 670 return 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
|
671 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
673 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 |
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
|
675 private static boolean checkTargetConditions(Invoke invoke, RiMethod method) { |
4530 | 676 if (method == null) { |
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
|
677 Debug.log("not inlining because method is not resolved"); |
4530 | 678 return false; |
679 } | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 if (!(method instanceof RiResolvedMethod)) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
681 Debug.log("not inlining %s because it is unresolved", method.toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
683 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
684 RiResolvedMethod resolvedMethod = (RiResolvedMethod) method; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 if (Modifier.isNative(resolvedMethod.accessFlags())) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
686 Debug.log("not inlining %s because it is a native method", methodName(resolvedMethod)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 if (Modifier.isAbstract(resolvedMethod.accessFlags())) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
690 Debug.log("not inlining %s because it is an abstract method", methodName(resolvedMethod)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 if (!resolvedMethod.holder().isInitialized()) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
694 Debug.log("not inlining %s because of non-initialized class", methodName(resolvedMethod)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
695 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
696 } |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
697 if (!resolvedMethod.canBeInlined()) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
698 Debug.log("not inlining %s because it is marked non-inlinable", methodName(resolvedMethod)); |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
699 return false; |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
700 } |
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
|
701 if (computeRecursiveInliningLevel(invoke.stateAfter(), (RiResolvedMethod) method) > GraalOptions.MaximumRecursiveInlining) { |
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
|
702 Debug.log("not inlining %s because it exceeds the maximum recursive inlining depth", methodName(resolvedMethod)); |
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
|
703 return false; |
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
|
704 } |
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
|
705 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 |
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
|
709 private static int computeRecursiveInliningLevel(FrameState state, RiResolvedMethod 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
|
710 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
|
711 |
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
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 } |
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
|
718 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
|
719 } |
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
|
720 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
|
721 } |
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
|
722 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
723 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
724 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
725 * @param invoke the invoke that will be replaced |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 * @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
|
727 * @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
|
728 * @return The node that represents the return value, 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
|
729 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
730 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
|
731 NodeInputList<ValueNode> parameters = invoke.callTarget().arguments(); |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
732 StructuredGraph graph = (StructuredGraph) invoke.node().graph(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 FrameState stateAfter = invoke.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 assert stateAfter.isAlive(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
737 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
|
738 ArrayList<Node> nodes = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 ReturnNode returnNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
740 UnwindNode unwindNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
741 BeginNode entryPointNode = inlineGraph.start(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 FixedNode firstCFGNode = entryPointNode.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
743 for (Node node : inlineGraph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 if (node == entryPointNode || node == entryPointNode.stateAfter()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 // Do nothing. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 } else if (node instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 replacements.put(node, parameters.get(((LocalNode) node).index())); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 nodes.add(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 if (node instanceof ReturnNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 returnNode = (ReturnNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
752 } else if (node instanceof UnwindNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
753 unwindNode = (UnwindNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
754 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
755 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
756 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
757 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 assert invoke.node().successors().first() != null : invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
759 assert invoke.node().predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
760 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
761 Map<Node, Node> duplicates = graph.addDuplicates(nodes, replacements); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
762 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
|
763 if (receiverNullCheck) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
764 receiverNullCheck(invoke); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
765 } |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
766 invoke.node().replaceAtPredecessors(firstCFGNodeDuplicate); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
767 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
768 FrameState stateAtExceptionEdge = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 if (invoke instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
770 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
771 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
772 assert unwindNode.predecessor() != null; |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4312
diff
changeset
|
773 assert invokeWithException.exceptionEdge().successors().count() == 1; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 stateAtExceptionEdge = obj.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
4455 | 777 obj.replaceAtUsages(unwindDuplicate.exception()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
778 unwindDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 Node n = obj.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
780 obj.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 unwindDuplicate.replaceAndDelete(n); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 invokeWithException.killExceptionEdge(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
785 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
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
|
788 DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptAction.InvalidateRecompile); |
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
|
789 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
|
790 // 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
|
791 // (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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 } |
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
|
799 } |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 FrameState stateBefore = null; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
804 FrameState outerFrameState = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 double invokeProbability = invoke.node().probability(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
806 for (Node node : duplicates.values()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 if (GraalOptions.ProbabilityAnalysis) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 FixedNode fixed = (FixedNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 fixed.setProbability(fixed.probability() * invokeProbability); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
813 if (node instanceof FrameState) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 FrameState frameState = (FrameState) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 if (frameState.bci == FrameState.BEFORE_BCI) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 if (stateBefore == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 stateBefore = stateAfter.duplicateModified(invoke.bci(), false, invoke.node().kind(), parameters.toArray(new ValueNode[parameters.size()])); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 frameState.replaceAndDelete(stateBefore); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 } else if (frameState.bci == FrameState.AFTER_BCI) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 frameState.replaceAndDelete(stateAfter); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 } 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
|
823 if (frameState.isAlive()) { |
4529
fc78ad20ec38
fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4528
diff
changeset
|
824 // TODO (ch) it happens sometimes that we have a FrameState.AFTER_EXCEPTION_BCI but no stateAtExceptionEdge |
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
|
825 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
|
826 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
|
827 } 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
|
828 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
|
829 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
830 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
831 if (outerFrameState == null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
832 outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invoke.node().kind()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
833 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
834 frameState.setOuterFrameState(outerFrameState); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
835 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
836 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
837 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
838 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
839 Node returnValue = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
840 if (returnNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
841 if (returnNode.result() instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
842 returnValue = replacements.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 returnValue = duplicates.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 } |
4455 | 846 invoke.node().replaceAtUsages(returnValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 Node returnDuplicate = duplicates.get(returnNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 returnDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 Node n = invoke.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 invoke.setNext(null); |
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
|
851 if (n instanceof BeginNode) { |
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
|
852 BeginNode begin = (BeginNode) n; |
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
|
853 FixedNode next = begin.next(); |
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
|
854 begin.setNext(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
|
855 returnDuplicate.replaceAndDelete(next); |
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
|
856 begin.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
|
857 } 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
|
858 returnDuplicate.replaceAndDelete(n); |
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
|
859 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
862 invoke.node().clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
863 invoke.node().replaceAtUsages(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
864 GraphUtil.killCFG(invoke.node()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
865 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 if (stateAfter.usages().isEmpty()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
867 stateAfter.safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
869 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
870 |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
871 public static void receiverNullCheck(Invoke invoke) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
872 MethodCallTargetNode callTarget = invoke.callTarget(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
873 StructuredGraph graph = (StructuredGraph) invoke.graph(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
874 NodeInputList<ValueNode> parameters = callTarget.arguments(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
875 ValueNode firstParam = parameters.size() <= 0 ? null : parameters.get(0); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
876 if (!callTarget.isStatic() && firstParam.kind() == CiKind.Object && !firstParam.stamp().nonNull()) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
877 graph.addBeforeFixed(invoke.node(), graph.add(new FixedGuardNode(graph.unique(new NullCheckNode(firstParam, false))))); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
878 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
879 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
880 } |