annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java @ 4636:495a81cd6969

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