annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java @ 5341:1fbc4a08d029

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