annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java @ 16328:34ac3ddfd5ac

[SPARC] fixing findbug warnings
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Mon, 30 Jun 2014 17:27:35 +0200
parents graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java@97eed257999b
children 41d479400da8
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 */
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
23 package com.oracle.graal.phases.common.inlining;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
11839
0e2cceed1caf Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11712
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
27 import static com.oracle.graal.compiler.common.GraalOptions.*;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
28 import static com.oracle.graal.compiler.common.type.StampFactory.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
32 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
33 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15152
diff changeset
34 import com.oracle.graal.compiler.common.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
35 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
36 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
37 import com.oracle.graal.debug.Debug.Scope;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.graph.*;
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
39 import com.oracle.graal.graph.Graph.DuplicationReplacement;
11573
8a3d99fc36cf Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 11270
diff changeset
40 import com.oracle.graal.graph.Node.Verbosity;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.nodes.java.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
45 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
8637
ce5750014c3d moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents: 8636
diff changeset
46 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
47 import com.oracle.graal.nodes.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
48 import com.oracle.graal.nodes.util.*;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
49 import com.oracle.graal.phases.common.inlining.info.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 public class InliningUtil {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
52
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
53 private static final String inliningDecisionsScopeString = "InliningDecisions";
7558
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
54 /**
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
55 * Meters the size (in bytecodes) of all methods processed during compilation (i.e., top level
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
56 * and all inlined methods), irrespective of how many bytecodes in each method are actually
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
57 * parsed (which may be none for methods whose IR is retrieved from a cache).
7558
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
58 */
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
59 public static final DebugMetric InlinedBytecodes = Debug.metric("InlinedBytecodes");
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
60
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
61 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
62 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
63 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
64 private static void printInlining(final InlineInfo info, final int inliningDepth, final boolean success, final String msg, final Object... args) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
65 printInlining(info.methodAt(0), info.invoke(), inliningDepth, success, msg, args);
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
66 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
67
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
68 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
69 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
70 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
71 private static void printInlining(final ResolvedJavaMethod method, final Invoke invoke, final int inliningDepth, final boolean success, final String msg, final Object... args) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
72 if (HotSpotPrintInlining.getValue()) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
73 // 1234567
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
74 TTY.print(" "); // print timestamp
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
75 // 1234
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
76 TTY.print(" "); // print compilation number
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
77 // % s ! b n
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
78 TTY.print("%c%c%c%c%c ", ' ', method.isSynchronized() ? 's' : ' ', ' ', ' ', method.isNative() ? 'n' : ' ');
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
79 TTY.print(" "); // more indent
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
80 TTY.print(" "); // initial inlining indent
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
81 for (int i = 0; i < inliningDepth; i++) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
82 TTY.print(" ");
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
83 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
84 TTY.println(String.format("@ %d %s %s%s", invoke.bci(), methodName(method, null), success ? "" : "not inlining ", String.format(msg, args)));
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
85 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
86 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
87
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
88 public static void logInlinedMethod(InlineInfo info, int inliningDepth, boolean allowLogging, String msg, Object... args) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
89 logInliningDecision(info, inliningDepth, allowLogging, true, msg, args);
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
90 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
91
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
92 public static void logNotInlinedMethod(InlineInfo info, int inliningDepth, String msg, Object... args) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
93 logInliningDecision(info, inliningDepth, true, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
94 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
95
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
96 public static void logInliningDecision(InlineInfo info, int inliningDepth, boolean allowLogging, boolean success, String msg, final Object... args) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
97 if (allowLogging) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
98 printInlining(info, inliningDepth, success, msg, args);
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
99 if (shouldLogInliningDecision()) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
100 logInliningDecision(methodName(info), success, msg, args);
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
101 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
102 }
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 public static void logInliningDecision(final String msg, final Object... args) {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
106 try (Scope s = Debug.scope(inliningDecisionsScopeString)) {
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
107 // Can't use log here since we are varargs
14869
89a079df9cb4 Backout changeset ae7cbf13e765708f228be3e2e666e13d421bbd8e
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14865
diff changeset
108 if (Debug.isLogEnabled()) {
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
109 Debug.logv(msg, args);
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
110 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
111 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
114 public static void logNotInlinedMethod(Invoke invoke, String msg) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
115 if (shouldLogInliningDecision()) {
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
116 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
117 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
118 }
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
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
121 public static void logNotInlined(Invoke invoke, int inliningDepth, ResolvedJavaMethod method, String msg) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
122 logNotInlinedInvoke(invoke, inliningDepth, method, msg, new Object[0]);
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
123 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
124
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
125 public static void logNotInlinedInvoke(Invoke invoke, int inliningDepth, ResolvedJavaMethod method, String msg, Object... args) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
126 printInlining(method, invoke, inliningDepth, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
127 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
128 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
129 logInliningDecision(methodString, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
130 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
131 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
132
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
133 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
134 String inliningMsg = "inlining " + methodString + ": " + msg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
135 if (!success) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
136 inliningMsg = "not " + inliningMsg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
137 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
138 logInliningDecision(inliningMsg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
139 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
140
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
141 public static boolean shouldLogInliningDecision() {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
142 try (Scope s = Debug.scope(inliningDecisionsScopeString)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
143 return Debug.isLogEnabled();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
144 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
145 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
146
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
147 private static String methodName(ResolvedJavaMethod method, Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
148 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
149 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
150 } 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
151 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
152 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
155 private static String methodName(InlineInfo info) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
156 if (info == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
157 return "null";
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
158 } else if (info.invoke() != null && info.invoke().stateAfter() != null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
159 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
160 } 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
161 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
162 }
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
163 }
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
164
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
165 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
166 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
167 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
168 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
169 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
170 }
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
171 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
172 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
173 return sb.toString();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
174 }
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
175
9310
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
176 public static void replaceInvokeCallTarget(Invoke invoke, StructuredGraph graph, InvokeKind invokeKind, ResolvedJavaMethod targetMethod) {
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
177 MethodCallTargetNode oldCallTarget = (MethodCallTargetNode) invoke.callTarget();
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
178 MethodCallTargetNode newCallTarget = graph.add(new MethodCallTargetNode(invokeKind, targetMethod, oldCallTarget.arguments().toArray(new ValueNode[0]), oldCallTarget.returnType()));
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
179 invoke.asNode().replaceFirstInput(oldCallTarget, newCallTarget);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
182 public static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) {
10041
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
183 return createAnchoredReceiver(graph, anchor, receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType));
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
184 }
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
185
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
186 private static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ValueNode receiver, Stamp stamp) {
4636
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
187 // to avoid that floating reads on receiver fields float above the type check
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
188 return graph.unique(new GuardedValueNode(receiver, anchor, stamp));
4636
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
189 }
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
190
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
191 /**
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
192 * @return null iff the check succeeds, otherwise a (non-null) descriptive message.
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
193 */
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
194 public static String checkInvokeConditions(Invoke invoke) {
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
195 if (invoke.predecessor() == null || !invoke.asNode().isAlive()) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
196 return "the invoke is dead code";
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
197 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
198 if (!(invoke.callTarget() instanceof MethodCallTargetNode)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
199 return "the invoke has already been lowered, or has been created as a low-level node";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
201 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
202 if (callTarget.targetMethod() == null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
203 return "target method is null";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204 }
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
205 if (invoke.stateAfter() == null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
206 // TODO (chaeubl): why should an invoke not have a state after?
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
207 return "the invoke has no after state";
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
208 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
209 if (!invoke.useForInlining()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
210 return "the invoke is marked to be not used for inlining";
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
211 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
212 ValueNode receiver = callTarget.receiver();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
213 if (receiver != null && receiver.isConstant() && receiver.asConstant().isNull()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
214 return "receiver is null";
8229
3d33975f6497 move test for null exception object passed to unwind operation from stub code to extra HIR
Doug Simon <doug.simon@oracle.com>
parents: 7901
diff changeset
215 }
3d33975f6497 move test for null exception object passed to unwind operation from stub code to extra HIR
Doug Simon <doug.simon@oracle.com>
parents: 7901
diff changeset
216 return null;
3d33975f6497 move test for null exception object passed to unwind operation from stub code to extra HIR
Doug Simon <doug.simon@oracle.com>
parents: 7901
diff changeset
217 }
3d33975f6497 move test for null exception object passed to unwind operation from stub code to extra HIR
Doug Simon <doug.simon@oracle.com>
parents: 7901
diff changeset
218
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14869
diff changeset
221 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 * @param invoke the invoke that will be replaced
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 * @param inlineGraph the graph that the invoke will be replaced with
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
224 * @param receiverNullCheck true if a null check needs to be generated for non-static inlinings,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
225 * false if no such check is required
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
226 * @param canonicalizedNodes if non-null then append to this list any nodes which should be
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
227 * canonicalized after inlining
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 */
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
229 public static Map<Node, Node> inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck, List<Node> canonicalizedNodes) {
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
230 final NodeInputList<ValueNode> parameters = invoke.callTarget().arguments();
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
231 FixedNode invokeNode = invoke.asNode();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
232 StructuredGraph graph = invokeNode.graph();
13285
54248131f787 InliningPhase asserts correct order on the garph stages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13217
diff changeset
233 assert inlineGraph.getGuardsStage().ordinal() >= graph.getGuardsStage().ordinal();
13977
39076a984c33 lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13953
diff changeset
234 assert !invokeNode.graph().isAfterFloatingReadPhase() : "inline isn't handled correctly after floating reads phase";
39076a984c33 lower arraycopy calls later and support unchecked object arraycopy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13953
diff changeset
235
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 FrameState stateAfter = invoke.stateAfter();
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
237 assert stateAfter == null || stateAfter.isAlive();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
238 if (receiverNullCheck && !((MethodCallTargetNode) invoke.callTarget()).isStatic()) {
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
239 nonNullReceiver(invoke);
9861
2d5c0f7ce7a1 Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9837
diff changeset
240 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
242 ArrayList<Node> nodes = new ArrayList<>(inlineGraph.getNodes().count());
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
243 ArrayList<ReturnNode> returnNodes = new ArrayList<>(4);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 UnwindNode unwindNode = null;
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
245 final StartNode entryPointNode = inlineGraph.start();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 FixedNode firstCFGNode = entryPointNode.next();
11712
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
247 if (firstCFGNode == null) {
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
248 throw new IllegalStateException("Inlined graph is in invalid state");
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
249 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 for (Node node : inlineGraph.getNodes()) {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
251 if (node == entryPointNode || node == entryPointNode.stateAfter() || node instanceof ParameterNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 // Do nothing.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 nodes.add(node);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 if (node instanceof ReturnNode) {
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
256 returnNodes.add((ReturnNode) node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 } 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
258 assert unwindNode == null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 unwindNode = (UnwindNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 }
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
263
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14996
diff changeset
264 final BeginNode prevBegin = BeginNode.prevBegin(invokeNode);
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
265 DuplicationReplacement localReplacement = new DuplicationReplacement() {
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
266
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
267 public Node replacement(Node node) {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
268 if (node instanceof ParameterNode) {
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
269 return parameters.get(((ParameterNode) node).index());
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
270 } else if (node == entryPointNode) {
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
271 return prevBegin;
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
272 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
273 return node;
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
274 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
275 };
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
277 assert invokeNode.successors().first() != null : invoke;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
278 assert invokeNode.predecessor() != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
280 Map<Node, Node> duplicates = graph.addDuplicates(nodes, inlineGraph, inlineGraph.getNodeCount(), localReplacement);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
282 invokeNode.replaceAtPredecessor(firstCFGNodeDuplicate);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 FrameState stateAtExceptionEdge = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 if (invoke instanceof InvokeWithExceptionNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 assert unwindNode.predecessor() != null;
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4312
diff changeset
289 assert invokeWithException.exceptionEdge().successors().count() == 1;
8461
6a8ad083746e The exception edge for invokes should still be a DispatchBeginNode to allow lowering of ExceptionObjectNode after guard lowering
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8441
diff changeset
290 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291 stateAtExceptionEdge = obj.stateAfter();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
293 obj.replaceAtUsages(unwindDuplicate.exception());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 Node n = obj.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 obj.setNext(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 unwindDuplicate.replaceAndDelete(n);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 invokeWithException.killExceptionEdge();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 }
11878
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
300
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
301 // get rid of memory kill
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14996
diff changeset
302 BeginNode begin = invokeWithException.next();
11878
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
303 if (begin instanceof KillingBeginNode) {
13502
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
304 BeginNode newBegin = new BeginNode();
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
305 graph.addAfterFixed(begin, graph.add(newBegin));
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
306 begin.replaceAtUsages(newBegin);
11878
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
307 graph.removeFixed(begin);
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
308 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
312 DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
313 unwindDuplicate.replaceAndDelete(deoptimizeNode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
317 if (stateAfter != null) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
318 processFrameStates(invoke, inlineGraph, duplicates, stateAtExceptionEdge);
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
319 int callerLockDepth = stateAfter.nestedLockDepth();
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
320 if (callerLockDepth != 0) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
321 for (MonitorIdNode original : inlineGraph.getNodes(MonitorIdNode.class)) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
322 MonitorIdNode monitor = (MonitorIdNode) duplicates.get(original);
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
323 monitor.setLockDepth(monitor.getLockDepth() + callerLockDepth);
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
324 }
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8469
diff changeset
325 }
9684
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
326 } else {
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
327 assert checkContainsOnlyInvalidOrAfterFrameState(duplicates);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 }
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
329 if (!returnNodes.isEmpty()) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
330 FixedNode n = invoke.next();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
331 invoke.setNext(null);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
332 if (returnNodes.size() == 1) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
333 ReturnNode returnNode = (ReturnNode) duplicates.get(returnNodes.get(0));
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
334 Node returnValue = returnNode.result();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
335 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
336 returnNode.replaceAndDelete(n);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
337 } else {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
338 ArrayList<ReturnNode> returnDuplicates = new ArrayList<>(returnNodes.size());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
339 for (ReturnNode returnNode : returnNodes) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
340 returnDuplicates.add((ReturnNode) duplicates.get(returnNode));
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
341 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
342 MergeNode merge = graph.add(new MergeNode());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
343 merge.setStateAfter(stateAfter);
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
344 ValueNode returnValue = mergeReturns(merge, returnDuplicates, canonicalizedNodes);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
345 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
346 merge.setNext(n);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
350 invokeNode.replaceAtUsages(null);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
351 GraphUtil.killCFG(invokeNode);
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
352
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
353 return duplicates;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 }
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
355
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
356 protected static void processFrameStates(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates, FrameState stateAtExceptionEdge) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
357 FrameState stateAtReturn = invoke.stateAfter();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
358 FrameState outerFrameState = null;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
359 Kind invokeReturnKind = invoke.asNode().getKind();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
360 for (FrameState original : inlineGraph.getNodes(FrameState.class)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
361 FrameState frameState = (FrameState) duplicates.get(original);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
362 if (frameState != null && frameState.isAlive()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
363 if (frameState.bci == BytecodeFrame.AFTER_BCI) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
364 /*
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
365 * pop return kind from invoke's stateAfter and replace with this frameState's
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
366 * return value (top of stack)
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
367 */
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
368 FrameState stateAfterReturn = stateAtReturn;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
369 if (invokeReturnKind != Kind.Void && frameState.stackSize() > 0 && stateAfterReturn.stackAt(0) != frameState.stackAt(0)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
370 stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, frameState.stackAt(0));
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
371 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
372 frameState.replaceAndDelete(stateAfterReturn);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
373 } else if (stateAtExceptionEdge != null && isStateAfterException(frameState)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
374 /*
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
375 * pop exception object from invoke's stateAfter and replace with this
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
376 * frameState's exception object (top of stack)
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
377 */
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
378 FrameState stateAfterException = stateAtExceptionEdge;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
379 if (frameState.stackSize() > 0 && stateAtExceptionEdge.stackAt(0) != frameState.stackAt(0)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
380 stateAfterException = stateAtExceptionEdge.duplicateModified(Kind.Object, frameState.stackAt(0));
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
381 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
382 frameState.replaceAndDelete(stateAfterException);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
383 } else if (frameState.bci == BytecodeFrame.UNWIND_BCI || frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
384 handleMissingAfterExceptionFrameState(frameState);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
385 } else {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
386 // only handle the outermost frame states
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
387 if (frameState.outerFrameState() == null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
388 assert frameState.bci != BytecodeFrame.BEFORE_BCI : frameState;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
389 assert frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method());
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
390 assert frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI && frameState.bci != BytecodeFrame.BEFORE_BCI && frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI &&
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
391 frameState.bci != BytecodeFrame.UNWIND_BCI : frameState.bci;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
392 if (outerFrameState == null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
393 outerFrameState = stateAtReturn.duplicateModified(invoke.bci(), stateAtReturn.rethrowException(), invokeReturnKind);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
394 outerFrameState.setDuringCall(true);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
395 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
396 frameState.setOuterFrameState(outerFrameState);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
397 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
398 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
399 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
400 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
401 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
402
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
403 private static boolean isStateAfterException(FrameState frameState) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
404 return frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI || (frameState.bci == BytecodeFrame.UNWIND_BCI && !frameState.method().isSynchronized());
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
405 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
406
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
407 protected static void handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
408 Graph graph = nonReplaceableFrameState.graph();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
409 NodeWorkList workList = graph.createNodeWorkList();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
410 workList.add(nonReplaceableFrameState);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
411 for (Node node : workList) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
412 FrameState fs = (FrameState) node;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
413 for (Node usage : fs.usages().snapshot()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
414 if (!usage.isAlive()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
415 continue;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
416 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
417 if (usage instanceof FrameState) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
418 workList.add(usage);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
419 } else {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
420 StateSplit stateSplit = (StateSplit) usage;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
421 FixedNode fixedStateSplit = stateSplit.asNode();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
422 if (fixedStateSplit instanceof MergeNode) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
423 MergeNode merge = (MergeNode) fixedStateSplit;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
424 while (merge.isAlive()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
425 AbstractEndNode end = merge.forwardEnds().first();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
426 DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
427 end.replaceAtPredecessor(deoptimizeNode);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
428 GraphUtil.killCFG(end);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
429 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
430 } else {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
431 FixedNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
432 if (fixedStateSplit instanceof BeginNode) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
433 deoptimizeNode = BeginNode.begin(deoptimizeNode);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
434 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
435 fixedStateSplit.replaceAtPredecessor(deoptimizeNode);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
436 GraphUtil.killCFG(fixedStateSplit);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
437 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
438 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
439 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
440 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
441 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
442
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
443 public static ValueNode mergeReturns(MergeNode merge, List<? extends ReturnNode> returnNodes, List<Node> canonicalizedNodes) {
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
444 PhiNode returnValuePhi = null;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
445
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
446 for (ReturnNode returnNode : returnNodes) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
447 // create and wire up a new EndNode
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
448 EndNode endNode = merge.graph().add(new EndNode());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
449 merge.addForwardEnd(endNode);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
450
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
451 if (returnNode.result() != null) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
452 if (returnValuePhi == null) {
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14906
diff changeset
453 returnValuePhi = merge.graph().addWithoutUnique(new ValuePhiNode(returnNode.result().stamp().unrestricted(), merge));
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
454 if (canonicalizedNodes != null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
455 canonicalizedNodes.add(returnValuePhi);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
456 }
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
457 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
458 returnValuePhi.addInput(returnNode.result());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
459 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
460 returnNode.replaceAndDelete(endNode);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
461
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
462 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
463 return returnValuePhi;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
464 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
465
9684
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
466 private static boolean checkContainsOnlyInvalidOrAfterFrameState(Map<Node, Node> duplicates) {
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
467 for (Node node : duplicates.values()) {
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
468 if (node instanceof FrameState) {
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
469 FrameState frameState = (FrameState) node;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
470 assert frameState.bci == BytecodeFrame.AFTER_BCI || frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger);
9684
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
471 }
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
472 }
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
473 return true;
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
474 }
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
475
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
476 /**
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
477 * Gets the receiver for an invoke, adding a guard if necessary to ensure it is non-null.
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
478 */
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
479 public static ValueNode nonNullReceiver(Invoke invoke) {
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
480 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
481 assert !callTarget.isStatic() : callTarget.targetMethod();
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9470
diff changeset
482 StructuredGraph graph = callTarget.graph();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
483 ValueNode firstParam = callTarget.arguments().get(0);
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
484 if (firstParam.getKind() == Kind.Object && !StampTool.isObjectNonNull(firstParam)) {
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
485 IsNullNode condition = graph.unique(new IsNullNode(firstParam));
10692
bebc9672f45e stamp for GuardingPiNode is determined by caller of constructor, not within constructor
Doug Simon <doug.simon@oracle.com>
parents: 10651
diff changeset
486 Stamp stamp = firstParam.stamp().join(objectNonNull());
bebc9672f45e stamp for GuardingPiNode is determined by caller of constructor, not within constructor
Doug Simon <doug.simon@oracle.com>
parents: 10651
diff changeset
487 GuardingPiNode nonNullReceiver = graph.add(new GuardingPiNode(firstParam, condition, true, NullCheckException, InvalidateReprofile, stamp));
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
488 graph.addBeforeFixed(invoke.asNode(), nonNullReceiver);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
489 callTarget.replaceFirstInput(firstParam, nonNullReceiver);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
490 return nonNullReceiver;
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
491 }
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
492 return firstParam;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
494
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
495 public static boolean canIntrinsify(Replacements replacements, ResolvedJavaMethod target) {
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
496 return getIntrinsicGraph(replacements, target) != null || getMacroNodeClass(replacements, target) != null;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
497 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
498
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
499 public static StructuredGraph getIntrinsicGraph(Replacements replacements, ResolvedJavaMethod target) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8617
diff changeset
500 return replacements.getMethodSubstitution(target);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
501 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
502
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
503 public static Class<? extends FixedWithNextNode> getMacroNodeClass(Replacements replacements, ResolvedJavaMethod target) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8617
diff changeset
504 return replacements.getMacroSubstitution(target);
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
505 }
10644
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
506
13601
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
507 public static FixedWithNextNode inlineMacroNode(Invoke invoke, ResolvedJavaMethod concrete, Class<? extends FixedWithNextNode> macroNodeClass) throws GraalInternalError {
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
508 StructuredGraph graph = invoke.asNode().graph();
14160
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 13977
diff changeset
509 if (!concrete.equals(((MethodCallTargetNode) invoke.callTarget()).targetMethod())) {
10644
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
510 assert ((MethodCallTargetNode) invoke.callTarget()).invokeKind() != InvokeKind.Static;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
511 InliningUtil.replaceInvokeCallTarget(invoke, graph, InvokeKind.Special, concrete);
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
512 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
513
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
514 FixedWithNextNode macroNode = createMacroNodeInstance(macroNodeClass, invoke);
10644
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
515
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
516 CallTargetNode callTarget = invoke.callTarget();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
517 if (invoke instanceof InvokeNode) {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
518 graph.replaceFixedWithFixed((InvokeNode) invoke, graph.add(macroNode));
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
519 } else {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
520 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
521 invokeWithException.killExceptionEdge();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
522 graph.replaceSplitWithFixed(invokeWithException, graph.add(macroNode), invokeWithException.next());
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
523 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
524 GraphUtil.killWithUnusedFloatingInputs(callTarget);
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
525 return macroNode;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
526 }
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
527
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
528 private static FixedWithNextNode createMacroNodeInstance(Class<? extends FixedWithNextNode> macroNodeClass, Invoke invoke) throws GraalInternalError {
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
529 try {
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
530 return macroNodeClass.getConstructor(Invoke.class).newInstance(invoke);
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
531 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15152
diff changeset
532 throw new GraalGraphInternalError(e).addContext(invoke.asNode()).addContext("macroSubstitution", macroNodeClass);
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
533 }
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
534 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 }