Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java @ 18995:a2cb19764970
Rename MergeNode to AbstractMergeNode.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 28 Jan 2015 01:04:20 +0100 |
parents | 8b4ef818169c |
children | 46c2e70d54ad |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18142
diff
changeset
|
2 * Copyright (c) 2012, 2014, 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 |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
30 import java.lang.reflect.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
33 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
|
34 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15152
diff
changeset
|
35 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
|
36 import com.oracle.graal.compiler.common.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 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
|
38 import com.oracle.graal.debug.Debug.Scope; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 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
|
40 import com.oracle.graal.graph.Graph.DuplicationReplacement; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16709
diff
changeset
|
41 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.nodes.*; |
16563
1e63cb55f61d
Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16480
diff
changeset
|
43 import com.oracle.graal.nodes.CallTargetNode.InvokeKind; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
44 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
45 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
46 import com.oracle.graal.nodes.java.*; |
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
|
47 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
|
48 import com.oracle.graal.nodes.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
49 import com.oracle.graal.nodes.util.*; |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
50 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
|
51 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 public class InliningUtil { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7510
diff
changeset
|
53 |
7071 | 54 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
|
55 /** |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7558
diff
changeset
|
56 * 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
|
57 * 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
|
58 * 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
|
59 */ |
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 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
|
61 |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
62 /** |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
63 * Print a HotSpot-style inlining message to the console. |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
64 */ |
9722
b5dd7e3c8c80
Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9711
diff
changeset
|
65 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
|
66 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
|
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 /** |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
70 * Print a HotSpot-style inlining message to the console. |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
71 */ |
9722
b5dd7e3c8c80
Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9711
diff
changeset
|
72 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
|
73 if (HotSpotPrintInlining.getValue()) { |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
74 // 1234567 |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
75 TTY.print(" "); // print timestamp |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
76 // 1234 |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
77 TTY.print(" "); // print compilation number |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
78 // % s ! b n |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
79 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
|
80 TTY.print(" "); // more indent |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
81 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
|
82 for (int i = 0; i < inliningDepth; i++) { |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
83 TTY.print(" "); |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
84 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
85 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
|
86 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
87 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
88 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
89 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
|
90 logInliningDecision(info, inliningDepth, allowLogging, true, msg, args); |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
91 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8649
diff
changeset
|
92 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
93 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
|
94 logInliningDecision(info, inliningDepth, true, false, msg, args); |
7071 | 95 } |
96 | |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
97 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
|
98 if (allowLogging) { |
9722
b5dd7e3c8c80
Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9711
diff
changeset
|
99 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
|
100 if (shouldLogInliningDecision()) { |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
101 logInliningDecision(methodName(info), success, msg, args); |
e538498d6eae
some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9699
diff
changeset
|
102 } |
7071 | 103 } |
104 } | |
105 | |
106 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
|
107 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
|
108 // Can't use log here since we are varargs |
14869
89a079df9cb4
Backout changeset ae7cbf13e765708f228be3e2e666e13d421bbd8e
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14865
diff
changeset
|
109 if (Debug.isLogEnabled()) { |
14719
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14708
diff
changeset
|
110 Debug.logv(msg, args); |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14708
diff
changeset
|
111 } |
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
|
112 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
115 public static void logNotInlinedMethod(Invoke invoke, String msg) { |
7071 | 116 if (shouldLogInliningDecision()) { |
7391
36dafe48bc38
added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7388
diff
changeset
|
117 String methodString = invoke.toString() + (invoke.callTarget() == null ? " callTarget=null" : invoke.callTarget().targetName()); |
7071 | 118 logInliningDecision(methodString, false, msg, new Object[0]); |
119 } | |
120 } | |
121 | |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
122 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
|
123 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
|
124 } |
ceb8c5b29419
print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7098
diff
changeset
|
125 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
126 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
|
127 printInlining(method, invoke, inliningDepth, false, msg, args); |
7071 | 128 if (shouldLogInliningDecision()) { |
129 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
|
130 logInliningDecision(methodString, false, msg, args); |
7071 | 131 } |
132 } | |
133 | |
134 private static void logInliningDecision(final String methodString, final boolean success, final String msg, final Object... args) { | |
135 String inliningMsg = "inlining " + methodString + ": " + msg; | |
136 if (!success) { | |
137 inliningMsg = "not " + inliningMsg; | |
138 } | |
139 logInliningDecision(inliningMsg, args); | |
140 } | |
141 | |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7392
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 } |
7071 | 146 } |
147 | |
148 private static String methodName(ResolvedJavaMethod method, Invoke invoke) { | |
149 if (invoke != null && invoke.stateAfter() != null) { | |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16330
diff
changeset
|
150 return methodName(invoke.stateAfter(), invoke.bci()) + ": " + method.format("%H.%n(%p):%r") + " (" + method.getCodeSize() + " bytes)"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 } else { |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16330
diff
changeset
|
152 return method.format("%H.%n(%p):%r") + " (" + method.getCodeSize() + " bytes)"; |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 |
7071 | 156 private static String methodName(InlineInfo info) { |
157 if (info == null) { | |
158 return "null"; | |
159 } else if (info.invoke() != null && info.invoke().stateAfter() != null) { | |
160 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
|
161 } 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
|
162 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
|
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 |
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 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
|
167 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
|
168 if (frameState.outerFrameState() != null) { |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
169 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci)); |
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
|
170 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
|
171 } |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16330
diff
changeset
|
172 sb.append(frameState.method().format("%h.%n")); |
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
|
173 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
|
174 return sb.toString(); |
5127
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
175 } |
7b2efb5ff2ea
better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5114
diff
changeset
|
176 |
9310
b0f9ab5a185b
Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
177 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
|
178 MethodCallTargetNode oldCallTarget = (MethodCallTargetNode) invoke.callTarget(); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
179 MethodCallTargetNode newCallTarget = graph.add(new MethodCallTargetNode(invokeKind, targetMethod, oldCallTarget.arguments().toArray(new ValueNode[0]), oldCallTarget.returnType())); |
9310
b0f9ab5a185b
Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
180 invoke.asNode().replaceFirstInput(oldCallTarget, newCallTarget); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
183 public static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) { |
18416
0c6504598b65
StampTool: add more methods to create object stamps to avoid using too many boolean arguments, add some javadoc, use them.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18228
diff
changeset
|
184 return createAnchoredReceiver(graph, anchor, receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredTrustedNonNull(commonType)); |
10041
595f1f253ef4
Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10040
diff
changeset
|
185 } |
595f1f253ef4
Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10040
diff
changeset
|
186 |
10706
8d961f93725c
Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10692
diff
changeset
|
187 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
|
188 // to avoid that floating reads on receiver fields float above the type check |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
189 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
|
190 } |
495a81cd6969
avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4635
diff
changeset
|
191 |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
192 /** |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
193 * @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
|
194 */ |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
195 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
|
196 if (invoke.predecessor() == null || !invoke.asNode().isAlive()) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
197 return "the invoke is dead code"; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
198 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
199 if (!(invoke.callTarget() instanceof MethodCallTargetNode)) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
200 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
|
201 } |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
202 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
203 if (callTarget.targetMethod() == null) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
204 return "target method is null"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 } |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
206 if (invoke.stateAfter() == null) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
207 // 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
|
208 return "the invoke has no after state"; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
209 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
210 if (!invoke.useForInlining()) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
211 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
|
212 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
213 ValueNode receiver = callTarget.receiver(); |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18416
diff
changeset
|
214 if (receiver != null && receiver.isConstant() && receiver.isNullConstant()) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
215 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
|
216 } |
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 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
|
218 } |
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
|
219 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph. |
14906 | 222 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 * @param invoke the invoke that will be replaced |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 * @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
|
225 * @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
|
226 * false if no such check is required |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
227 * @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
|
228 * canonicalized after inlining |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 */ |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
230 public static Map<Node, Node> inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck, List<Node> canonicalizedNodes) { |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
231 if (Fingerprint.ENABLED) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
232 Fingerprint.submit("inlining %s into %s: %s", formatGraph(inlineGraph), formatGraph(invoke.asNode().graph()), inlineGraph.getNodes().snapshot()); |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
233 } |
11669
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
234 final NodeInputList<ValueNode> parameters = invoke.callTarget().arguments(); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
235 FixedNode invokeNode = invoke.asNode(); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
236 StructuredGraph graph = invokeNode.graph(); |
13285
54248131f787
InliningPhase asserts correct order on the garph stages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13217
diff
changeset
|
237 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
|
238 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
|
239 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 FrameState stateAfter = invoke.stateAfter(); |
9672
67804a97c1ce
allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents:
9610
diff
changeset
|
241 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
|
242 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
|
243 nonNullReceiver(invoke); |
9861
2d5c0f7ce7a1
Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9837
diff
changeset
|
244 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 |
11669
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
246 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
|
247 ArrayList<ReturnNode> returnNodes = new ArrayList<>(4); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 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
|
249 final StartNode entryPointNode = inlineGraph.start(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 FixedNode firstCFGNode = entryPointNode.next(); |
11712
0d16339188ef
Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11710
diff
changeset
|
251 if (firstCFGNode == null) { |
18142
a94e85e5256b
InliningUtil: tell which graph in error message.
Bernhard Urban <bernhard.urban@jku.at>
parents:
17328
diff
changeset
|
252 throw new IllegalStateException("Inlined graph is in invalid state: " + inlineGraph); |
11712
0d16339188ef
Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11710
diff
changeset
|
253 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 for (Node node : inlineGraph.getNodes()) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13554
diff
changeset
|
255 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
|
256 // Do nothing. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 nodes.add(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 if (node instanceof ReturnNode) { |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
260 returnNodes.add((ReturnNode) node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 } 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
|
262 assert unwindNode == null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 unwindNode = (UnwindNode) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 } |
11669
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
267 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
268 final AbstractBeginNode prevBegin = AbstractBeginNode.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
|
269 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
|
270 |
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
271 public Node replacement(Node node) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13554
diff
changeset
|
272 if (node instanceof ParameterNode) { |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13554
diff
changeset
|
273 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
|
274 } 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
|
275 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
|
276 } |
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
277 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
|
278 } |
a625d254e137
Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11657
diff
changeset
|
279 }; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
281 assert invokeNode.successors().first() != null : invoke; |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
282 assert invokeNode.predecessor() != null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11669
diff
changeset
|
284 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
|
285 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
286 invokeNode.replaceAtPredecessor(firstCFGNodeDuplicate); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 FrameState stateAtExceptionEdge = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 if (invoke instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 assert unwindNode.predecessor() != null; |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4312
diff
changeset
|
293 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
|
294 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 stateAtExceptionEdge = obj.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
4455 | 297 obj.replaceAtUsages(unwindDuplicate.exception()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 Node n = obj.next(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 obj.setNext(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 unwindDuplicate.replaceAndDelete(n); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 invokeWithException.killExceptionEdge(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 } |
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
|
304 |
39e9ec0cf310
Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents:
11839
diff
changeset
|
305 // get rid of memory kill |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
306 AbstractBeginNode 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
|
307 if (begin instanceof KillingBeginNode) { |
18994
8b4ef818169c
Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
308 AbstractBeginNode newBegin = new BeginNode(); |
13502
89a9d3f5bc17
Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13378
diff
changeset
|
309 graph.addAfterFixed(begin, graph.add(newBegin)); |
89a9d3f5bc17
Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13378
diff
changeset
|
310 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
|
311 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
|
312 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 if (unwindNode != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
316 DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler)); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
317 unwindDuplicate.replaceAndDelete(deoptimizeNode); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 |
16573
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
321 processSimpleInfopoints(invoke, inlineGraph, duplicates); |
9672
67804a97c1ce
allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents:
9610
diff
changeset
|
322 if (stateAfter != null) { |
16594
c4104e5ef7ab
correctly handle inlining of method with multiple returns
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16573
diff
changeset
|
323 processFrameStates(invoke, inlineGraph, duplicates, stateAtExceptionEdge, returnNodes.size() > 1); |
9672
67804a97c1ce
allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents:
9610
diff
changeset
|
324 int callerLockDepth = stateAfter.nestedLockDepth(); |
13554
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13502
diff
changeset
|
325 if (callerLockDepth != 0) { |
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13502
diff
changeset
|
326 for (MonitorIdNode original : inlineGraph.getNodes(MonitorIdNode.class)) { |
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13502
diff
changeset
|
327 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
|
328 monitor.setLockDepth(monitor.getLockDepth() + callerLockDepth); |
67804a97c1ce
allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents:
9610
diff
changeset
|
329 } |
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
|
330 } |
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
|
331 } 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
|
332 assert checkContainsOnlyInvalidOrAfterFrameState(duplicates); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 } |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
334 if (!returnNodes.isEmpty()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
335 FixedNode n = invoke.next(); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
336 invoke.setNext(null); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
337 if (returnNodes.size() == 1) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
338 ReturnNode returnNode = (ReturnNode) duplicates.get(returnNodes.get(0)); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
339 Node returnValue = returnNode.result(); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
340 invokeNode.replaceAtUsages(returnValue); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
341 returnNode.replaceAndDelete(n); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
342 } else { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
343 ArrayList<ReturnNode> returnDuplicates = new ArrayList<>(returnNodes.size()); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
344 for (ReturnNode returnNode : returnNodes) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
345 returnDuplicates.add((ReturnNode) duplicates.get(returnNode)); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
346 } |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18994
diff
changeset
|
347 AbstractMergeNode merge = graph.add(new AbstractMergeNode()); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
348 merge.setStateAfter(stateAfter); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
349 ValueNode returnValue = mergeReturns(merge, returnDuplicates, canonicalizedNodes); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
350 invokeNode.replaceAtUsages(returnValue); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
351 merge.setNext(n); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
355 invokeNode.replaceAtUsages(null); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
356 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
|
357 |
75c18356504d
Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7257
diff
changeset
|
358 return duplicates; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 } |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
360 |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
361 private static String formatGraph(StructuredGraph graph) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
362 if (graph.method() == null) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
363 return graph.name; |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
364 } |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
365 return graph.method().format("%H.%n(%p)"); |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
366 } |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
367 |
16573
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
368 private static void processSimpleInfopoints(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates) { |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
369 if (inlineGraph.getNodes(SimpleInfopointNode.class).isEmpty()) { |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
370 return; |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
371 } |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
372 BytecodePosition pos = new BytecodePosition(toBytecodePosition(invoke.stateAfter()), invoke.asNode().graph().method(), invoke.bci()); |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
373 for (SimpleInfopointNode original : inlineGraph.getNodes(SimpleInfopointNode.class)) { |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
374 SimpleInfopointNode duplicate = (SimpleInfopointNode) duplicates.get(original); |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
375 duplicate.addCaller(pos); |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
376 } |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
377 } |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
378 |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
379 private static BytecodePosition toBytecodePosition(FrameState fs) { |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
380 if (fs == null) { |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
381 return null; |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
382 } |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
383 return new BytecodePosition(toBytecodePosition(fs.outerFrameState()), fs.method(), fs.bci); |
16573
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
384 } |
a2ec1ac769e4
Add simple infopoint nodes which do not contain debugging informations for values. Use them when shouldDebugNonSafepoints is true.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16563
diff
changeset
|
385 |
16594
c4104e5ef7ab
correctly handle inlining of method with multiple returns
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16573
diff
changeset
|
386 protected static void processFrameStates(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates, FrameState stateAtExceptionEdge, boolean alwaysDuplicateStateAfter) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
387 FrameState stateAtReturn = invoke.stateAfter(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
388 FrameState outerFrameState = null; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
389 Kind invokeReturnKind = invoke.asNode().getKind(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
390 for (FrameState original : inlineGraph.getNodes(FrameState.class)) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
391 FrameState frameState = (FrameState) duplicates.get(original); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
392 if (frameState != null && frameState.isAlive()) { |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
393 if (frameState.bci == BytecodeFrame.AFTER_BCI) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
394 /* |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
395 * 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
|
396 * return value (top of stack) |
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 FrameState stateAfterReturn = stateAtReturn; |
16709 | 399 if (invokeReturnKind != Kind.Void && (alwaysDuplicateStateAfter || (frameState.stackSize() > 0 && stateAfterReturn.stackAt(0) != frameState.stackAt(0)))) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
400 stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, frameState.stackAt(0)); |
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 frameState.replaceAndDelete(stateAfterReturn); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
403 } else if (stateAtExceptionEdge != null && isStateAfterException(frameState)) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
404 /* |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
405 * 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
|
406 * frameState's exception object (top of stack) |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
407 */ |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
408 FrameState stateAfterException = stateAtExceptionEdge; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
409 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
|
410 stateAfterException = stateAtExceptionEdge.duplicateModified(Kind.Object, frameState.stackAt(0)); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
411 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
412 frameState.replaceAndDelete(stateAfterException); |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
413 } else if (frameState.bci == BytecodeFrame.UNWIND_BCI || frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) { |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
414 handleMissingAfterExceptionFrameState(frameState); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
415 } else { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
416 // only handle the outermost frame states |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
417 if (frameState.outerFrameState() == null) { |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
418 assert frameState.bci != BytecodeFrame.BEFORE_BCI : frameState; |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
419 assert frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method()); |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
420 assert frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI && frameState.bci != BytecodeFrame.BEFORE_BCI && frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI && |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
421 frameState.bci != BytecodeFrame.UNWIND_BCI : frameState.bci; |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
422 if (outerFrameState == null) { |
18228
ab489bac3bc8
Correct the bci used by stateDuring in ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18187
diff
changeset
|
423 outerFrameState = stateAtReturn.duplicateModifiedDuringCall(invoke.bci(), invokeReturnKind); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
424 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
425 frameState.setOuterFrameState(outerFrameState); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
426 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
427 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
428 } |
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 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
431 |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
432 private static boolean isStateAfterException(FrameState frameState) { |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
433 return frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI || (frameState.bci == BytecodeFrame.UNWIND_BCI && !frameState.method().isSynchronized()); |
16328
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 |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
436 protected static void handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
437 Graph graph = nonReplaceableFrameState.graph(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
438 NodeWorkList workList = graph.createNodeWorkList(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
439 workList.add(nonReplaceableFrameState); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
440 for (Node node : workList) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
441 FrameState fs = (FrameState) node; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
442 for (Node usage : fs.usages().snapshot()) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
443 if (!usage.isAlive()) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
444 continue; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
445 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
446 if (usage instanceof FrameState) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
447 workList.add(usage); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
448 } else { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
449 StateSplit stateSplit = (StateSplit) usage; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
450 FixedNode fixedStateSplit = stateSplit.asNode(); |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18994
diff
changeset
|
451 if (fixedStateSplit instanceof AbstractMergeNode) { |
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18994
diff
changeset
|
452 AbstractMergeNode merge = (AbstractMergeNode) fixedStateSplit; |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
453 while (merge.isAlive()) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
454 AbstractEndNode end = merge.forwardEnds().first(); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
455 DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler)); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
456 end.replaceAtPredecessor(deoptimizeNode); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
457 GraphUtil.killCFG(end); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
458 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
459 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
460 FixedNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler)); |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
461 if (fixedStateSplit instanceof AbstractBeginNode) { |
18994
8b4ef818169c
Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
462 deoptimizeNode = BeginNode.begin(deoptimizeNode); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
463 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
464 fixedStateSplit.replaceAtPredecessor(deoptimizeNode); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
465 GraphUtil.killCFG(fixedStateSplit); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
466 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
467 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
468 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
469 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
470 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
471 |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18994
diff
changeset
|
472 public static ValueNode mergeReturns(AbstractMergeNode 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
|
473 PhiNode returnValuePhi = null; |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
474 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
475 for (ReturnNode returnNode : returnNodes) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
476 // create and wire up a new EndNode |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
477 EndNode endNode = merge.graph().add(new EndNode()); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
478 merge.addForwardEnd(endNode); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
479 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
480 if (returnNode.result() != null) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
481 if (returnValuePhi == null) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
482 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
|
483 if (canonicalizedNodes != null) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
484 canonicalizedNodes.add(returnValuePhi); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15200
diff
changeset
|
485 } |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
486 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
487 returnValuePhi.addInput(returnNode.result()); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
488 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
489 returnNode.replaceAndDelete(endNode); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
490 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
491 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
492 return returnValuePhi; |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
493 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13615
diff
changeset
|
494 |
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
|
495 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
|
496 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
|
497 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
|
498 FrameState frameState = (FrameState) node; |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
499 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
|
500 } |
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
|
501 } |
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
|
502 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
|
503 } |
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
|
504 |
10637
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
505 /** |
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
506 * 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
|
507 */ |
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 StructuredGraph graph = callTarget.graph(); |
10637
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
512 ValueNode firstParam = callTarget.arguments().get(0); |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18487
diff
changeset
|
513 if (firstParam.getKind() == Kind.Object && !StampTool.isPointerNonNull(firstParam)) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
514 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
|
515 Stamp stamp = firstParam.stamp().join(objectNonNull()); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
516 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
|
517 graph.addBeforeFixed(invoke.asNode(), nonNullReceiver); |
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
518 callTarget.replaceFirstInput(firstParam, nonNullReceiver); |
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
519 return nonNullReceiver; |
4451
defa1b705f14
NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4449
diff
changeset
|
520 } |
10637
ba1fbbfac0cd
remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10041
diff
changeset
|
521 return firstParam; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 } |
7071 | 523 |
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
|
524 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
|
525 return getIntrinsicGraph(replacements, target) != null || getMacroNodeClass(replacements, target) != null; |
7071 | 526 } |
527 | |
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
|
528 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
|
529 return replacements.getMethodSubstitution(target); |
7071 | 530 } |
531 | |
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
|
532 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
|
533 return replacements.getMacroSubstitution(target); |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7392
diff
changeset
|
534 } |
10644
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
535 |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13554
diff
changeset
|
536 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
|
537 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
|
538 if (!concrete.equals(((MethodCallTargetNode) invoke.callTarget()).targetMethod())) { |
18822
fad37aaed6d2
Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18490
diff
changeset
|
539 assert ((MethodCallTargetNode) invoke.callTarget()).invokeKind().hasReceiver(); |
10644
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
540 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
|
541 } |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
542 |
13128
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
543 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
|
544 |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
545 CallTargetNode callTarget = invoke.callTarget(); |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
546 if (invoke instanceof InvokeNode) { |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
547 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
|
548 } else { |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
549 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
550 invokeWithException.killExceptionEdge(); |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
551 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
|
552 } |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
553 GraphUtil.killWithUnusedFloatingInputs(callTarget); |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
554 return macroNode; |
90a7a58bf54f
Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10041
diff
changeset
|
555 } |
13128
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
556 |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
557 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
|
558 try { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
559 Constructor<?> cons = macroNodeClass.getDeclaredConstructor(Invoke.class); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18822
diff
changeset
|
560 return (FixedWithNextNode) cons.newInstance(invoke); |
13128
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
561 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15152
diff
changeset
|
562 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
|
563 } |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
564 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 } |