Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java @ 4454:008a5ea590ca
fixed merge control flow for inlining
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Mon, 30 Jan 2012 11:13:45 -0800 |
parents | c0430421d43d |
children | b788ebbb7ef8 |
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.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
4199
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4195
diff
changeset
|
28 import com.oracle.max.cri.ci.*; |
aaac4894175c
Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4195
diff
changeset
|
29 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.max.criutils.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.max.graal.compiler.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.max.graal.cri.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.max.graal.graph.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.max.graal.nodes.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 import com.oracle.max.graal.nodes.extended.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.max.graal.nodes.java.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 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
|
41 import com.oracle.max.graal.nodes.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 public class InliningUtil { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 public interface InliningCallback { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 StructuredGraph buildGraph(RiResolvedMethod method); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 double inliningWeight(RiResolvedMethod caller, RiResolvedMethod method, Invoke invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 void recordConcreteMethodAssumption(RiResolvedMethod method, RiResolvedType context, RiResolvedMethod impl); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 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
|
52 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
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private static String methodName(RiResolvedMethod method, Invoke invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 if (invoke != null && invoke.stateAfter() != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 RiMethod parent = invoke.stateAfter().method(); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
58 return parent.name() + "@" + invoke.bci() + ": " + 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
|
59 } else { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
60 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
|
61 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 * 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
|
66 * 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
|
67 * 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
|
68 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 public abstract static class InlineInfo implements Comparable<InlineInfo> { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 public final Invoke invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 public final double weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 public final int level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 public InlineInfo(Invoke invoke, double weight, int level) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 this.invoke = invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 this.weight = weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 this.level = level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 public int compareTo(InlineInfo o) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 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
|
83 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
85 protected static StructuredGraph getGraph(Invoke invoke, RiResolvedMethod concrete, InliningCallback callback) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
86 // TODO: Solve graph caching differently! GraphBuilderPhase.cachedGraphs.get(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
87 // if (graph != null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
88 // if (GraalOptions.TraceInlining) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
89 // TTY.println("Reusing graph for %s", methodName(concrete, invoke)); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
90 // } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
91 // } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
92 if (GraalOptions.TraceInlining) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
93 TTY.println("Building graph for %s, locals: %d, stack: %d", methodName(concrete, invoke), concrete.maxLocals(), concrete.maxStackSize()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
94 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
95 return callback.buildGraph(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
96 // } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
97 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
98 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 public abstract boolean canDeopt(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 * 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
|
103 * 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
|
104 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 * @param graph |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 * @param runtime |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 * @param callback |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
109 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
|
110 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 * 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
|
114 * 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
|
115 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 private static class ExactInlineInfo extends InlineInfo { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 public final RiResolvedMethod concrete; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 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
|
120 super(invoke, weight, level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 this.concrete = 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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 @Override |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
125 public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
126 StructuredGraph calleeGraph = getGraph(invoke, concrete, callback); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
127 InliningUtil.inline(invoke, calleeGraph, true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
132 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
|
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 * 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
|
143 * 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
|
144 */ |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
145 private static class TypeGuardInlineInfo extends InlineInfo { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
146 public final RiResolvedMethod concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 public final RiResolvedType type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
149 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
|
150 super(invoke, weight, level); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
151 this.concrete = concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 @Override |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
156 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
|
157 // 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
|
158 InliningUtil.receiverNullCheck(invoke); |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
159 ReadClassNode objectClass = graph.add(new ReadClassNode(invoke.callTarget().receiver())); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
160 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
|
161 FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 assert invoke.predecessor() != null; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
163 |
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
164 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
|
165 graph.addBeforeFixed(invoke.node(), guard); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 if (GraalOptions.TraceInlining) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
168 TTY.println("inlining 1 method using 1 type check"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
170 |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
171 StructuredGraph calleeGraph = getGraph(invoke, concrete, callback); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
172 InliningUtil.inline(invoke, calleeGraph, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
177 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
|
178 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
186 /** |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
187 * Polymorphic inlining of m methods with n type checks (n >= m) in case that the profiling information suggests a reasonable |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
188 * amounts of different receiver types and different methods. |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
189 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
190 private static class MultiTypeGuardInlineInfo extends InlineInfo { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
191 public final List<RiResolvedMethod> concretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
192 public final RiResolvedType[] types; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
193 public final int[] typesToConcretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
194 public final double[] probabilities; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
195 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
196 public MultiTypeGuardInlineInfo(Invoke invoke, double weight, int level, List<RiResolvedMethod> concretes, RiResolvedType[] types, int[] typesToConcretes, double[] probabilities) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
197 super(invoke, weight, level); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
198 assert concretes.size() > 0 && concretes.size() <= types.length : "must have at least one method but no more than types methods"; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
199 assert types.length == typesToConcretes.length && types.length == probabilities.length : "array length must match"; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
200 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
201 this.concretes = concretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
202 this.types = types; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
203 this.typesToConcretes = typesToConcretes; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
204 this.probabilities = probabilities; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
205 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
206 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
207 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
208 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
|
209 MethodCallTargetNode callTargetNode = invoke.callTarget(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
210 int numberOfMethods = concretes.size(); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
211 boolean hasReturnValue = callTargetNode.kind() != CiKind.Void; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
212 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
213 // 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
|
214 InliningUtil.receiverNullCheck(invoke); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
215 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
216 // save node after invoke so that invoke can be deleted safely |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
217 FixedNode continuation = invoke.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
218 invoke.setNext(null); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
219 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
220 // setup a merge node and a phi node for the result |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
221 MergeNode merge = null; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
222 PhiNode returnValuePhi = null; |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
223 Node returnValue = null; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
224 if (numberOfMethods > 1) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
225 merge = graph.add(new MergeNode()); |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
226 merge.setStateAfter(invoke.stateAfter()); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
227 merge.setNext(continuation); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
228 if (hasReturnValue) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
229 returnValuePhi = graph.unique(new PhiNode(callTargetNode.kind(), merge, PhiType.Value)); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
230 returnValue = returnValuePhi; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
231 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
232 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
233 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
234 // create a separate block for each invoked method |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
235 BeginNode[] successorMethods = new BeginNode[numberOfMethods]; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
236 for (int i = 0; i < numberOfMethods; i++) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
237 Invoke duplicatedInvoke = duplicateInvoke(invoke); |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
238 BeginNode calleeEntryNode; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
239 if (getPredecessorCount(i) > 1) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
240 calleeEntryNode = graph.add(new MergeNode()); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
241 } else { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
242 calleeEntryNode = graph.add(new BeginNode()); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
243 } |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
244 calleeEntryNode.setNext(duplicatedInvoke.node()); |
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
245 successorMethods[i] = calleeEntryNode; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
246 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
247 if (merge != null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
248 EndNode endNode = graph.add(new EndNode()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
249 duplicatedInvoke.setNext(endNode); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
250 merge.addEnd(endNode); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
251 if (returnValuePhi != null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
252 returnValuePhi.addInput(duplicatedInvoke.node()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
253 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
254 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
255 duplicatedInvoke.setNext(continuation); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
256 if (hasReturnValue) { |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
257 returnValue = (Node) duplicatedInvoke; |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
258 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
259 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
260 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
261 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
262 // create a cascade of ifs with the type checks |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
263 ReadClassNode objectClassNode = graph.add(new ReadClassNode(invoke.callTarget().receiver())); |
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
264 graph.addBeforeFixed(invoke.node(), objectClassNode); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
265 |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
266 int lastIndex = types.length - 1; |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
267 BeginNode tsux = successorMethods[typesToConcretes[lastIndex]]; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
268 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClassNode, types[lastIndex])); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
269 FixedGuardNode guardNode = graph.add(new FixedGuardNode(isTypeNode)); |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
270 if (tsux instanceof MergeNode) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
271 EndNode endNode = graph.add(new EndNode()); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
272 guardNode.setNext(endNode); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
273 ((MergeNode) tsux).addEnd(endNode); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
274 } else { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
275 guardNode.setNext(tsux); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
276 } |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
277 |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
278 FixedNode nextNode = guardNode; |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
279 for (int i = lastIndex - 1; i >= 0; i--) { |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
280 tsux = successorMethods[typesToConcretes[i]]; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
281 isTypeNode = graph.unique(new IsTypeNode(objectClassNode, types[i])); |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
282 if (tsux instanceof MergeNode) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
283 EndNode endNode = graph.add(new EndNode()); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
284 nextNode = graph.add(new IfNode(isTypeNode, endNode, nextNode, probabilities[i])); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
285 ((MergeNode) tsux).addEnd(endNode); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
286 } else { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
287 nextNode = graph.add(new IfNode(isTypeNode, tsux, nextNode, probabilities[i])); |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
288 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
289 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
290 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
291 // replace the original invocation with a cascade of if nodes and replace the usages of invoke with the return value (phi or duplicatedInvoke) |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
292 invoke.node().replaceAtUsages(returnValue); |
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
293 invoke.node().replaceAndDelete(nextNode); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
294 GraphUtil.killCFG(invoke.node()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
295 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
296 // do the actual inlining for every invocation |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
297 for (int i = 0; i < successorMethods.length; i++) { |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
298 BeginNode node = successorMethods[i]; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
299 Invoke invokeForInlining = (Invoke) node.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
300 StructuredGraph calleeGraph = getGraph(invokeForInlining, concretes.get(i), callback); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
301 InliningUtil.inline(invokeForInlining, calleeGraph, false); |
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 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
304 if (GraalOptions.TraceInlining) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
305 TTY.println("inlining %d methods with %d type checks", numberOfMethods, types.length); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
306 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
307 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
308 |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
309 private int getPredecessorCount(int concreteMethodIndex) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
310 if (concretes.size() == types.length) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
311 return 1; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
312 } else { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
313 int count = 0; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
314 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
|
315 if (typesToConcretes[i] == concreteMethodIndex) { |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
316 count++; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
317 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
318 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
319 return count; |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
320 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
321 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
322 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
323 private static Invoke duplicateInvoke(Invoke invoke) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
324 Invoke result = (Invoke) invoke.node().copyWithInputs(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
325 if (invoke instanceof InvokeWithExceptionNode) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
326 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
327 BeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
328 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
329 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
330 BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
331 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
332 newExceptionEdge.setNext(newExceptionObject); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
333 newExceptionObject.setNext(exceptionObject.next()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
334 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
335 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
336 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
337 return result; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
338 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
339 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
340 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
341 public String toString() { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
342 StringBuilder builder = new StringBuilder("type-checked inlining of multiple methods: "); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
343 for (int i = 0; i < concretes.size(); i++) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
344 CiUtil.format("\n%H.%n(%p):%r", concretes.get(i)); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
345 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
346 return builder.toString(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
347 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
348 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
349 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
350 public boolean canDeopt() { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
351 return true; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
352 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
353 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
354 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
355 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
356 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 * 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
|
358 * 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
|
359 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 private static class AssumptionInlineInfo extends ExactInlineInfo { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 public final RiResolvedType context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 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
|
364 super(invoke, weight, level, concrete); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 this.context = context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
367 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 @Override |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
369 public 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
|
370 if (GraalOptions.TraceInlining) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
371 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
|
372 String concreteName = CiUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
373 TTY.println("recording concrete method assumption: %s on receiver type %s -> %s", targetName, context, concreteName); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 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
|
376 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
377 super.inline(graph, runtime, callback); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
380 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
381 public String toString() { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
382 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
|
383 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
388 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 * 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
|
393 * @param invoke the invoke that should be inlined |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 * @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
|
395 * @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
|
396 * @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
|
397 * @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
|
398 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 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
|
400 if (!checkInvokeConditions(invoke)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 RiResolvedMethod parent = invoke.stateAfter().method(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 MethodCallTargetNode callTarget = invoke.callTarget(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 if (callTarget.invokeKind() == InvokeKind.Special || callTarget.targetMethod().canBeStaticallyBound()) { |
4195
7703a9f4769f
Removed inlining decisions from CRI.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
407 if (checkTargetConditions(callTarget.targetMethod())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 double weight = callback == null ? 0 : callback.inliningWeight(parent, callTarget.targetMethod(), invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 return new ExactInlineInfo(invoke, weight, level, callTarget.targetMethod()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
413 if (callTarget.receiver().exactType() != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
414 RiResolvedType exact = callTarget.receiver().exactType(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 assert exact.isSubtypeOf(callTarget.targetMethod().holder()) : exact + " subtype of " + callTarget.targetMethod().holder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 RiResolvedMethod resolved = exact.resolveMethodImpl(callTarget.targetMethod()); |
4195
7703a9f4769f
Removed inlining decisions from CRI.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
417 if (checkTargetConditions(resolved)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 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
|
419 return new ExactInlineInfo(invoke, weight, level, resolved); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 RiResolvedType holder = callTarget.targetMethod().holder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
424 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 if (callTarget.receiver().declaredType() != null) { |
4249
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
426 RiResolvedType declared = callTarget.receiver().declaredType(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 // 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
|
428 // TODO (ls) fix this |
4249
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
429 if (declared != null && declared.isSubtypeOf(holder)) { |
1aaf3592e516
Fix some warnings from findbugs
Gilles Duboscq <gilles.m.duboscq@gmail.com>
parents:
4233
diff
changeset
|
430 holder = declared; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 // TODO (tw) fix this |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 if (assumptions == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 RiResolvedMethod concrete = holder.uniqueConcreteMethod(callTarget.targetMethod()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 if (concrete != null) { |
4195
7703a9f4769f
Removed inlining decisions from CRI.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
439 if (checkTargetConditions(concrete)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 return new AssumptionInlineInfo(invoke, weight, level, holder, concrete); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 } |
4440
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
445 |
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
446 RiProfilingInfo profilingInfo = parent.profilingInfo(); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
447 RiTypeProfile typeProfile = profilingInfo.getTypeProfile(invoke.bci()); |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
448 if (typeProfile != null) { |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
449 RiResolvedType[] types = typeProfile.getTypes(); |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
450 double[] probabilities = typeProfile.getProbabilities(); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
451 if (types != null && probabilities != null && types.length > 0) { |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
452 assert types.length == probabilities.length : "length must match"; |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
453 if (GraalOptions.InlineWithTypeCheck) { |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
454 // type check and inlining... |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
455 if (types.length == 1) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
456 RiResolvedType type = types[0]; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
457 concrete = type.resolveMethodImpl(callTarget.targetMethod()); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
458 if (concrete != null && checkTargetConditions(concrete)) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
459 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
|
460 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
|
461 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
462 return null; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
463 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
464 // TODO (ch) sort types by probability |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
465 // 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
|
466 ArrayList<RiResolvedMethod> concreteMethods = new ArrayList<>(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
467 int[] typesToConcretes = new int[types.length]; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
468 for (int i = 0; i < types.length; i++) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
469 concrete = types[i].resolveMethodImpl(callTarget.targetMethod()); |
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 int index = concreteMethods.indexOf(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
472 if (index < 0) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
473 index = concreteMethods.size(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
474 concreteMethods.add(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
475 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
476 typesToConcretes[index] = index; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
477 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
478 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
479 double totalWeight = 0; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
480 boolean canInline = true; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
481 for (RiResolvedMethod method: concreteMethods) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
482 if (method == null || !checkTargetConditions(method)) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
483 canInline = false; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
484 break; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
485 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
486 totalWeight += callback == null ? 0 : callback.inliningWeight(parent, method, invoke); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
487 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
488 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
489 if (canInline) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
490 return new MultiTypeGuardInlineInfo(invoke, totalWeight, level, concreteMethods, types, typesToConcretes, probabilities); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
491 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
492 if (GraalOptions.TraceInlining) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
493 TTY.println("not inlining %s because it is a polymorphic method call and at least one invoked method cannot be inlined", methodName(callTarget.targetMethod(), invoke)); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
494 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
495 return null; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
496 } |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
497 } |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
498 } else { |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
499 if (GraalOptions.TraceInlining) { |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
500 TTY.println("not inlining %s because GraalOptions.InlineWithTypeCheck == false", methodName(callTarget.targetMethod(), invoke)); |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
501 } |
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
502 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 } |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
505 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 if (GraalOptions.TraceInlining) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
508 TTY.println("not inlining %s because no type profile exists", methodName(callTarget.targetMethod(), invoke)); |
3733
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 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
514 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 private static boolean checkInvokeConditions(Invoke invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 if (invoke.stateAfter() == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 TTY.println("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 if (invoke.predecessor() == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 TTY.println("not inlining %s because the invoke is dead code", methodName(invoke.callTarget().targetMethod(), invoke)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 |
4195
7703a9f4769f
Removed inlining decisions from CRI.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4142
diff
changeset
|
531 private static boolean checkTargetConditions(RiMethod method) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 if (!(method instanceof RiResolvedMethod)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 TTY.println("not inlining %s because it is unresolved", method.toString()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 RiResolvedMethod resolvedMethod = (RiResolvedMethod) method; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 if (Modifier.isNative(resolvedMethod.accessFlags())) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 TTY.println("not inlining %s because it is a native method", methodName(resolvedMethod)); |
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 false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 if (Modifier.isAbstract(resolvedMethod.accessFlags())) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 TTY.println("not inlining %s because it is an abstract method", methodName(resolvedMethod)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
551 if (!resolvedMethod.holder().isInitialized()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 if (GraalOptions.TraceInlining) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 TTY.println("not inlining %s because of non-initialized class", methodName(resolvedMethod)); |
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 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 } |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
557 if (!resolvedMethod.canBeInlined()) { |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
558 if (GraalOptions.TraceInlining) { |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
559 TTY.println("not inlining %s because it is marked non-inlinable", methodName(resolvedMethod)); |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
560 } |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
561 return false; |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
562 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
563 return true; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
566 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
567 * 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
|
568 * @param invoke the invoke that will be replaced |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
569 * @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
|
570 * @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
|
571 * @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
|
572 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
573 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
|
574 NodeInputList<ValueNode> parameters = invoke.callTarget().arguments(); |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
575 StructuredGraph graph = (StructuredGraph) invoke.node().graph(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
577 FrameState stateAfter = invoke.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
578 assert stateAfter.isAlive(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
579 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
580 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
|
581 ArrayList<Node> nodes = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
582 ReturnNode returnNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
583 UnwindNode unwindNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
584 BeginNode entryPointNode = inlineGraph.start(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
585 FixedNode firstCFGNode = entryPointNode.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
586 for (Node node : inlineGraph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
587 if (node == entryPointNode || node == entryPointNode.stateAfter()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
588 // Do nothing. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
589 } else if (node instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
590 replacements.put(node, parameters.get(((LocalNode) node).index())); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
591 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
592 nodes.add(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
593 if (node instanceof ReturnNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
594 returnNode = (ReturnNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
595 } else if (node instanceof UnwindNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
596 unwindNode = (UnwindNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
597 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
598 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
599 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
600 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
601 assert invoke.node().successors().first() != null : invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 assert invoke.node().predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
604 Map<Node, Node> duplicates = graph.addDuplicates(nodes, replacements); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
605 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
|
606 if (receiverNullCheck) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
607 receiverNullCheck(invoke); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
608 } |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
609 invoke.node().replaceAtPredecessors(firstCFGNodeDuplicate); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
610 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
611 FrameState stateAtExceptionEdge = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
612 if (invoke instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
613 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
614 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
615 assert unwindNode.predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 assert invokeWithException.exceptionEdge().successors().explicitCount() == 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 stateAtExceptionEdge = obj.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
619 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
620 for (Node usage : obj.usages().snapshot()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
621 usage.replaceFirstInput(obj, unwindDuplicate.exception()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
622 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 unwindDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
624 Node n = obj.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 obj.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
626 unwindDuplicate.replaceAndDelete(n); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 invokeWithException.killExceptionEdge(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 unwindDuplicate.replaceAndDelete(graph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
637 FrameState stateBefore = null; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
638 FrameState outerFrameState = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 double invokeProbability = invoke.node().probability(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
640 for (Node node : duplicates.values()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
641 if (GraalOptions.ProbabilityAnalysis) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
642 if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 FixedNode fixed = (FixedNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 fixed.setProbability(fixed.probability() * invokeProbability); |
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 if (node instanceof FrameState) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 FrameState frameState = (FrameState) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
649 if (frameState.bci == FrameState.BEFORE_BCI) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 if (stateBefore == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
651 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
|
652 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 frameState.replaceAndDelete(stateBefore); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
654 } else if (frameState.bci == FrameState.AFTER_BCI) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 frameState.replaceAndDelete(stateAfter); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 assert stateAtExceptionEdge != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 frameState.replaceAndDelete(stateAtExceptionEdge); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
659 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
660 if (outerFrameState == null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
661 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
|
662 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
663 frameState.setOuterFrameState(outerFrameState); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
668 Node returnValue = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
669 if (returnNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
670 if (returnNode.result() instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
671 returnValue = replacements.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
673 returnValue = duplicates.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
675 for (Node usage : invoke.node().usages().snapshot()) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
676 usage.replaceFirstInput(invoke.node(), returnValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 Node returnDuplicate = duplicates.get(returnNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 returnDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 Node n = invoke.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
681 invoke.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 returnDuplicate.replaceAndDelete(n); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 invoke.node().clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 invoke.node().replaceAtUsages(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 GraphUtil.killCFG(invoke.node()); |
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 (stateAfter.usages().isEmpty()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 stateAfter.safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
693 |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
694 public static void receiverNullCheck(Invoke invoke) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
695 MethodCallTargetNode callTarget = invoke.callTarget(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
696 StructuredGraph graph = (StructuredGraph) invoke.graph(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
697 NodeInputList<ValueNode> parameters = callTarget.arguments(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
698 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
|
699 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
|
700 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
|
701 } |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
702 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 } |