annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java @ 21682:df4579cb9503

Infer stamp in newly created return value phi in the inlining utility.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 03 Jun 2015 02:40:53 +0200
parents cd6b1b2189a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
25 import com.oracle.jvmci.code.BytecodeFrame;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
26 import com.oracle.jvmci.code.BytecodePosition;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
27 import com.oracle.jvmci.meta.ResolvedJavaType;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
28 import com.oracle.jvmci.meta.Assumptions;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
29 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
30 import com.oracle.jvmci.meta.DeoptimizationReason;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
31 import com.oracle.jvmci.meta.DeoptimizationAction;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
32 import com.oracle.jvmci.meta.ResolvedJavaMethod;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
33 import static com.oracle.jvmci.meta.DeoptimizationAction.*;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
34 import static com.oracle.jvmci.meta.DeoptimizationReason.*;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
35 import static com.oracle.graal.compiler.common.GraalOptions.*;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
36 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
37
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
38 import java.lang.reflect.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
41 import com.oracle.graal.api.replacements.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
42 import com.oracle.graal.compiler.common.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 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
44 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
45 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
46 import com.oracle.graal.nodes.*;
16563
1e63cb55f61d Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16480
diff changeset
47 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
48 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
49 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
50 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
51 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
52 import com.oracle.graal.nodes.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
53 import com.oracle.graal.nodes.util.*;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
54 import com.oracle.graal.phases.common.inlining.info.*;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21477
diff changeset
55 import com.oracle.jvmci.common.*;
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21543
diff changeset
56 import com.oracle.jvmci.debug.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21543
diff changeset
57 import com.oracle.jvmci.debug.Debug.Scope;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 public class InliningUtil {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
60
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
61 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
62
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
63 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
64 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
65 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
66 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
67 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
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 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
71 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
72 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
73 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
74 if (HotSpotPrintInlining.getValue()) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
75 // 1234567
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
76 TTY.print(" "); // print timestamp
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
77 // 1234
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
78 TTY.print(" "); // print compilation number
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
79 // % s ! b n
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
80 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
81 TTY.print(" "); // more indent
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
82 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
83 for (int i = 0; i < inliningDepth; i++) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
84 TTY.print(" ");
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
85 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
86 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
87 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
88 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
89
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
90 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
91 logInliningDecision(info, inliningDepth, allowLogging, true, msg, args);
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
92 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
93
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
94 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
95 logInliningDecision(info, inliningDepth, true, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
96 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
97
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
98 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
99 if (allowLogging) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
100 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
101 if (shouldLogInliningDecision()) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
102 logInliningDecision(methodName(info), success, msg, args);
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
103 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
104 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
105 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
106
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
107 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
108 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
109 // Can't use log here since we are varargs
14869
89a079df9cb4 Backout changeset ae7cbf13e765708f228be3e2e666e13d421bbd8e
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14865
diff changeset
110 if (Debug.isLogEnabled()) {
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
111 Debug.logv(msg, args);
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
112 }
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
113 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
116 public static void logNotInlinedMethod(Invoke invoke, String msg) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
117 if (shouldLogInliningDecision()) {
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
118 String methodString = invoke.toString();
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
119 if (invoke.callTarget() == null) {
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
120 methodString += " callTarget=null";
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
121 } else {
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
122 String targetName = invoke.callTarget().targetName();
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
123 if (!methodString.endsWith(targetName)) {
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
124 methodString += " " + targetName;
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
125 }
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
126 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
127 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
128 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
129 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
130
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
131 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
132 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
133 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
134
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
135 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
136 printInlining(method, invoke, inliningDepth, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
137 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
138 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
139 logInliningDecision(methodString, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
140 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
141 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
142
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
143 private static void logInliningDecision(final String methodString, final boolean success, final String msg, final Object... args) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
144 String inliningMsg = "inlining " + methodString + ": " + msg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
145 if (!success) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
146 inliningMsg = "not " + inliningMsg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
147 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
148 logInliningDecision(inliningMsg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
149 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
150
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
151 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
152 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
153 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
154 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
155 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
156
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
157 private static String methodName(ResolvedJavaMethod method, Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
158 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
159 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
160 } 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
161 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
162 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
165 private static String methodName(InlineInfo info) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
166 if (info == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
167 return "null";
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
168 } else if (info.invoke() != null && info.invoke().stateAfter() != null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
169 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
170 } 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
171 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
172 }
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 }
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
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
175 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
176 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
177 if (frameState.outerFrameState() != null) {
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
178 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
179 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
180 }
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
181 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
182 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
183 return sb.toString();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
184 }
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
185
9310
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
186 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
187 MethodCallTargetNode oldCallTarget = (MethodCallTargetNode) invoke.callTarget();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
188 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
189 invoke.asNode().replaceFirstInput(oldCallTarget, newCallTarget);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
192 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
193 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
194 }
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
195
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
196 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
197 // 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
198 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
199 }
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
200
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
201 /**
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
202 * @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
203 */
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
204 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
205 if (invoke.predecessor() == null || !invoke.asNode().isAlive()) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
206 return "the invoke is dead code";
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
207 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
208 if (!(invoke.callTarget() instanceof MethodCallTargetNode)) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
209 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
210 }
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
211 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
212 if (callTarget.targetMethod() == null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
213 return "target method is null";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 }
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19994
diff changeset
215 assert invoke.stateAfter() != null : invoke;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
216 if (!invoke.useForInlining()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
217 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
218 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
219 ValueNode receiver = callTarget.receiver();
18487
0f4813e0b4a9 Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
220 if (receiver != null && receiver.isConstant() && receiver.isNullConstant()) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
221 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
222 }
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
223 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
224 }
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
225
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 14869
diff changeset
228 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 * @param invoke the invoke that will be replaced
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 * @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
231 * @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
232 * false if no such check is required
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
233 * @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
234 * canonicalized after inlining
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 */
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
236 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
237 if (Fingerprint.ENABLED) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
238 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
239 }
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
240 final NodeInputList<ValueNode> parameters = invoke.callTarget().arguments();
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
241 FixedNode invokeNode = invoke.asNode();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
242 StructuredGraph graph = invokeNode.graph();
13285
54248131f787 InliningPhase asserts correct order on the garph stages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13217
diff changeset
243 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
244 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
245
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
246 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
247 nonNullReceiver(invoke);
9861
2d5c0f7ce7a1 Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9837
diff changeset
248 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
250 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
251 ArrayList<ReturnNode> returnNodes = new ArrayList<>(4);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 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
253 final StartNode entryPointNode = inlineGraph.start();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 FixedNode firstCFGNode = entryPointNode.next();
11712
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
255 if (firstCFGNode == null) {
18142
a94e85e5256b InliningUtil: tell which graph in error message.
Bernhard Urban <bernhard.urban@jku.at>
parents: 17328
diff changeset
256 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
257 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 for (Node node : inlineGraph.getNodes()) {
20144
921eeb012866 Don't drop entry framestate in inline graph if it has more usages than just the start node.
Roland Schatz <roland.schatz@oracle.com>
parents: 20051
diff changeset
259 if (node == entryPointNode || (node == entryPointNode.stateAfter() && node.usages().count() == 1) || node instanceof ParameterNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 // Do nothing.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 nodes.add(node);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 if (node instanceof ReturnNode) {
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
264 returnNodes.add((ReturnNode) node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 } 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
266 assert unwindNode == null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 unwindNode = (UnwindNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
271
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
272 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
273 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
274
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
275 public Node replacement(Node node) {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
276 if (node instanceof ParameterNode) {
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
277 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
278 } 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
279 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
280 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
281 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
282 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
283 };
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
285 assert invokeNode.successors().first() != null : invoke;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
286 assert invokeNode.predecessor() != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
288 Map<Node, Node> duplicates = graph.addDuplicates(nodes, inlineGraph, inlineGraph.getNodeCount(), localReplacement);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
289
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
290 FrameState stateAfter = invoke.stateAfter();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
291 assert stateAfter == null || stateAfter.isAlive();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 FrameState stateAtExceptionEdge = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 if (invoke instanceof InvokeWithExceptionNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 if (unwindNode != null) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
297 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
298 stateAtExceptionEdge = obj.stateAfter();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
299 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
300 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
301
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
302 processSimpleInfopoints(invoke, inlineGraph, duplicates);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
303 if (stateAfter != null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
304 processFrameStates(invoke, inlineGraph, duplicates, stateAtExceptionEdge, returnNodes.size() > 1);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
305 int callerLockDepth = stateAfter.nestedLockDepth();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
306 if (callerLockDepth != 0) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
307 for (MonitorIdNode original : inlineGraph.getNodes(MonitorIdNode.TYPE)) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
308 MonitorIdNode monitor = (MonitorIdNode) duplicates.get(original);
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
309 processMonitorId(invoke.stateAfter(), monitor);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
310 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
311 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
312 } else {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
313 assert checkContainsOnlyInvalidOrAfterFrameState(duplicates);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
314 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
315
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
316 firstCFGNode = (FixedNode) duplicates.get(firstCFGNode);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
317 for (int i = 0; i < returnNodes.size(); i++) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
318 returnNodes.set(i, (ReturnNode) duplicates.get(returnNodes.get(i)));
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
319 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
320 if (unwindNode != null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
321 unwindNode = (UnwindNode) duplicates.get(unwindNode);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
322 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
323
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 21298
diff changeset
324 finishInlining(invoke, graph, firstCFGNode, returnNodes, unwindNode, inlineGraph.getAssumptions(), inlineGraph, canonicalizedNodes);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
325
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
326 GraphUtil.killCFG(invokeNode);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
327
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
328 return duplicates;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
329 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
330
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
331 public static ValueNode finishInlining(Invoke invoke, StructuredGraph graph, FixedNode firstNode, List<ReturnNode> returnNodes, UnwindNode unwindNode, Assumptions inlinedAssumptions,
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 21298
diff changeset
332 StructuredGraph inlineGraph, List<Node> canonicalizedNodes) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
333 FixedNode invokeNode = invoke.asNode();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
334 FrameState stateAfter = invoke.stateAfter();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
335 assert stateAfter == null || stateAfter.isAlive();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
336
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
337 invokeNode.replaceAtPredecessor(firstNode);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
338
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
339 if (invoke instanceof InvokeWithExceptionNode) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
340 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
341 if (unwindNode != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 assert unwindNode.predecessor() != null;
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4312
diff changeset
343 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
344 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge();
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
345 obj.replaceAtUsages(unwindNode.exception());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 Node n = obj.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 obj.setNext(null);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
348 unwindNode.replaceAndDelete(n);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
349
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
350 obj.replaceAtPredecessor(null);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
351 obj.safeDelete();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 invokeWithException.killExceptionEdge();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 }
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
355
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
356 // get rid of memory kill
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
357 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
358 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
359 AbstractBeginNode newBegin = new BeginNode();
13502
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
360 graph.addAfterFixed(begin, graph.add(newBegin));
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
361 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
362 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
363 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 } else {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
365 if (unwindNode != null && !unwindNode.isDeleted()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
366 DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
367 unwindNode.replaceAndDelete(deoptimizeNode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
371 ValueNode returnValue;
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
372 if (!returnNodes.isEmpty()) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
373 FixedNode n = invoke.next();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
374 invoke.setNext(null);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
375 if (returnNodes.size() == 1) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
376 ReturnNode returnNode = returnNodes.get(0);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
377 returnValue = returnNode.result();
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
378 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
379 returnNode.replaceAndDelete(n);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
380 } else {
18996
46c2e70d54ad Make AbstractMergeNode abstract and introduce concrete subclass MergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
381 AbstractMergeNode merge = graph.add(new MergeNode());
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
382 merge.setStateAfter(stateAfter);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
383 returnValue = mergeReturns(merge, returnNodes, canonicalizedNodes);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
384 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
385 merge.setNext(n);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 }
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
387 } else {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
388 returnValue = null;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
389 invokeNode.replaceAtUsages(null);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
390 GraphUtil.killCFG(invoke.next());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
393 // Copy assumptions from inlinee to caller
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
394 Assumptions assumptions = graph.getAssumptions();
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
395 if (assumptions != null) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
396 if (inlinedAssumptions != null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
397 assumptions.record(inlinedAssumptions);
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
398 }
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
399 } else {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
400 assert inlinedAssumptions == null : "cannot inline graph which makes assumptions into a graph that doesn't";
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
401 }
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 18996
diff changeset
402
19346
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19318
diff changeset
403 // Copy inlined methods from inlinee to caller
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 21298
diff changeset
404 graph.updateInlinedMethods(inlineGraph);
19318
9842ffb5788d copy method dependencies from inlinee to caller
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
405
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
406 return returnValue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 }
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
408
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
409 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
410 if (graph.method() == null) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
411 return graph.name;
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
412 }
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
413 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
414 }
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
415
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
416 private static void processSimpleInfopoints(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19346
diff changeset
417 if (inlineGraph.getNodes(SimpleInfopointNode.TYPE).isEmpty()) {
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
418 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
419 }
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
420 BytecodePosition pos = null;
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19346
diff changeset
421 for (SimpleInfopointNode original : inlineGraph.getNodes(SimpleInfopointNode.TYPE)) {
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
422 SimpleInfopointNode duplicate = (SimpleInfopointNode) duplicates.get(original);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
423 pos = processSimpleInfopoint(invoke, duplicate, pos);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
424 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
425 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
426
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
427 public static BytecodePosition processSimpleInfopoint(Invoke invoke, SimpleInfopointNode infopointNode, BytecodePosition incomingPos) {
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
428 BytecodePosition pos = processBytecodePosition(invoke, incomingPos);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
429 infopointNode.addCaller(pos);
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
430 assert infopointNode.verify();
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
431 return pos;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
432 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
433
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
434 public static BytecodePosition processBytecodePosition(Invoke invoke, BytecodePosition incomingPos) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
435 assert invoke.stateAfter() != null;
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
436 assert incomingPos == null || incomingPos.equals(InliningUtil.processBytecodePosition(invoke, null)) : incomingPos + " " + InliningUtil.processBytecodePosition(invoke, null);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
437 return incomingPos != null ? incomingPos : new BytecodePosition(FrameState.toBytecodePosition(invoke.stateAfter().outerFrameState()), invoke.stateAfter().method(), invoke.bci());
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
438 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21143
diff changeset
439
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
440 public static void processMonitorId(FrameState stateAfter, MonitorIdNode monitorIdNode) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
441 if (stateAfter != null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
442 int callerLockDepth = stateAfter.nestedLockDepth();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
443 monitorIdNode.setLockDepth(monitorIdNode.getLockDepth() + callerLockDepth);
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
444 }
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
445 }
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
446
16594
c4104e5ef7ab correctly handle inlining of method with multiple returns
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16573
diff changeset
447 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
448 FrameState stateAtReturn = invoke.stateAfter();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
449 FrameState outerFrameState = null;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
450 Kind invokeReturnKind = invoke.asNode().getKind();
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19346
diff changeset
451 for (FrameState original : inlineGraph.getNodes(FrameState.TYPE)) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
452 FrameState frameState = (FrameState) duplicates.get(original);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
453 if (frameState != null && frameState.isAlive()) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
454 if (outerFrameState == null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
455 outerFrameState = stateAtReturn.duplicateModifiedDuringCall(invoke.bci(), invokeReturnKind);
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
456 }
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
457 processFrameState(frameState, invoke, inlineGraph.method(), stateAtExceptionEdge, outerFrameState, alwaysDuplicateStateAfter);
16328
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 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
460 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
461
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
462 public static FrameState processFrameState(FrameState frameState, Invoke invoke, ResolvedJavaMethod inlinedMethod, FrameState stateAtExceptionEdge, FrameState outerFrameState,
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
463 boolean alwaysDuplicateStateAfter) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
464
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
465 FrameState stateAtReturn = invoke.stateAfter();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
466 Kind invokeReturnKind = invoke.asNode().getKind();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
467
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
468 if (frameState.bci == BytecodeFrame.AFTER_BCI) {
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
469 FrameState stateAfterReturn = stateAtReturn;
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
470 if (frameState.method() == null) {
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
471 // This is a frame state for a side effect within an intrinsic
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
472 // that was parsed for post-parse intrinsification
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
473 for (Node usage : frameState.usages()) {
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
474 if (usage instanceof ForeignCallNode) {
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
475 // A foreign call inside an intrinsic needs to have
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
476 // the BCI of the invoke being intrinsified
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
477 ForeignCallNode foreign = (ForeignCallNode) usage;
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
478 foreign.setBci(invoke.bci());
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
479 }
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
480 }
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
481 }
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
482
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
483 /*
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
484 * pop return kind from invoke's stateAfter and replace with this frameState's return
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
485 * value (top of stack)
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
486 */
21477
b1e712f66fe0 Make inlining code more robust in the context of inlining substituted graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21473
diff changeset
487 if (frameState.stackSize() > 0 && (alwaysDuplicateStateAfter || stateAfterReturn.stackAt(0) != frameState.stackAt(0))) {
21567
f41409c6ff26 Do not rely on single/double slot information from the Kind of the value in a local variable or expression stack entry. With word type rewriting during parsing, long values can be single slot values when they are rewritten from Object values.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
488 stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, invokeReturnKind, frameState.stackAt(0));
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
489 }
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
490
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
491 frameState.replaceAndDelete(stateAfterReturn);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
492 return stateAfterReturn;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
493 } else if (stateAtExceptionEdge != null && isStateAfterException(frameState)) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
494 /*
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
495 * pop exception object from invoke's stateAfter and replace with this frameState's
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
496 * exception object (top of stack)
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
497 */
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
498 FrameState stateAfterException = stateAtExceptionEdge;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
499 if (frameState.stackSize() > 0 && stateAtExceptionEdge.stackAt(0) != frameState.stackAt(0)) {
21567
f41409c6ff26 Do not rely on single/double slot information from the Kind of the value in a local variable or expression stack entry. With word type rewriting during parsing, long values can be single slot values when they are rewritten from Object values.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
500 stateAfterException = stateAtExceptionEdge.duplicateModified(Kind.Object, Kind.Object, frameState.stackAt(0));
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
501 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
502 frameState.replaceAndDelete(stateAfterException);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
503 return stateAfterException;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
504 } else if (frameState.bci == BytecodeFrame.UNWIND_BCI || frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
505 return handleMissingAfterExceptionFrameState(frameState);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
506 } else if (frameState.bci == BytecodeFrame.BEFORE_BCI) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
507 // This is an intrinsic. Deoptimizing within an intrinsic
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
508 // must re-execute the intrinsified invocation
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
509 assert frameState.outerFrameState() == null;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
510 NodeInputList<ValueNode> invokeArgsList = invoke.callTarget().arguments();
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
511 ValueNode[] invokeArgs = invokeArgsList.isEmpty() ? NO_ARGS : invokeArgsList.toArray(new ValueNode[invokeArgsList.size()]);
21567
f41409c6ff26 Do not rely on single/double slot information from the Kind of the value in a local variable or expression stack entry. With word type rewriting during parsing, long values can be single slot values when they are rewritten from Object values.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
512 ResolvedJavaMethod targetMethod = invoke.callTarget().targetMethod();
f41409c6ff26 Do not rely on single/double slot information from the Kind of the value in a local variable or expression stack entry. With word type rewriting during parsing, long values can be single slot values when they are rewritten from Object values.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
513 FrameState stateBeforeCall = stateAtReturn.duplicateModifiedBeforeCall(invoke.bci(), invokeReturnKind, targetMethod.getSignature().toParameterKinds(!targetMethod.isStatic()), invokeArgs);
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
514 frameState.replaceAndDelete(stateBeforeCall);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
515 return stateBeforeCall;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
516 } else {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
517 // only handle the outermost frame states
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
518 if (frameState.outerFrameState() == null) {
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
519 assert checkInlineeFrameState(invoke, inlinedMethod, frameState);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
520 frameState.setOuterFrameState(outerFrameState);
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
521 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
522 return frameState;
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
523 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
524 }
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
525
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
526 static boolean checkInlineeFrameState(Invoke invoke, ResolvedJavaMethod inlinedMethod, FrameState frameState) {
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
527 assert frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI : frameState;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
528 assert frameState.bci != BytecodeFrame.BEFORE_BCI : frameState;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
529 assert frameState.bci != BytecodeFrame.UNKNOWN_BCI : frameState;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
530 assert frameState.bci != BytecodeFrame.UNWIND_BCI : frameState;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
531 if (frameState.bci != BytecodeFrame.INVALID_FRAMESTATE_BCI) {
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
532 if (frameState.method().equals(inlinedMethod)) {
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
533 // Normal inlining expects all outermost inlinee frame states to
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
534 // denote the inlinee method
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
535 } else if (frameState.method().equals(invoke.callTarget().targetMethod())) {
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
536 // This occurs when an intrinsic calls back to the original
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
537 // method to handle a slow path. During parsing of such a
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
538 // partial intrinsic, these calls are given frame states
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
539 // that exclude the outer frame state denoting a position
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
540 // in the intrinsic code.
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
541 assert inlinedMethod.getAnnotation(MethodSubstitution.class) != null : "expected an intrinsic when inlinee frame state matches method of call target but does not match the method of the inlinee graph: " +
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
542 frameState;
21477
b1e712f66fe0 Make inlining code more robust in the context of inlining substituted graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21473
diff changeset
543 } else if (frameState.method().getName().equals(inlinedMethod.getName())) {
b1e712f66fe0 Make inlining code more robust in the context of inlining substituted graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21473
diff changeset
544 // This can happen for method substitutions.
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
545 } else {
21477
b1e712f66fe0 Make inlining code more robust in the context of inlining substituted graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21473
diff changeset
546 throw new AssertionError(String.format("inlinedMethod=%s frameState.method=%s frameState=%s invoke.method=%s", inlinedMethod, frameState.method(), frameState,
b1e712f66fe0 Make inlining code more robust in the context of inlining substituted graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21473
diff changeset
547 invoke.callTarget().targetMethod()));
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
548 }
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
549 }
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
550 return true;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
551 }
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
552
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
553 private static final ValueNode[] NO_ARGS = {};
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19956
diff changeset
554
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
555 private static boolean isStateAfterException(FrameState frameState) {
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
556 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
557 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
558
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
559 protected static FrameState handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
560 Graph graph = nonReplaceableFrameState.graph();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
561 NodeWorkList workList = graph.createNodeWorkList();
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
562 workList.add(nonReplaceableFrameState);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
563 for (Node node : workList) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
564 FrameState fs = (FrameState) node;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
565 for (Node usage : fs.usages().snapshot()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
566 if (!usage.isAlive()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
567 continue;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
568 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
569 if (usage instanceof FrameState) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
570 workList.add(usage);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
571 } else {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
572 StateSplit stateSplit = (StateSplit) usage;
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
573 FixedNode fixedStateSplit = stateSplit.asNode();
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18994
diff changeset
574 if (fixedStateSplit instanceof AbstractMergeNode) {
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18994
diff changeset
575 AbstractMergeNode merge = (AbstractMergeNode) fixedStateSplit;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
576 while (merge.isAlive()) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
577 AbstractEndNode end = merge.forwardEnds().first();
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
578 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
579 end.replaceAtPredecessor(deoptimizeNode);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
580 GraphUtil.killCFG(end);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
581 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
582 } else {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
583 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
584 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
585 deoptimizeNode = BeginNode.begin(deoptimizeNode);
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
586 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
587 fixedStateSplit.replaceAtPredecessor(deoptimizeNode);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
588 GraphUtil.killCFG(fixedStateSplit);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
589 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
590 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
591 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
592 }
20823
3c1f872f280e Refactoring to allow re-use of inlining methods during a partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20166
diff changeset
593 return null;
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
594 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
595
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18994
diff changeset
596 public static ValueNode mergeReturns(AbstractMergeNode merge, List<? extends ReturnNode> returnNodes, List<Node> canonicalizedNodes) {
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
597 ValueNode singleReturnValue = null;
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
598 PhiNode returnValuePhi = null;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
599 for (ReturnNode returnNode : returnNodes) {
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
600 ValueNode result = returnNode.result();
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
601 if (result != null) {
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
602 if (returnValuePhi == null && (singleReturnValue == null || singleReturnValue == result)) {
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
603 /* Only one return value, so no need yet for a phi node. */
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
604 singleReturnValue = result;
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
605
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
606 } else if (returnValuePhi == null) {
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
607 /* Found a second return value, so create phi node. */
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
608 returnValuePhi = merge.graph().addWithoutUnique(new ValuePhiNode(result.stamp().unrestricted(), merge));
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
609 if (canonicalizedNodes != null) {
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
610 canonicalizedNodes.add(returnValuePhi);
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15200
diff changeset
611 }
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
612 for (int i = 0; i < merge.forwardEndCount(); i++) {
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
613 returnValuePhi.addInput(singleReturnValue);
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
614 }
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
615 returnValuePhi.addInput(result);
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
616
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
617 } else {
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
618 /* Multiple return values, just add to existing phi node. */
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 21143
diff changeset
619 returnValuePhi.addInput(result);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
620 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
621 }
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
622
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
623 // create and wire up a new EndNode
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
624 EndNode endNode = merge.graph().add(new EndNode());
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
625 merge.addForwardEnd(endNode);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
626 returnNode.replaceAndDelete(endNode);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
627 }
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
628
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
629 if (returnValuePhi != null) {
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
630 assert returnValuePhi.verify();
21682
df4579cb9503 Infer stamp in newly created return value phi in the inlining utility.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21654
diff changeset
631 returnValuePhi.inferStamp();
20896
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
632 return returnValuePhi;
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
633 } else {
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
634 return singleReturnValue;
c7f1ab98d950 Improve speed of Graph partial evaluation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20823
diff changeset
635 }
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
636 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
637
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
638 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
639 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
640 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
641 FrameState frameState = (FrameState) node;
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
642 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
643 }
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
644 }
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
645 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
646 }
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
647
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
648 /**
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
649 * 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
650 */
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
651 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
652 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
653 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
654 StructuredGraph graph = callTarget.graph();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
655 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
656 if (firstParam.getKind() == Kind.Object && !StampTool.isPointerNonNull(firstParam)) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
657 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
658 Stamp stamp = firstParam.stamp().join(objectNonNull());
21654
cd6b1b2189a0 Remove GuardingPiNode and replace with FixedGuardNode + PiNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21567
diff changeset
659 FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true));
cd6b1b2189a0 Remove GuardingPiNode and replace with FixedGuardNode + PiNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21567
diff changeset
660 PiNode nonNullReceiver = graph.unique(new PiNode(firstParam, stamp, fixedGuard));
cd6b1b2189a0 Remove GuardingPiNode and replace with FixedGuardNode + PiNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21567
diff changeset
661 graph.addBeforeFixed(invoke.asNode(), fixedGuard);
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
662 callTarget.replaceFirstInput(firstParam, nonNullReceiver);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
663 return nonNullReceiver;
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
664 }
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
665 return firstParam;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
666 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
667
20935
30cbb666e512 expand API for retrieving method substitution graphs to indicate the BCI of the invoke being inlined or -1 if the request is not in the context of inlining
Doug Simon <doug.simon@oracle.com>
parents: 20896
diff changeset
668 public static boolean canIntrinsify(Replacements replacements, ResolvedJavaMethod target, int invokeBci) {
30cbb666e512 expand API for retrieving method substitution graphs to indicate the BCI of the invoke being inlined or -1 if the request is not in the context of inlining
Doug Simon <doug.simon@oracle.com>
parents: 20896
diff changeset
669 return replacements.hasSubstitution(target, false, invokeBci);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
670 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
671
20935
30cbb666e512 expand API for retrieving method substitution graphs to indicate the BCI of the invoke being inlined or -1 if the request is not in the context of inlining
Doug Simon <doug.simon@oracle.com>
parents: 20896
diff changeset
672 public static StructuredGraph getIntrinsicGraph(Replacements replacements, ResolvedJavaMethod target, int invokeBci) {
30cbb666e512 expand API for retrieving method substitution graphs to indicate the BCI of the invoke being inlined or -1 if the request is not in the context of inlining
Doug Simon <doug.simon@oracle.com>
parents: 20896
diff changeset
673 return replacements.getSubstitution(target, invokeBci);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
674 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
675
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21477
diff changeset
676 public static FixedWithNextNode inlineMacroNode(Invoke invoke, ResolvedJavaMethod concrete, Class<? extends FixedWithNextNode> macroNodeClass) throws JVMCIError {
13601
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
677 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
678 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
679 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
680 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
681 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
682
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
683 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
684
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
685 CallTargetNode callTarget = invoke.callTarget();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
686 if (invoke instanceof InvokeNode) {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
687 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
688 } else {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
689 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
690 invokeWithException.killExceptionEdge();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
691 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
692 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
693 GraphUtil.killWithUnusedFloatingInputs(callTarget);
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
694 return macroNode;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
695 }
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
696
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21477
diff changeset
697 private static FixedWithNextNode createMacroNodeInstance(Class<? extends FixedWithNextNode> macroNodeClass, Invoke invoke) throws JVMCIError {
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
698 try {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
699 Constructor<?> cons = macroNodeClass.getDeclaredConstructor(Invoke.class);
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18822
diff changeset
700 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
701 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21477
diff changeset
702 throw new GraalGraphJVMCIError(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
703 }
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
704 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 }