annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java @ 7510:225002aba5a5

added new macro node facility, removed ArrayCopyIntrinsificationPhase
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 22 Jan 2013 11:29:40 +0100
parents 42b6e0905881
children 5e3d1a68664e 417bd4ca6e4a
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 */
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
23 package com.oracle.graal.phases.common;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.lang.reflect.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import java.util.*;
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4312
diff changeset
27 import java.util.concurrent.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
29 import com.oracle.graal.api.code.*;
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
30 import com.oracle.graal.api.code.Assumptions.Assumption;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
31 import com.oracle.graal.api.meta.*;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
32 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
33 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.debug.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
36 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.nodes.java.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
5720
46ad94a0574a moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
41 import com.oracle.graal.nodes.spi.*;
5339
e8f80481326d use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents: 5316
diff changeset
42 import com.oracle.graal.nodes.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.nodes.util.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6522
diff changeset
44 import com.oracle.graal.phases.*;
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 {
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
47 private static final DebugMetric metricInliningTailDuplication = Debug.metric("InliningTailDuplication");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
48 private static final String inliningDecisionsScopeString = "InliningDecisions";
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
49
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 public interface InliningCallback {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
51 StructuredGraph buildGraph(final ResolvedJavaMethod method);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
52 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
53
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
54 public interface InliningPolicy {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
55 void initialize(StructuredGraph graph);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
56 boolean continueInlining(StructuredGraph graph);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
57 InlineInfo next();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
58 void scanInvokes(Iterable<? extends Node> newNodes);
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
59 double inliningWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
60 boolean isWorthInlining(InlineInfo info);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
61 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
62
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
63 public interface WeightComputationPolicy {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
64 double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
65 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
66
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
67 public static void logNotInlinedMethod(InlineInfo info, String msg, Object... args) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
68 logInliningDecision(info, false, msg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
69 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
70
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
71 public static void logInliningDecision(InlineInfo info, boolean success, String msg, final Object... args) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
72 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
73 logInliningDecision(methodName(info), success, msg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
74 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
75 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
76
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
77 public static void logInliningDecision(final String msg, final Object... args) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
78 Debug.scope(inliningDecisionsScopeString, new Runnable() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
79 public void run() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
80 Debug.log(msg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
81 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
82 });
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
85 private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, String msg) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
86 if (shouldLogInliningDecision()) {
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
87 String methodString = invoke.toString() + (invoke.callTarget() == null ? " callTarget=null" : invoke.callTarget().targetName());
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
88 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
89 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
90 return false;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
91 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
92
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
93 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, ResolvedJavaMethod method, String msg) {
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
94 return logNotInlinedMethodAndReturnNull(invoke, method, msg, new Object[0]);
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
95 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
96
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
97 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, ResolvedJavaMethod method, String msg, Object... args) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
98 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
99 String methodString = methodName(method, invoke);
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
100 logInliningDecision(methodString, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
101 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
102 return null;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
103 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
104
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
105 private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, ResolvedJavaMethod method, String msg) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
106 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
107 String methodString = methodName(method, invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
108 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
109 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
110 return false;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
111 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
112
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
113 private static void logInliningDecision(final String methodString, final boolean success, final String msg, final Object... args) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
114 String inliningMsg = "inlining " + methodString + ": " + msg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
115 if (!success) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
116 inliningMsg = "not " + inliningMsg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
117 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
118 logInliningDecision(inliningMsg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
119 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
120
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
121 private static boolean shouldLogInliningDecision() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
122 return Debug.scope(inliningDecisionsScopeString, new Callable<Boolean>() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
123 public Boolean call() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
124 return Debug.isLogEnabled();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
125 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
126 });
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
127 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
128
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
129 private static String methodName(ResolvedJavaMethod method, Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
130 if (invoke != null && invoke.stateAfter() != null) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
131 return methodName(invoke.stateAfter(), invoke.bci()) + ": " + MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
133 return MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)";
3733
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
137 private static String methodName(InlineInfo info) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
138 if (info == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
139 return "null";
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
140 } else if (info.invoke() != null && info.invoke().stateAfter() != null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
141 return methodName(info.invoke().stateAfter(), info.invoke().bci()) + ": " + info.toString();
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
142 } 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
143 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
144 }
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
145 }
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
146
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
147 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
148 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
149 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
150 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
151 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
152 }
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
153 sb.append(MetaUtil.format("%h.%n", frameState.method()));
5316
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
154 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
155 return sb.toString();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
156 }
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
157
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 * 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
160 * 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
161 * 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
162 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
163 public interface InlineInfo extends Comparable<InlineInfo> {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
164 Invoke invoke();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
165 double weight();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
166 int level();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
167 int compiledCodeSize();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
168 int compareTo(InlineInfo o);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 * 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
172 * 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
173 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
174 void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
175 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
176
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
177 public abstract static class AbstractInlineInfo implements InlineInfo {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
178 protected final Invoke invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
179 protected final double weight;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
180
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
181 public AbstractInlineInfo(Invoke invoke, double weight) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
182 this.invoke = invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
183 this.weight = weight;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
184 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
185
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
186 @Override
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
187 public int compareTo(InlineInfo o) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
188 return (weight < o.weight()) ? -1 : (weight > o.weight()) ? 1 : 0;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
189 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
190
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
191 public Invoke invoke() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
192 return invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
193 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
194
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
195 public double weight() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
196 return weight;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
197 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
198
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
199 public int level() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
200 return computeInliningLevel(invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
201 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
202
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
203 protected static void inline(Invoke invoke, ResolvedJavaMethod concrete, InliningCallback callback, Assumptions assumptions, boolean receiverNullCheck) {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
204 Class< ? extends FixedWithNextNode> macroNodeClass = getMacroNodeClass(concrete);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
205 if (macroNodeClass != null) {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
206 StructuredGraph graph = (StructuredGraph) invoke.graph();
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
207 assert invoke instanceof InvokeNode;
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
208 FixedWithNextNode macroNode;
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
209 try {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
210 macroNode = macroNodeClass.getConstructor(InvokeNode.class).newInstance(invoke);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
211 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
212 throw new GraalInternalError(e).addContext(invoke.node()).addContext("macroSubstitution", macroNodeClass);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
213 }
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
214 CallTargetNode callTarget = invoke.callTarget();
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
215 graph.replaceFixedWithFixed((InvokeNode) invoke, graph.add(macroNode));
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
216 GraphUtil.killWithUnusedFloatingInputs(callTarget);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
217 } else {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
218 StructuredGraph calleeGraph = getIntrinsicGraph(concrete);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
219 if (calleeGraph == null) {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
220 calleeGraph = getGraph(concrete, callback);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
221 }
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
222 assumptions.recordMethodContents(concrete);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
223 InliningUtil.inline(invoke, calleeGraph, receiverNullCheck);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
224 }
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
225 }
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
226
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
227 private static StructuredGraph getGraph(final ResolvedJavaMethod concrete, final InliningCallback callback) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
228 return Debug.scope("GetInliningGraph", concrete, new Callable<StructuredGraph>() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
229 @Override
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
230 public StructuredGraph call() throws Exception {
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
231 assert !Modifier.isNative(concrete.getModifiers());
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
232 return callback.buildGraph(concrete);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
233 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
234 });
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
235 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 * 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
240 * 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
241 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
242 private static class ExactInlineInfo extends AbstractInlineInfo {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
243 public final ResolvedJavaMethod concrete;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
245 public ExactInlineInfo(Invoke invoke, double weight, ResolvedJavaMethod concrete) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
246 super(invoke, weight);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 this.concrete = concrete;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 @Override
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
251 public void inline(StructuredGraph compilerGraph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) {
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
252 inline(invoke, concrete, callback, assumptions, true);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 @Override
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
256 public int compiledCodeSize() {
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
257 return InliningUtil.compiledCodeSize(concrete);
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
258 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
259
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
260 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 public String toString() {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
262 return "exact " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 * 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
268 * 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
269 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
270 private static class TypeGuardInlineInfo extends AbstractInlineInfo {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
271 public final ResolvedJavaMethod concrete;
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
272 public final ResolvedJavaType type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
274 public TypeGuardInlineInfo(Invoke invoke, double weight, ResolvedJavaMethod concrete, ResolvedJavaType type) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
275 super(invoke, weight);
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
276 this.concrete = concrete;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 this.type = type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 @Override
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
281 public int compiledCodeSize() {
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
282 return InliningUtil.compiledCodeSize(concrete);
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
283 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
284
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
285 @Override
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
286 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) {
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4451
diff changeset
287 // 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
288 InliningUtil.receiverNullCheck(invoke);
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6383
diff changeset
289 ValueNode receiver = invoke.methodCallTarget().receiver();
6457
03a1a0c5ee84 removed IsTypeNode and replaced its usage with an ObjectEqualsNode
Doug Simon <doug.simon@oracle.com>
parents: 6456
diff changeset
290 ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), runtime, graph);
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
291 LoadHubNode receiverHub = graph.add(new LoadHubNode(receiver, typeHub.kind()));
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
292 CompareNode typeCheck = CompareNode.createCompareNode(Condition.EQ, receiverHub, typeHub);
6457
03a1a0c5ee84 removed IsTypeNode and replaced its usage with an ObjectEqualsNode
Doug Simon <doug.simon@oracle.com>
parents: 6456
diff changeset
293 FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, invoke.leafGraphId()));
5642
6c3a5ccec483 Merge AnchorNode and ValueAnchorNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5547
diff changeset
294 ValueAnchorNode anchor = graph.add(new ValueAnchorNode());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 assert invoke.predecessor() != null;
4453
c0430421d43d bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4452
diff changeset
296
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
297 ValueNode anchoredReceiver = createAnchoredReceiver(graph, anchor, type, receiver, true);
5339
e8f80481326d use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents: 5316
diff changeset
298 invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver);
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
299
6463
41f0849e107b reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents: 6460
diff changeset
300 graph.addBeforeFixed(invoke.node(), receiverHub);
4305
0768bf0a4898 move part of the cfg-modifying operations into one place (currently: StructuredGraph)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4249
diff changeset
301 graph.addBeforeFixed(invoke.node(), guard);
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
302 graph.addBeforeFixed(invoke.node(), anchor);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
304 inline(invoke, concrete, callback, assumptions, false);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 public String toString() {
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
309 return "type-checked with type " + type.getName() + " and method " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 /**
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
314 * 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
315 * 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
316 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
317 private static class MultiTypeGuardInlineInfo extends AbstractInlineInfo {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
318 public final List<ResolvedJavaMethod> concretes;
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
319 public final ArrayList<ProfiledType> ptypes;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
320 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
321 public final double notRecordedTypeProbability;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
322
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
323 public MultiTypeGuardInlineInfo(Invoke invoke, double weight, ArrayList<ResolvedJavaMethod> concretes, ArrayList<ProfiledType> ptypes,
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5316
diff changeset
324 int[] typesToConcretes, double notRecordedTypeProbability) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
325 super(invoke, weight);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
326 assert concretes.size() > 0 && concretes.size() <= ptypes.size() : "must have at least one method but no more than types methods";
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
327 assert ptypes.size() == typesToConcretes.length : "array lengths must match";
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
328
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
329 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
330 this.ptypes = ptypes;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
331 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
332 this.notRecordedTypeProbability = notRecordedTypeProbability;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
333 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
334
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
335 @Override
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
336 public int compiledCodeSize() {
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
337 int result = 0;
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
338 for (ResolvedJavaMethod m: concretes) {
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
339 result += InliningUtil.compiledCodeSize(m);
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
340 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
341 return result;
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
342 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
343
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
344 @Override
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
345 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) {
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
346 int numberOfMethods = concretes.size();
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
347 boolean hasReturnValue = invoke.node().kind() != Kind.Void;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
348
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4451
diff changeset
349 // 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
350 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
351 if (numberOfMethods > 1 || shouldFallbackToInvoke()) {
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
352 inlineMultipleMethods(graph, callback, assumptions, numberOfMethods, hasReturnValue);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
353 } else {
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
354 inlineSingleMethod(graph, callback, assumptions);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
355 }
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
356 }
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
357
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
358 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
359 return notRecordedTypeProbability > 0;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
360 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
361
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
362 private void inlineMultipleMethods(StructuredGraph graph, InliningCallback callback, Assumptions assumptions, int numberOfMethods, boolean hasReturnValue) {
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
363 FixedNode continuation = invoke.next();
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
364
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6383
diff changeset
365 ValueNode originalReceiver = invoke.methodCallTarget().receiver();
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
366 // setup merge and phi nodes for results and exceptions
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
367 MergeNode returnMerge = graph.add(new MergeNode());
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
368 returnMerge.setProbability(invoke.probability());
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
369 returnMerge.setStateAfter(invoke.stateAfter().duplicate(invoke.stateAfter().bci));
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
370
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
371 PhiNode returnValuePhi = null;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
372 if (hasReturnValue) {
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
373 returnValuePhi = graph.unique(new PhiNode(invoke.node().kind(), returnMerge));
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
374 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
375
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
376 MergeNode exceptionMerge = null;
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
377 PhiNode exceptionObjectPhi = null;
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
378 if (invoke instanceof InvokeWithExceptionNode) {
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
379 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5365
diff changeset
380 DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge();
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
381 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
382
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
383 exceptionMerge = graph.add(new MergeNode());
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
384 exceptionMerge.setProbability(exceptionEdge.probability());
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
385
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
386 FixedNode exceptionSux = exceptionObject.next();
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
387 graph.addBeforeFixed(exceptionSux, exceptionMerge);
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
388 exceptionObjectPhi = graph.unique(new PhiNode(Kind.Object, exceptionMerge));
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
389 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Void, exceptionObjectPhi));
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
390 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
391
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
392 // create one separate block for each invoked method
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
393 BeginNode[] successors = new BeginNode[numberOfMethods + 1];
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
394 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
395 double probability = 0;
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
396 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
397 if (typesToConcretes[j] == i) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
398 probability += ptypes.get(j).getProbability();
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
399 }
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
400 }
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
401
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
402 successors[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, 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
403 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
404
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
405 // create the successor for an unknown type
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
406 FixedNode unknownTypeSux;
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
407 if (shouldFallbackToInvoke()) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
408 unknownTypeSux = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, 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
409 } else {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
410 unknownTypeSux = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId()));
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
411 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
412 successors[successors.length - 1] = BeginNode.begin(unknownTypeSux);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
413
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
414 // replace the invoke exception edge
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
415 if (invoke instanceof InvokeWithExceptionNode) {
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
416 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke;
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
417 BeginNode exceptionEdge = invokeWithExceptionNode.exceptionEdge();
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
418 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
419 exceptionObject.replaceAtUsages(exceptionObjectPhi);
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
420 exceptionObject.setNext(null);
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
421 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge());
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
422 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
423
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
424 assert invoke.node().isAlive();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
425
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
426 // replace the invoke with a switch on the type of the actual receiver
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
427 Kind hubKind = invoke.methodCallTarget().targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind();
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
428 LoadHubNode receiverHub = graph.add(new LoadHubNode(invoke.methodCallTarget().receiver(), hubKind));
6463
41f0849e107b reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents: 6460
diff changeset
429 graph.addBeforeFixed(invoke.node(), receiverHub);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
430 FixedNode dispatchOnType = createDispatchOnType(graph, receiverHub, successors);
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
431
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
432 assert invoke.next() == continuation;
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
433 invoke.setNext(null);
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
434 returnMerge.setNext(continuation);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
435 invoke.node().replaceAtUsages(returnValuePhi);
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
436 invoke.node().replaceAndDelete(dispatchOnType);
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
437
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
438 ArrayList<PiNode> replacements = new ArrayList<>();
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
439
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
440 // do the actual inlining for every invoke
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
441 for (int i = 0; i < numberOfMethods; i++) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
442 BeginNode node = successors[i];
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
443 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
444
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
445 ResolvedJavaType commonType = getLeastCommonType(i);
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6383
diff changeset
446 ValueNode receiver = invokeForInlining.methodCallTarget().receiver();
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
447 boolean exact = getTypeCount(i) == 1;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
448 PiNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver, exact);
5339
e8f80481326d use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents: 5316
diff changeset
449 invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver);
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
450
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
451 inline(invokeForInlining, concretes.get(i), callback, assumptions, false);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
452
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
453 replacements.add(anchoredReceiver);
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
454 }
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
455 if (shouldFallbackToInvoke()) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
456 replacements.add(null);
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
457 }
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
458 if (GraalOptions.OptTailDuplication) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
459 /*
5792
fa6ed51ac198 more aggressive tail duplication
Lukas Stadler <lukas.stadler@jku.at>
parents: 5791
diff changeset
460 * We might want to perform tail duplication at the merge after a type switch, if there are invokes that would
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
461 * benefit from the improvement in type information.
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
462 */
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
463 FixedNode current = returnMerge;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
464 int opportunities = 0;
5791
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
465 do {
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6383
diff changeset
466 if (current instanceof InvokeNode && ((InvokeNode) current).methodCallTarget().receiver() == originalReceiver) {
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
467 opportunities++;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
468 } else if (current.inputs().contains(originalReceiver)) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
469 opportunities++;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
470 }
5791
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
471 current = ((FixedWithNextNode) current).next();
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
472 } while (current instanceof FixedWithNextNode);
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
473 if (opportunities > 0) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
474 metricInliningTailDuplication.increment();
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
475 Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities);
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
476 TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacements);
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
477 }
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
478 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
479 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
480
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
481 private int getTypeCount(int concreteMethodIndex) {
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
482 int count = 0;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
483 for (int i = 0; i < typesToConcretes.length; i++) {
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
484 if (typesToConcretes[i] == concreteMethodIndex) {
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
485 count++;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
486 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
487 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
488 return count;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
489 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
490
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
491 private ResolvedJavaType getLeastCommonType(int concreteMethodIndex) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
492 ResolvedJavaType commonType = null;
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
493 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
494 if (typesToConcretes[i] == concreteMethodIndex) {
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
495 if (commonType == null) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
496 commonType = ptypes.get(i).getType();
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
497 } else {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
498 commonType = commonType.findLeastCommonAncestor(ptypes.get(i).getType());
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
499 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
500 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
501 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
502 assert commonType != null;
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
503 return commonType;
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
504 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
505
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
506 private void inlineSingleMethod(StructuredGraph graph, InliningCallback callback, Assumptions assumptions) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
507 assert concretes.size() == 1 && ptypes.size() > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
508
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
509 BeginNode calleeEntryNode = graph.add(new BeginNode());
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
510 calleeEntryNode.setProbability(invoke.probability());
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
511 Kind hubKind = invoke.methodCallTarget().targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind();
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6683
diff changeset
512 LoadHubNode receiverHub = graph.add(new LoadHubNode(invoke.methodCallTarget().receiver(), hubKind));
6463
41f0849e107b reverted LoadHubNode to be a fixed node
Doug Simon <doug.simon@oracle.com>
parents: 6460
diff changeset
513 graph.addBeforeFixed(invoke.node(), receiverHub);
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
514
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
515 BeginNode unknownTypeSux = BeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, invoke.leafGraphId())));
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
516 BeginNode[] successors = new BeginNode[] {calleeEntryNode, unknownTypeSux};
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
517 FixedNode dispatchOnType = createDispatchOnType(graph, receiverHub, successors);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
518
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
519 FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor();
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
520 pred.setNext(dispatchOnType);
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
521 calleeEntryNode.setNext(invoke.node());
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
522
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
523 ResolvedJavaMethod concrete = concretes.get(0);
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
524 inline(invoke, concrete, callback, assumptions, false);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
525 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
526
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
527 private FixedNode createDispatchOnType(StructuredGraph graph, LoadHubNode hub, BeginNode[] successors) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
528 assert ptypes.size() > 1;
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
529
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
530 ResolvedJavaType[] keys = new ResolvedJavaType[ptypes.size()];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
531 double[] keyProbabilities = new double[ptypes.size() + 1];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
532 int[] keySuccessors = new int[ptypes.size() + 1];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
533 for (int i = 0; i < ptypes.size(); i++) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
534 keys[i] = ptypes.get(i).getType();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
535 keyProbabilities[i] = ptypes.get(i).getProbability();
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
536 keySuccessors[i] = typesToConcretes[i];
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
537 assert keySuccessors[i] < successors.length - 1 : "last successor is the unknownTypeSux";
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
538 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
539 keyProbabilities[keyProbabilities.length - 1] = notRecordedTypeProbability;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
540 keySuccessors[keySuccessors.length - 1] = successors.length - 1;
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
541
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
542 double[] successorProbabilities = SwitchNode.successorProbabilites(successors.length, keySuccessors, keyProbabilities);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
543 TypeSwitchNode typeSwitch = graph.add(new TypeSwitchNode(hub, successors, successorProbabilities, keys, keyProbabilities, keySuccessors));
5662
13166af0809e added TypeSwitchNode for polymorphic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5647
diff changeset
544
13166af0809e added TypeSwitchNode for polymorphic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5647
diff changeset
545 return typeSwitch;
4454
008a5ea590ca fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
546 }
008a5ea590ca fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
547
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
548 private static BeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi,
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
549 MergeNode exceptionMerge, PhiNode exceptionObjectPhi, double probability, boolean useForInlining) {
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
550 Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining, probability);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
551 BeginNode calleeEntryNode = graph.add(new BeginNode());
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
552 calleeEntryNode.setNext(duplicatedInvoke.node());
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
553 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
554
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
555 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
556 endNode.setProbability(probability);
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
557
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
558 duplicatedInvoke.setNext(endNode);
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4571
diff changeset
559 returnMerge.addForwardEnd(endNode);
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
560
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
561 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
562 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
563 }
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
564 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
565 }
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
566
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
567 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
568 Invoke result = (Invoke) invoke.node().copyWithInputs();
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
569 Node callTarget = result.callTarget().copyWithInputs();
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
570 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
571 result.setUseForInlining(useForInlining);
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
572 result.setProbability(probability);
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
573 result.setInliningRelevance(invoke.inliningRelevance() * probability);
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
574
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
575 Kind kind = invoke.node().kind();
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7097
diff changeset
576 if (kind != Kind.Void) {
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
577 FrameState stateAfter = invoke.stateAfter();
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
578 stateAfter = stateAfter.duplicate(stateAfter.bci);
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
579 stateAfter.replaceFirstInput(invoke.node(), result.node());
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
580 result.setStateAfter(stateAfter);
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
581 }
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
582
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
583 if (invoke instanceof InvokeWithExceptionNode) {
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
584 assert exceptionMerge != null && exceptionObjectPhi != null;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
585
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
586 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
7257
b1ebd583be14 Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7243
diff changeset
587 DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge();
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
588 ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
589 FrameState stateAfterException = exceptionObject.stateAfter();
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
590
7257
b1ebd583be14 Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7243
diff changeset
591 DispatchBeginNode newExceptionEdge = (DispatchBeginNode) exceptionEdge.copyWithInputs();
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
592 ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs();
4529
fc78ad20ec38 fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4528
diff changeset
593 // set new state (pop old exception object, push new one)
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
594 newExceptionObject.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionObject));
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
595 newExceptionEdge.setNext(newExceptionObject);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
596
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
597 EndNode endNode = graph.add(new EndNode());
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
598 newExceptionObject.setNext(endNode);
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4571
diff changeset
599 exceptionMerge.addForwardEnd(endNode);
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
600 exceptionObjectPhi.addInput(newExceptionObject);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
601
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
602 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
603 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
604 return result;
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
605 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
606
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
607 @Override
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
608 public String toString() {
5019
836e4fce33ab changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5005
diff changeset
609 StringBuilder builder = new StringBuilder(shouldFallbackToInvoke() ? "megamorphic" : "polymorphic");
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
610 builder.append(", ");
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
611 builder.append(concretes.size());
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
612 builder.append(" methods [ ");
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
613 for (int i = 0; i < concretes.size(); i++) {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
614 builder.append(MetaUtil.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
615 }
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
616 builder.append(" ], ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
617 builder.append(ptypes.size());
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
618 builder.append(" type checks [ ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
619 for (int i = 0; i < ptypes.size(); i++) {
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
620 builder.append(" ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
621 builder.append(ptypes.get(i).getType().getName());
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
622 builder.append(ptypes.get(i).getProbability());
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
623 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
624 builder.append(" ]");
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
625 return builder.toString();
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
626 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
627 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
628
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
629
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
630 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 * 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
632 * 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
633 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
634 private static class AssumptionInlineInfo extends ExactInlineInfo {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
635 private final Assumption takenAssumption;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
637 public AssumptionInlineInfo(Invoke invoke, double weight, ResolvedJavaMethod concrete, Assumption takenAssumption) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
638 super(invoke, weight, concrete);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
639 this.takenAssumption = takenAssumption;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
641
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
642 @Override
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
643 public void inline(StructuredGraph graph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
644 assumptions.record(takenAssumption);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
645 Debug.log("recording assumption: %s", takenAssumption);
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
646
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
647 super.inline(graph, runtime, callback, assumptions);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
649
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
650 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
651 public String toString() {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
652 return "assumption " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
653 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
655
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
656 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 * 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
658 * @param invoke the invoke that should be inlined
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
659 * @param inliningPolicy used to determine the weight of a specific inlining
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660 * @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
661 */
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
662 public static InlineInfo getInlineInfo(Invoke invoke, Assumptions assumptions, InliningPolicy inliningPolicy, OptimisticOptimizations optimisticOpts) {
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
663 if (!checkInvokeConditions(invoke)) {
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
664 return null;
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
665 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
666 ResolvedJavaMethod caller = getCaller(invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
667 MethodCallTargetNode callTarget = invoke.methodCallTarget();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
668 ResolvedJavaMethod targetMethod = callTarget.targetMethod();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
669
4571
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
670 if (callTarget.invokeKind() == InvokeKind.Special || targetMethod.canBeStaticallyBound()) {
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
671 return getExactInlineInfo(invoke, inliningPolicy, optimisticOpts, caller, targetMethod);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672 }
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
673
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
674 assert callTarget.invokeKind() == InvokeKind.Virtual || callTarget.invokeKind() == InvokeKind.Interface;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
675
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
676 ResolvedJavaType holder = targetMethod.getDeclaringClass();
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
677 ObjectStamp receiverStamp = callTarget.receiver().objectStamp();
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
678 if (receiverStamp.type() != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
679 // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...)
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
680 ResolvedJavaType receiverType = receiverStamp.type();
7097
6644cecbd3a7 Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7079
diff changeset
681 if (receiverType != null && holder.isAssignableFrom(receiverType)) {
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
682 holder = receiverType;
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
683 if (receiverStamp.isExactType()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
684 assert targetMethod.getDeclaringClass().isAssignableFrom(holder) : holder + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod;
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
685 return getExactInlineInfo(invoke, inliningPolicy, optimisticOpts, caller, holder.resolveMethod(targetMethod));
4457
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
686 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
687 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 }
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4249
diff changeset
689
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
690 if (holder.isArray()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
691 // arrays can be treated as Objects
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
692 return getExactInlineInfo(invoke, inliningPolicy, optimisticOpts, caller, holder.resolveMethod(targetMethod));
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
693 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
694
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
695 // TODO (chaeubl): we could also use the type determined after assumptions for the type-checked inlining case as it might have an effect on type filtering
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
696 if (assumptions.useOptimisticAssumptions()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
697 ResolvedJavaType uniqueSubtype = holder.findUniqueConcreteSubtype();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
698 if (uniqueSubtype != null) {
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
699 return getAssumptionInlineInfo(invoke, inliningPolicy, optimisticOpts, caller, uniqueSubtype.resolveMethod(targetMethod), new Assumptions.ConcreteSubtype(holder, uniqueSubtype));
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
700 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
701
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
702 ResolvedJavaMethod concrete = holder.findUniqueConcreteMethod(targetMethod);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
703 if (concrete != null) {
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
704 return getAssumptionInlineInfo(invoke, inliningPolicy, optimisticOpts, caller, concrete, new Assumptions.ConcreteMethod(targetMethod, holder, concrete));
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
705 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
706
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
707 // TODO (chaeubl): C1 has one more assumption in the case of interfaces
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
708 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
709
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
710 // type check based inlining
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
711 return getTypeCheckedInlineInfo(invoke, inliningPolicy, caller, holder, targetMethod, optimisticOpts);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
712 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
713
7226
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7223 7162
diff changeset
714 private static InlineInfo getAssumptionInlineInfo(Invoke invoke, InliningPolicy inliningPolicy, OptimisticOptimizations optimisticOpts,
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
715 ResolvedJavaMethod caller, ResolvedJavaMethod concrete, Assumption takenAssumption) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
716 assert !Modifier.isAbstract(concrete.getModifiers());
7226
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7223 7162
diff changeset
717 if (!checkTargetConditions(invoke, concrete, optimisticOpts)) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
718 return null;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
719 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
720 double weight = inliningPolicy.inliningWeight(caller, concrete, invoke);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
721 return new AssumptionInlineInfo(invoke, weight, concrete, takenAssumption);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
722 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
723
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
724 private static InlineInfo getExactInlineInfo(Invoke invoke, InliningPolicy inliningPolicy, OptimisticOptimizations optimisticOpts,
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
725 ResolvedJavaMethod caller, ResolvedJavaMethod targetMethod) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
726 assert !Modifier.isAbstract(targetMethod.getModifiers());
7227
8fbb97b0016a fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7226
diff changeset
727 if (!checkTargetConditions(invoke, targetMethod, optimisticOpts)) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
728 return null;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
729 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
730 double weight = inliningPolicy.inliningWeight(caller, targetMethod, invoke);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
731 return new ExactInlineInfo(invoke, weight, targetMethod);
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
732 }
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
733
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
734 private static InlineInfo getTypeCheckedInlineInfo(Invoke invoke, InliningPolicy inliningPolicy, ResolvedJavaMethod caller,
7226
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7223 7162
diff changeset
735 ResolvedJavaType holder, ResolvedJavaMethod targetMethod, OptimisticOptimizations optimisticOpts) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
736 ProfilingInfo profilingInfo = caller.getProfilingInfo();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
737 JavaTypeProfile typeProfile = profilingInfo.getTypeProfile(invoke.bci());
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
738 if (typeProfile == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
739 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "no type profile exists");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
740 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
741
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
742 ProfiledType[] rawProfiledTypes = typeProfile.getTypes();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
743 ArrayList<ProfiledType> ptypes = getCompatibleTypes(rawProfiledTypes, holder);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
744 if (ptypes == null || ptypes.size() <= 0) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
745 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "no types remained after filtering (%d types were recorded)", rawProfiledTypes.length);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
746 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
747
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
748 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability();
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
749 if (ptypes.size() == 1 && notRecordedTypeProbability == 0) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
750 if (!optimisticOpts.inlineMonomorphicCalls()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
751 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining monomorphic calls is disabled");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 }
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
753
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
754 ResolvedJavaType type = ptypes.get(0).getType();
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
755 ResolvedJavaMethod concrete = type.resolveMethod(targetMethod);
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
756 if (!checkTargetConditions(invoke, concrete, optimisticOpts)) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
757 return null;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
758 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
759 double weight = inliningPolicy.inliningWeight(caller, concrete, invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
760 return new TypeGuardInlineInfo(invoke, weight, concrete, type);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
761 } else {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
762 invoke.setPolymorphic(true);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
763
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
764 if (!optimisticOpts.inlinePolymorphicCalls() && notRecordedTypeProbability == 0) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
765 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining polymorphic calls is disabled (%d types)", ptypes.size());
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
766 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
767 if (!optimisticOpts.inlineMegamorphicCalls() && notRecordedTypeProbability > 0) {
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
768 // due to filtering impossible types, notRecordedTypeProbability can be > 0 although the number of types is lower than what can be recorded in a type profile
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
769 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "inlining megamorphic calls is disabled (%d types, %f %% not recorded types)", ptypes.size(), notRecordedTypeProbability * 100);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
770 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
771
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
772 // TODO (chaeubl) inlining of multiple methods should work differently
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
773 // 1. check which methods can be inlined
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
774 // 2. for those methods, use weight and probability to compute which of them should be inlined
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
775 // 3. do the inlining
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
776 // a) all seen methods can be inlined -> do so and guard with deopt
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
777 // b) some methods can be inlined -> inline them and fall back to invocation if violated
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
778
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
779 // determine concrete methods and map type to specific method
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
780 ArrayList<ResolvedJavaMethod> concreteMethods = new ArrayList<>();
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
781 int[] typesToConcretes = new int[ptypes.size()];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
782 for (int i = 0; i < ptypes.size(); i++) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
783 ResolvedJavaMethod concrete = ptypes.get(i).getType().resolveMethod(targetMethod);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
784
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
785 int index = concreteMethods.indexOf(concrete);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
786 if (index < 0) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
787 index = concreteMethods.size();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
788 concreteMethods.add(concrete);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
789 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
790 typesToConcretes[i] = index;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
791 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
792
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
793 double totalWeight = 0;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
794 for (ResolvedJavaMethod concrete: concreteMethods) {
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
795 if (!checkTargetConditions(invoke, concrete, optimisticOpts)) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
796 return logNotInlinedMethodAndReturnNull(invoke, targetMethod, "it is a polymorphic method call and at least one invoked method cannot be inlined");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
797 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
798 totalWeight += inliningPolicy.inliningWeight(caller, concrete, invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
799 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
800 return new MultiTypeGuardInlineInfo(invoke, totalWeight, concreteMethods, ptypes, typesToConcretes, notRecordedTypeProbability);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
801 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
804
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
805 private static ArrayList<ProfiledType> getCompatibleTypes(ProfiledType[] types, ResolvedJavaType holder) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
806 ArrayList<ProfiledType> result = new ArrayList<>();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
807 for (int i = 0; i < types.length; i++) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
808 ProfiledType ptype = types[i];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
809 ResolvedJavaType type = ptype.getType();
7243
4979267ab857 Fix warning, Fix overly strong assert (the value of the 'abstract' modifier for array types is unspecified)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7241
diff changeset
810 assert !type.isInterface() && (type.isArray() || !Modifier.isAbstract(type.getModifiers())) : type;
7386
707e9cca11de fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7243
diff changeset
811 if (!GraalOptions.OptFilterProfiledTypes || holder.isAssignableFrom(type)) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
812 result.add(ptype);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
813 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
814 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
815 return result;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
816 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
817
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
818 private static ResolvedJavaMethod getCaller(Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
819 return invoke.stateAfter().method();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
820 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
821
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
822 private static PiNode createAnchoredReceiver(StructuredGraph graph, FixedNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) {
4636
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
823 // to avoid that floating reads on receiver fields float above the type check
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
824 return graph.unique(new PiNode(receiver, anchor, exact ? StampFactory.exactNonNull(commonType) : 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
825 }
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
826
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
827 private static boolean checkInvokeConditions(Invoke invoke) {
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
828 if (invoke.predecessor() == null || !invoke.node().isAlive()) {
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
829 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke is dead code");
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
830 } else if (!(invoke.callTarget() instanceof MethodCallTargetNode)) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
831 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke has already been lowered, or has been created as a low-level node");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
832 } else if (invoke.methodCallTarget().targetMethod() == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
833 return logNotInlinedMethodAndReturnFalse(invoke, "target method is null");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
834 } else if (invoke.stateAfter() == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
835 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke has no after state");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
836 } else if (!invoke.useForInlining()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
837 return logNotInlinedMethodAndReturnFalse(invoke, "the invoke is marked to be not used for inlining");
7241
26ffe1669cc8 avoid rare useless inlinings
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7227
diff changeset
838 } else if (invoke.methodCallTarget().receiver() != null && invoke.methodCallTarget().receiver().isConstant() && invoke.methodCallTarget().receiver().asConstant().isNull()) {
26ffe1669cc8 avoid rare useless inlinings
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7227
diff changeset
839 return logNotInlinedMethodAndReturnFalse(invoke, "receiver is null");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
840 } else {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
841 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
842 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
844
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
845 private static boolean checkTargetConditions(Invoke invoke, ResolvedJavaMethod method, OptimisticOptimizations optimisticOpts) {
4530
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4529
diff changeset
846 if (method == null) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
847 return logNotInlinedMethodAndReturnFalse(invoke, method, "the method is not resolved");
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
848 } else if (Modifier.isNative(method.getModifiers()) && (!GraalOptions.Intrinsify || !InliningUtil.canIntrinsify(method))) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
849 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is a non-intrinsic native method");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
850 } else if (Modifier.isAbstract(method.getModifiers())) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
851 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is an abstract method");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
852 } else if (!method.getDeclaringClass().isInitialized()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
853 return logNotInlinedMethodAndReturnFalse(invoke, method, "the method's class is not initialized");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
854 } else if (!method.canBeInlined()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
855 return logNotInlinedMethodAndReturnFalse(invoke, method, "it is marked non-inlinable");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
856 } else if (computeInliningLevel(invoke) > GraalOptions.MaximumInlineLevel) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
857 return logNotInlinedMethodAndReturnFalse(invoke, method, "it exceeds the maximum inlining depth");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
858 } else if (computeRecursiveInliningLevel(invoke.stateAfter(), method) > GraalOptions.MaximumRecursiveInlining) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
859 return logNotInlinedMethodAndReturnFalse(invoke, method, "it exceeds the maximum recursive inlining depth");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
860 } else if (new OptimisticOptimizations(method).lessOptimisticThan(optimisticOpts)) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
861 return logNotInlinedMethodAndReturnFalse(invoke, method, "the callee uses less optimistic optimizations than caller");
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
862 } else {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
863 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
865 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
866
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
867 private static int computeInliningLevel(Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
868 int count = -1;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
869 FrameState curState = invoke.stateAfter();
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
870 while (curState != null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
871 count++;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
872 curState = curState.outerFrameState();
4296
d089b71a5237 Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents: 4249
diff changeset
873 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
874 return count;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
875 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
877 private static int computeRecursiveInliningLevel(FrameState state, ResolvedJavaMethod method) {
4564
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4539
diff changeset
878 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
879
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
880 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
881 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
882 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
883 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
884 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
885 }
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
886 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
887 }
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
888 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
889 }
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
890
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
891 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
892 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph.
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5341
diff changeset
893 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
894 * @param invoke the invoke that will be replaced
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
895 * @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
896 * @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
897 */
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
898 public static Map<Node, Node> inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 NodeInputList<ValueNode> parameters = invoke.callTarget().arguments();
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4305
diff changeset
900 StructuredGraph graph = (StructuredGraph) invoke.node().graph();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
901
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902 FrameState stateAfter = invoke.stateAfter();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
903 assert stateAfter.isAlive();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
904
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
905 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
906 ArrayList<Node> nodes = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
907 ReturnNode returnNode = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
908 UnwindNode unwindNode = null;
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5365
diff changeset
909 StartNode entryPointNode = inlineGraph.start();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
910 FixedNode firstCFGNode = entryPointNode.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
911 for (Node node : inlineGraph.getNodes()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
912 if (node == entryPointNode || node == entryPointNode.stateAfter()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
913 // Do nothing.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
914 } else if (node instanceof LocalNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
915 replacements.put(node, parameters.get(((LocalNode) node).index()));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 nodes.add(node);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918 if (node instanceof ReturnNode) {
5693
0356d95f01ba While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5662
diff changeset
919 assert returnNode == null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
920 returnNode = (ReturnNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
921 } else if (node instanceof UnwindNode) {
5693
0356d95f01ba While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5662
diff changeset
922 assert unwindNode == null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
923 unwindNode = (UnwindNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
924 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
925 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926 }
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
927 replacements.put(entryPointNode, BeginNode.prevBegin(invoke.node())); // ensure proper anchoring of things that were anchored to the StartNode
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
928
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 assert invoke.node().successors().first() != null : invoke;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930 assert invoke.node().predecessor() != null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
931
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932 Map<Node, Node> duplicates = graph.addDuplicates(nodes, replacements);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
933 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
934 if (receiverNullCheck) {
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
935 receiverNullCheck(invoke);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936 }
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5444
diff changeset
937 invoke.node().replaceAtPredecessor(firstCFGNodeDuplicate);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
938
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 FrameState stateAtExceptionEdge = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 if (invoke instanceof InvokeWithExceptionNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
942 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 assert unwindNode.predecessor() != null;
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4312
diff changeset
944 assert invokeWithException.exceptionEdge().successors().count() == 1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
945 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
946 stateAtExceptionEdge = obj.stateAfter();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
947 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
948 obj.replaceAtUsages(unwindDuplicate.exception());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
949 unwindDuplicate.clearInputs();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
950 Node n = obj.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
951 obj.setNext(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
952 unwindDuplicate.replaceAndDelete(n);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
954 invokeWithException.killExceptionEdge();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
955 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
956 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
957 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
958 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
959 DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler, invoke.leafGraphId());
4339
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
960 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
961 // 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
962 // (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
963 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
964 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
965 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
966 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
967 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
968 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
969 }
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
970 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
971 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
972 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
974 FrameState outerFrameState = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
975 double invokeProbability = invoke.node().probability();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
976 for (Node node : duplicates.values()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
977 if (GraalOptions.ProbabilityAnalysis) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
978 if (node instanceof FixedNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
979 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
980 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
981 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
982 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
983 }
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
984 fixed.setProbability(newProbability);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
985 }
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
986 if (node instanceof Invoke) {
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
987 Invoke newInvoke = (Invoke) node;
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
988 double newRelevance = newInvoke.inliningRelevance() * invoke.inliningRelevance();
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
989 if (GraalOptions.LimitInlinedProbability) {
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
990 newRelevance = Math.min(newRelevance, invoke.inliningRelevance());
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
991 }
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
992 newInvoke.setInliningRelevance(newRelevance);
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
993 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
994 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
995 if (node instanceof FrameState) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
996 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
997 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
998 if (frameState.bci == FrameState.AFTER_BCI) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
999 frameState.replaceAndDelete(stateAfter);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1000 } 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
1001 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
1002 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
1003 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
1004 } 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
1005 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
1006 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1007 } else {
6435
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1008 // only handle the outermost frame states
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1009 if (frameState.outerFrameState() == null) {
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1010 assert frameState.method() == inlineGraph.method();
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1011 if (outerFrameState == null) {
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1012 outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invoke.node().kind());
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1013 outerFrameState.setDuringCall(true);
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1014 }
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1015 frameState.setOuterFrameState(outerFrameState);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1016 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1019 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1020
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1021 Node returnValue = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022 if (returnNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023 if (returnNode.result() instanceof LocalNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1024 returnValue = replacements.get(returnNode.result());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1025 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 returnValue = duplicates.get(returnNode.result());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 }
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
1028 invoke.node().replaceAtUsages(returnValue);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 Node returnDuplicate = duplicates.get(returnNode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1030 returnDuplicate.clearInputs();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1031 Node n = invoke.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 invoke.setNext(null);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1033 returnDuplicate.replaceAndDelete(n);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 invoke.node().replaceAtUsages(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1037 GraphUtil.killCFG(invoke.node());
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
1038
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
1039 return duplicates;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1040 }
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1041
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1042 public static void receiverNullCheck(Invoke invoke) {
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6383
diff changeset
1043 MethodCallTargetNode callTarget = invoke.methodCallTarget();
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1044 StructuredGraph graph = (StructuredGraph) invoke.graph();
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1045 NodeInputList<ValueNode> parameters = callTarget.arguments();
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1046 ValueNode firstParam = parameters.size() <= 0 ? null : parameters.get(0);
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
1047 if (!callTarget.isStatic() && firstParam.kind() == Kind.Object && !firstParam.objectStamp().nonNull()) {
6683
45872267325e Fix Inlining : null check guard should use reason NullCheckException
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6673
diff changeset
1048 graph.addBeforeFixed(invoke.node(), graph.add(new FixedGuardNode(graph.unique(new IsNullNode(firstParam)), DeoptimizationReason.NullCheckException, DeoptimizationAction.InvalidateReprofile, true, invoke.leafGraphId())));
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1049 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1050 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1051
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1052 public static boolean canIntrinsify(ResolvedJavaMethod target) {
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1053 return getIntrinsicGraph(target) != null || getMacroNodeClass(target) != null;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1054 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1055
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1056 public static StructuredGraph getIntrinsicGraph(ResolvedJavaMethod target) {
7162
a59a3d25d952 removed support for non-snippet based intrinsification
Doug Simon <doug.simon@oracle.com>
parents: 7133
diff changeset
1057 return (StructuredGraph) target.getCompilerStorage().get(Graph.class);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1058 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1059
7388
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1060 private static int compiledCodeSize(ResolvedJavaMethod target) {
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1061 if (GraalOptions.AlwaysInlineIntrinsics && canIntrinsify(target)) {
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1062 return 0;
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1063 } else {
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1064 return target.getCompiledCodeSize();
599ea4fcdb6d added flag AlwaysInlineIntrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7387
diff changeset
1065 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1066 }
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1067
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1068 public static Class< ? extends FixedWithNextNode> getMacroNodeClass(ResolvedJavaMethod target) {
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1069 Object result = target.getCompilerStorage().get(Node.class);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1070 return result == null ? null : ((Class< ? >) result).asSubclass(FixedWithNextNode.class);
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1071 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1072 }