Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java @ 5642:6c3a5ccec483
Merge AnchorNode and ValueAnchorNode
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sat, 16 Jun 2012 16:13:32 +0200 |
parents | b6617d13ea44 |
children | 419df70cc6a2 |
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 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.compiler.util; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.lang.reflect.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import java.util.*; |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4312
diff
changeset
|
27 import java.util.concurrent.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
31 import com.oracle.graal.api.meta.JavaTypeProfile.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.compiler.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.compiler.phases.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.cri.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
42 import com.oracle.graal.nodes.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
43 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 public class InliningUtil { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 public interface InliningCallback { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
48 StructuredGraph buildGraph(ResolvedJavaMethod method); |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
49 double inliningWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke); |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
50 void recordMethodContentsAssumption(ResolvedJavaMethod method); |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
51 void recordConcreteMethodAssumption(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
54 public static String methodName(ResolvedJavaMethod method, Invoke invoke) { |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
55 if (!Debug.isLogEnabled()) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
56 return null; |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
57 } else if (invoke != null && invoke.stateAfter() != null) { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
58 return methodName(invoke.stateAfter(), invoke.bci()) + ": " + CodeUtil.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 { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
60 return CodeUtil.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 |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
64 public static String methodName(InlineInfo info) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
65 if (!Debug.isLogEnabled()) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
66 return null; |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
67 } else if (info.invoke != null && info.invoke.stateAfter() != null) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
68 return methodName(info.invoke.stateAfter(), info.invoke.bci()) + ": " + info.toString(); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
69 } else { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
70 return info.toString(); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
71 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
72 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
73 |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
74 private static String methodName(FrameState frameState, int bci) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
75 StringBuilder sb = new StringBuilder(); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
76 if (frameState.outerFrameState() != null) { |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
77 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci)); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
78 sb.append("->"); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
79 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
80 sb.append(CodeUtil.format("%h.%n", frameState.method())); |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
81 sb.append("@").append(bci); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5210
diff
changeset
|
82 return sb.toString(); |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
83 } |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
84 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 * 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
|
87 * 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
|
88 * 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
|
89 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 public abstract static class InlineInfo implements Comparable<InlineInfo> { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 public final Invoke invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 public final double weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 public final int level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 public InlineInfo(Invoke invoke, double weight, int level) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 this.invoke = invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 this.weight = weight; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 this.level = level; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
101 public abstract int compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
102 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 public int compareTo(InlineInfo o) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 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
|
106 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
108 protected static StructuredGraph getGraph(final ResolvedJavaMethod concrete, final InliningCallback callback) { |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
109 return Debug.scope("Inlining", concrete, new Callable<StructuredGraph>() { |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
110 @Override |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
111 public StructuredGraph call() throws Exception { |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
112 return callback.buildGraph(concrete); |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
113 } |
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
114 }); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
115 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
116 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 public abstract boolean canDeopt(); |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 * 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
|
121 * 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
|
122 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 * @param graph |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 * @param runtime |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 * @param callback |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 */ |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
127 public abstract void inline(StructuredGraph graph, ExtendedRiRuntime runtime, InliningCallback callback); |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 * 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
|
132 * 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
|
133 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 private static class ExactInlineInfo extends InlineInfo { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
135 public final ResolvedJavaMethod concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
137 public ExactInlineInfo(Invoke invoke, double weight, int level, ResolvedJavaMethod concrete) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 super(invoke, weight, level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 this.concrete = concrete; |
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 @Override |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
143 public void inline(StructuredGraph compilerGraph, ExtendedRiRuntime runtime, final InliningCallback callback) { |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
144 StructuredGraph graph = getGraph(concrete, callback); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
145 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4636
diff
changeset
|
146 callback.recordMethodContentsAssumption(concrete); |
4461 | 147 InliningUtil.inline(invoke, graph, true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
151 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
152 return concrete.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
153 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
154 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
155 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 public String toString() { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
157 return "exact " + CodeUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
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 * 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
|
168 * 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
|
169 */ |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
170 private static class TypeGuardInlineInfo extends InlineInfo { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
171 public final ResolvedJavaMethod concrete; |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
172 public final ResolvedJavaType type; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
174 public TypeGuardInlineInfo(Invoke invoke, double weight, int level, ResolvedJavaMethod concrete, ResolvedJavaType type) { |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
175 super(invoke, weight, level); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
176 this.concrete = concrete; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 this.type = type; |
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 |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
181 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
182 return concrete.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
183 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
184 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
185 @Override |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
186 public void inline(StructuredGraph graph, ExtendedRiRuntime 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
|
187 // 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
|
188 InliningUtil.receiverNullCheck(invoke); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
189 ValueNode receiver = invoke.callTarget().receiver(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
190 ReadHubNode objectClass = graph.add(new ReadHubNode(receiver)); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
191 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClass, type)); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
192 FixedGuardNode guard = graph.add(new FixedGuardNode(isTypeNode, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, invoke.leafGraphId())); |
5642
6c3a5ccec483
Merge AnchorNode and ValueAnchorNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
193 ValueAnchorNode anchor = graph.add(new ValueAnchorNode()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 assert invoke.predecessor() != null; |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
195 |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
196 ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver); |
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
197 invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
198 |
4453
c0430421d43d
bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4452
diff
changeset
|
199 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
|
200 graph.addBeforeFixed(invoke.node(), guard); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
201 graph.addBeforeFixed(invoke.node(), anchor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 |
4462
428a91f18858
fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
203 StructuredGraph calleeGraph = getGraph(concrete, callback); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
204 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4636
diff
changeset
|
205 callback.recordMethodContentsAssumption(concrete); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
206 InliningUtil.inline(invoke, calleeGraph, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 public String toString() { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
211 return "type-checked " + CodeUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 /** |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
221 * Polymorphic inlining of m methods with n type checks (n >= m) in case that the profiling information suggests a reasonable |
4455 | 222 * amounts of different receiver types and different methods. If an unknown type is encountered a deoptimization is triggered. |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
223 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
224 private static class MultiTypeGuardInlineInfo extends InlineInfo { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
225 public final List<ResolvedJavaMethod> concretes; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
226 public final ProfiledType[] ptypes; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
227 public final int[] typesToConcretes; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
228 public final double notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
229 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
230 public MultiTypeGuardInlineInfo(Invoke invoke, double weight, int level, List<ResolvedJavaMethod> concretes, ProfiledType[] ptypes, |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
231 int[] typesToConcretes, double notRecordedTypeProbability) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
232 super(invoke, weight, level); |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
233 assert concretes.size() > 0 && concretes.size() <= ptypes.length : "must have at least one method but no more than types methods"; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
234 assert ptypes.length == typesToConcretes.length : "array lengths must match"; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
235 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
236 this.concretes = concretes; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
237 this.ptypes = ptypes; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
238 this.typesToConcretes = typesToConcretes; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
239 this.notRecordedTypeProbability = notRecordedTypeProbability; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
240 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
241 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
242 @Override |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
243 public int compiledCodeSize() { |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
244 int result = 0; |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
245 for (ResolvedJavaMethod m: concretes) { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
246 result += m.compiledCodeSize(); |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
247 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
248 return result; |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
249 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
250 |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4473
diff
changeset
|
251 @Override |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
252 public void inline(StructuredGraph graph, ExtendedRiRuntime runtime, InliningCallback callback) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
253 int numberOfMethods = concretes.size(); |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
254 boolean hasReturnValue = invoke.node().kind() != Kind.Void; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
255 |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
256 // 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
|
257 InliningUtil.receiverNullCheck(invoke); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
258 if (numberOfMethods > 1 || shouldFallbackToInvoke()) { |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
259 inlineMultipleMethods(graph, runtime, callback, numberOfMethods, hasReturnValue); |
4455 | 260 } else { |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
261 inlineSingleMethod(graph, runtime, callback); |
4455 | 262 } |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
263 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
264 |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
265 private boolean shouldFallbackToInvoke() { |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
266 return notRecordedTypeProbability > 0; |
4455 | 267 } |
268 | |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
269 private void inlineMultipleMethods(StructuredGraph graph, ExtendedRiRuntime runtime, InliningCallback callback, int numberOfMethods, boolean hasReturnValue) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
270 FixedNode continuation = invoke.next(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
271 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
272 // setup merge and phi nodes for results and exceptions |
4455 | 273 MergeNode returnMerge = graph.add(new MergeNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
274 returnMerge.setProbability(invoke.probability()); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
275 returnMerge.setStateAfter(invoke.stateAfter().duplicate(invoke.stateAfter().bci)); |
4455 | 276 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
277 PhiNode returnValuePhi = null; |
4455 | 278 if (hasReturnValue) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
279 returnValuePhi = graph.unique(new PhiNode(invoke.node().kind(), returnMerge)); |
4455 | 280 } |
281 | |
282 MergeNode exceptionMerge = null; | |
283 PhiNode exceptionObjectPhi = null; | |
284 if (invoke instanceof InvokeWithExceptionNode) { | |
285 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; | |
5373
53cc37c27b04
used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents:
5365
diff
changeset
|
286 DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
4455 | 287 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
288 | |
289 exceptionMerge = graph.add(new MergeNode()); | |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
290 exceptionMerge.setProbability(exceptionEdge.probability()); |
4455 | 291 |
292 FixedNode exceptionSux = exceptionObject.next(); | |
293 graph.addBeforeFixed(exceptionSux, exceptionMerge); | |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
294 exceptionObjectPhi = graph.unique(new PhiNode(Kind.Object, exceptionMerge)); |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
295 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Void, exceptionObjectPhi)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
296 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
297 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
298 // create one separate block for each invoked method |
4455 | 299 BeginNode[] calleeEntryNodes = new BeginNode[numberOfMethods]; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
300 for (int i = 0; i < numberOfMethods; i++) { |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
301 int predecessors = 0; |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
302 double probability = 0; |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
303 for (int j = 0; j < typesToConcretes.length; j++) { |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
304 if (typesToConcretes[j] == i) { |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
305 predecessors++; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
306 probability += ptypes[j].probability; |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
307 } |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
308 } |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
309 |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
310 calleeEntryNodes[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, predecessors, invoke.probability() * probability, true); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
311 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
312 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
313 // create the successor for an unknown type |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
314 FixedNode unknownTypeNode; |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
315 if (shouldFallbackToInvoke()) { |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
316 unknownTypeNode = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, 1, notRecordedTypeProbability, false); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
317 } else { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
318 unknownTypeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId())); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
319 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
320 |
4455 | 321 // replace the invoke exception edge |
322 if (invoke instanceof InvokeWithExceptionNode) { | |
323 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke; | |
324 BeginNode exceptionEdge = invokeWithExceptionNode.exceptionEdge(); | |
325 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); | |
326 exceptionObject.replaceAtUsages(exceptionObjectPhi); | |
327 exceptionObject.setNext(null); | |
328 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge()); | |
329 } | |
330 | |
331 // replace the invoke with a cascade of if nodes | |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
332 ReadHubNode objectClassNode = graph.add(new ReadHubNode(invoke.callTarget().receiver())); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
333 graph.addBeforeFixed(invoke.node(), objectClassNode); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
334 FixedNode dispatchOnType = createDispatchOnType(graph, objectClassNode, calleeEntryNodes, unknownTypeNode); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
335 |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
336 assert invoke.next() == continuation; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
337 invoke.setNext(null); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
338 returnMerge.setNext(continuation); |
4455 | 339 invoke.node().replaceAtUsages(returnValuePhi); |
340 invoke.node().replaceAndDelete(dispatchOnType); | |
341 | |
342 // do the actual inlining for every invoke | |
343 for (int i = 0; i < calleeEntryNodes.length; i++) { | |
344 BeginNode node = calleeEntryNodes[i]; | |
345 Invoke invokeForInlining = (Invoke) node.next(); | |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
346 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
347 ResolvedJavaType commonType = getLeastCommonType(i); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
348 ValueNode receiver = invokeForInlining.callTarget().receiver(); |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
349 ValueNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver); |
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
350 invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
351 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
352 ResolvedJavaMethod concrete = concretes.get(i); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
353 StructuredGraph calleeGraph = getGraph(concrete, callback); |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4636
diff
changeset
|
354 callback.recordMethodContentsAssumption(concrete); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
355 assert !IntrinsificationPhase.canIntrinsify(invokeForInlining, concrete, runtime); |
4455 | 356 InliningUtil.inline(invokeForInlining, calleeGraph, false); |
357 } | |
358 } | |
359 | |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
360 private ResolvedJavaType getLeastCommonType(int concreteMethodIndex) { |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
361 ResolvedJavaType commonType = null; |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
362 for (int i = 0; i < typesToConcretes.length; i++) { |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
363 if (typesToConcretes[i] == concreteMethodIndex) { |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
364 if (commonType == null) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
365 commonType = ptypes[i].type; |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
366 } else { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
367 commonType = commonType.leastCommonAncestor(ptypes[i].type); |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
368 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
369 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
370 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
371 assert commonType != null; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
372 return commonType; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
373 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4627
diff
changeset
|
374 |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
375 private void inlineSingleMethod(StructuredGraph graph, ExtendedRiRuntime runtime, InliningCallback callback) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
376 assert concretes.size() == 1 && ptypes.length > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0; |
4455 | 377 |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
378 MergeNode calleeEntryNode = graph.add(new MergeNode()); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
379 calleeEntryNode.setProbability(invoke.probability()); |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
380 ReadHubNode objectClassNode = graph.add(new ReadHubNode(invoke.callTarget().receiver())); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
381 graph.addBeforeFixed(invoke.node(), objectClassNode); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
382 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
383 FixedNode unknownTypeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId())); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
384 FixedNode dispatchOnType = createDispatchOnType(graph, objectClassNode, new BeginNode[] {calleeEntryNode}, unknownTypeNode); |
4455 | 385 |
386 FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor(); | |
387 pred.setNext(dispatchOnType); | |
388 calleeEntryNode.setNext(invoke.node()); | |
389 | |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
390 ResolvedJavaMethod concrete = concretes.get(0); |
4590
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
391 StructuredGraph calleeGraph = getGraph(concrete, callback); |
d8d865b9de30
added assertion to ensure that methods are only inlined if they cannot be intrinsified
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4571
diff
changeset
|
392 assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime); |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4636
diff
changeset
|
393 callback.recordMethodContentsAssumption(concrete); |
4455 | 394 InliningUtil.inline(invoke, calleeGraph, false); |
395 } | |
396 | |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4464
diff
changeset
|
397 private FixedNode createDispatchOnType(StructuredGraph graph, ReadHubNode objectClassNode, BeginNode[] calleeEntryNodes, FixedNode unknownTypeSux) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
398 assert ptypes.length > 1; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
399 |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
400 int lastIndex = ptypes.length - 1; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
401 double[] branchProbabilities = convertTypeToBranchProbabilities(ptypes, notRecordedTypeProbability); |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
402 double nodeProbability = ptypes[lastIndex].probability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
403 IfNode nextNode = createTypeCheck(graph, objectClassNode, ptypes[lastIndex].type, calleeEntryNodes[typesToConcretes[lastIndex]], unknownTypeSux, branchProbabilities[lastIndex], invoke.probability() * nodeProbability); |
4452
b225da954a32
inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4451
diff
changeset
|
404 for (int i = lastIndex - 1; i >= 0; i--) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
405 nodeProbability += ptypes[i].probability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
406 nextNode = createTypeCheck(graph, objectClassNode, ptypes[i].type, calleeEntryNodes[typesToConcretes[i]], nextNode, branchProbabilities[i], invoke.probability() * nodeProbability); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
407 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
408 |
4455 | 409 return nextNode; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
410 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
411 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
412 private static IfNode createTypeCheck(StructuredGraph graph, ReadHubNode objectClassNode, ResolvedJavaType type, BeginNode tsux, FixedNode nextNode, double tsuxProbability, double probability) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
413 IfNode result; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
414 IsTypeNode isTypeNode = graph.unique(new IsTypeNode(objectClassNode, type)); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
415 if (tsux instanceof MergeNode) { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
416 EndNode endNode = graph.add(new EndNode()); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
417 result = graph.add(new IfNode(isTypeNode, endNode, nextNode, tsuxProbability)); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
418 ((MergeNode) tsux).addForwardEnd(endNode); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
419 } else { |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
420 result = graph.add(new IfNode(isTypeNode, tsux, nextNode, tsuxProbability)); |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
421 } |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
422 result.setProbability(probability); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
423 return result; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
424 } |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
425 |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
426 private static double[] convertTypeToBranchProbabilities(ProfiledType[] ptypes, double notRecordedTypeProbability) { |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
427 double[] result = new double[ptypes.length]; |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
428 double total = notRecordedTypeProbability; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
429 for (int i = ptypes.length - 1; i >= 0; i--) { |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
430 total += ptypes[i].probability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
431 result[i] = ptypes[i].probability / total; |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
432 } |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
433 assert total > 0.99 && total < 1.01; |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
434 return result; |
4454
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
435 } |
008a5ea590ca
fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
436 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
437 private static BeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi, |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
438 MergeNode exceptionMerge, PhiNode exceptionObjectPhi, int predecessors, double probability, boolean useForInlining) { |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
439 Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining, probability); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
440 BeginNode calleeEntryNode = graph.add(predecessors > 1 ? new MergeNode() : new BeginNode()); |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
441 calleeEntryNode.setNext(duplicatedInvoke.node()); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
442 calleeEntryNode.setProbability(probability); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
443 |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
444 EndNode endNode = graph.add(new EndNode()); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
445 endNode.setProbability(probability); |
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
446 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
447 duplicatedInvoke.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
448 returnMerge.addForwardEnd(endNode); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
449 |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
450 if (returnValuePhi != null) { |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
451 returnValuePhi.addInput(duplicatedInvoke.node()); |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
452 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
453 return calleeEntryNode; |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
454 } |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
455 |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
456 private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, MergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining, double probability) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
457 Invoke result = (Invoke) invoke.node().copyWithInputs(); |
4622
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
458 Node callTarget = result.callTarget().copyWithInputs(); |
00e01f401c03
Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4618
diff
changeset
|
459 result.node().replaceFirstInput(result.callTarget(), callTarget); |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
460 result.setUseForInlining(useForInlining); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5003
diff
changeset
|
461 result.setProbability(probability); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
462 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
463 Kind kind = invoke.node().kind(); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
464 if (!kind.isVoid()) { |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
465 FrameState stateAfter = invoke.stateAfter(); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
466 stateAfter = stateAfter.duplicate(stateAfter.bci); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
467 stateAfter.replaceFirstInput(invoke.node(), result.node()); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
468 result.setStateAfter(stateAfter); |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
469 } |
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
470 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
471 if (invoke instanceof InvokeWithExceptionNode) { |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
472 assert exceptionMerge != null && exceptionObjectPhi != null; |
4455 | 473 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
474 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
475 BeginNode exceptionEdge = invokeWithException.exceptionEdge(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
476 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next(); |
4539
98b3b255913c
Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4530
diff
changeset
|
477 FrameState stateAfterException = exceptionObject.stateAfter(); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
478 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
479 BeginNode newExceptionEdge = (BeginNode) exceptionEdge.copyWithInputs(); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
480 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs(); |
4529
fc78ad20ec38
fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4528
diff
changeset
|
481 // set new state (pop old exception object, push new one) |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
482 newExceptionObject.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionObject)); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
483 newExceptionEdge.setNext(newExceptionObject); |
4455 | 484 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
485 EndNode endNode = graph.add(new EndNode()); |
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
486 newExceptionObject.setNext(endNode); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4571
diff
changeset
|
487 exceptionMerge.addForwardEnd(endNode); |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
488 exceptionObjectPhi.addInput(newExceptionObject); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
489 |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
490 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
491 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
492 return result; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
493 } |
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 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
496 public String toString() { |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
497 StringBuilder builder = new StringBuilder(shouldFallbackToInvoke() ? "megamorphic" : "polymorphic"); |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
498 builder.append(String.format(", %d methods with %d type checks:", concretes.size(), ptypes.length)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
499 for (int i = 0; i < concretes.size(); i++) { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
500 builder.append(CodeUtil.format(" %H.%n(%p):%r", concretes.get(i))); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
501 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
502 return builder.toString(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
503 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
504 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
505 @Override |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
506 public boolean canDeopt() { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
507 return true; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
508 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
509 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
510 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
511 |
3733
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 * 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
|
514 * 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
|
515 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 private static class AssumptionInlineInfo extends ExactInlineInfo { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
517 public final ResolvedJavaType context; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
519 public AssumptionInlineInfo(Invoke invoke, double weight, int level, ResolvedJavaType context, ResolvedJavaMethod concrete) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 super(invoke, weight, level, concrete); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 this.context = context; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 @Override |
5499
8d7d009a54d8
Introduction of com.oracle.graal.api project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
525 public void inline(StructuredGraph graph, ExtendedRiRuntime runtime, InliningCallback callback) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
526 if (Debug.isLogEnabled()) { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
527 String targetName = CodeUtil.format("%H.%n(%p):%r", invoke.callTarget().targetMethod()); |
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
528 String concreteName = CodeUtil.format("%H.%n(%p):%r", concrete); |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
529 Debug.log("recording concrete method assumption: %s on receiver type %s -> %s", targetName, context, concreteName); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 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
|
532 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
533 super.inline(graph, runtime, callback); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 public String toString() { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
538 return "assumption " + CodeUtil.format("%H.%n(%p):%r", concrete); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 public boolean canDeopt() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 return true; |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 * 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
|
549 * @param invoke the invoke that should be inlined |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 * @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
|
551 * @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
|
552 * @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
|
553 * @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
|
554 */ |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
555 public static InlineInfo getInlineInfo(Invoke invoke, int level, ExtendedRiRuntime runtime, Assumptions assumptions, InliningCallback callback, OptimisticOptimizations optimisticOpts) { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
556 ResolvedJavaMethod parent = invoke.stateAfter().method(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 MethodCallTargetNode callTarget = invoke.callTarget(); |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
558 ResolvedJavaMethod targetMethod = callTarget.targetMethod(); |
4571 | 559 if (targetMethod == null) { |
560 return null; | |
561 } | |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
562 if (!checkInvokeConditions(invoke)) { |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
563 return null; |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
564 } |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
565 |
4571 | 566 if (callTarget.invokeKind() == InvokeKind.Special || targetMethod.canBeStaticallyBound()) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
567 if (checkTargetConditions(invoke, targetMethod, optimisticOpts)) { |
4571 | 568 double weight = callback == null ? 0 : callback.inliningWeight(parent, targetMethod, invoke); |
569 return new ExactInlineInfo(invoke, weight, level, targetMethod); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
570 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
571 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
572 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
573 ObjectStamp receiverStamp = callTarget.receiver().objectStamp(); |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
574 ResolvedJavaType receiverType = receiverStamp.type(); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
575 if (receiverStamp.isExactType()) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
576 assert receiverType.isSubtypeOf(targetMethod.holder()) : receiverType + " subtype of " + targetMethod.holder() + " for " + targetMethod; |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
577 ResolvedJavaMethod resolved = receiverType.resolveMethodImpl(targetMethod); |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
578 if (checkTargetConditions(invoke, resolved, optimisticOpts)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
579 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
|
580 return new ExactInlineInfo(invoke, weight, level, resolved); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
581 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
582 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
583 } |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
584 ResolvedJavaType holder = targetMethod.holder(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
585 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
586 if (receiverStamp.type() != null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
587 // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...) |
5056
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5020
diff
changeset
|
588 // TODO (lstadler) fix this |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
589 if (receiverType != null && receiverType.isSubtypeOf(holder)) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5426
diff
changeset
|
590 holder = receiverType; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
591 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
592 } |
5056
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5020
diff
changeset
|
593 // TODO (thomaswue) fix this |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
594 if (assumptions != null) { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
595 ResolvedJavaMethod concrete = holder.uniqueConcreteMethod(targetMethod); |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
596 if (concrete != null) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
597 if (checkTargetConditions(invoke, concrete, optimisticOpts)) { |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
598 double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
599 return new AssumptionInlineInfo(invoke, weight, level, holder, concrete); |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
600 } |
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4456
diff
changeset
|
601 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 } |
4440
271220b49abc
profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4249
diff
changeset
|
604 |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
605 // type check based inlining |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
606 return getTypeCheckedInlineInfo(invoke, level, callback, parent, targetMethod, optimisticOpts); |
5109
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
607 } |
6766253384bf
more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5105
diff
changeset
|
608 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
609 private static InlineInfo getTypeCheckedInlineInfo(Invoke invoke, int level, InliningCallback callback, ResolvedJavaMethod parent, ResolvedJavaMethod targetMethod, OptimisticOptimizations optimisticOpts) { |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
610 ProfilingInfo profilingInfo = parent.profilingInfo(); |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
611 JavaTypeProfile typeProfile = profilingInfo.getTypeProfile(invoke.bci()); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
612 if (typeProfile != null) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
613 ProfiledType[] ptypes = typeProfile.getTypes(); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
614 |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
615 if (ptypes != null && ptypes.length > 0) { |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
616 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability(); |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
617 if (ptypes.length == 1 && notRecordedTypeProbability == 0) { |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
618 if (optimisticOpts.inlineMonomorphicCalls()) { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
619 ResolvedJavaType type = ptypes[0].type; |
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
620 ResolvedJavaMethod concrete = type.resolveMethodImpl(targetMethod); |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
621 if (checkTargetConditions(invoke, concrete, optimisticOpts)) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
622 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
|
623 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
|
624 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
625 |
4571 | 626 Debug.log("not inlining %s because method can't be inlined", methodName(targetMethod, invoke)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
627 return null; |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
628 } else { |
5003
5e6f1026a63e
fixes to vtable stub inlining: compute offset on demand, look out for interface methods
Lukas Stadler <lukas.stadler@jku.at>
parents:
4696
diff
changeset
|
629 Debug.log("not inlining %s because GraalOptions.InlineMonomorphicCalls == false", methodName(targetMethod, invoke)); |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
630 return null; |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
631 } |
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
632 } else { |
5374
6ed04fb6affd
rename: megamorph -> megamorphic
Doug Simon <doug.simon@oracle.com>
parents:
5373
diff
changeset
|
633 invoke.setMegamorphic(true); |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
634 if (optimisticOpts.inlinePolymorphicCalls() && notRecordedTypeProbability == 0 || optimisticOpts.inlineMegamorphicCalls() && notRecordedTypeProbability > 0) { |
5057
3d7e78f17df5
more comments tag updates
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5056
diff
changeset
|
635 // TODO (chaeubl) inlining of multiple methods should work differently |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
636 // 1. check which methods can be inlined |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
637 // 2. for those methods, use weight and probability to compute which of them should be inlined |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
638 // 3. do the inlining |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
639 // a) all seen methods can be inlined -> do so and guard with deopt |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
640 // b) some methods can be inlined -> inline them and fall back to invocation if violated |
5057
3d7e78f17df5
more comments tag updates
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5056
diff
changeset
|
641 // TODO (chaeubl) sort types by probability |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
642 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
643 // determine concrete methods and map type to specific method |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
644 ArrayList<ResolvedJavaMethod> concreteMethods = new ArrayList<>(); |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
645 int[] typesToConcretes = new int[ptypes.length]; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
646 for (int i = 0; i < ptypes.length; i++) { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
647 ResolvedJavaMethod concrete = ptypes[i].type.resolveMethodImpl(targetMethod); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
648 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
649 int index = concreteMethods.indexOf(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
650 if (index < 0) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
651 index = concreteMethods.size(); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
652 concreteMethods.add(concrete); |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
653 } |
4458
cdf13998f705
inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
654 typesToConcretes[i] = index; |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
655 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
656 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
657 double totalWeight = 0; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
658 boolean canInline = true; |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
659 for (ResolvedJavaMethod concrete: concreteMethods) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
660 if (!checkTargetConditions(invoke, concrete, optimisticOpts)) { |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
661 canInline = false; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
662 break; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
663 } |
4464
f304ba0d4e24
inlining seems stable but deoptimizes too frequently
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4462
diff
changeset
|
664 totalWeight += callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
665 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
666 |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
667 if (canInline) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5316
diff
changeset
|
668 return new MultiTypeGuardInlineInfo(invoke, totalWeight, level, concreteMethods, ptypes, typesToConcretes, notRecordedTypeProbability); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
669 } else { |
4571 | 670 Debug.log("not inlining %s because it is a polymorphic method call and at least one invoked method cannot be inlined", methodName(targetMethod, invoke)); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
671 return null; |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
672 } |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4455
diff
changeset
|
673 } else { |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5110
diff
changeset
|
674 if (!optimisticOpts.inlinePolymorphicCalls() && notRecordedTypeProbability == 0) { |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
675 Debug.log("not inlining %s because GraalOptions.InlinePolymorphicCalls == false", methodName(targetMethod, invoke)); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
676 } else { |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
677 Debug.log("not inlining %s because GraalOptions.InlineMegamorphicCalls == false", methodName(targetMethod, invoke)); |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5005
diff
changeset
|
678 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
679 return null; |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
680 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
681 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 } |
4459
d389f4b5bdd6
fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4458
diff
changeset
|
683 |
4571 | 684 Debug.log("not inlining %s because no types/probabilities were recorded", methodName(targetMethod, invoke)); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4440
diff
changeset
|
685 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 } else { |
4571 | 687 Debug.log("not inlining %s because no type profile exists", methodName(targetMethod, invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
692 private static ValueNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, ResolvedJavaType commonType, ValueNode receiver) { |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
693 // to avoid that floating reads on receiver fields float above the type check |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5316
diff
changeset
|
694 return graph.unique(new PiNode(receiver, anchor, StampFactory.declaredNonNull(commonType))); |
4636
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
695 } |
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
696 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
697 private static boolean checkInvokeConditions(Invoke invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
698 if (invoke.stateAfter() == null) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
699 Debug.log("not inlining %s because the invoke has no after state", methodName(invoke.callTarget().targetMethod(), invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
701 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 if (invoke.predecessor() == null) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
703 Debug.log("not inlining %s because the invoke is dead code", methodName(invoke.callTarget().targetMethod(), invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
705 } |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
706 if (!invoke.useForInlining()) { |
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
707 Debug.log("not inlining %s because invoke is marked to be not used for inlining", methodName(invoke.callTarget().targetMethod(), invoke)); |
4473 | 708 return false; |
4472
63cd21fda79b
hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4467
diff
changeset
|
709 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
710 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
711 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
712 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
713 private static boolean checkTargetConditions(Invoke invoke, JavaMethod method, OptimisticOptimizations optimisticOpts) { |
4530 | 714 if (method == null) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
715 Debug.log("not inlining because method is not resolved"); |
4530 | 716 return false; |
717 } | |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
718 if (!(method instanceof ResolvedJavaMethod)) { |
4402
8220fa69f075
Remove TraceInlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
719 Debug.log("not inlining %s because it is unresolved", method.toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
721 } |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
722 ResolvedJavaMethod resolvedMethod = (ResolvedJavaMethod) method; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
723 if (Modifier.isNative(resolvedMethod.accessFlags())) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
724 Debug.log("not inlining %s because it is a native method", methodName(resolvedMethod, invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
725 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
727 if (Modifier.isAbstract(resolvedMethod.accessFlags())) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
728 Debug.log("not inlining %s because it is an abstract method", methodName(resolvedMethod, invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
729 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
730 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
731 if (!resolvedMethod.holder().isInitialized()) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
732 Debug.log("not inlining %s because of non-initialized class", methodName(resolvedMethod, invoke)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 } |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
735 if (!resolvedMethod.canBeInlined()) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
736 Debug.log("not inlining %s because it is marked non-inlinable", methodName(resolvedMethod, invoke)); |
4296
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
737 return false; |
d089b71a5237
Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents:
4249
diff
changeset
|
738 } |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
739 if (computeRecursiveInliningLevel(invoke.stateAfter(), (ResolvedJavaMethod) method) > GraalOptions.MaximumRecursiveInlining) { |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
740 Debug.log("not inlining %s because it exceeds the maximum recursive inlining depth", methodName(resolvedMethod, invoke)); |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
741 return false; |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
742 } |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
743 OptimisticOptimizations calleeOpts = new OptimisticOptimizations(resolvedMethod); |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
744 if (calleeOpts.lessOptimisticThan(optimisticOpts)) { |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
745 Debug.log("not inlining %s because callee uses less optimistic optimizations than caller", methodName(resolvedMethod, invoke)); |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
746 return false; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
747 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
748 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
752 private static int computeRecursiveInliningLevel(FrameState state, ResolvedJavaMethod method) { |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
753 assert state != null; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
754 |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
755 int count = 0; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
756 FrameState curState = state; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
757 while (curState != null) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
758 if (curState.method() == method) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
759 count++; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
760 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
761 curState = curState.outerFrameState(); |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
762 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
763 return count; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
764 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4539
diff
changeset
|
765 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
766 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
767 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph. |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
5341
diff
changeset
|
768 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 * @param invoke the invoke that will be replaced |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
770 * @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
|
771 * @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
|
772 */ |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
773 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
|
774 NodeInputList<ValueNode> parameters = invoke.callTarget().arguments(); |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4305
diff
changeset
|
775 StructuredGraph graph = (StructuredGraph) invoke.node().graph(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
777 FrameState stateAfter = invoke.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
778 assert stateAfter.isAlive(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
780 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
|
781 ArrayList<Node> nodes = new ArrayList<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 ReturnNode returnNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 UnwindNode unwindNode = null; |
5373
53cc37c27b04
used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents:
5365
diff
changeset
|
784 StartNode entryPointNode = inlineGraph.start(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
785 FixedNode firstCFGNode = entryPointNode.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 for (Node node : inlineGraph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 if (node == entryPointNode || node == entryPointNode.stateAfter()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
788 // Do nothing. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
789 } else if (node instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
790 replacements.put(node, parameters.get(((LocalNode) node).index())); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
792 nodes.add(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
793 if (node instanceof ReturnNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
794 returnNode = (ReturnNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
795 } else if (node instanceof UnwindNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 unwindNode = (UnwindNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
801 assert invoke.node().successors().first() != null : invoke; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 assert invoke.node().predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 Map<Node, Node> duplicates = graph.addDuplicates(nodes, replacements); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 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
|
806 if (receiverNullCheck) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
807 receiverNullCheck(invoke); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 } |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5444
diff
changeset
|
809 invoke.node().replaceAtPredecessor(firstCFGNodeDuplicate); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 FrameState stateAtExceptionEdge = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 if (invoke instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
813 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 assert unwindNode.predecessor() != null; |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4312
diff
changeset
|
816 assert invokeWithException.exceptionEdge().successors().count() == 1; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 stateAtExceptionEdge = obj.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
4455 | 820 obj.replaceAtUsages(unwindDuplicate.exception()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 unwindDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 Node n = obj.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
823 obj.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 unwindDuplicate.replaceAndDelete(n); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 invokeWithException.killExceptionEdge(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
831 DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler, invoke.leafGraphId()); |
4339
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
832 unwindDuplicate.replaceAndDelete(graph.add(deoptimizeNode)); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
833 // move the deopt upwards if there is a monitor exit that tries to use the "after exception" frame state |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
834 // (because there is no "after exception" frame state!) |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
835 if (deoptimizeNode.predecessor() instanceof MonitorExitNode) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
836 MonitorExitNode monitorExit = (MonitorExitNode) deoptimizeNode.predecessor(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
837 if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == FrameState.AFTER_EXCEPTION_BCI) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
838 FrameState monitorFrameState = monitorExit.stateAfter(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
839 graph.removeFixed(monitorExit); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
840 monitorFrameState.safeDelete(); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
841 } |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
842 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
846 FrameState outerFrameState = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 double invokeProbability = invoke.node().probability(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 for (Node node : duplicates.values()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 if (GraalOptions.ProbabilityAnalysis) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
851 FixedNode fixed = (FixedNode) node; |
4605
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
852 double newProbability = fixed.probability() * invokeProbability; |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
853 if (GraalOptions.LimitInlinedProbability) { |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
854 newProbability = Math.min(newProbability, invokeProbability); |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
855 } |
f0569f6336f7
disabled megamorphic calls, trying an inlining policy where invokes within loops do not have any advantages
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4590
diff
changeset
|
856 fixed.setProbability(newProbability); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
858 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 if (node instanceof FrameState) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 FrameState frameState = (FrameState) node; |
4687
bacc18e07f7b
Removed dead code from the inlining util. STATE_BEFORE is only used in BlockBegin, which in turn is not added to the caller graph during inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4678
diff
changeset
|
861 assert frameState.bci != FrameState.BEFORE_BCI; |
bacc18e07f7b
Removed dead code from the inlining util. STATE_BEFORE is only used in BlockBegin, which in turn is not added to the caller graph during inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4678
diff
changeset
|
862 if (frameState.bci == FrameState.AFTER_BCI) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
863 frameState.replaceAndDelete(stateAfter); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
864 } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) { |
4339
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
865 if (frameState.isAlive()) { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
866 assert stateAtExceptionEdge != null; |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
867 frameState.replaceAndDelete(stateAtExceptionEdge); |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
868 } else { |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
869 assert stateAtExceptionEdge == null; |
15ec30809d0f
enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents:
4312
diff
changeset
|
870 } |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
871 } else { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
872 if (outerFrameState == null) { |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
873 outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invoke.node().kind()); |
4678
a03f3fd16b22
Fix reexecute boolean in HotSpot debug information. Introduce "duringCall" flag in FrameState that indicates that the bci of the frame state denotes an invoke that should *not* be reexecuted.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4670
diff
changeset
|
874 outerFrameState.setDuringCall(true); |
4449
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
875 } |
d84ccb0cc897
some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4442
diff
changeset
|
876 frameState.setOuterFrameState(outerFrameState); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
877 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
878 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
879 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
880 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
881 Node returnValue = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
882 if (returnNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 if (returnNode.result() instanceof LocalNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
884 returnValue = replacements.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
885 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
886 returnValue = duplicates.get(returnNode.result()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
887 } |
4455 | 888 invoke.node().replaceAtUsages(returnValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
889 Node returnDuplicate = duplicates.get(returnNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 returnDuplicate.clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 Node n = invoke.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
892 invoke.setNext(null); |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5160
diff
changeset
|
893 returnDuplicate.replaceAndDelete(n); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
894 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
895 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
896 invoke.node().clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
897 invoke.node().replaceAtUsages(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
898 GraphUtil.killCFG(invoke.node()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
900 if (stateAfter.usages().isEmpty()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
901 stateAfter.safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
902 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
903 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
904 |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
905 public static void receiverNullCheck(Invoke invoke) { |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
906 MethodCallTargetNode callTarget = invoke.callTarget(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
907 StructuredGraph graph = (StructuredGraph) invoke.graph(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
908 NodeInputList<ValueNode> parameters = callTarget.arguments(); |
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
909 ValueNode firstParam = parameters.size() <= 0 ? null : parameters.get(0); |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
910 if (!callTarget.isStatic() && firstParam.kind() == Kind.Object && !firstParam.objectStamp().nonNull()) { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
911 graph.addBeforeFixed(invoke.node(), graph.add(new FixedGuardNode(graph.unique(new IsNullNode(firstParam)), DeoptimizationReason.ClassCastException, DeoptimizationAction.InvalidateReprofile, true, invoke.leafGraphId()))); |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
912 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
913 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
914 } |